Package jj2000.j2k.io

Interface BinaryDataOutput

All Known Subinterfaces:
RandomAccessIO
All Known Implementing Classes:
BEBufferedRandomAccessFile, BufferedRandomAccessFile, IISRandomAccessIO, ISRandomAccessIO

public interface BinaryDataOutput
This interface defines the output of binary data to streams and/or files.

Byte level output (i.e., for byte, int, long, float, etc.) should always be byte aligned. For example, a request to write an int should always realign the output at the byte level.

The implementation of this interface should clearly define if multi-byte output data is written in little- or big-endian byte ordering (least significant byte first or most significant byte first, respectively).

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Any data that has been buffered must be written, and the stream should be realigned at the byte level.
    int
    Returns the endianness (i.e., byte ordering) of the implementing class.
    void
    writeByte(int v)
    Should write the byte value of v (i.e., 8 least significant bits) to the output.
    void
    writeDouble(double v)
    Should write the IEEE double value v (i.e., 64 bits) to the output.
    void
    writeFloat(float v)
    Should write the IEEE float value v (i.e., 32 bits) to the output.
    void
    writeInt(int v)
    Should write the int value of v (i.e., the 32 bits) to the output.
    void
    writeLong(long v)
    Should write the long value of v (i.e., the 64 bits) to the output.
    void
    writeShort(int v)
    Should write the short value of v (i.e., 16 least significant bits) to the output.
  • Method Details

    • writeByte

      void writeByte(int v) throws IOException
      Should write the byte value of v (i.e., 8 least significant bits) to the output. Prior to writing, the output should be realigned at the byte level.

      Signed or unsigned data can be written. To write a signed value just pass the byte value as an argument. To write unsigned data pass the int value as an argument (it will be automatically casted, and only the 8 least significant bits will be written).

      Parameters:
      v - The value to write to the output
      Throws:
      IOException - If an I/O error ocurred.
    • writeShort

      void writeShort(int v) throws IOException
      Should write the short value of v (i.e., 16 least significant bits) to the output. Prior to writing, the output should be realigned at the byte level.

      Signed or unsigned data can be written. To write a signed value just pass the short value as an argument. To write unsigned data pass the int value as an argument (it will be automatically casted, and only the 16 least significant bits will be written).

      Parameters:
      v - The value to write to the output
      Throws:
      IOException - If an I/O error ocurred.
    • writeInt

      void writeInt(int v) throws IOException
      Should write the int value of v (i.e., the 32 bits) to the output. Prior to writing, the output should be realigned at the byte level.
      Parameters:
      v - The value to write to the output
      Throws:
      IOException - If an I/O error ocurred.
    • writeLong

      void writeLong(long v) throws IOException
      Should write the long value of v (i.e., the 64 bits) to the output. Prior to writing, the output should be realigned at the byte level.
      Parameters:
      v - The value to write to the output
      Throws:
      IOException - If an I/O error ocurred.
    • writeFloat

      void writeFloat(float v) throws IOException
      Should write the IEEE float value v (i.e., 32 bits) to the output. Prior to writing, the output should be realigned at the byte level.
      Parameters:
      v - The value to write to the output
      Throws:
      IOException - If an I/O error ocurred.
    • writeDouble

      void writeDouble(double v) throws IOException
      Should write the IEEE double value v (i.e., 64 bits) to the output. Prior to writing, the output should be realigned at the byte level.
      Parameters:
      v - The value to write to the output
      Throws:
      IOException - If an I/O error ocurred.
    • getByteOrdering

      int getByteOrdering()
      Returns the endianness (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.
      Returns:
      Either EndianType.BIG_ENDIAN or EndianType.LITTLE_ENDIAN
      See Also:
    • flush

      void flush() throws IOException
      Any data that has been buffered must be written, and the stream should be realigned at the byte level.
      Throws:
      IOException - If an I/O error ocurred.