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 ([email protected])
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.mina.core.buffer.IoBufferInternal storage for array contents.protected IDataInputObject used to read from array.protected IDataOutputObject used to write to array. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturn number of bytes available for reading.voidcompress()Compress contents using zlib.booleanprotected org.apache.mina.core.buffer.IoBuffergetData()Get internal data.Return the byteorder used when loading values.inthashCode()intlength()Return total number of bytes in array.intposition()Get the current position in the data.voidposition(int position) Set the current position in the data.protected voidCreate internal objects used for reading and writing.booleanRead boolean value.bytereadByte()Read signed single byte value.voidreadBytes(byte[] bytes) Read list of bytes.voidreadBytes(byte[] bytes, int offset) Read list of bytes to given offset.voidreadBytes(byte[] bytes, int offset, int length) Read given number of bytes to given offset.doubleRead double-precision floating point value.floatRead single-precision floating point value.intreadInt()Read signed integer value.readMultiByte(int length, String charSet) Read multibyte string.Read arbitrary object.shortRead signed short value.intRead unsigned single byte value.longRead unsigned integer value.intRead unsigned short value.readUTF()Read UTF-8 encoded string.readUTFBytes(int length) Read UTF-8 encoded string with given length.voidSet the byteorder to use when loading values.toString()Return string representation of the array's contents.voidDecompress contents using zlib.voidwriteBoolean(boolean value) Write boolean value.voidwriteByte(byte value) Write signed byte value.voidwriteBytes(byte[] bytes) Write multiple bytes.voidwriteBytes(byte[] bytes, int offset) Write multiple bytes from given offset.voidwriteBytes(byte[] bytes, int offset, int length) Write given number of bytes from given offset.voidwriteDouble(double value) Write double-precision floating point value.voidwriteFloat(float value) Write single-precision floating point value.voidwriteInt(int value) Write signed integer value.voidwriteMultiByte(String value, String encoding) Write string in given character set.voidwriteObject(Object value) Write arbitrary object.voidwriteShort(short value) Write signed short value.voidwriteUnsignedInt(long value) Write unsigned integer value.voidWrite UTF-8 encoded string.voidwriteUTFBytes(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:
getEndianin interfaceIDataInput- Specified by:
getEndianin interfaceIDataOutput- Returns:
- the byteorder
-
readBoolean
public boolean readBoolean()Read boolean value.- Specified by:
readBooleanin interfaceIDataInput- Returns:
- the value
-
readByte
public byte readByte()Read signed single byte value.- Specified by:
readBytein interfaceIDataInput- Returns:
- the value
-
readBytes
public void readBytes(byte[] bytes) Read list of bytes.- Specified by:
readBytesin interfaceIDataInput- Parameters:
bytes- destination for read bytes
-
readBytes
public void readBytes(byte[] bytes, int offset) Read list of bytes to given offset.- Specified by:
readBytesin 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:
readBytesin 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:
readDoublein interfaceIDataInput- Returns:
- the value
-
readFloat
public float readFloat()Read single-precision floating point value.- Specified by:
readFloatin interfaceIDataInput- Returns:
- the value
-
readInt
public int readInt()Read signed integer value.- Specified by:
readIntin interfaceIDataInput- Returns:
- the value
-
readMultiByte
Read multibyte string.- Specified by:
readMultiBytein interfaceIDataInput- Parameters:
length- length of string to readcharSet- character set of string to read- Returns:
- the string
-
readObject
Read arbitrary object.- Specified by:
readObjectin interfaceIDataInput- Returns:
- the object
-
readShort
public short readShort()Read signed short value.- Specified by:
readShortin interfaceIDataInput- Returns:
- the value
-
readUTF
Read UTF-8 encoded string.- Specified by:
readUTFin interfaceIDataInput- Returns:
- the string
-
readUTFBytes
Read UTF-8 encoded string with given length.- Specified by:
readUTFBytesin interfaceIDataInput- Parameters:
length- the length of the string- Returns:
- the string
-
readUnsignedByte
public int readUnsignedByte()Read unsigned single byte value.- Specified by:
readUnsignedBytein interfaceIDataInput- Returns:
- the value
-
readUnsignedInt
public long readUnsignedInt()Read unsigned integer value.- Specified by:
readUnsignedIntin interfaceIDataInput- Returns:
- the value
-
readUnsignedShort
public int readUnsignedShort()Read unsigned short value.- Specified by:
readUnsignedShortin interfaceIDataInput- Returns:
- the value
-
setEndian
Set the byteorder to use when loading values.- Specified by:
setEndianin interfaceIDataInput- Specified by:
setEndianin interfaceIDataOutput- Parameters:
endian- the byteorder to use
-
writeBoolean
public void writeBoolean(boolean value) Write boolean value.- Specified by:
writeBooleanin interfaceIDataOutput- Parameters:
value- the value
-
writeByte
public void writeByte(byte value) Write signed byte value.- Specified by:
writeBytein interfaceIDataOutput- Parameters:
value- the value
-
writeBytes
public void writeBytes(byte[] bytes) Write multiple bytes.- Specified by:
writeBytesin interfaceIDataOutput- Parameters:
bytes- the bytes
-
writeBytes
public void writeBytes(byte[] bytes, int offset) Write multiple bytes from given offset.- Specified by:
writeBytesin 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:
writeBytesin 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:
writeDoublein interfaceIDataOutput- Parameters:
value- the value
-
writeFloat
public void writeFloat(float value) Write single-precision floating point value.- Specified by:
writeFloatin interfaceIDataOutput- Parameters:
value- the value
-
writeInt
public void writeInt(int value) Write signed integer value.- Specified by:
writeIntin interfaceIDataOutput- Parameters:
value- the value
-
writeMultiByte
Write string in given character set.- Specified by:
writeMultiBytein interfaceIDataOutput- Parameters:
value- the stringencoding- the character set
-
writeObject
Write arbitrary object.- Specified by:
writeObjectin interfaceIDataOutput- Parameters:
value- the object
-
writeShort
public void writeShort(short value) Write signed short value.- Specified by:
writeShortin interfaceIDataOutput- Parameters:
value- the value
-
writeUTF
Write UTF-8 encoded string.- Specified by:
writeUTFin 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:
writeUTFBytesin interfaceIDataOutput- Parameters:
value- the string
-
writeUnsignedInt
public void writeUnsignedInt(long value) Write unsigned integer value.- Specified by:
writeUnsignedIntin interfaceIDataOutput- Parameters:
value- the value
-
hashCode
public int hashCode() -
equals
-
toString
Return string representation of the array's contents.
-