Class IISRandomAccessIO

    • Constructor Summary

      Constructors 
      Constructor Description
      IISRandomAccessIO​(ImageInputStream iis)
      Creates a RandomAccessIO instance from the supplied ImageInputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the I/O stream.
      void flush()
      A null operation as writing is not supported.
      int getByteOrdering()
      Returns the endianess (i.e., byte ordering) of the implementing class.
      int getPos()
      Returns the stream position clamped to a maximum of Integer.MAX_VALUE.
      int length()
      Returns the length of the data stream.
      int read()
      Reads a byte of data from the stream.
      byte readByte()
      Should read a signed byte (i.e., 8 bit) from the input.
      double readDouble()
      Should read an IEEE double precision (i.e., 64 bit) floating-point number from the input.
      float readFloat()
      Should read an IEEE single precision (i.e., 32 bit) floating-point number from the input.
      void readFully​(byte[] b, int off, int n)
      Reads up to len bytes of data from this file into an array of bytes.
      int readInt()
      Should read a signed int (i.e., 32 bit) from the input.
      long readLong()
      Should read a signed long (i.e., 64 bit) from the input.
      short readShort()
      Should read a signed short (i.e., 16 bit) from the input.
      int readUnsignedByte()
      Should read an unsigned byte (i.e., 8 bit) from the input.
      long readUnsignedInt()
      Should read an unsigned int (i.e., 32 bit) from the input.
      int readUnsignedShort()
      Should read an unsigned short (i.e., 16 bit) from the input.
      void seek​(int off)
      Moves the current position for the next read or write operation to offset.
      int skipBytes​(int n)
      Skips n bytes from the input.
      void write​(int b)
      Throws an IOException as writing is not supported.
      void writeByte​(int v)
      Throws an IOException as writing is not supported.
      void writeDouble​(double v)
      Throws an IOException as writing is not supported.
      void writeFloat​(float v)
      Throws an IOException as writing is not supported.
      void writeInt​(int v)
      Throws an IOException as writing is not supported.
      void writeLong​(long v)
      Throws an IOException as writing is not supported.
      void writeShort​(int v)
      Throws an IOException as writing is not supported.
    • Constructor Detail

      • IISRandomAccessIO

        public IISRandomAccessIO​(ImageInputStream iis)
        Creates a RandomAccessIO instance from the supplied ImageInputStream.
        Parameters:
        iis - The source ImageInputStream.
    • Method Detail

      • close

        public void close()
                   throws IOException
        Description copied from interface: RandomAccessIO
        Closes the I/O stream. Prior to closing the stream, any buffered data (at the bit and byte level) should be written.
        Specified by:
        close in interface RandomAccessIO
        Throws:
        IOException - If an I/O error ocurred.
      • getPos

        public int getPos()
                   throws IOException
        Returns the stream position clamped to a maximum of Integer.MAX_VALUE.
        Specified by:
        getPos in interface RandomAccessIO
        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: RandomAccessIO
        Moves 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:
        seek in interface RandomAccessIO
        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 ImageInputStream is not -1, then it is returned after being clamped to a maximum value of Integer.MAX_VALUE. If the ImageInputStream is -1, the stream is read to a maximum position of Integer.MAX_VALUE and its final position is returned. The position of the stream is unchanged from the value it had prior to the call.

        Specified by:
        length in interface RandomAccessIO
        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: RandomAccessIO
        Reads a byte of data from the stream. Prior to reading, the stream is realigned at the byte level.
        Specified by:
        read in interface RandomAccessIO
        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: RandomAccessIO
        Reads 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:
        readFully in interface RandomAccessIO
        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: BinaryDataInput
        Returns 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:
        getByteOrdering in interface BinaryDataInput
        Specified by:
        getByteOrdering in interface BinaryDataOutput
        Returns:
        Either EndianType.BIG_ENDIAN or EndianType.LITTLE_ENDIAN
        See Also:
        EndianType
      • readByte

        public byte readByte()
                      throws IOException
        Description copied from interface: BinaryDataInput
        Should read a signed byte (i.e., 8 bit) from the input. reading, the input should be realigned at the byte level.
        Specified by:
        readByte in interface BinaryDataInput
        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: BinaryDataInput
        Should 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:
        readUnsignedByte in interface BinaryDataInput
        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: BinaryDataInput
        Should 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:
        readShort in interface BinaryDataInput
        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: BinaryDataInput
        Should 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:
        readUnsignedShort in interface BinaryDataInput
        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: BinaryDataInput
        Should 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:
        readInt in interface BinaryDataInput
        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: BinaryDataInput
        Should 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:
        readUnsignedInt in interface BinaryDataInput
        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: BinaryDataInput
        Should 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:
        readLong in interface BinaryDataInput
        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: BinaryDataInput
        Should 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:
        readFloat in interface BinaryDataInput
        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: BinaryDataInput
        Should 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:
        readDouble in interface BinaryDataInput
        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: BinaryDataInput
        Skips n bytes from the input. Prior to skipping, the input should be realigned at the byte level.
        Specified by:
        skipBytes in interface BinaryDataInput
        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:
        flush in interface BinaryDataOutput
      • write

        public void write​(int b)
                   throws IOException
        Throws an IOException as writing is not supported.
        Specified by:
        write in interface RandomAccessIO
        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 an IOException as writing is not supported.
        Specified by:
        writeByte in interface BinaryDataOutput
        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 an IOException as writing is not supported.
        Specified by:
        writeShort in interface BinaryDataOutput
        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 an IOException as writing is not supported.
        Specified by:
        writeInt in interface BinaryDataOutput
        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 an IOException as writing is not supported.
        Specified by:
        writeLong in interface BinaryDataOutput
        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 an IOException as writing is not supported.
        Specified by:
        writeFloat in interface BinaryDataOutput
        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 an IOException as writing is not supported.
        Specified by:
        writeDouble in interface BinaryDataOutput
        Parameters:
        v - The value to write to the output
        Throws:
        IOException - If an I/O error ocurred.