blob: 867d80843d8315aec0bfa203136ee11227c20a1b [file] [log] [blame]
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07001/*
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 Projecte09fd9e2008-12-17 18:05:43 -080021
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070022package javax.imageio.stream;
23
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080024//
25// @author Sergey I. Salishev
26// @version $Revision: 1.2 $
27//
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070028
29/**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080030 * 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 Project7c1b96a2008-10-21 07:00:00 -070034 */
35public class IIOByteBuffer {
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080036
37 /**
38 * The data.
39 */
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070040 private byte[] data;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080041
42 /**
43 * The offset.
44 */
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070045 private int offset;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080046
47 /**
48 * The length.
49 */
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070050 private int length;
51
52 /**
53 * Instantiates a new IIOByteBuffer.
54 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080055 * @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 Project7c1b96a2008-10-21 07:00:00 -070061 */
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 Projecte09fd9e2008-12-17 18:05:43 -080098 * @param data
99 * the new data array.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700100 */
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 Projecte09fd9e2008-12-17 18:05:43 -0800108 * @param length
109 * the new length.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700110 */
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 Projecte09fd9e2008-12-17 18:05:43 -0800118 * @param offset
119 * the new offset.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700120 */
121 public void setOffset(int offset) {
122 this.offset = offset;
123 }
124}