The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | * contributor license agreements. See the NOTICE file distributed with |
| 4 | * this work for additional information regarding copyright ownership. |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | * (the "License"); you may not use this file except in compliance with |
| 7 | * the License. You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | /** |
| 18 | * @author Sergey I. Salishev |
| 19 | * @version $Revision: 1.2 $ |
| 20 | */ |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 21 | |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 22 | package javax.imageio.stream; |
| 23 | |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 24 | // |
| 25 | // @author Sergey I. Salishev |
| 26 | // @version $Revision: 1.2 $ |
| 27 | // |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 30 | * The IIOByteBuffer class represents a byte array with offset and length that |
| 31 | * is used by ImageInputStream for obtaining a sequence of bytes. |
| 32 | * |
| 33 | * @since Android 1.0 |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 34 | */ |
| 35 | public class IIOByteBuffer { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 36 | |
| 37 | /** |
| 38 | * The data. |
| 39 | */ |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 40 | private byte[] data; |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 41 | |
| 42 | /** |
| 43 | * The offset. |
| 44 | */ |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 45 | private int offset; |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 46 | |
| 47 | /** |
| 48 | * The length. |
| 49 | */ |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 50 | private int length; |
| 51 | |
| 52 | /** |
| 53 | * Instantiates a new IIOByteBuffer. |
| 54 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 55 | * @param data |
| 56 | * the byte array. |
| 57 | * @param offset |
| 58 | * the offset in the array. |
| 59 | * @param length |
| 60 | * the length of array. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 61 | */ |
| 62 | public IIOByteBuffer(byte[] data, int offset, int length) { |
| 63 | this.data = data; |
| 64 | this.offset = offset; |
| 65 | this.length = length; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Gets the byte array of this IIOByteBuffer. |
| 70 | * |
| 71 | * @return the byte array. |
| 72 | */ |
| 73 | public byte[] getData() { |
| 74 | return data; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Gets the length in the array which will be used. |
| 79 | * |
| 80 | * @return the length of the data. |
| 81 | */ |
| 82 | public int getLength() { |
| 83 | return length; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Gets the offset of this IIOByteBuffer. |
| 88 | * |
| 89 | * @return the offset of this IIOByteBuffer. |
| 90 | */ |
| 91 | public int getOffset() { |
| 92 | return offset; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Sets the new data array to this IIOByteBuffer object. |
| 97 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 98 | * @param data |
| 99 | * the new data array. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 100 | */ |
| 101 | public void setData(byte[] data) { |
| 102 | this.data = data; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Sets the length of data which will be used. |
| 107 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 108 | * @param length |
| 109 | * the new length. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 110 | */ |
| 111 | public void setLength(int length) { |
| 112 | this.length = length; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Sets the offset in the data array of this IIOByteBuffer. |
| 117 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 118 | * @param offset |
| 119 | * the new offset. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 120 | */ |
| 121 | public void setOffset(int offset) { |
| 122 | this.offset = offset; |
| 123 | } |
| 124 | } |