Package org.ka2ddo.opentrac
Class OpenTracEntity
java.lang.Object
org.ka2ddo.opentrac.OpenTracElement
org.ka2ddo.opentrac.OpenTracEntity
- All Implemented Interfaces:
Serializable
This class defines a sub-component of an OpenTracMessage, for the information elements
about one entity managed by a station, where entity extension ID #0 is the station itself.
Note that the station callsign-SSID does not have to be for the transmitting station (i.e.,
this can be a digipeated or I-gated message whose Level 2 wrapper is using the callsign-SSID
of the repeating station, not the originating station).
- Author:
- Andrew Pavlin, KA2DDO
- See Also:
-
Field Summary
Fields inherited from class org.ka2ddo.opentrac.OpenTracElement
id
-
Constructor Summary
ConstructorDescriptionCreate an empty uninitialized OpenTracEntity.OpenTracEntity
(byte[] body, int offset, int length, boolean includesExtension) Read an OpenTracEntity from a byte array.OpenTracEntity
(int sequenceNumber, OpenTracEntity oldEntity) Create an uninitialized clone of another OpenTracEntity with the changed sequence number.OpenTracEntity
(String station, short extensionId) Create an empty uninitialized OpenTracEntity for the specified callsign/SSID and extension ID.OpenTracEntity
(AX25Callsign station, short extensionId) Create an empty uninitialized OpenTracEntity for the specified callsign/SSID and extension ID. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendElement
(OpenTracElement element) Add another element to this entity.int
computeBody
(byte[] buf, int offset) Generate an OpenTrac entity ID element for this entity.boolean
Indicates whether some other object is "equal to" this one.boolean
equalsElement
(OpenTracElement other) Test if this OpenTracElement has the same type and value as another OpenTracElement.Get the callsign of this entity with any appended SSID.Get the full name of this entity with any appended SSID and entity IDshort
Get the ID number of the extension being reported by this entity.getMatchingElement
(int type) Get the first element of this entity of the specified OpenTrac element ID.static short
getNextAvailableEntityId
(String entityName) Get an unused entity ID number for an OpenTracEntity record.Report the traffic-handling precedence for this entity's elements.int
Get the sequence number for the data in this entity.int
hashCode()
Returns a hash code value for the object.boolean
Test if this entity has been properly addressed.boolean
Test if this entity has any elements.int
length()
Return the number of bytes needed to encode this entity, including all its child elements.static void
reserveEntityId
(short id, String entityName) Reserve an entity ID value as already in use.void
setCallsign
(String callsign) Set the callsign-SSID of this entity.Returns a string representation of the value of this entity.Methods inherited from class org.ka2ddo.opentrac.OpenTracElement
getId, toString
-
Constructor Details
-
OpenTracEntity
public OpenTracEntity()Create an empty uninitialized OpenTracEntity. -
OpenTracEntity
Create an empty uninitialized OpenTracEntity for the specified callsign/SSID and extension ID.- Parameters:
station
- AX25Callsign of station containing the entityextensionId
- extension ID for sub-element within the station
-
OpenTracEntity
Create an empty uninitialized OpenTracEntity for the specified callsign/SSID and extension ID.- Parameters:
station
- String of station containing the entityextensionId
- extension ID for sub-element within the station
-
OpenTracEntity
Create an uninitialized clone of another OpenTracEntity with the changed sequence number.- Parameters:
sequenceNumber
- the sequence number to use for this copyoldEntity
- OpenTracEntity whose identifiers should be copied
-
OpenTracEntity
public OpenTracEntity(byte[] body, int offset, int length, boolean includesExtension) Read an OpenTracEntity from a byte array.- Parameters:
body
- byte array to read the entity fromoffset
- zero-based starting position in the array to read the entity fromlength
- number of bytes to read from the arrayincludesExtension
- boolean true if entity includes the extension ID in its encoding
-
-
Method Details
-
getNextAvailableEntityId
Get an unused entity ID number for an OpenTracEntity record.- Parameters:
entityName
- String name of APRS entity that needs an ID (that should be repeated for same object name)- Returns:
- a short entity ID value in the range 1 to 32767
- Throws:
IllegalArgumentException
- if no entity ID values are left unused
-
reserveEntityId
public static void reserveEntityId(short id, String entityName) throws IllegalArgumentException, IllegalStateException Reserve an entity ID value as already in use. Intended for ObjectReports restored on YAAC restart.- Parameters:
id
- entity ID value to reserveentityName
- String name of APRS entity that needs an ID (that should be repeated for same object name)- Throws:
IllegalArgumentException
- if id value is out of rangeIllegalStateException
- if specified entity ID value is already in use
-
getExtensionId
public short getExtensionId()Get the ID number of the extension being reported by this entity.- Returns:
- entity ID number, or zero if this is for the station itself
-
getSequenceNumber
public int getSequenceNumber()Get the sequence number for the data in this entity.- Returns:
- sequence number
-
isEntityEmpty
public boolean isEntityEmpty()Test if this entity has any elements.- Returns:
- boolean true if the entity doesn't have any elements
-
getMatchingElement
Get the first element of this entity of the specified OpenTrac element ID.- Parameters:
type
- OpenTrac element ID- Returns:
- OpenTracElement of the specified type ID, or null if no matching element on this entity
-
appendElement
Add another element to this entity.- Parameters:
element
- OpenTracElement to add
-
valueString
Returns a string representation of the value of this entity.- Specified by:
valueString
in classOpenTracElement
- Returns:
- a string representation of the entity.
-
isEntityAddressed
public boolean isEntityAddressed()Test if this entity has been properly addressed. Locally-generated entities can be left unaddressed until transmit time, so the correct originating callsign for the transmitting port can be filled in.- Returns:
- boolean true if entity has an originator's address (callsign-SSID)
-
getCallsign
Get the callsign of this entity with any appended SSID.- Returns:
- String form of the SSID-qualified callsign
-
setCallsign
Set the callsign-SSID of this entity.- Parameters:
callsign
- String form of the SSID-qualified callsign
-
getEntityName
Get the full name of this entity with any appended SSID and entity ID- Returns:
- String form of the SSID-qualified callsign
-
computeBody
public int computeBody(byte[] buf, int offset) Generate an OpenTrac entity ID element for this entity.- Specified by:
computeBody
in classOpenTracElement
- Parameters:
buf
- byte array to append the element tooffset
- starting index in buf to start appending the element- Returns:
- the next unused index in buf after appending this element
-
length
public int length()Return the number of bytes needed to encode this entity, including all its child elements.- Specified by:
length
in classOpenTracElement
- Returns:
- byte count needed to hold this entity
-
getPrecedence
Report the traffic-handling precedence for this entity's elements.- Returns:
- Precedence level for this entity
-
equals
Indicates whether some other object is "equal to" this one. -
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
-
hashCode
public int hashCode()Returns a hash code value for the object.
-