[6785] | 1 | /**************************************************************** |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one * |
---|
| 3 | * or more contributor license agreements. See the NOTICE file * |
---|
| 4 | * distributed with this work for additional information * |
---|
| 5 | * regarding copyright ownership. The ASF licenses this file * |
---|
| 6 | * to you under the Apache License, Version 2.0 (the * |
---|
| 7 | * "License"); you may not use this file except in compliance * |
---|
| 8 | * with the License. You may obtain a copy of the License at * |
---|
| 9 | * * |
---|
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 * |
---|
| 11 | * * |
---|
| 12 | * Unless required by applicable law or agreed to in writing, * |
---|
| 13 | * software distributed under the License is distributed on an * |
---|
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * |
---|
| 15 | * KIND, either express or implied. See the License for the * |
---|
| 16 | * specific language governing permissions and limitations * |
---|
| 17 | * under the License. * |
---|
| 18 | ****************************************************************/ |
---|
| 19 | |
---|
| 20 | package org.apache.james.mime4j.util; |
---|
| 21 | |
---|
| 22 | /** |
---|
| 23 | * An immutable sequence of bytes. |
---|
| 24 | */ |
---|
| 25 | public interface ByteSequence { |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * An empty byte sequence. |
---|
| 29 | */ |
---|
| 30 | ByteSequence EMPTY = new EmptyByteSequence(); |
---|
| 31 | |
---|
| 32 | /** |
---|
| 33 | * Returns the length of this byte sequence. |
---|
| 34 | * |
---|
| 35 | * @return the number of <code>byte</code>s in this sequence. |
---|
| 36 | */ |
---|
| 37 | int length(); |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Returns the <code>byte</code> value at the specified index. |
---|
| 41 | * |
---|
| 42 | * @param index |
---|
| 43 | * the index of the <code>byte</code> value to be returned. |
---|
| 44 | * @return the corresponding <code>byte</code> value |
---|
| 45 | * @throws IndexOutOfBoundsException |
---|
| 46 | * if <code>index < 0 || index >= length()</code>. |
---|
| 47 | */ |
---|
| 48 | byte byteAt(int index); |
---|
| 49 | |
---|
| 50 | /** |
---|
| 51 | * Copies the contents of this byte sequence into a newly allocated byte |
---|
| 52 | * array and returns that array. |
---|
| 53 | * |
---|
| 54 | * @return a byte array holding a copy of this byte sequence. |
---|
| 55 | */ |
---|
| 56 | byte[] toByteArray(); |
---|
| 57 | |
---|
| 58 | } |
---|