org.ka2ddo.yaac.io
Class PortConfig

java.lang.Object
  extended by org.ka2ddo.yaac.io.PortConfig
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class PortConfig
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

This class contains all the parameters for configuring a PortConnector in this application, and the encoding and decoding code for saving its value in the persisted configuration data.

See Also:
Serialized Form

Nested Class Summary
static class PortConfig.Cfg
          Port-type-specific configuration parameters for a PortConnector.
 
Field Summary
 boolean enabled
          Whether port should be opened automatically upon startup.
static int FLAGS_HF
          Indicates this is a TNC port over HF (low bandwidth, wide geographic coverage).
static int FLAGS_LOCAL
          Indicates that this data should be consumed locally as well as transmitted.
static int FLAGS_UDP
          Indicates this is a UDP socket (not TCP).
static int MAX_PROTOCOL_BIT
          Highest bit number supported in protocol bit mask.
static java.lang.String[] NO_ALIASES
          Empty array for ports that have no supported aliases.
 java.lang.String portType
          Type of PortConnector used to implement this port, generally defined as a String constant named PORT_TYPE on the PortConnector subclass.
static int PROTOCOL_APRS
          Flag bit indicating this port allows transmitting APRS packets.
static int PROTOCOL_AX25
          Flag bit indicating this port allows transmitting AX.25 frames containing traffic of types other than APRS or OpenTRAC UI frames.
static int PROTOCOL_OPENTRAC
          Flag bit indicating this port allows transmitting OpenTRAC packets.
static int SENTENCE_GPWPL
          Send NMEA standard waypoint message back to GPS.
static int SENTENCE_NONE
          No waypoint sentences sent to GPS on this port.
static int SENTENCE_PKWDWPL
          Send Kenwood-specific waypoint message back to GPS.
 
Constructor Summary
PortConfig()
          Create a new PortConfig record with a new port instance identifier.
 
Method Summary
 void assignPortNumber()
          Allocate a new port number for this PortConfig object.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 void copyInto(PortConfig dest)
          Do a deep copy of this PortConfig object into another object..
 PortConfig.Cfg current()
          Get the port-type-specific configuration parameters for the currently specified port type.
 PortConfig dup()
          Make a deep copy of this PortConfig object.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one.
 java.lang.String getDisplayName()
          Get the name by which this port will be identified.
 int getPortNumber()
          Get the arbitrary sequence port number assigned to this configuration record.
 int hashCode()
          Returns a hash code value for the object.
static PortConfig readFromPreferences(java.util.prefs.Preferences root, java.lang.String displayName)
          Read a PortConfig object from Java Preferences.
 void removeFromPreferences(java.util.prefs.Preferences root)
          Delete this PortConfig from the Java Preferences backing store.
 PortConfig.Cfg specific(java.lang.String portType)
          Get the port-type-specific configuration parameters for a specific port type.
 java.lang.String toString()
          Returns a string representation of the object.
 void writeToPreferences(java.util.prefs.Preferences root)
          Write this PortConfig object to Java Preferences on the Ports sub-node of the specified Preferences node.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_ALIASES

public static final java.lang.String[] NO_ALIASES
Empty array for ports that have no supported aliases.


PROTOCOL_APRS

public static final int PROTOCOL_APRS
Flag bit indicating this port allows transmitting APRS packets.

See Also:
Constant Field Values

PROTOCOL_OPENTRAC

public static final int PROTOCOL_OPENTRAC
Flag bit indicating this port allows transmitting OpenTRAC packets.

See Also:
Constant Field Values

PROTOCOL_AX25

public static final int PROTOCOL_AX25
Flag bit indicating this port allows transmitting AX.25 frames containing traffic of types other than APRS or OpenTRAC UI frames.

See Also:
PROTOCOL_APRS, PROTOCOL_OPENTRAC, Constant Field Values

MAX_PROTOCOL_BIT

public static final int MAX_PROTOCOL_BIT
Highest bit number supported in protocol bit mask.

See Also:
PortConfig.Cfg.acceptableProtocolsMask, Constant Field Values

SENTENCE_NONE

public static final int SENTENCE_NONE
No waypoint sentences sent to GPS on this port.

See Also:
Constant Field Values

SENTENCE_GPWPL

public static final int SENTENCE_GPWPL
Send NMEA standard waypoint message back to GPS.

See Also:
Constant Field Values

SENTENCE_PKWDWPL

public static final int SENTENCE_PKWDWPL
Send Kenwood-specific waypoint message back to GPS.

See Also:
Constant Field Values

FLAGS_HF

public static final int FLAGS_HF
Indicates this is a TNC port over HF (low bandwidth, wide geographic coverage).

See Also:
Constant Field Values

FLAGS_UDP

public static final int FLAGS_UDP
Indicates this is a UDP socket (not TCP).

See Also:
Constant Field Values

FLAGS_LOCAL

public static final int FLAGS_LOCAL
Indicates that this data should be consumed locally as well as transmitted.

See Also:
Constant Field Values

portType

public java.lang.String portType
Type of PortConnector used to implement this port, generally defined as a String constant named PORT_TYPE on the PortConnector subclass.


enabled

public boolean enabled
Whether port should be opened automatically upon startup.

Constructor Detail

PortConfig

public PortConfig()
Create a new PortConfig record with a new port instance identifier.

Method Detail

current

public final PortConfig.Cfg current()
Get the port-type-specific configuration parameters for the currently specified port type.

Returns:
type-specific Cfg record

specific

public final PortConfig.Cfg specific(java.lang.String portType)
Get the port-type-specific configuration parameters for a specific port type.

Parameters:
portType - the name of the port type whose configuration parameters should be obtained
Returns:
type-specific Cfg record (created if it did not previously exist)

assignPortNumber

public void assignPortNumber()
Allocate a new port number for this PortConfig object.


equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
hashCode()

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.
See Also:
equals(Object)

getDisplayName

public java.lang.String getDisplayName()
Get the name by which this port will be identified.

Returns:
String port name

getPortNumber

public int getPortNumber()
Get the arbitrary sequence port number assigned to this configuration record.

Returns:
port number

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.

dup

public PortConfig dup()
Make a deep copy of this PortConfig object.

Returns:
duplicate PortConfig

copyInto

public void copyInto(PortConfig dest)
Do a deep copy of this PortConfig object into another object..

Parameters:
dest - destination PortConfig

compareTo

public int compareTo(java.lang.Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this object.

writeToPreferences

public void writeToPreferences(java.util.prefs.Preferences root)
Write this PortConfig object to Java Preferences on the Ports sub-node of the specified Preferences node.

Parameters:
root - Preferences node to use to store the Ports sub-node

removeFromPreferences

public void removeFromPreferences(java.util.prefs.Preferences root)
Delete this PortConfig from the Java Preferences backing store.

Parameters:
root - Preferences node used to store the Ports sub-node

readFromPreferences

public static PortConfig readFromPreferences(java.util.prefs.Preferences root,
                                             java.lang.String displayName)
Read a PortConfig object from Java Preferences.

Parameters:
root - Preferences node used to store the Ports sub-node
displayName - the String port identifier name to read
Returns:
a populated PortConfig object for the specified name, or null if no such record exists in the specified node of Preferences