public abstract class AX25Message extends java.lang.Object implements java.lang.Comparable<AX25Message>, java.io.Serializable, java.lang.Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
AX25Message.Precedence
This enum defines the allowed traffic precedence levels for messages.
|
Modifier and Type | Field and Description |
---|---|
protected static java.util.Set<ProtocolFamily> |
APRS_AND_OPENTRAC
A read-only protocol set that includes both APRS and OpenTRAC.
|
AX25Frame |
ax25Frame
The AX.25 frame object from which this Message was extracted.
|
protected java.util.Map<java.lang.Enum,java.lang.Object> |
extensions
Optional map of extracted data fields in this APRS message.
|
protected boolean |
invalid
Indicates whether message was correctly formatted or otherwise parseable.
|
java.lang.String |
originatingCallsign
Callsign of the station originating this message.
|
java.lang.String |
originatingDest
Destination "callsign" from the station originating this message.
|
static long |
PERMANENT
Reserved constant for non-expiring objects' timestamp.
|
long |
rcptTime
The time the message was received by the system in Java standard milliseconds since 1970 UTC.
|
java.lang.String |
thirdParty
The entire third-party routing path for this AX25Message, or null if this AX25message
is still on its original network.
|
long |
timestamp
Message timestamp in Java standard milliseconds since 1970 UTC.
|
static java.util.TimeZone |
UTC
TimeZone object for Greenwich Mean Time (or Universal Coordinated Time), used for converting
text string times and dates into binary.
|
Modifier | Constructor and Description |
---|---|
protected |
AX25Message()
Constructor for partially initialized AX25Message.
|
protected |
AX25Message(java.lang.String thirdParty,
long rcptTime)
Constructor for AX25Message specifying the third-party network routing and receive time of the message.
|
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
bodyEquals(AX25Message other)
Compare the contents of the body of the message, reporting if they match.
|
int |
compareTo(AX25Message o)
Compares this object with the specified object for order.
|
AX25Message |
dup()
Creates and returns a copy of this AX25Message.
|
boolean |
equals(java.lang.Object o)
Test if the Object o is a duplicate of this Message.
|
void |
extractSource()
Extract the originating station callsign for this AX25Message.
|
AX25Frame |
getAx25Frame()
Get the AX.25 frame from which this Message was extracted.
|
java.lang.Object |
getExtension(java.lang.Enum key)
Get a particular extension value from this message.
|
java.lang.String |
getFirstDigipeat(AX25Callsign[] digipeaters)
Return the callsign of the first digipeat station for this message.
|
java.lang.String |
getLastDigipeat(AX25Callsign[] digipeaters)
Return the callsign of the last digipeat station for this message.
|
java.lang.String |
getNthDigipeat(AX25Callsign[] digipeaters,
int index)
Return the callsign of the Nth digipeat station for this message.
|
static java.lang.String |
getOriginalDestination(AX25Callsign dest,
java.lang.String thirdParty)
Extract the callsign of the original destination of this message.
|
static java.lang.String |
getOriginalSource(AX25Callsign src,
java.lang.String thirdParty)
Extract the callsign of the original destination of this message.
|
java.lang.String |
getOriginatingCallsign()
Get the callsign of the station that originated this message (not of any Tx-Igate relay).
|
java.lang.String |
getOriginatingDest()
Get the destination address oeiginally specified bv the station that originated this message.
|
AX25Message.Precedence |
getPrecedence()
Report the traffic-handling precedence for this message instance.
|
java.util.Set<ProtocolFamily> |
getProtocols()
Get the protocol family or families that this message corresponds to, so
ports that don't support all protocols will not forward inappropriate packets.
|
long |
getRcptTime()
Get the timestamp this AX25Message was received in milliseconds since
1 Jan 1970 UTC.
|
java.util.Map<java.lang.Enum,java.lang.Object> |
getReadOnlyExtensionMap()
Get a reference to the extension map that should not be modified.
|
long |
getTimestamp()
Get the timestamp associated with this Message in milliseconds since
1 Jan 1970 UTC.
|
int |
hashCode()
Returns a hash code for this Message.
|
boolean |
hasPosition()
Report if this AX25Message contains position data.
|
boolean |
hasThisFirstDigi(AX25Callsign[] digipeaters,
java.lang.String digiCallsign)
Test if the specified callsign is the first digipeat station for this message.
|
abstract boolean |
hasWeather()
Report if this AX25Message contains weather information.
|
static int |
indexOf(byte[] buf,
int bufLen,
char matchCh,
int startPos)
Search a byte array (assumed to be an ASCII string) for a matching character.
|
static int |
indexOf(byte[] buf,
int bufLen,
java.lang.String matchStr,
int startPos)
Search a byte array (assumed to be an ASCII string) for a matching ASCII string.
|
boolean |
isDirect()
Test if this message was sent directly (without any relay station).
|
boolean |
isInvalid()
Test if this message was flagged as invalid.
|
java.lang.Boolean |
isRf(int maxDigis)
Test if this AX25Message came from an RF connection.
|
static boolean |
onlyDigits(byte[] body,
int pos,
int len)
Test if the specified part of the message body is strictly only ASCII digits.
|
static boolean |
onlyDigits(java.lang.String body,
int pos,
int len)
Test if the specified part of the message body is strictly only ASCII digits.
|
static boolean |
onlyDigitsOrMinus(byte[] body,
int pos,
int len)
Test if the specified part of the message body is strictly only ASCII digits.
|
static boolean |
onlyDigitsOrPeriod(java.lang.String body,
int pos,
int len)
Test if the specified part of the message body is strictly only ASCII digits.
|
protected static boolean |
onlyDigitsOrSpace(byte[] body,
int pos,
int len)
Test if the specified part of the message body is strictly only ASCII digits or space characters.
|
protected static boolean |
onlyDigitsPlus(byte[] body,
int pos,
int len)
Test if the specified part of the message body is only ASCII digits or
characters just after the digits (to support base+offset message codes in APRS).
|
protected static boolean |
onlyPeriods(byte[] body,
int pos,
int len)
Test if the specified part of the message body is strictly only period characters.
|
java.lang.String |
paramString()
Descriptive text about this message, to be included in the toString() method's response.
|
void |
setAx25Frame(AX25Frame ax25Frame)
Attach the AX.25 frame from which this Message was extracted.
|
void |
setInvalid(boolean invalid)
Mark if this message is invalid or not.
|
void |
setOriginatingCallsign(java.lang.String originatingCallsign)
Set the originating callsign for this AX25Message.
|
void |
setRcptTime(long rcptTime)
Change the receive time of this message.
|
void |
setTimestamp(long timestamp)
Change the timestamp of this message.
|
static java.lang.String[] |
split(java.lang.String line,
char separator)
This is a more optimized version of String.split() that doesn't require
compiling and evaluating regular expression patterns to do it, thereby
saving chunks of transient heap (and probably some CPU time as well).
|
<K extends java.lang.Enum,V> |
storeExtension(K key,
V value)
Store an extracted data element in the Message.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
public static final long PERMANENT
public AX25Frame ax25Frame
public java.lang.String originatingCallsign
AX25Frame.sender
public java.lang.String originatingDest
AX25Frame.dest
public java.lang.String thirdParty
public long timestamp
public long rcptTime
protected boolean invalid
protected java.util.Map<java.lang.Enum,java.lang.Object> extensions
public static final java.util.TimeZone UTC
protected static final java.util.Set<ProtocolFamily> APRS_AND_OPENTRAC
getProtocols()
protected AX25Message()
protected AX25Message(java.lang.String thirdParty, long rcptTime)
thirdParty
- The entire third-party routing path for this AX25Message, or null if this AX25message
is still on its original network.rcptTime
- The time the message was received by the system in Java standard milliseconds since 1970 UTC.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Object to compare against this message.protected abstract boolean bodyEquals(AX25Message other)
other
- another AX25Message to compare againstpublic int hashCode()
hashCode
in class java.lang.Object
public int compareTo(AX25Message o)
compareTo
in interface java.lang.Comparable<AX25Message>
o
- the object to be compared.java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this object.public static boolean onlyDigits(java.lang.String body, int pos, int len)
body
- String containing the message bodypos
- starting index in the array to testlen
- number of bytes to testpublic static boolean onlyDigitsOrPeriod(java.lang.String body, int pos, int len)
body
- String containing the message bodypos
- starting index in the array to testlen
- number of bytes to testpublic static boolean onlyDigits(byte[] body, int pos, int len)
body
- byte array containing the message bodypos
- starting index in the array to testlen
- number of bytes to testpublic static boolean onlyDigitsOrMinus(byte[] body, int pos, int len)
body
- byte array containing the message bodypos
- starting index in the array to testlen
- number of bytes to testprotected static boolean onlyDigitsPlus(byte[] body, int pos, int len)
body
- byte array containing the message bodypos
- starting index in the array to testlen
- number of bytes to testprotected static boolean onlyDigitsOrSpace(byte[] body, int pos, int len)
body
- byte array containing the message bodypos
- starting index in the array to testlen
- number of bytes to testprotected static boolean onlyPeriods(byte[] body, int pos, int len)
body
- byte array containing the message bodypos
- starting index in the array to testlen
- number of bytes to testpublic static int indexOf(byte[] buf, int bufLen, char matchCh, int startPos)
buf
- byte array to searchbufLen
- index of end of used part of buffermatchCh
- character value to search for in a forward searchstartPos
- zero-based index to start searching atpublic static int indexOf(byte[] buf, int bufLen, java.lang.String matchStr, int startPos)
buf
- byte array to searchbufLen
- index of end of used part of buffermatchStr
- String value to search for in a forward searchstartPos
- zero-based index to start searching atpublic java.lang.String paramString()
toString()
public java.lang.String toString()
toString
in class java.lang.Object
public void extractSource() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if thirdParty string is provided but doesn't have a sender>dest delimiterpublic final AX25Frame getAx25Frame()
public final void setAx25Frame(AX25Frame ax25Frame)
ax25Frame
- AX25Frame object containing the encoding of this Messagepublic static java.lang.String getOriginalSource(AX25Callsign src, java.lang.String thirdParty)
src
- AX25Callsign of the source of the original AX25FramethirdParty
- String of the third-party routing of this message, or null if not routed over another networkpublic static java.lang.String getOriginalDestination(AX25Callsign dest, java.lang.String thirdParty)
dest
- AX25Callsign of the destination (tocall) of the original AX25FramethirdParty
- String of the third-party routing of this message, or null if not routed over another networkpublic java.lang.String getLastDigipeat(AX25Callsign[] digipeaters)
digipeaters
- array of AX25Callsign digipeater addresses in AX.25 framepublic java.lang.String getFirstDigipeat(AX25Callsign[] digipeaters)
digipeaters
- array of AX25Callsign digipeater addresses in AX.25 framepublic java.lang.String getNthDigipeat(AX25Callsign[] digipeaters, int index)
digipeaters
- array of AX25Callsign digipeater addresses in AX.25 frameindex
- zero-based index into the list of digipeat aliasespublic boolean hasThisFirstDigi(AX25Callsign[] digipeaters, java.lang.String digiCallsign)
digipeaters
- array of AX25Callsign digipeater addresses in AX.25 framedigiCallsign
- String callsign/SSID of digipeaterpublic long getTimestamp()
public abstract boolean hasWeather()
public boolean hasPosition()
public void setTimestamp(long timestamp)
timestamp
- new time in Java milliseconds since epochpublic void setOriginatingCallsign(java.lang.String originatingCallsign)
originatingCallsign
- String of the originating station callsign of this messagepublic java.lang.String getOriginatingCallsign()
public java.lang.String getOriginatingDest()
public long getRcptTime()
public void setRcptTime(long rcptTime)
rcptTime
- new time in Java milliseconds since epochpublic boolean isInvalid()
public void setInvalid(boolean invalid)
invalid
- boolean true if message should be considered invalid or incorrect syntaxpublic AX25Message.Precedence getPrecedence()
public AX25Message dup()
Cloneable
public <K extends java.lang.Enum,V> void storeExtension(K key, V value)
K
- any enum subclassV
- any Java object classkey
- Enum that identifies the particular data itemvalue
- the data valueDataExtensionEnum
,
WeatherEnum
public java.util.Map<java.lang.Enum,java.lang.Object> getReadOnlyExtensionMap()
DataExtensionEnum
,
WeatherEnum
public java.lang.Object getExtension(java.lang.Enum key)
key
- Enum instance identifying the desired extensionDataExtensionEnum
,
WeatherEnum
public java.util.Set<ProtocolFamily> getProtocols()
public java.lang.Boolean isRf(int maxDigis)
maxDigis
- int maximum number of digipeat hops before we're not going to count itpublic boolean isDirect()
public static java.lang.String[] split(java.lang.String line, char separator)
line
- the String to split at occurrences of the separatorseparator
- the String delimiting substrings of the line