org.ka2ddo.aprs
Class MessageMessage

java.lang.Object
  extended by org.ka2ddo.ax25.AX25Message
      extended by org.ka2ddo.aprs.Message
          extended by org.ka2ddo.aprs.MessageMessage
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<AX25Message>, AprsSignableMessage, CommentedMessage, SendableMessage, SignableMessage

public class MessageMessage
extends Message
implements SendableMessage, AprsSignableMessage

This class encodes an addressed Message APRS message (APRS protocol specification chapter 14). Note that one form of Message can be a directed query (APRS protocol specification chapter 15).

See Also:
Query, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.ka2ddo.ax25.AX25Message
AX25Message.Precedence
 
Nested classes/interfaces inherited from interface org.ka2ddo.ax25.SignableMessage
SignableMessage.SignatureState
 
Field Summary
 boolean acked
          Flag indicating if a locally-originated message has been acknowledged.
 java.lang.String addressee
          Addressee of the message.
 int numTransmissions
          Number of times the message should be transmitted before giving up.
 java.lang.String serialNumber
          Sequence number of this message used for acknowledgment.
 SignableMessage.SignatureState signatureState
          Quality of the signature (if any) associated with this message.
 
Fields inherited from class org.ka2ddo.aprs.Message
comment, extensions, msgType, S_PERMANENT, S_PERMANENT_UC, symbolCode, symTableId, USASCII
 
Fields inherited from class org.ka2ddo.ax25.AX25Message
ax25Frame, invalid, ISO_8859_1, originatingCallsign, PERMANENT, rcptTime, thirdParty, timestamp, UTC, UTF8
 
Constructor Summary
MessageMessage(byte[] body, int offset, java.lang.String tp, long rcvTimestamp)
          Decode a MessageMessage from a byte array.
MessageMessage(java.lang.String addressee, java.lang.String body)
          Create a new partially-initialized MessageMessage, suitable for transmission.
MessageMessage(java.lang.String addressee, java.lang.String body, java.lang.String serialNum)
          Create a new partially-initialized MessageMessage, suitable for transmission.
 
Method Summary
 java.lang.String getAddressee()
          Report the addressee of this message.
 byte[] getBody(boolean countTransmission, byte protocolId, AX25Frame frame)
          Get an instance of this message, suitable for transmitting.
 java.lang.String getKeyAlias()
          Get the alias for the key that should be used to sign this message at transmission time.
 java.lang.String getQuery()
          Test whether this MessageMessage contains a directed query (APRS protocol specification chapter 15).
 java.lang.String getSignature()
          Get the ASCII-encoded signature of this message.
 SignableMessage.SignatureState getSignatureState()
          Report the status of the signature of this message.
 boolean isEnabled()
          Test if message should still be transmitted.
 java.lang.String paramString()
          Descriptive text about this message, to be included in the toString() method's response.
 void setKeyAlias(java.lang.String alias)
          Set the alias for the key that should be used to sign this message at transmission time.
 void setSignature(java.lang.String signature)
          Set the ASCII-encoded signature of this message.
 void writeToSigningBuf(java.io.DataOutput dos, java.io.PrintStream ps)
          Write the appropriate part of the body of this message to the signing buffer.
 
Methods inherited from class org.ka2ddo.aprs.Message
bodyEquals, compareTo, decodeDatestamp, decodeHurricaneParams, decodeTimestamp, decodeWeatherParams, decodeWeatherParams, dup, encodeTimestamp, extractComment, extractComment, extractSymbol, formatBody, getComment, getExtension, getExtensionString, getMsgType, getReadOnlyExtensionMap, getSymbolCode, getSymTableId, hasWeather, inferSymbol, isSymbolInferred, looksLikeLongFormatLatitude, setComment, setSymbolCode, setSymTableId, storeExtension, toString
 
Methods inherited from class org.ka2ddo.ax25.AX25Message
equals, extractSource, getAx25Frame, getFirstDigipeat, getLastDigipeat, getOriginalDestination, getOriginalSource, getOriginatingCallsign, getPrecedence, getRcptTime, getTimestamp, hashCode, hasPosition, hasThisFirstDigi, indexOf, indexOf, isInvalid, onlyDigits, onlyDigits, onlyDigitsOrPeriod, onlyDigitsOrSpace, onlyDigitsPlus, onlyPeriods, setAx25Frame, setInvalid, setOriginatingCallsign, setRcptTime, setTimestamp, split
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ka2ddo.ax25.SignableMessage
getOriginatingCallsign, getTimestamp
 
Methods inherited from interface org.ka2ddo.ax25.SendableMessage
dup
 

Field Detail

addressee

public java.lang.String addressee
Addressee of the message. May be a bulletin sequence number or a broadcast group (such as NWS_WARN).


serialNumber

public java.lang.String serialNumber
Sequence number of this message used for acknowledgment. May be null if no sequence number.


acked

public boolean acked
Flag indicating if a locally-originated message has been acknowledged. Used to stop automatic retransmissions of messages with serial numbers.


numTransmissions

public int numTransmissions
Number of times the message should be transmitted before giving up.


signatureState

public SignableMessage.SignatureState signatureState
Quality of the signature (if any) associated with this message.

Constructor Detail

MessageMessage

public MessageMessage(byte[] body,
                      int offset,
                      java.lang.String tp,
                      long rcvTimestamp)
Decode a MessageMessage from a byte array.

Parameters:
body - byte array containing the message
offset - index into the array where the message starts
tp - third-party routing String, or null if not routed from another network
rcvTimestamp - time in Java milliseconds since 1 Jan 1970 UTC when the message was received

MessageMessage

public MessageMessage(java.lang.String addressee,
                      java.lang.String body)
Create a new partially-initialized MessageMessage, suitable for transmission.

Parameters:
addressee - String addressee for the message
body - String body text of the message

MessageMessage

public MessageMessage(java.lang.String addressee,
                      java.lang.String body,
                      java.lang.String serialNum)
Create a new partially-initialized MessageMessage, suitable for transmission.

Parameters:
addressee - String addressee for the message
body - String body text of the message
serialNum - String serial number for the message (indicates it should be acknowledged)
Method Detail

paramString

public java.lang.String paramString()
Descriptive text about this message, to be included in the toString() method's response.

Overrides:
paramString in class Message
Returns:
String describing the contents of this message
See Also:
Message.toString()

getAddressee

public java.lang.String getAddressee()
Report the addressee of this message.

Returns:
addressee String

getQuery

public java.lang.String getQuery()
Test whether this MessageMessage contains a directed query (APRS protocol specification chapter 15).

Returns:
query String if this is a query, or null if not

getBody

public byte[] getBody(boolean countTransmission,
                      byte protocolId,
                      AX25Frame frame)
Get an instance of this message, suitable for transmitting.

Specified by:
getBody in interface SendableMessage
Parameters:
countTransmission - number of times the message has been transmitted
protocolId - AX.25 protocol type for this message
frame - AX25Frame into which the message will be placed, so any alternate AX25Message can be linked to it
Returns:
byte array of message
See Also:
AX25Frame.parsedAX25Msg

isEnabled

public boolean isEnabled()
Test if message should still be transmitted.

Specified by:
isEnabled in interface SendableMessage
Returns:
boolean true if message should still be transmitted

getSignatureState

public SignableMessage.SignatureState getSignatureState()
Report the status of the signature of this message.

Specified by:
getSignatureState in interface SignableMessage
Returns:
signature state of this message

setKeyAlias

public void setKeyAlias(java.lang.String alias)
Set the alias for the key that should be used to sign this message at transmission time.

Specified by:
setKeyAlias in interface SignableMessage
Parameters:
alias - String name that should match a secret key in the key manager

getKeyAlias

public java.lang.String getKeyAlias()
Get the alias for the key that should be used to sign this message at transmission time.

Specified by:
getKeyAlias in interface SignableMessage
Returns:
String name of key alias, matching a secret key in the key manager, or null if message should not be signed

getSignature

public java.lang.String getSignature()
Get the ASCII-encoded signature of this message.

Specified by:
getSignature in interface AprsSignableMessage
Returns:
ASCII String of the signature, or null if not signed

setSignature

public void setSignature(java.lang.String signature)
Set the ASCII-encoded signature of this message.

Specified by:
setSignature in interface AprsSignableMessage
Parameters:
signature - String of the signature, or null to remove any pre-existing signature

writeToSigningBuf

public void writeToSigningBuf(java.io.DataOutput dos,
                              java.io.PrintStream ps)
Write the appropriate part of the body of this message to the signing buffer.

Specified by:
writeToSigningBuf in interface SignableMessage
Parameters:
dos - DataOutput that will accept binary writes of the message data
ps - PrintStream that will accept character writes of the message data