0N/A/*
2362N/A * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.imageio.stream;
0N/A
0N/A/**
0N/A * A class representing a mutable reference to an array of bytes and
0N/A * an offset and length within that array. <code>IIOByteBuffer</code>
0N/A * is used by <code>ImageInputStream</code> to supply a sequence of bytes
0N/A * to the caller, possibly with fewer copies than using the conventional
0N/A * <code>read</code> methods that take a user-supplied byte array.
0N/A *
0N/A * <p> The byte array referenced by an <code>IIOByteBuffer</code> will
0N/A * generally be part of an internal data structure belonging to an
0N/A * <code>ImageReader</code> implementation; its contents should be
0N/A * considered read-only and must not be modified.
0N/A *
0N/A */
0N/Apublic class IIOByteBuffer {
0N/A
0N/A private byte[] data;
0N/A
0N/A private int offset;
0N/A
0N/A private int length;
0N/A
0N/A /**
0N/A * Constructs an <code>IIOByteBuffer</code> that references a
0N/A * given byte array, offset, and length.
0N/A *
0N/A * @param data a byte array.
0N/A * @param offset an int offset within the array.
0N/A * @param length an int specifying the length of the data of
0N/A * interest within byte array, in bytes.
0N/A */
0N/A public IIOByteBuffer(byte[] data, int offset, int length) {
0N/A this.data = data;
0N/A this.offset = offset;
0N/A this.length = length;
0N/A }
0N/A
0N/A /**
0N/A * Returns a reference to the byte array. The returned value should
0N/A * be treated as read-only, and only the portion specified by the
0N/A * values of <code>getOffset</code> and <code>getLength</code> should
0N/A * be used.
0N/A *
0N/A * @return a byte array reference.
0N/A *
0N/A * @see #getOffset
0N/A * @see #getLength
0N/A * @see #setData
0N/A */
0N/A public byte[] getData() {
0N/A return data;
0N/A }
0N/A
0N/A /**
0N/A * Updates the array reference that will be returned by subsequent calls
0N/A * to the <code>getData</code> method.
0N/A *
0N/A * @param data a byte array reference containing the new data value.
0N/A *
0N/A * @see #getData
0N/A */
0N/A public void setData(byte[] data) {
0N/A this.data = data;
0N/A }
0N/A
0N/A /**
0N/A * Returns the offset within the byte array returned by
0N/A * <code>getData</code> at which the data of interest start.
0N/A *
0N/A * @return an int offset.
0N/A *
0N/A * @see #getData
0N/A * @see #getLength
0N/A * @see #setOffset
0N/A */
0N/A public int getOffset() {
0N/A return offset;
0N/A }
0N/A
0N/A /**
0N/A * Updates the value that will be returned by subsequent calls
0N/A * to the <code>getOffset</code> method.
0N/A *
0N/A * @param offset an int containing the new offset value.
0N/A *
0N/A * @see #getOffset
0N/A */
0N/A public void setOffset(int offset) {
0N/A this.offset = offset;
0N/A }
0N/A
0N/A /**
0N/A * Returns the length of the data of interest within the byte
0N/A * array returned by <code>getData</code>.
0N/A *
0N/A * @return an int length.
0N/A *
0N/A * @see #getData
0N/A * @see #getOffset
0N/A * @see #setLength
0N/A */
0N/A public int getLength() {
0N/A return length;
0N/A }
0N/A
0N/A /**
0N/A * Updates the value that will be returned by subsequent calls
0N/A * to the <code>getLength</code> method.
0N/A *
0N/A * @param length an int containing the new length value.
0N/A *
0N/A * @see #getLength
0N/A */
0N/A public void setLength(int length) {
0N/A this.length = length;
0N/A }
0N/A}