public final class AX25Callsign extends java.lang.Object implements java.lang.Comparable<AX25Callsign>, java.lang.Cloneable, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static java.util.Comparator<AX25Callsign> |
CALLSIGN_COMPARATOR
A Comparator to use for callsigns when it is more efficient than using the
Comparable interface to AX25Callsign.
|
boolean |
h_c
Has_been_repeated flag (for digipeater callsigns) or command/response flags (for destination and source callsigns).
|
boolean |
last
Flag bit in SSID byte indicating this is the last callsign in a digipeater sequence.
|
boolean |
valid
Indicates whether the callsign in this object can be exported as a valid AX.25 binary protocol address.
|
Constructor and Description |
---|
AX25Callsign()
Construct an empty but assumed-valid callsign.
|
AX25Callsign(byte[] buf,
int offset,
int length)
Extract an AX.25 callsign from an AX.25 frame byte array in network byte order.
|
AX25Callsign(int startPos,
int endPos,
byte[] byteCallsign)
Construct a AX25Callsign from the specified part of the byte array of text containing the callsign.
|
AX25Callsign(java.lang.String textCallsign)
Construct a AX25Callsign from the string representation of the callsign.
|
AX25Callsign(java.lang.String textCallsign,
int startPos,
int endPos)
Construct a AX25Callsign from the specified sub-string representation of the callsign.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Creates and returns a copy of this object.
|
int |
compareTo(AX25Callsign o)
Compares this object with the specified object for order.
|
void |
decrementSSID()
Decrement a non-zero SSID value, as is done for NewN-n paradigm digipeat aliases.
|
AX25Callsign |
dup()
Create a shallow clone of this AX25Callsign, discarding any cached toString() value.
|
boolean |
equals(java.lang.Object o)
Test if some other object is the same as this AX25Callsign.
|
java.lang.String |
getBaseCallsign()
Gets the base callsign (without the AX.25 SSID extension).
|
static byte |
getDefaultReserved()
Get the current default value for the reserved bits of the AX25 callsign SSID byte.
|
byte |
getReserved()
Get the reserved bits of the 7th byte of the callsign (per the AX.25 specification).
|
int |
getSSID()
Return the numeric SSID associated with this callsign.
|
boolean |
hasBeenRepeated()
Report if the hasBeenRepeated flag in the callsign is set.
|
int |
hashCode()
Returns a hash code for this callsign.
|
static boolean |
isDigipeatableCallsign(java.lang.String callsign)
Test if a callsign looks like a real callsign (at least one digit somewhere other than
the last character, all letters uppercase), and an AX.25-legal SSID.
|
boolean |
isNewNParadigmAlias()
Test if this callsign appears to be a valid New n-N digipeat alias.
|
static boolean |
isNewNParadigmAlias(java.lang.String callsign)
Test if the parameter appears to be a valid New n-N digipeat alias.
|
static boolean |
isOldParadigmAlias(java.lang.String callsign)
Test if the parameter appears to be an old paradigm digipeat alias.
|
static boolean |
isRealCallsign(java.lang.String callsign)
Test if a callsign looks like a real callsign (at least one digit somewhere other than
the last character, all letters uppercase).
|
boolean |
isValid()
Indicates if this callsign has valid syntax to be transmitted in the header of an AX.25 frame.
|
static void |
setDefaultReserved(byte defaultReserved)
Set the default value for the reserved bits of newly generated AX25 callsign SSID byte.
|
void |
setReserved(byte reserved)
Set the reserved bits of the 7th byte of the callsign (per the AX.25 specification).
|
void |
setSSID(int ssid)
Specify the numeric SSID associated with this callsign.
|
java.lang.String |
toAnnotatedString()
Return a String representing this AX25Frame object, with an additional note if the reserved field in the SSID byte
is not the default value.
|
byte[] |
toByteArray()
Return the callsign as the actual byte sequence that would be transmitted
over the air (without HDLC bit-stuffing).
|
java.lang.String |
toString()
Return a String representing this AX25Callsign object.
|
void |
write(java.io.OutputStream os,
boolean last)
Encode this AX25Callsign into binary radio transmission format on a stream.
|
public boolean h_c
public boolean last
public boolean valid
public static final java.util.Comparator<AX25Callsign> CALLSIGN_COMPARATOR
compareTo(AX25Callsign)
public AX25Callsign()
public AX25Callsign(java.lang.String textCallsign)
textCallsign
- String to parse into an AX.25-compliant callsignpublic AX25Callsign(java.lang.String textCallsign, int startPos, int endPos)
textCallsign
- String to parse into an AX.25-compliant callsignstartPos
- int position in string where callsign startsendPos
- int position in string where callsign endspublic AX25Callsign(int startPos, int endPos, byte[] byteCallsign)
startPos
- int position in byte array where callsign startsendPos
- int position in byte array where callsign endsbyteCallsign
- byte array of ASCII text to parse into an AX.25-compliant callsignpublic AX25Callsign(byte[] buf, int offset, int length) throws java.lang.IndexOutOfBoundsException, java.lang.IllegalArgumentException
buf
- byte array containing the AX.25-encoded callsignoffset
- index into the array where the callsign beginslength
- bytes remaining in the array after the offsetjava.lang.IndexOutOfBoundsException
- if not enough bytes left in the array to contain an AX.25 callsignjava.lang.IllegalArgumentException
- if the callsign has an invalid format, such as embedded whitespace in
the middle of a callsign with following non-blank characterspublic static boolean isRealCallsign(java.lang.String callsign)
callsign
- String callsign to testpublic static boolean isDigipeatableCallsign(java.lang.String callsign)
callsign
- String callsign to testpublic boolean isNewNParadigmAlias()
public static boolean isNewNParadigmAlias(java.lang.String callsign)
callsign
- String supposedly containing an AX.25 callsignpublic static boolean isOldParadigmAlias(java.lang.String callsign)
callsign
- String supposedly containing an AX.25 callsignpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Object to compare against this callsignpublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toAnnotatedString()
public int compareTo(AX25Callsign o)
compareTo
in interface java.lang.Comparable<AX25Callsign>
o
- the object to be compared.java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this object.public void write(java.io.OutputStream os, boolean last) throws java.io.IOException
os
- the OutputStream to write the binary encoding tolast
- boolean true if this callsign should have the last bit set in
its last byte to indicate there will be no following callsigns
according to the AX.25 protocol specificationjava.io.IOException
- if callsign could not be written to the streampublic byte[] toByteArray()
public java.lang.Object clone()
clone
in class java.lang.Object
public AX25Callsign dup()
public java.lang.String getBaseCallsign()
public int getSSID()
public void setSSID(int ssid)
ssid
- numeric SSID in the range 0 to 15public void decrementSSID()
public boolean hasBeenRepeated()
public byte getReserved()
public void setReserved(byte reserved)
reserved
- the new value of the reserved bits (masked to the range 0 to 3)public boolean isValid()
public static byte getDefaultReserved()
public static void setDefaultReserved(byte defaultReserved)
defaultReserved
- current default RR bit value