Package org.red5.io.amf3
Class ByteArray
java.lang.Object
org.red5.io.amf3.ByteArray
- All Implemented Interfaces:
IDataInput
,IDataOutput
Red5 version of the Flex ByteArray class.
- Author:
- The Red5 Project, Joachim Bauch (jojo@struktur.de)
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.apache.mina.core.buffer.IoBuffer
Internal storage for array contents.protected IDataInput
Object used to read from array.protected IDataOutput
Object used to write to array. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Return number of bytes available for reading.void
compress()
Compress contents using zlib.boolean
protected org.apache.mina.core.buffer.IoBuffer
getData()
Get internal data.Return the byteorder used when loading values.int
hashCode()
int
length()
Return total number of bytes in array.int
position()
Get the current position in the data.void
position
(int position) Set the current position in the data.protected void
Create internal objects used for reading and writing.boolean
Read boolean value.byte
readByte()
Read signed single byte value.void
readBytes
(byte[] bytes) Read list of bytes.void
readBytes
(byte[] bytes, int offset) Read list of bytes to given offset.void
readBytes
(byte[] bytes, int offset, int length) Read given number of bytes to given offset.double
Read double-precision floating point value.float
Read single-precision floating point value.int
readInt()
Read signed integer value.readMultiByte
(int length, String charSet) Read multibyte string.Read arbitrary object.short
Read signed short value.int
Read unsigned single byte value.long
Read unsigned integer value.int
Read unsigned short value.readUTF()
Read UTF-8 encoded string.readUTFBytes
(int length) Read UTF-8 encoded string with given length.void
Set the byteorder to use when loading values.toString()
Return string representation of the array's contents.void
Decompress contents using zlib.void
writeBoolean
(boolean value) Write boolean value.void
writeByte
(byte value) Write signed byte value.void
writeBytes
(byte[] bytes) Write multiple bytes.void
writeBytes
(byte[] bytes, int offset) Write multiple bytes from given offset.void
writeBytes
(byte[] bytes, int offset, int length) Write given number of bytes from given offset.void
writeDouble
(double value) Write double-precision floating point value.void
writeFloat
(float value) Write single-precision floating point value.void
writeInt
(int value) Write signed integer value.void
writeMultiByte
(String value, String encoding) Write string in given character set.void
writeObject
(Object value) Write arbitrary object.void
writeShort
(short value) Write signed short value.void
writeUnsignedInt
(long value) Write unsigned integer value.void
Write UTF-8 encoded string.void
writeUTFBytes
(String value) Write UTF-8 encoded string as byte array.
-
Field Details
-
data
protected org.apache.mina.core.buffer.IoBuffer dataInternal storage for array contents. -
dataInput
Object used to read from array. -
dataOutput
Object used to write to array.
-
-
Constructor Details
-
ByteArray
protected ByteArray(org.apache.mina.core.buffer.IoBuffer buffer, int length) Internal constructor used to create ByteArray during deserialization.- Parameters:
buffer
- io bufferlength
- length
-
ByteArray
public ByteArray()Public constructor. Creates new empty ByteArray.
-
-
Method Details
-
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. -
getEndian
Return the byteorder used when loading values.- Specified by:
getEndian
in interfaceIDataInput
- Specified by:
getEndian
in interfaceIDataOutput
- Returns:
- the byteorder
-
readBoolean
public boolean readBoolean()Read boolean value.- Specified by:
readBoolean
in interfaceIDataInput
- Returns:
- the value
-
readByte
public byte readByte()Read signed single byte value.- Specified by:
readByte
in interfaceIDataInput
- Returns:
- the value
-
readBytes
public void readBytes(byte[] bytes) Read list of bytes.- Specified by:
readBytes
in interfaceIDataInput
- 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 interfaceIDataInput
- Parameters:
bytes
- destination for read bytesoffset
- 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 interfaceIDataInput
- Parameters:
bytes
- destination for read bytesoffset
- offset in destination to write tolength
- number of bytes to read
-
readDouble
public double readDouble()Read double-precision floating point value.- Specified by:
readDouble
in interfaceIDataInput
- Returns:
- the value
-
readFloat
public float readFloat()Read single-precision floating point value.- Specified by:
readFloat
in interfaceIDataInput
- Returns:
- the value
-
readInt
public int readInt()Read signed integer value.- Specified by:
readInt
in interfaceIDataInput
- Returns:
- the value
-
readMultiByte
Read multibyte string.- Specified by:
readMultiByte
in interfaceIDataInput
- Parameters:
length
- length of string to readcharSet
- character set of string to read- Returns:
- the string
-
readObject
Read arbitrary object.- Specified by:
readObject
in interfaceIDataInput
- Returns:
- the object
-
readShort
public short readShort()Read signed short value.- Specified by:
readShort
in interfaceIDataInput
- Returns:
- the value
-
readUTF
Read UTF-8 encoded string.- Specified by:
readUTF
in interfaceIDataInput
- Returns:
- the string
-
readUTFBytes
Read UTF-8 encoded string with given length.- Specified by:
readUTFBytes
in interfaceIDataInput
- Parameters:
length
- the length of the string- Returns:
- the string
-
readUnsignedByte
public int readUnsignedByte()Read unsigned single byte value.- Specified by:
readUnsignedByte
in interfaceIDataInput
- Returns:
- the value
-
readUnsignedInt
public long readUnsignedInt()Read unsigned integer value.- Specified by:
readUnsignedInt
in interfaceIDataInput
- Returns:
- the value
-
readUnsignedShort
public int readUnsignedShort()Read unsigned short value.- Specified by:
readUnsignedShort
in interfaceIDataInput
- Returns:
- the value
-
setEndian
Set the byteorder to use when loading values.- Specified by:
setEndian
in interfaceIDataInput
- Specified by:
setEndian
in interfaceIDataOutput
- Parameters:
endian
- the byteorder to use
-
writeBoolean
public void writeBoolean(boolean value) Write boolean value.- Specified by:
writeBoolean
in interfaceIDataOutput
- Parameters:
value
- the value
-
writeByte
public void writeByte(byte value) Write signed byte value.- Specified by:
writeByte
in interfaceIDataOutput
- Parameters:
value
- the value
-
writeBytes
public void writeBytes(byte[] bytes) Write multiple bytes.- Specified by:
writeBytes
in interfaceIDataOutput
- Parameters:
bytes
- the bytes
-
writeBytes
public void writeBytes(byte[] bytes, int offset) Write multiple bytes from given offset.- Specified by:
writeBytes
in interfaceIDataOutput
- Parameters:
bytes
- the bytesoffset
- 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 interfaceIDataOutput
- Parameters:
bytes
- the bytesoffset
- offset in bytes to start writing fromlength
- number of bytes to write
-
writeDouble
public void writeDouble(double value) Write double-precision floating point value.- Specified by:
writeDouble
in interfaceIDataOutput
- Parameters:
value
- the value
-
writeFloat
public void writeFloat(float value) Write single-precision floating point value.- Specified by:
writeFloat
in interfaceIDataOutput
- Parameters:
value
- the value
-
writeInt
public void writeInt(int value) Write signed integer value.- Specified by:
writeInt
in interfaceIDataOutput
- Parameters:
value
- the value
-
writeMultiByte
Write string in given character set.- Specified by:
writeMultiByte
in interfaceIDataOutput
- Parameters:
value
- the stringencoding
- the character set
-
writeObject
Write arbitrary object.- Specified by:
writeObject
in interfaceIDataOutput
- Parameters:
value
- the object
-
writeShort
public void writeShort(short value) Write signed short value.- Specified by:
writeShort
in interfaceIDataOutput
- Parameters:
value
- the value
-
writeUTF
Write UTF-8 encoded string.- Specified by:
writeUTF
in interfaceIDataOutput
- Parameters:
value
- the string
-
writeUTFBytes
Write UTF-8 encoded string as byte array. This string is stored without informations about its length, soIDataInput.readUTFBytes(int)
must be used to load it.- Specified by:
writeUTFBytes
in interfaceIDataOutput
- Parameters:
value
- the string
-
writeUnsignedInt
public void writeUnsignedInt(long value) Write unsigned integer value.- Specified by:
writeUnsignedInt
in interfaceIDataOutput
- Parameters:
value
- the value
-
hashCode
public int hashCode() -
equals
-
toString
Return string representation of the array's contents.
-