Class ByteArray

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.mina.core.buffer.IoBuffer data
      Internal storage for array contents.
      protected IDataInput dataInput
      Object used to read from array.
      protected IDataOutput dataOutput
      Object used to write to array.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        ByteArray()
      Public constructor.
      protected ByteArray​(org.apache.mina.core.buffer.IoBuffer buffer, int length)
      Internal constructor used to create ByteArray during deserialization.
    • Field Detail

      • data

        protected org.apache.mina.core.buffer.IoBuffer data
        Internal storage for array contents.
      • dataInput

        protected IDataInput dataInput
        Object used to read from array.
      • dataOutput

        protected IDataOutput dataOutput
        Object used to write to array.
    • Constructor Detail

      • ByteArray

        protected ByteArray​(org.apache.mina.core.buffer.IoBuffer buffer,
                            int length)
        Internal constructor used to create ByteArray during deserialization.
        Parameters:
        buffer - io buffer
        length - length
      • ByteArray

        public ByteArray()
        Public constructor. Creates new empty ByteArray.
    • Method Detail

      • prepareIO

        protected void prepareIO()
        Create internal objects used for reading and writing.
      • getData

        protected org.apache.mina.core.buffer.IoBuffer getData()
        Get internal data.
        Returns:
        byte buffer
      • position

        public int position()
        Get the current position in the data.
        Returns:
        current position
      • position

        public void position​(int position)
        Set the current position in the data.
        Parameters:
        position - position to set
      • bytesAvailable

        public int bytesAvailable()
        Return number of bytes available for reading.
        Returns:
        bytes available
      • length

        public int length()
        Return total number of bytes in array.
        Returns:
        number of bytes in array
      • compress

        public void compress()
        Compress contents using zlib.
      • uncompress

        public void uncompress()
        Decompress contents using zlib.
      • readBoolean

        public boolean readBoolean()
        Read boolean value.
        Specified by:
        readBoolean in interface IDataInput
        Returns:
        the value
      • readByte

        public byte readByte()
        Read signed single byte value.
        Specified by:
        readByte in interface IDataInput
        Returns:
        the value
      • readBytes

        public void readBytes​(byte[] bytes)
        Read list of bytes.
        Specified by:
        readBytes in interface IDataInput
        Parameters:
        bytes - destination for read bytes
      • readBytes

        public void readBytes​(byte[] bytes,
                              int offset)
        Read list of bytes to given offset.
        Specified by:
        readBytes in interface IDataInput
        Parameters:
        bytes - destination for read bytes
        offset - offset in destination to write to
      • readBytes

        public void readBytes​(byte[] bytes,
                              int offset,
                              int length)
        Read given number of bytes to given offset.
        Specified by:
        readBytes in interface IDataInput
        Parameters:
        bytes - destination for read bytes
        offset - offset in destination to write to
        length - number of bytes to read
      • readDouble

        public double readDouble()
        Read double-precision floating point value.
        Specified by:
        readDouble in interface IDataInput
        Returns:
        the value
      • readFloat

        public float readFloat()
        Read single-precision floating point value.
        Specified by:
        readFloat in interface IDataInput
        Returns:
        the value
      • readInt

        public int readInt()
        Read signed integer value.
        Specified by:
        readInt in interface IDataInput
        Returns:
        the value
      • readMultiByte

        public String readMultiByte​(int length,
                                    String charSet)
        Read multibyte string.
        Specified by:
        readMultiByte in interface IDataInput
        Parameters:
        length - length of string to read
        charSet - character set of string to read
        Returns:
        the string
      • readObject

        public Object readObject()
        Read arbitrary object.
        Specified by:
        readObject in interface IDataInput
        Returns:
        the object
      • readShort

        public short readShort()
        Read signed short value.
        Specified by:
        readShort in interface IDataInput
        Returns:
        the value
      • readUTF

        public String readUTF()
        Read UTF-8 encoded string.
        Specified by:
        readUTF in interface IDataInput
        Returns:
        the string
      • readUTFBytes

        public String readUTFBytes​(int length)
        Read UTF-8 encoded string with given length.
        Specified by:
        readUTFBytes in interface IDataInput
        Parameters:
        length - the length of the string
        Returns:
        the string
      • readUnsignedByte

        public int readUnsignedByte()
        Read unsigned single byte value.
        Specified by:
        readUnsignedByte in interface IDataInput
        Returns:
        the value
      • readUnsignedInt

        public long readUnsignedInt()
        Read unsigned integer value.
        Specified by:
        readUnsignedInt in interface IDataInput
        Returns:
        the value
      • readUnsignedShort

        public int readUnsignedShort()
        Read unsigned short value.
        Specified by:
        readUnsignedShort in interface IDataInput
        Returns:
        the value
      • setEndian

        public void setEndian​(ByteOrder endian)
        Set the byteorder to use when loading values.
        Specified by:
        setEndian in interface IDataInput
        Specified by:
        setEndian in interface IDataOutput
        Parameters:
        endian - the byteorder to use
      • writeBoolean

        public void writeBoolean​(boolean value)
        Write boolean value.
        Specified by:
        writeBoolean in interface IDataOutput
        Parameters:
        value - the value
      • writeByte

        public void writeByte​(byte value)
        Write signed byte value.
        Specified by:
        writeByte in interface IDataOutput
        Parameters:
        value - the value
      • writeBytes

        public void writeBytes​(byte[] bytes)
        Write multiple bytes.
        Specified by:
        writeBytes in interface IDataOutput
        Parameters:
        bytes - the bytes
      • writeBytes

        public void writeBytes​(byte[] bytes,
                               int offset)
        Write multiple bytes from given offset.
        Specified by:
        writeBytes in interface IDataOutput
        Parameters:
        bytes - the bytes
        offset - offset in bytes to start writing from
      • writeBytes

        public void writeBytes​(byte[] bytes,
                               int offset,
                               int length)
        Write given number of bytes from given offset.
        Specified by:
        writeBytes in interface IDataOutput
        Parameters:
        bytes - the bytes
        offset - offset in bytes to start writing from
        length - number of bytes to write
      • writeDouble

        public void writeDouble​(double value)
        Write double-precision floating point value.
        Specified by:
        writeDouble in interface IDataOutput
        Parameters:
        value - the value
      • writeFloat

        public void writeFloat​(float value)
        Write single-precision floating point value.
        Specified by:
        writeFloat in interface IDataOutput
        Parameters:
        value - the value
      • writeInt

        public void writeInt​(int value)
        Write signed integer value.
        Specified by:
        writeInt in interface IDataOutput
        Parameters:
        value - the value
      • writeMultiByte

        public void writeMultiByte​(String value,
                                   String encoding)
        Write string in given character set.
        Specified by:
        writeMultiByte in interface IDataOutput
        Parameters:
        value - the string
        encoding - the character set
      • writeObject

        public void writeObject​(Object value)
        Write arbitrary object.
        Specified by:
        writeObject in interface IDataOutput
        Parameters:
        value - the object
      • writeShort

        public void writeShort​(short value)
        Write signed short value.
        Specified by:
        writeShort in interface IDataOutput
        Parameters:
        value - the value
      • writeUTF

        public void writeUTF​(String value)
        Write UTF-8 encoded string.
        Specified by:
        writeUTF in interface IDataOutput
        Parameters:
        value - the string
      • writeUTFBytes

        public void writeUTFBytes​(String value)
        Write UTF-8 encoded string as byte array. This string is stored without informations about its length, so IDataInput.readUTFBytes(int) must be used to load it.
        Specified by:
        writeUTFBytes in interface IDataOutput
        Parameters:
        value - the string
      • writeUnsignedInt

        public void writeUnsignedInt​(long value)
        Write unsigned integer value.
        Specified by:
        writeUnsignedInt in interface IDataOutput
        Parameters:
        value - the value
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Return string representation of the array's contents.
        Overrides:
        toString in class Object
        Returns:
        string representation of array's contents.