Class IISRandomAccessIO
- java.lang.Object
-
- com.github.jaiimageio.jpeg2000.impl.IISRandomAccessIO
-
- All Implemented Interfaces:
BinaryDataInput,BinaryDataOutput,RandomAccessIO
public class IISRandomAccessIO extends Object implements RandomAccessIO
A wrapper for converting anImageInputStreaminto aRandomAccessIO. The resulting class is read-only.
-
-
Constructor Summary
Constructors Constructor Description IISRandomAccessIO(ImageInputStream iis)Creates aRandomAccessIOinstance from the suppliedImageInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the I/O stream.voidflush()A null operation as writing is not supported.intgetByteOrdering()Returns the endianess (i.e., byte ordering) of the implementing class.intgetPos()Returns the stream position clamped to a maximum ofInteger.MAX_VALUE.intlength()Returns the length of the data stream.intread()Reads a byte of data from the stream.bytereadByte()Should read a signed byte (i.e., 8 bit) from the input.doublereadDouble()Should read an IEEE double precision (i.e., 64 bit) floating-point number from the input.floatreadFloat()Should read an IEEE single precision (i.e., 32 bit) floating-point number from the input.voidreadFully(byte[] b, int off, int n)Reads up to len bytes of data from this file into an array of bytes.intreadInt()Should read a signed int (i.e., 32 bit) from the input.longreadLong()Should read a signed long (i.e., 64 bit) from the input.shortreadShort()Should read a signed short (i.e., 16 bit) from the input.intreadUnsignedByte()Should read an unsigned byte (i.e., 8 bit) from the input.longreadUnsignedInt()Should read an unsigned int (i.e., 32 bit) from the input.intreadUnsignedShort()Should read an unsigned short (i.e., 16 bit) from the input.voidseek(int off)Moves the current position for the next read or write operation to offset.intskipBytes(int n)Skips n bytes from the input.voidwrite(int b)Throws anIOExceptionas writing is not supported.voidwriteByte(int v)Throws anIOExceptionas writing is not supported.voidwriteDouble(double v)Throws anIOExceptionas writing is not supported.voidwriteFloat(float v)Throws anIOExceptionas writing is not supported.voidwriteInt(int v)Throws anIOExceptionas writing is not supported.voidwriteLong(long v)Throws anIOExceptionas writing is not supported.voidwriteShort(int v)Throws anIOExceptionas writing is not supported.
-
-
-
Constructor Detail
-
IISRandomAccessIO
public IISRandomAccessIO(ImageInputStream iis)
Creates aRandomAccessIOinstance from the suppliedImageInputStream.- Parameters:
iis- The sourceImageInputStream.
-
-
Method Detail
-
close
public void close() throws IOException
Description copied from interface:RandomAccessIOCloses the I/O stream. Prior to closing the stream, any buffered data (at the bit and byte level) should be written.- Specified by:
closein interfaceRandomAccessIO- Throws:
IOException- If an I/O error ocurred.
-
getPos
public int getPos() throws IOException
Returns the stream position clamped to a maximum ofInteger.MAX_VALUE.- Specified by:
getPosin interfaceRandomAccessIO- Returns:
- The offset of the current position, in bytes.
- Throws:
IOException- If an I/O error ocurred.
-
seek
public void seek(int off) throws IOException
Description copied from interface:RandomAccessIOMoves the current position for the next read or write operation to offset. The offset is measured from the beginning of the stream. The offset may be set beyond the end of the file, if in write mode. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.- Specified by:
seekin interfaceRandomAccessIO- Parameters:
off- The offset where to move to.- Throws:
EOFException- If in read-only and seeking beyond EOF.IOException- If an I/O error ocurred.
-
length
public int length() throws IOException
Returns the length of the data stream.If the length of the
ImageInputStreamis not-1, then it is returned after being clamped to a maximum value ofInteger.MAX_VALUE. If theImageInputStreamis-1, the stream is read to a maximum position ofInteger.MAX_VALUEand its final position is returned. The position of the stream is unchanged from the value it had prior to the call.- Specified by:
lengthin interfaceRandomAccessIO- Returns:
- The length of the stream, in bytes.
- Throws:
IOException- If an I/O error ocurred.
-
read
public int read() throws IOException
Description copied from interface:RandomAccessIOReads a byte of data from the stream. Prior to reading, the stream is realigned at the byte level.- Specified by:
readin interfaceRandomAccessIO- Returns:
- The byte read, as an int.
- Throws:
EOFException- If the end-of file was reached.IOException- If an I/O error ocurred.
-
readFully
public void readFully(byte[] b, int off, int n) throws IOException
Description copied from interface:RandomAccessIOReads up to len bytes of data from this file into an array of bytes. This method reads repeatedly from the stream until all the bytes are read. This method blocks until all the bytes are read, the end of the stream is detected, or an exception is thrown.- Specified by:
readFullyin interfaceRandomAccessIO- Parameters:
b- The buffer into which the data is to be read. It must be long enough.off- The index in 'b' where to place the first byte read.n- The number of bytes to read.- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
getByteOrdering
public int getByteOrdering()
Description copied from interface:BinaryDataInputReturns the endianess (i.e., byte ordering) of the implementing class. Note that an implementing class may implement only one type of endianness or both, which would be decided at creatiuon time.- Specified by:
getByteOrderingin interfaceBinaryDataInput- Specified by:
getByteOrderingin interfaceBinaryDataOutput- Returns:
- Either EndianType.BIG_ENDIAN or EndianType.LITTLE_ENDIAN
- See Also:
EndianType
-
readByte
public byte readByte() throws IOException
Description copied from interface:BinaryDataInputShould read a signed byte (i.e., 8 bit) from the input. reading, the input should be realigned at the byte level.- Specified by:
readBytein interfaceBinaryDataInput- Returns:
- The next byte-aligned signed byte (8 bit) from the input.
- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
readUnsignedByte
public int readUnsignedByte() throws IOException
Description copied from interface:BinaryDataInputShould read an unsigned byte (i.e., 8 bit) from the input. It is returned as an int since Java does not have an unsigned byte type. Prior to reading, the input should be realigned at the byte level.- Specified by:
readUnsignedBytein interfaceBinaryDataInput- Returns:
- The next byte-aligned unsigned byte (8 bit) from the input, as an int.
- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
readShort
public short readShort() throws IOException
Description copied from interface:BinaryDataInputShould read a signed short (i.e., 16 bit) from the input. Prior to reading, the input should be realigned at the byte level.- Specified by:
readShortin interfaceBinaryDataInput- Returns:
- The next byte-aligned signed short (16 bit) from the input.
- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
readUnsignedShort
public int readUnsignedShort() throws IOException
Description copied from interface:BinaryDataInputShould read an unsigned short (i.e., 16 bit) from the input. It is returned as an int since Java does not have an unsigned short type. Prior to reading, the input should be realigned at the byte level.- Specified by:
readUnsignedShortin interfaceBinaryDataInput- Returns:
- The next byte-aligned unsigned short (16 bit) from the input, as an int.
- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
readInt
public int readInt() throws IOException
Description copied from interface:BinaryDataInputShould read a signed int (i.e., 32 bit) from the input. Prior to reading, the input should be realigned at the byte level.- Specified by:
readIntin interfaceBinaryDataInput- Returns:
- The next byte-aligned signed int (32 bit) from the input.
- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
readUnsignedInt
public long readUnsignedInt() throws IOException
Description copied from interface:BinaryDataInputShould read an unsigned int (i.e., 32 bit) from the input. It is returned as a long since Java does not have an unsigned short type. Prior to reading, the input should be realigned at the byte level.- Specified by:
readUnsignedIntin interfaceBinaryDataInput- Returns:
- The next byte-aligned unsigned int (32 bit) from the input, as a long.
- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
readLong
public long readLong() throws IOException
Description copied from interface:BinaryDataInputShould read a signed long (i.e., 64 bit) from the input. Prior to reading, the input should be realigned at the byte level.- Specified by:
readLongin interfaceBinaryDataInput- Returns:
- The next byte-aligned signed long (64 bit) from the input.
- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
readFloat
public float readFloat() throws IOException
Description copied from interface:BinaryDataInputShould read an IEEE single precision (i.e., 32 bit) floating-point number from the input. Prior to reading, the input should be realigned at the byte level.- Specified by:
readFloatin interfaceBinaryDataInput- Returns:
- The next byte-aligned IEEE float (32 bit) from the input.
- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
readDouble
public double readDouble() throws IOException
Description copied from interface:BinaryDataInputShould read an IEEE double precision (i.e., 64 bit) floating-point number from the input. Prior to reading, the input should be realigned at the byte level.- Specified by:
readDoublein interfaceBinaryDataInput- Returns:
- The next byte-aligned IEEE double (64 bit) from the input.
- Throws:
EOFException- If the end-of file was reached before getting all the necessary data.IOException- If an I/O error ocurred.
-
skipBytes
public int skipBytes(int n) throws IOException
Description copied from interface:BinaryDataInputSkips n bytes from the input. Prior to skipping, the input should be realigned at the byte level.- Specified by:
skipBytesin interfaceBinaryDataInput- Parameters:
n- The number of bytes to skip- Throws:
EOFException- If the end-of file was reached before all the bytes could be skipped.IOException- If an I/O error ocurred.
-
flush
public void flush()
A null operation as writing is not supported.- Specified by:
flushin interfaceBinaryDataOutput
-
write
public void write(int b) throws IOException
Throws anIOExceptionas writing is not supported.- Specified by:
writein interfaceRandomAccessIO- Parameters:
b- The byte to write. The lower 8 bits of b are written.- Throws:
IOException- If an I/O error ocurred.
-
writeByte
public void writeByte(int v) throws IOException
Throws anIOExceptionas writing is not supported.- Specified by:
writeBytein interfaceBinaryDataOutput- Parameters:
v- The value to write to the output- Throws:
IOException- If an I/O error ocurred.
-
writeShort
public void writeShort(int v) throws IOException
Throws anIOExceptionas writing is not supported.- Specified by:
writeShortin interfaceBinaryDataOutput- Parameters:
v- The value to write to the output- Throws:
IOException- If an I/O error ocurred.
-
writeInt
public void writeInt(int v) throws IOException
Throws anIOExceptionas writing is not supported.- Specified by:
writeIntin interfaceBinaryDataOutput- Parameters:
v- The value to write to the output- Throws:
IOException- If an I/O error ocurred.
-
writeLong
public void writeLong(long v) throws IOException
Throws anIOExceptionas writing is not supported.- Specified by:
writeLongin interfaceBinaryDataOutput- Parameters:
v- The value to write to the output- Throws:
IOException- If an I/O error ocurred.
-
writeFloat
public void writeFloat(float v) throws IOException
Throws anIOExceptionas writing is not supported.- Specified by:
writeFloatin interfaceBinaryDataOutput- Parameters:
v- The value to write to the output- Throws:
IOException- If an I/O error ocurred.
-
writeDouble
public void writeDouble(double v) throws IOException
Throws anIOExceptionas writing is not supported.- Specified by:
writeDoublein interfaceBinaryDataOutput- Parameters:
v- The value to write to the output- Throws:
IOException- If an I/O error ocurred.
-
-