Class ByteBufferDataIO

  • All Implemented Interfaces:
    DataIn, DataIO, DataOut

    public class ByteBufferDataIO
    extends java.lang.Object
    implements DataIO
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteBufferDataIO​(int capacity)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears this output stream.
      int getSizeForRead()
      Returns the size of the data that can be read from this input stream, in bytes.
      int getSizeForWrite()
      Returns the size of this output stream for writing, in bytes.
      int indexOf​(int limit, byte val)
      Returns the index within this input stream of the first occurrence of the specified byte, or -1 if no such byte exists.
      boolean isEmpty()
      Returns true if this input stream is empty, false otherwise.
      boolean isWritable()
      Returns whether this output stream is writable or not.
      int read​(byte[] b, int offset, int len)
      Reads a byte array from this input stream and returns the number of bytes actually read.
      boolean readBoolean()
      Reads a byte from this input stream and returns it as an integer.
      double readDouble()
      Returns the next double value from this input stream, casting it to a double value in the range -1.7976931348623157E+308D to 1.7976931348623157E+308D.
      float readFloat()
      Returns the next float value from this input stream, casting it to a float value in the range -3.4028235E+38F to 3.4028235E+38F.
      int readInt()
      Returns the next int value from this input stream, casting it to an int value in the range -2147483648 to 2147483647.
      long readLong()
      Returns the next long value from this input stream, casting it to a long value in the range -9223372036854775808 to 9223372036854775807.
      short readShort()
      Returns the next short value from this input stream, casting it to a short value in the range -32768 to 32767.
      DataIO readSubData​(int length)
      Reads a subarray of bytes from this input stream and returns the number of bytes actually read.
      int readUByte()
      Returns the next byte of data from this input stream, casting it to an unsigned byte value in the range 0-255.
      void skipAllBytes()
      Skips all bytes in this input stream.
      void skipBytes​(int n)
      Skips the specified number of bytes in this input stream.
      byte[] toArray()
      Returns a copy of this input stream as an array of bytes.
      void write​(byte[] b)
      Writes a byte array to this output stream and returns the number of bytes actually written.
      int write​(byte[] b, int off, int len)
      Writes a byte array to this output stream and returns the number of bytes actually written.
      void write​(DataIn data)
      Writes a data input stream to this output stream.
      void write​(DataInOut data)
      Writes a data input stream to this output stream.
      void write​(DataInOutStatic data)
      Writes a static data input stream to this output stream.
      void writeBoolean​(boolean v)
      Writes a boolean value to this output stream.
      void writeByte​(int b)
      Writes a byte value to this output stream.
      void writeDouble​(double v)
      Writes a double value to this output stream.
      void writeFloat​(float v)
      Writes a float value to this output stream.
      void writeHexBytes​(java.lang.String hex)
      Writes a string to this output stream as hexadecimal bytes.
      void writeInt​(int v)
      Writes an integer value to this output stream.
      void writeLong​(long v)
      Writes a long value to this output stream.
      void writeShort​(int v)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteBufferDataIO

        public ByteBufferDataIO​(int capacity)
    • Method Detail

      • getSizeForWrite

        public int getSizeForWrite()
        Description copied from interface: DataOut
        Returns the size of this output stream for writing, in bytes.
        Specified by:
        getSizeForWrite in interface DataOut
      • isWritable

        public boolean isWritable()
        Description copied from interface: DataOut
        Returns whether this output stream is writable or not.
        Specified by:
        isWritable in interface DataOut
      • clear

        public void clear()
        Description copied from interface: DataOut
        Clears this output stream.
        Specified by:
        clear in interface DataOut
      • getSizeForRead

        public int getSizeForRead()
        Description copied from interface: DataIn
        Returns the size of the data that can be read from this input stream, in bytes.
        Specified by:
        getSizeForRead in interface DataIn
      • read

        public int read​(byte[] b,
                        int offset,
                        int len)
        Description copied from interface: DataIn
        Reads a byte array from this input stream and returns the number of bytes actually read.
        Specified by:
        read in interface DataIn
        Parameters:
        b - The byte array to read into.
        offset - The starting position in the array to write to.
        len - The maximum number of bytes to read.
        Returns:
        The number of bytes actually read.
      • write

        public void write​(byte[] b)
        Description copied from interface: DataOut
        Writes a byte array to this output stream and returns the number of bytes actually written.
        Specified by:
        write in interface DataOut
        Parameters:
        b - The byte array to write from.
      • write

        public int write​(byte[] b,
                         int off,
                         int len)
        Description copied from interface: DataOut
        Writes a byte array to this output stream and returns the number of bytes actually written.
        Specified by:
        write in interface DataOut
        Parameters:
        b - The byte array to write from.
        off - The starting position in the array to read from.
        len - The maximum number of bytes to write.
      • writeShort

        public void writeShort​(int v)
        Specified by:
        writeShort in interface DataOut
      • readShort

        public short readShort()
        Description copied from interface: DataIn
        Returns the next short value from this input stream, casting it to a short value in the range -32768 to 32767.
        Specified by:
        readShort in interface DataIn
      • writeInt

        public void writeInt​(int v)
        Description copied from interface: DataOut
        Writes an integer value to this output stream.
        Specified by:
        writeInt in interface DataOut
        Parameters:
        v - The integer value to write.
      • readInt

        public int readInt()
        Description copied from interface: DataIn
        Returns the next int value from this input stream, casting it to an int value in the range -2147483648 to 2147483647.
        Specified by:
        readInt in interface DataIn
      • writeLong

        public void writeLong​(long v)
        Description copied from interface: DataOut
        Writes a long value to this output stream.
        Specified by:
        writeLong in interface DataOut
        Parameters:
        v - The long value to write.
      • readLong

        public long readLong()
        Description copied from interface: DataIn
        Returns the next long value from this input stream, casting it to a long value in the range -9223372036854775808 to 9223372036854775807.
        Specified by:
        readLong in interface DataIn
      • writeFloat

        public void writeFloat​(float v)
        Description copied from interface: DataOut
        Writes a float value to this output stream.
        Specified by:
        writeFloat in interface DataOut
        Parameters:
        v - The float value to write.
      • readFloat

        public float readFloat()
        Description copied from interface: DataIn
        Returns the next float value from this input stream, casting it to a float value in the range -3.4028235E+38F to 3.4028235E+38F.
        Specified by:
        readFloat in interface DataIn
      • writeDouble

        public void writeDouble​(double v)
        Description copied from interface: DataOut
        Writes a double value to this output stream.
        Specified by:
        writeDouble in interface DataOut
        Parameters:
        v - The double value to write.
      • readDouble

        public double readDouble()
        Description copied from interface: DataIn
        Returns the next double value from this input stream, casting it to a double value in the range -1.7976931348623157E+308D to 1.7976931348623157E+308D.
        Specified by:
        readDouble in interface DataIn
      • writeBoolean

        public void writeBoolean​(boolean v)
        Description copied from interface: DataOut
        Writes a boolean value to this output stream.
        Specified by:
        writeBoolean in interface DataOut
        Parameters:
        v - The boolean value to write.
      • readBoolean

        public boolean readBoolean()
        Description copied from interface: DataIn
        Reads a byte from this input stream and returns it as an integer.
        Specified by:
        readBoolean in interface DataIn
      • toArray

        public byte[] toArray()
        Description copied from interface: DataIn
        Returns a copy of this input stream as an array of bytes.
        Specified by:
        toArray in interface DataIn
      • skipBytes

        public void skipBytes​(int n)
        Description copied from interface: DataIn
        Skips the specified number of bytes in this input stream.
        Specified by:
        skipBytes in interface DataIn
        Parameters:
        n - The number of bytes to skip.
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: DataIn
        Returns true if this input stream is empty, false otherwise.
        Specified by:
        isEmpty in interface DataIn
      • skipAllBytes

        public void skipAllBytes()
        Description copied from interface: DataIn
        Skips all bytes in this input stream.
        Specified by:
        skipAllBytes in interface DataIn
      • indexOf

        public int indexOf​(int limit,
                           byte val)
        Description copied from interface: DataIn
        Returns the index within this input stream of the first occurrence of the specified byte, or -1 if no such byte exists.
        Specified by:
        indexOf in interface DataIn
      • readSubData

        public DataIO readSubData​(int length)
        Description copied from interface: DataIn
        Reads a subarray of bytes from this input stream and returns the number of bytes actually read.
        Specified by:
        readSubData in interface DataIn
        Parameters:
        length - The maximum number of bytes to read.
      • writeHexBytes

        public void writeHexBytes​(java.lang.String hex)
        Description copied from interface: DataOut
        Writes a string to this output stream as hexadecimal bytes.
        Specified by:
        writeHexBytes in interface DataOut
        Parameters:
        hex - The string to write as hexadecimal bytes.
      • write

        public void write​(DataInOut data)
        Description copied from interface: DataOut
        Writes a data input stream to this output stream.
        Specified by:
        write in interface DataOut
        Parameters:
        data - The data input stream to write.
      • write

        public void write​(DataInOutStatic data)
        Description copied from interface: DataOut
        Writes a static data input stream to this output stream.
        Specified by:
        write in interface DataOut
        Parameters:
        data - The static data input stream to write.
      • write

        public void write​(DataIn data)
        Description copied from interface: DataOut
        Writes a data input stream to this output stream.
        Specified by:
        write in interface DataOut
        Parameters:
        data - The data input stream to write.
      • readUByte

        public int readUByte()
        Description copied from interface: DataIn
        Returns the next byte of data from this input stream, casting it to an unsigned byte value in the range 0-255.
        Specified by:
        readUByte in interface DataIn
      • writeByte

        public void writeByte​(int b)
        Description copied from interface: DataOut
        Writes a byte value to this output stream.
        Specified by:
        writeByte in interface DataOut
        Parameters:
        b - The byte value to write.