|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opengts.util.Payload
public class Payload
For reading/writing binary fields
Field Summary | |
---|---|
static int |
DEFAULT_MAX_PAYLOAD_LENGTH
|
static byte[] |
EMPTY_BYTE_ARRAY
|
Constructor Summary | |
---|---|
|
Payload()
Destination Constructor |
|
Payload(boolean bigEndian)
Destination Constructor |
|
Payload(byte[] b)
Source Constuctor |
|
Payload(byte[] b,
boolean bigEndian)
Source Constuctor |
|
Payload(byte[] b,
int ofs,
int len)
Source Constuctor |
|
Payload(byte[] n,
int ofs,
int len,
boolean bigEndian)
Source Constuctor |
|
Payload(int maxPayloadLen)
Destination Constructor |
|
Payload(int maxPayloadLen,
boolean bigEndian)
Destination Constructor |
protected |
Payload(int frame,
byte[] n,
int ofs,
int len,
boolean bigEndian)
Source Constuctor |
Method Summary | |
---|---|
protected byte[] |
_readBytes(int length,
java.lang.String msg,
int frame)
Read length
|
protected double |
_readDouble(int length,
double dft,
boolean bigEndian,
int frame,
java.lang.String msg)
Read a double value from payload (with default), using IEEE 754 format |
protected long |
_readLong(int length,
long dft,
boolean bigEndian,
int frame,
java.lang.String msg)
Read a long value from payload (with default) |
protected void |
_readSkip(int length,
int frame,
java.lang.String msg)
Skip a specified number of bytes |
protected java.lang.String |
_readString(int length,
boolean varLength,
int frame,
java.lang.String msg)
Read a string from the payload. |
protected java.lang.String |
_readStringHex(int length,
int frame,
java.lang.String msg)
Reads a fixed length hex string from the payload bytes. |
protected long |
_readULong(int length,
long dft,
boolean bigEndian,
int frame,
java.lang.String msg)
Read an unsigned long value from payload (with default) |
protected int |
_writeBytes(byte[] n,
int nOfs,
int nLen,
int wrtLen,
int frame)
Write an array of bytes to the payload |
protected int |
_writeDouble(double val,
int wrtLen,
boolean bigEndian,
int frame)
Write a double value to the payload |
protected int |
_writeLong(long val,
int wrtLen,
boolean bigEndian,
int frame)
Write a long value to the payload |
protected int |
_writeZeroFill(int wrtLen,
int frame)
Write a zero fill to the payload |
long |
calcChecksum(Checksum.CRC crc,
int bOfs,
int bLen)
Calculate/Return CCITT CRC for specified offset/length |
int |
calcCrc16(int bOfs,
int bLen)
Calculate/Return standard CRC-16 (0x0000) for specified offset/length |
int |
calcCrc16Modbus(int bOfs,
int bLen)
Calculate/Return CRC-16 (0xFFFF Modbus variant) for specified offset/length |
int |
calcCrcCCITT(int bOfs,
int bLen)
Calculate/Return standard CCITT CRC (0xFFFF) for specified offset/length |
int |
calcCrcSum8(int bOfs,
int bLen)
Calculate/Return byte Sum8 CRC for specified offset/length |
int |
calcCrcXmodem(int bOfs,
int bLen)
Calculate/Return CCITT CRC (0x0000 Xmodem variant) for specified offset/length |
protected static void |
checkOverflow(int length,
int maxLen,
int frame,
java.lang.String msg)
Check for read overflow |
void |
clear()
Resets the payload to an empty state |
static double |
decodeDouble(byte[] data,
int ofs,
int len,
boolean bigEndian,
double dft)
Decodes a double value from bytes, using IEEE 754 format |
static long |
decodeLong(byte[] data,
int ofs,
int len,
boolean bigEndian,
boolean signed,
long dft)
Decodes a long value from bytes |
static int |
encodeDouble(byte[] data,
int ofs,
int len,
boolean bigEndian,
double val)
Encodes a double value into bytes |
static int |
encodeLong(byte[] data,
int ofs,
int len,
boolean bigEndian,
long val)
Encodes a long value into bytes |
static byte[] |
encodeLong(long val,
int len,
boolean bigEndian)
Encodes a long value into bytes |
static long |
extendSignBit(long val,
int bitLen)
Extends the sign-bit into a long value |
int |
getAvailableReadLength()
Gets the number of remaining available to read |
int |
getAvailableWriteLength()
Gets the nubmer of remaining availible bytes to write |
boolean |
getBigEndian()
Gets the byte ordering of the payload |
byte[] |
getBytes()
Return a byte array representing the data currently in the payload (may be a copy) |
static boolean |
GetDebugLogging()
Gets internal debug logging |
int |
getIndex()
Gets the current read/write index |
int |
getMaximumReadLength()
Return the maximum allowed read length (same as " getAvailableReadLength ") |
int |
getMaximumReadLength(int length)
Return the maximum allowed read length up to the specific length |
int |
getMaximumWriteLength(int wrtLen)
Return the maximum allowed write length up to the specific length |
int |
getSize()
For an output/write Payload, returns the number of bytes written. |
boolean |
hasAvailableRead()
Returns true if there are bytes available for reading |
boolean |
hasAvailableWrite()
Returns true if there are bytes available for writing |
boolean |
isBigEndian()
Returns true if the payload is big-endian |
boolean |
isValidBCD(int length)
Returns true if the length fields contains only BCD nybbles |
boolean |
isValidReadLength(int length)
Returns true if there are at least length bytes that
can be read from the payload |
boolean |
isValidWriteLength(int length)
Returns true if there are at least length bytes that
can be written to the payload |
static void |
main(java.lang.String[] argv)
Main entry point for testing/debugging |
int |
peekByte()
Read the next byte without moving the read pointer |
byte[] |
peekBytes(int length)
Reads the specified number of bytes from the stream The read pointer is left as is |
byte[] |
peekBytes(int offset,
int length)
Reads the specified number of bytes from the stream The read pointer is left as is |
byte[] |
readBytes(int length)
Read length
|
byte[] |
readBytes(int length,
java.lang.String msg)
Read length
|
double |
readDouble(int length,
double dft)
Read a double value from payload (with default), using IEEE 754 format |
double |
readDouble(int length,
double dft,
boolean bigEndian)
Read a double value from payload (with default), using IEEE 754 format |
double |
readDouble(int length,
double dft,
boolean bigEndian,
java.lang.String msg)
Read a double value from payload (with default), using IEEE 754 format |
double |
readDouble(int length,
double dft,
java.lang.String msg)
Read a double value from payload (with default), using IEEE 754 format |
GeoPoint |
readGPS(int length)
Reads an encoded GPS point (latitude,longitude) from the payload |
GeoPoint |
readGPS(int length,
java.lang.String msg)
Reads an encoded GPS point (latitude,longitude) from the payload |
int |
readInt(int length,
int dft)
Read a int value from payload (with default) |
int |
readInt(int length,
int dft,
java.lang.String msg)
Read a int value from payload (with default) |
int |
readIntBCD(int length,
int dft)
Read an unsigned BCD (hex) encoded int value from the payload. |
int |
readIntBCD(int length,
int dft,
java.lang.String msg)
Read an unsigned BCD (hex) encoded int value from the payload. |
long |
readLong(int length,
long dft)
Read a long value from payload (with default) |
long |
readLong(int length,
long dft,
boolean bigEndian)
Read a long value from payload (with default) |
long |
readLong(int length,
long dft,
boolean bigEndian,
java.lang.String msg)
Read a long value from payload (with default) |
long |
readLong(int length,
long dft,
java.lang.String msg)
Read a long value from payload (with default) |
long |
readLongBCD(int length,
long dft)
Read an unsigned BCD (hex) encoded long value from the payload. |
long |
readLongBCD(int length,
long dft,
java.lang.String msg)
Read an unsigned BCD (hex) encoded long value from the payload. |
void |
readSkip(int length)
Skip a specified number of bytes |
void |
readSkip(int length,
java.lang.String msg)
Skip a specified number of bytes |
java.lang.String |
readString(int length)
Reads a variable length string from the payload |
java.lang.String |
readString(int length,
boolean varLength)
Read a string from the payload. |
java.lang.String |
readString(int length,
boolean varLength,
java.lang.String msg)
Read a string from the payload. |
java.lang.String |
readString(int length,
java.lang.String msg)
Reads a variable length string from the payload |
java.lang.String |
readStringHex(int length)
Reads a fixed length hex string from the payload bytes. |
java.lang.String |
readStringHex(int length,
java.lang.String msg)
Reads a fixed length hex string from the payload bytes. |
int |
readUInt(int length,
int dft)
Read an unsigned int value from payload (with default) |
int |
readUInt(int length,
int dft,
boolean bigEndian)
Read an unsigned int value from payload (with default) |
int |
readUInt(int length,
int dft,
boolean bigEndian,
java.lang.String msg)
Read an unsigned int value from payload (with default) |
int |
readUInt(int length,
int dft,
java.lang.String msg)
Read an unsigned int value from payload (with default) |
long |
readULong(int length,
long dft)
Read an unsigned long value from payload (with default) |
long |
readULong(int length,
long dft,
boolean bigEndian)
Read an unsigned long value from payload (with default) |
long |
readULong(int length,
long dft,
boolean bigEndian,
java.lang.String msg)
Read an unsigned long value from payload (with default) |
long |
readULong(int length,
long dft,
java.lang.String msg)
Read an unsigned long value from payload (with default) |
void |
resetIndex()
Resets the read/write index to ' 0 ' |
void |
resetIndex(int ndx)
Resets the read/write index to the specified value |
boolean |
restoreIndex()
Restores the current index (restore to marker). |
static long |
reverseByteOrder(long value,
int byteCount)
Reverses the byte order of the specified value. IE: Convert Bit-Endian to Little-Endian, and visa-versa. |
boolean |
saveIndex()
Saves the current index (set marker). |
int |
scanForPattern(byte[] p)
Scans the remainder of the payload for the specified byte pattern and returns the offset from the current pointer to the beginning of the matching pattern. |
int |
scanForPattern(byte[] p,
int fromNdx)
Scans the remainder of the payload for the specified byte pattern and returns the offset from the current pointer to the beginning of the matching pattern. |
void |
setBigEndian()
Sets the byte ordering of the payload to "Big-Endian" Also called "Network Byte Order", "MSB first", ... |
void |
setBigEndian(boolean bigEndFirst)
Sets the byte ordering of the payload |
static void |
SetDebugLogging(boolean debug)
Sets internal debug logging |
void |
setLittleEndian()
Sets the byte ordering of the payload to "Little-Endian" Also called "LSB first", ... |
java.lang.String |
toString()
Returns a hex string representation of the payload |
int |
writeByte(byte val)
Write a byte value to the payload |
int |
writeBytes(byte[] n)
Write an array of bytes to the payload |
int |
writeBytes(byte[] n,
int wrtLen)
Write an array of bytes to the payload |
int |
writeBytes(byte[] n,
int nOfs,
int nLen,
int wrtLen)
Write an array of bytes to the payload |
int |
writeDouble(double val,
int wrtLen)
Write a double value to the payload |
int |
writeDouble(double val,
int wrtLen,
boolean bigEndian)
Write a double value to the payload |
int |
writeGPS(double lat,
double lon,
int length)
Encode a new GPS point into the payload |
int |
writeGPS(GeoPoint gp,
int wrtLen)
Encode a GPS point into the payload |
int |
writeInt(int val,
int length)
Write a int value to the payload |
int |
writeLong(long val,
int length)
Write a long value to the payload |
int |
writeLong(long val,
int length,
boolean bigEndian)
Write a long value to the payload |
int |
writeRandomBytes(java.util.Random rand,
int wrtLen)
Write random bytes to the payload |
int |
writeString(java.lang.String s,
int wrtLen)
Write a string to the payload. |
int |
writeString(java.lang.String s,
int wrtLen,
boolean varLength)
Write a string to the payload. |
int |
writeUInt(int val,
int length)
Write a unsigned int value to the payload. |
int |
writeULong(long val,
int length)
Write a unsigned long value to the payload. |
int |
writeULong(long val,
int length,
boolean bigEndian)
Write a unsigned long value to the payload. |
int |
writeZeroFill(int wrtLen)
Write a zero fill to the payload |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_MAX_PAYLOAD_LENGTH
public static final byte[] EMPTY_BYTE_ARRAY
Constructor Detail |
---|
public Payload()
public Payload(int maxPayloadLen)
maxPayloadLen
- The maximum payload lengthpublic Payload(boolean bigEndian)
public Payload(int maxPayloadLen, boolean bigEndian)
maxPayloadLen
- The maximum payload lengthbigEndian
- If the payload uses big-endian byte orderingpublic Payload(byte[] b)
b
- The payload (default big-endian byte ordering)public Payload(byte[] b, boolean bigEndian)
b
- The payloadbigEndian
- If the payload uses big-endian byte orderingpublic Payload(byte[] b, int ofs, int len)
b
- The byte array to copy the payload from (defalt big-endian byte orderingofs
- The offset at which copying of b
should beginlen
- The length of the resultant payloadpublic Payload(byte[] n, int ofs, int len, boolean bigEndian)
n
- The byte array to copy the payload from (defalt big-endian byte orderingofs
- The offset at which copying of b
should beginlen
- The length of the resultant payloadbigEndian
- If the payload uses big-endian byte orderingprotected Payload(int frame, byte[] n, int ofs, int len, boolean bigEndian)
frame
- The caller stackframn
- The byte array to copy the payload from (defalt big-endian byte orderingofs
- The offset at which copying of b
should beginlen
- The length of the resultant payloadbigEndian
- If the payload uses big-endian byte orderingMethod Detail |
---|
public static void SetDebugLogging(boolean debug)
public static boolean GetDebugLogging()
protected static void checkOverflow(int length, int maxLen, int frame, java.lang.String msg)
public void setBigEndian()
public void setLittleEndian()
public void setBigEndian(boolean bigEndFirst)
bigEndFirst
- True for big-endian, false for little-endian numeric encodingpublic boolean getBigEndian()
public boolean isBigEndian()
public int getSize()
public void clear()
public byte[] getBytes()
public long calcChecksum(Checksum.CRC crc, int bOfs, int bLen)
crc
- The CRC algorithm to usebOfs
- The offsetbLen
- The length
public int calcCrcCCITT(int bOfs, int bLen)
bOfs
- The offsetbLen
- The length
public int calcCrcXmodem(int bOfs, int bLen)
bOfs
- The offsetbLen
- The length
public int calcCrc16(int bOfs, int bLen)
bOfs
- The offsetbLen
- The length
public int calcCrc16Modbus(int bOfs, int bLen)
bOfs
- The offsetbLen
- The length
public int calcCrcSum8(int bOfs, int bLen)
bOfs
- The offsetbLen
- The length
public int getIndex()
public void resetIndex()
0
'
public void resetIndex(int ndx)
ndx
- The value to set the indexpublic boolean saveIndex()
public boolean restoreIndex()
public int getMaximumReadLength(int length)
length
- The preferred length
public int getMaximumReadLength()
getAvailableReadLength
")
getAvailableReadLength()
public int getAvailableReadLength()
public boolean isValidReadLength(int length)
length
bytes that
can be read from the payload
length
readable bytes
in the payloadpublic boolean hasAvailableRead()
public int getMaximumWriteLength(int wrtLen)
wrtLen
- The preferred length
public int getAvailableWriteLength()
public boolean isValidWriteLength(int length)
length
bytes that
can be written to the payload
length
writeable bytes
in the payloadpublic boolean hasAvailableWrite()
public void readSkip(int length)
length
- The number of bytes to skippublic void readSkip(int length, java.lang.String msg)
length
- The number of bytes to skipmsg
- Debug message (used during "DebugLogging")protected void _readSkip(int length, int frame, java.lang.String msg)
length
- The number of bytes to skipmsg
- Debug message (used during "DebugLogging")public int peekByte()
public byte[] peekBytes(int length)
length
- The number of bytes to read
public byte[] peekBytes(int offset, int length)
offset
- The offset from the current indexlength
- The number of bytes to read
public int scanForPattern(byte[] p)
p
- The byte pattern array
public int scanForPattern(byte[] p, int fromNdx)
p
- The byte pattern arrayfromNdx
- The the starting index relative to the current payload index
public byte[] readBytes(int length)
length
length
- The number fo bytes to read from the payload
public byte[] readBytes(int length, java.lang.String msg)
length
length
- The number fo bytes to read from the payloadmsg
- Debug message (used during "DebugLogging")
protected byte[] _readBytes(int length, java.lang.String msg, int frame)
length
length
- The number fo bytes to read from the payloadmsg
- Debug message (used during "DebugLogging")
public static long extendSignBit(long val, int bitLen)
public static long reverseByteOrder(long value, int byteCount)
value
- The Long value to reversebyteCount
- The number of bytes to reverse
public static long decodeLong(byte[] data, int ofs, int len, boolean bigEndian, boolean signed, long dft)
long
value from bytes
data
- The byte array to decode the value fromofs
- The offset into data
to start decoding fromlen
- The number of bytes to decode into the long valuebigEndian
- True if the bytes are Big-Endian ordered, false if Little-Endiansigned
- If the encoded bytes represent a signed valuedft
- The default value if a value cannot be decoded
protected long _readLong(int length, long dft, boolean bigEndian, int frame, java.lang.String msg)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedbigEndian
- True to read bytes in big-endian order, otherwise little-endianframe
- The current stackframe indexmsg
- Debug message (used during "DebugLogging")
public long readLong(int length, long dft, boolean bigEndian)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedbigEndian
- True to read bytes in big-endian order, otherwise little-endian
public long readLong(int length, long dft, boolean bigEndian, java.lang.String msg)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedbigEndian
- True to read bytes in big-endian order, otherwise little-endianmsg
- Debug message (used during "DebugLogging")
public long readLong(int length, long dft)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decoded
public long readLong(int length, long dft, java.lang.String msg)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedmsg
- Debug message (used during "DebugLogging")
public int readInt(int length, int dft)
int
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decoded
public int readInt(int length, int dft, java.lang.String msg)
int
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedmsg
- Debug message (used during "DebugLogging")
protected long _readULong(int length, long dft, boolean bigEndian, int frame, java.lang.String msg)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedbigEndian
- True to read bytes in big-endian order, otherwise little-endianframe
- The current stackframe indexmsg
- Debug message (used during "DebugLogging")
public long readULong(int length, long dft, boolean bigEndian)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedbigEndian
- True to read bytes in big-endian order, otherwise little-endian
public long readULong(int length, long dft, boolean bigEndian, java.lang.String msg)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedbigEndian
- True to read bytes in big-endian order, otherwise little-endianmsg
- Debug message (used during "DebugLogging")
public long readULong(int length, long dft)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decoded
public long readULong(int length, long dft, java.lang.String msg)
long
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedmsg
- Debug message (used during "DebugLogging")
public int readUInt(int length, int dft, boolean bigEndian)
int
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedbigEndian
- True to read bytes in big-endian order, otherwise little-endian
public int readUInt(int length, int dft, boolean bigEndian, java.lang.String msg)
int
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedbigEndian
- True to read bytes in big-endian order, otherwise little-endianmsg
- Debug message (used during "DebugLogging")
public int readUInt(int length, int dft)
int
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decoded
public int readUInt(int length, int dft, java.lang.String msg)
int
value from payload (with default)
length
- The number of bytes to decode the value fromdft
- The default value if a value could not be decodedmsg
- Debug message (used during "DebugLogging")
public boolean isValidBCD(int length)
length
- The number of bytes to check for BCD nybbles
public long readLongBCD(int length, long dft)
long
value from the payload.
length
- The number of bytes from which to decode the valuedft
- The default value if a value could not be decoded
public long readLongBCD(int length, long dft, java.lang.String msg)
long
value from the payload.
length
- The number of bytes from which to decode the valuedft
- The default value if a value could not be decodedmsg
- Debug message (used during "DebugLogging")
public int readIntBCD(int length, int dft)
int
value from the payload.
length
- The number of bytes from which to decode the valuedft
- The default value if a value could not be decoded
public int readIntBCD(int length, int dft, java.lang.String msg)
int
value from the payload.
length
- The number of bytes from which to decode the valuedft
- The default value if a value could not be decodedmsg
- Debug message (used during "DebugLogging")
public static double decodeDouble(byte[] data, int ofs, int len, boolean bigEndian, double dft)
double
value from bytes, using IEEE 754 format
data
- The byte array from which to decode the double
valueofs
- The offset into data
to start decodinglen
- The number of bytes from which the value is decodedbigEndian
- True if the bytes are in big-endian order, false if little-endiandft
- The default value if a value cannot be decoded
protected double _readDouble(int length, double dft, boolean bigEndian, int frame, java.lang.String msg)
double
value from payload (with default), using IEEE 754 format
length
- The number of bytes from which the value is decodeddft
- The default value if a value could not be decodedbigEndian
- True if the bytes are in big-endian order, false if little-endianframe
- The current stackframe indexmsg
- Debug message (used during "DebugLogging")
public double readDouble(int length, double dft, boolean bigEndian)
double
value from payload (with default), using IEEE 754 format
length
- The number of bytes from which the value is decodeddft
- The default value if a value could not be decodedbigEndian
- True if the bytes are in big-endian order, false if little-endian
public double readDouble(int length, double dft, boolean bigEndian, java.lang.String msg)
double
value from payload (with default), using IEEE 754 format
length
- The number of bytes from which the value is decodeddft
- The default value if a value could not be decodedbigEndian
- True if the bytes are in big-endian order, false if little-endianmsg
- Debug message (used during "DebugLogging")
public double readDouble(int length, double dft)
double
value from payload (with default), using IEEE 754 format
length
- The number of bytes from which the value is decodeddft
- The default value if a value could not be decoded
public double readDouble(int length, double dft, java.lang.String msg)
double
value from payload (with default), using IEEE 754 format
length
- The number of bytes from which the value is decodeddft
- The default value if a value could not be decodedmsg
- Debug message (used during "DebugLogging")
protected java.lang.String _readString(int length, boolean varLength, int frame, java.lang.String msg)
length
bytes have been readvarLength==true
)
length
- The maximum length to readvarLength
- If the string can be variable in length (stop on a null)frame
- The current stackframe indexmsg
- Debug message (used during "DebugLogging")
public java.lang.String readString(int length, boolean varLength)
length
bytes have been readvarLength==true
)
length
- The maximum length to readvarLength
- If the string can be variable in length (stop on a null)
public java.lang.String readString(int length, boolean varLength, java.lang.String msg)
length
bytes have been readvarLength==true
)
length
- The maximum length to readvarLength
- If the string can be variable in length (stop on a null)msg
- Debug message (used during "DebugLogging")
public java.lang.String readString(int length)
length
- The maximum length of the string to read
readString(int length, boolean varLength)
public java.lang.String readString(int length, java.lang.String msg)
length
- The maximum length of the string to readmsg
- Debug message (used during "DebugLogging")
readString(int length, boolean varLength)
protected java.lang.String _readStringHex(int length, int frame, java.lang.String msg)
length
- The maximum number of bytes to read into a hex stringmsg
- Debug message (used during "DebugLogging")
public java.lang.String readStringHex(int length)
length
- The maximum number of bytes to read into a hex string
public java.lang.String readStringHex(int length, java.lang.String msg)
length
- The maximum number of bytes to read into a hex stringmsg
- Debug message (used during "DebugLogging")
public GeoPoint readGPS(int length)
length
- The number of bytes to decode the GeoPoint from
GeoPoint.decodeGeoPoint(byte[], int, int)
,
GeoPoint.encodeGeoPoint(org.opengts.util.GeoPoint, byte[], int, int)
public GeoPoint readGPS(int length, java.lang.String msg)
length
- The number of bytes to decode the GeoPoint frommsg
- Debug message (used during "DebugLogging")
GeoPoint.decodeGeoPoint(byte[], int, int)
,
GeoPoint.encodeGeoPoint(org.opengts.util.GeoPoint, byte[], int, int)
public static int encodeLong(byte[] data, int ofs, int len, boolean bigEndian, long val)
long
value into bytes
data
- The byte array into which the value is encodedofs
- The offset into data
to start encodinglen
- The number of bytes to encodebigEndian
- True if the bytes are to be big-endian ordered, false if little-endianval
- The value to encode
data.
public static byte[] encodeLong(long val, int len, boolean bigEndian)
long
value into bytes
val
- The value to encodelen
- The number of bytes to encodebigEndian
- True if the bytes are to be Big-Endian ordered, false if Little-Endian
protected int _writeLong(long val, int wrtLen, boolean bigEndian, int frame)
long
value to the payload
val
- The value to writewrtLen
- The number of bytes into which the value is writtenbigEndian
- True if the bytes are to be big-endian ordered, false if little-endian
public int writeLong(long val, int length, boolean bigEndian)
long
value to the payload
val
- The value to writelength
- The number of bytes into which the value is writtenbigEndian
- True if the bytes are to be big-endian ordered, false if little-endian
public int writeLong(long val, int length)
long
value to the payload
val
- The value to writelength
- The number of bytes into which the value is written
public int writeULong(long val, int length, boolean bigEndian)
long
value to the payload.
val
- The value to writelength
- The number of bytes into which the value is writtenbigEndian
- True if the bytes are to be big-endian ordered, false if little-endian
writeLong(long, int, boolean)
public int writeULong(long val, int length)
long
value to the payload.
val
- The value to writelength
- The number of bytes into which the value is written
writeLong(long, int, boolean)
public int writeInt(int val, int length)
int
value to the payload
val
- The value to writelength
- The number of bytes into which the value is written
public int writeUInt(int val, int length)
int
value to the payload.
val
- The value to writelength
- The number of bytes into which the value is written
writeInt(int, int)
public int writeByte(byte val)
byte
value to the payload
val
- The value to write
public static int encodeDouble(byte[] data, int ofs, int len, boolean bigEndian, double val)
double
value into bytes
data
- The byte array to encode the value toofs
- The offset into data
to start encoding tolen
- The number of bytes to encode the value tobigEndian
- True if the bytes are to be big-endian ordered,
false if little-endianval
- The value to encode
data. 0 or
len
protected int _writeDouble(double val, int wrtLen, boolean bigEndian, int frame)
double
value to the payload
val
- The value to writewrtLen
- The number of bytes to write the value intobigEndian
- True if the bytes are to be big-endian ordered, false if little-endian
public int writeDouble(double val, int wrtLen, boolean bigEndian)
double
value to the payload
val
- The value to writewrtLen
- The number of bytes to write the value intobigEndian
- True if the bytes are to be big-endian ordered, false if little-endian
public int writeDouble(double val, int wrtLen)
double
value to the payload
val
- The value to writewrtLen
- The number of bytes to write the value into
protected int _writeZeroFill(int wrtLen, int frame)
wrtLen
- The number of bytes to writeframe
- The current stackframe index
public int writeZeroFill(int wrtLen)
wrtLen
- The number of bytes to write
protected int _writeBytes(byte[] n, int nOfs, int nLen, int wrtLen, int frame)
n
- The bytes to write to the payloadnOfs
- The offset into n
to start reading fromnLen
- The number of bytes to write from n
wrtLen
- The total number of bytes to write. (remaining bytes
filled with '0' if greater than nLen
frame
- The current stackframe index
public int writeBytes(byte[] n, int nOfs, int nLen, int wrtLen)
n
- The bytes to write to the payloadnOfs
- The offset into n
to start reading fromnLen
- The number of bytes to write from n
wrtLen
- The total number of bytes to write. (remaining bytes
filled with '0' if greater than nLen
public int writeBytes(byte[] n, int wrtLen)
n
- The bytes to write to the payloadwrtLen
- The total number of bytes to write. (remaining bytes
filled with '0' if greater than n.length
public int writeBytes(byte[] n)
n
- The bytes to write to the payload
public int writeRandomBytes(java.util.Random rand, int wrtLen)
rand
- The randomizer from this the random byte are retrievedwrtLen
- The number of bytes to write to the payload
public int writeString(java.lang.String s, int wrtLen)
wrtLen
bytes are written or the string terminates
s
- The string to writewrtLen
- The maximum number of bytes to write to the payload
public int writeString(java.lang.String s, int wrtLen, boolean varLength)
wrtLen
bytes are written or the string terminates
s
- The string to writewrtLen
- The maximum number of bytes to write
public int writeGPS(double lat, double lon, int length)
lat
- The latitude of the GPS pointlon
- The longitude of the GPS pointlength
- The total number of bytes to write.
Defaults to a minimum of 6
GeoPoint.encodeGeoPoint(org.opengts.util.GeoPoint, byte[], int, int)
,
GeoPoint.decodeGeoPoint(byte[], int, int)
public int writeGPS(GeoPoint gp, int wrtLen)
gp
- The GPS point to encodewrtLen
- The total number of bytes to write.
Defaults to a minimum of 6
GeoPoint.encodeGeoPoint(org.opengts.util.GeoPoint, byte[], int, int)
,
GeoPoint.decodeGeoPoint(byte[], int, int)
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] argv)
argv
- Comand-line arguments
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |