Package com.inductiveautomation.rm.base
Class RMByteArray
- java.lang.Object
-
- com.inductiveautomation.rm.base.RMListenerList
-
- com.inductiveautomation.rm.base.RMObject
-
- com.inductiveautomation.rm.base.RMByteArray
-
- All Implemented Interfaces:
RMPropertyChanger,java.io.Serializable,java.lang.Cloneable
public class RMByteArray extends RMObject implements java.io.Serializable
This class is like a StringBuffer for bytes instead of chars. It implements StringBuffer styled append() methods, only everything is forced into ASCII bytes. It is also enhanced with additional binary writing capabilities, so that many core types can be written as binary.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RMByteArray()Creates an empty RMData.RMByteArray(byte[] theBytes)Creates an RMData with the given byte array.RMByteArray(byte[] theBytes, int aLength)Creates an RMData with the given byte array (only to the given length).RMByteArray(int aCapacity)Creates an empty RMData with the given capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RMByteArrayappend(byte[] bytes)Appends raw binary from byte array to data.RMByteArrayappend(byte[] bytes, int offset, int length)Appends raw binary from byte array to data.RMByteArrayappend(char c)Append common types as ASCII.RMByteArrayappend(char[] str)Append the given char array.RMByteArrayappend(char[] str, int offset, int length)Appends the given char array.RMByteArrayappend(double d)Appends the given double.RMByteArrayappend(float f)Appends the given float.RMByteArrayappend(int anInt)Appends an int string to the data.RMByteArrayappend(RMByteArray data)Appends raw binary from given data to data.RMByteArrayappend(java.lang.Object o)Appends an object's string representation to the data.RMByteArrayappend(java.lang.String aString)Appends a string to the data.voidappendByte(int aByte)Appends byte to data.voidappendInt(int anInt)Appends int to data.voidappendLittleInt(int anInt)Appends little endian int to data.voidappendLittleShort(int aShortInt)Appends little endian short to data.voidappendLittleUInt(long aUInt)Appends little endian unsigned int to data.voidappendLittleUShort(int aShort)Appends little endian unsigned short to data.voidappendShort(int aShortInt)Appends short to data.voidappendUByte(int aByte)Appends unsigned byte to data.short[]bigShortArrayAt(int index, int len)Returns the array of big endian shorts at the given byte index with the given length.shortbigShortAtIndex(int index)Returns the short at the given index (assumed to be in big endian format).longbigUIntAtIndex(int index)Returns the big endian unsigned int at the given byte index.int[]bigUShortArrayAt(int index, int len)Returns the array of big endian unsigned shorts at the given byte index with the given length.intbigUShortAtIndex(int index)Returns the big endian unsigned short at the given byte index.char[]charArrayAt(int index, int len)Returns the char array at the given byte index with the given length.java.lang.Objectclone()Standard clone implementation.booleanequals(java.lang.Object anObj)Standard equals implementation.voidflateCompressedData()Flate compresses data.bytegetByte(int index)Returns the specific byte at the given index.byte[]getBytes()Returns the bytes in the data.voidgetBytes(int srcBegin, int srcEnd, byte[] destBytes)Copies the bytes from this data to the given byte array.voidgetBytes(int srcBegin, int srcEnd, byte[] destBytes, int destBegin)Copies the bytes from this data to the given byte array.intgetCapacity()Returns the size of the internal byte array.java.io.InputStreamgetInputStream()Returns an input stream of this data's bytes.voidinsert(int index, byte[] bytes)Inserts raw binary from byte array to data.voidinsert(int index, byte[] bytes, int offset, int length)Inserts raw binary from byte array to data.voidinsert(int index, RMByteArray data)Inserts raw binary from given data to data.voidinsertLittleUIntAtIndex(long aUInt, int byteIndex)Inserts little endian unsigned int to data at given index.intlength()Returns the length of the data.shortlittleShortAtIndex(int index)Returns the little endian short at the given byte index.longlittleUIntAtIndex(int index)Returns the little endian unsigned int at the given byte index.intlittleUShortAtIndex(int index)Returns the little endian unsigned short at the given byte index.voidreplace(int start, int end, byte[] bytes, int offset, int length)Replace raw binary from byte array in data.voidsetCapacity(int aMinimumCapacity)Makes sure internal byte array is at least a given size.voidsetLittleIntAtIndex(int anInt, int byteIndex)Sets little endian int to data at given index.voidsetLittleShortAtIndex(int aShortInt, int byteIndex)Sets little endian short to data at given index.voidsetLittleUShortAtIndex(int aShort, int byteIndex)Sets little endian unsigned short to data at given index.byte[]toByteArray()Returns a byte array for the bytes in the data.byte[]toByteArray(int start, int end)Returns a byte array for the bytes in the data.java.lang.StringtoString()Returns the string initialized from the data's bytes (ISO Latin).java.lang.StringtoString(int start, int end, java.lang.String encoding)Returns the string initialized from the data's bytes in the given encoding.-
Methods inherited from class com.inductiveautomation.rm.base.RMObject
addPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChange
-
Methods inherited from class com.inductiveautomation.rm.base.RMListenerList
addListener, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListener
-
-
-
-
Constructor Detail
-
RMByteArray
public RMByteArray()
Creates an empty RMData.
-
RMByteArray
public RMByteArray(int aCapacity)
Creates an empty RMData with the given capacity.
-
RMByteArray
public RMByteArray(byte[] theBytes)
Creates an RMData with the given byte array.
-
RMByteArray
public RMByteArray(byte[] theBytes, int aLength)Creates an RMData with the given byte array (only to the given length).
-
-
Method Detail
-
getBytes
public byte[] getBytes()
Returns the bytes in the data.
-
length
public int length()
Returns the length of the data.
-
getByte
public byte getByte(int index)
Returns the specific byte at the given index.
-
getBytes
public void getBytes(int srcBegin, int srcEnd, byte[] destBytes)Copies the bytes from this data to the given byte array.
-
getBytes
public void getBytes(int srcBegin, int srcEnd, byte[] destBytes, int destBegin)Copies the bytes from this data to the given byte array.
-
getInputStream
public java.io.InputStream getInputStream()
Returns an input stream of this data's bytes.
-
append
public RMByteArray append(char c)
Append common types as ASCII.
-
append
public RMByteArray append(char[] str)
Append the given char array.
-
append
public RMByteArray append(char[] str, int offset, int length)
Appends the given char array.
-
append
public RMByteArray append(double d)
Appends the given double.
-
append
public RMByteArray append(float f)
Appends the given float.
-
append
public RMByteArray append(int anInt)
Appends an int string to the data.
-
append
public RMByteArray append(java.lang.Object o)
Appends an object's string representation to the data.
-
append
public RMByteArray append(java.lang.String aString)
Appends a string to the data.
-
append
public RMByteArray append(RMByteArray data)
Appends raw binary from given data to data.
-
append
public RMByteArray append(byte[] bytes)
Appends raw binary from byte array to data.
-
append
public RMByteArray append(byte[] bytes, int offset, int length)
Appends raw binary from byte array to data.
-
insert
public void insert(int index, RMByteArray data)Inserts raw binary from given data to data.
-
insert
public void insert(int index, byte[] bytes)Inserts raw binary from byte array to data.
-
insert
public void insert(int index, byte[] bytes, int offset, int length)Inserts raw binary from byte array to data.
-
replace
public void replace(int start, int end, byte[] bytes, int offset, int length)Replace raw binary from byte array in data.
-
appendByte
public void appendByte(int aByte)
Appends byte to data.
-
appendUByte
public void appendUByte(int aByte)
Appends unsigned byte to data.
-
appendShort
public void appendShort(int aShortInt)
Appends short to data.
-
appendLittleShort
public void appendLittleShort(int aShortInt)
Appends little endian short to data.
-
appendLittleUShort
public void appendLittleUShort(int aShort)
Appends little endian unsigned short to data.
-
appendInt
public void appendInt(int anInt)
Appends int to data.
-
appendLittleInt
public void appendLittleInt(int anInt)
Appends little endian int to data.
-
appendLittleUInt
public void appendLittleUInt(long aUInt)
Appends little endian unsigned int to data.
-
setLittleShortAtIndex
public void setLittleShortAtIndex(int aShortInt, int byteIndex)Sets little endian short to data at given index.
-
setLittleUShortAtIndex
public void setLittleUShortAtIndex(int aShort, int byteIndex)Sets little endian unsigned short to data at given index.
-
setLittleIntAtIndex
public void setLittleIntAtIndex(int anInt, int byteIndex)Sets little endian int to data at given index.
-
insertLittleUIntAtIndex
public void insertLittleUIntAtIndex(long aUInt, int byteIndex)Inserts little endian unsigned int to data at given index.
-
bigShortAtIndex
public short bigShortAtIndex(int index)
Returns the short at the given index (assumed to be in big endian format).
-
bigUShortAtIndex
public int bigUShortAtIndex(int index)
Returns the big endian unsigned short at the given byte index.
-
littleShortAtIndex
public short littleShortAtIndex(int index)
Returns the little endian short at the given byte index.
-
littleUShortAtIndex
public int littleUShortAtIndex(int index)
Returns the little endian unsigned short at the given byte index.
-
bigUIntAtIndex
public long bigUIntAtIndex(int index)
Returns the big endian unsigned int at the given byte index.
-
littleUIntAtIndex
public long littleUIntAtIndex(int index)
Returns the little endian unsigned int at the given byte index.
-
charArrayAt
public char[] charArrayAt(int index, int len)Returns the char array at the given byte index with the given length.
-
bigShortArrayAt
public short[] bigShortArrayAt(int index, int len)Returns the array of big endian shorts at the given byte index with the given length.
-
bigUShortArrayAt
public int[] bigUShortArrayAt(int index, int len)Returns the array of big endian unsigned shorts at the given byte index with the given length.
-
getCapacity
public int getCapacity()
Returns the size of the internal byte array.
-
setCapacity
public void setCapacity(int aMinimumCapacity)
Makes sure internal byte array is at least a given size.
-
equals
public boolean equals(java.lang.Object anObj)
Standard equals implementation.- Overrides:
equalsin classjava.lang.Object
-
clone
public java.lang.Object clone()
Standard clone implementation.- Overrides:
clonein classRMListenerList
-
toString
public java.lang.String toString()
Returns the string initialized from the data's bytes (ISO Latin).
-
toString
public java.lang.String toString(int start, int end, java.lang.String encoding)Returns the string initialized from the data's bytes in the given encoding.
-
toByteArray
public byte[] toByteArray()
Returns a byte array for the bytes in the data.
-
toByteArray
public byte[] toByteArray(int start, int end)Returns a byte array for the bytes in the data.
-
flateCompressedData
public void flateCompressedData()
Flate compresses data.
-
-