Package org.ka2ddo.opentrac
Class OpenTracString
java.lang.Object
org.ka2ddo.opentrac.OpenTracElement
org.ka2ddo.opentrac.OpenTracString
- All Implemented Interfaces:
Serializable
This class represents any type of OpenTRAC data element that has one UTF-8-encoded string
as its value.
- Author:
- Andrew Pavlin, KA2DDO
- See Also:
-
Field Summary
Fields inherited from class org.ka2ddo.opentrac.OpenTracElement
id
-
Constructor Summary
ConstructorDescriptionCreate an uninitialized OpenTracString element.OpenTracString
(int type, byte[] body, int offset, int length) Create an OpenTRAC element with a variable-length UTF8 string value from the next series of bytes in an encoded OpenTRAC message.OpenTracString
(int type, String val) Create an OpenTracString element with the specified OpenTRAC type code and string value. -
Method Summary
Modifier and TypeMethodDescriptionint
computeBody
(byte[] buf, int offset) Append this element to a message bufferboolean
equalsElement
(OpenTracElement other) Test if this OpenTracElement has the same type and value as another OpenTracElement.int
length()
Return the number of bytes needed to encode this element.Get the string representation of the value of this element.Methods inherited from class org.ka2ddo.opentrac.OpenTracElement
getId, toString
-
Constructor Details
-
OpenTracString
public OpenTracString()Create an uninitialized OpenTracString element. -
OpenTracString
public OpenTracString(int type, byte[] body, int offset, int length) Create an OpenTRAC element with a variable-length UTF8 string value from the next series of bytes in an encoded OpenTRAC message.- Parameters:
type
- OpenTRAC element type codebody
- byte array containing the encoded OpenTRAC elementsoffset
- starting index in the array where this element beginslength
- remaining number of bytes in the OpenTRAC encoded message
-
OpenTracString
Create an OpenTracString element with the specified OpenTRAC type code and string value.- Parameters:
type
- OpenTRAC type codeval
- String value
-
-
Method Details
-
valueString
Get the string representation of the value of this element.- Specified by:
valueString
in classOpenTracElement
- Returns:
- value string
-
computeBody
public int computeBody(byte[] buf, int offset) Append this element to a message buffer- Specified by:
computeBody
in classOpenTracElement
- Parameters:
buf
- byte array to add the element tooffset
- starting index to store the element- Returns:
- index after the end of the stored element
-
length
public int length()Return the number of bytes needed to encode this element.- Specified by:
length
in classOpenTracElement
- Returns:
- byte count needed to hold this element
-
equalsElement
Test if this OpenTracElement has the same type and value as another OpenTracElement.- Specified by:
equalsElement
in classOpenTracElement
- Parameters:
other
- OpenTracElement to compare against this element- Returns:
- boolean true if elements are of the same type, class, and value
-