Class IISRandomAccessIO
java.lang.Object
com.sun.media.imageioimpl.plugins.jpeg2000.IISRandomAccessIO
- All Implemented Interfaces:
BinaryDataInput,BinaryDataOutput,RandomAccessIO
A wrapper for converting an
ImageInputStream into a
RandomAccessIO. The resulting class is read-only.-
Constructor Summary
ConstructorsConstructorDescriptionCreates aRandomAccessIOinstance from the suppliedImageInputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the I/O stream.voidflush()A null operation as writing is not supported.intReturns 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.doubleShould read an IEEE double precision (i.e., 64 bit) floating-point number from the input.floatShould 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.shortShould read a signed short (i.e., 16 bit) from the input.intShould read an unsigned byte (i.e., 8 bit) from the input.longShould read an unsigned int (i.e., 32 bit) from the input.intShould 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 Details
-
IISRandomAccessIO
Creates aRandomAccessIOinstance from the suppliedImageInputStream.- Parameters:
iis- The sourceImageInputStream.
-
-
Method Details
-
close
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
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
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
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
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
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:
-
readByte
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
-