com.alien.enterpriseRFID.discovery
Class DiscoveryItem

java.lang.Object
  extended bycom.alien.enterpriseRFID.discovery.DiscoveryItem

public class DiscoveryItem
extends java.lang.Object

DiscoveryItem details an individual reader that is discovered on a serial port or on the network.

Both of the discovery classes (SerialDiscoveryListenerService and NetworkDiscoveryListenerService) return discovered readers as DiscoveryItems. This class contains a number of key information points that allow any software system to identify and contact the reader in question, such as the reader name, type and address.

The DiscoveryItem, although just a collection of keyword-value pairs, does have a single method, getReader(), to translate this information into a usable reader class. Calling this method on a DiscoveryItem returns an AlienClass1Reader object.

Version:
1.4 Aug 2004
Author:
David Krull

Field Summary
static java.lang.String AUTOMATIC
          Constant used to specify how a reader was discovered.
 boolean isUpdated
          Flag to indicate if this discovery item has been updated with new reader info.
static java.lang.String MANUAL
          Constant used to specify how a reader was discovered.
static java.lang.String NETWORK
          Constant defining a "Network" connection method.
static java.lang.String SERIAL
          Constant defining a "Serial" connection method.
 
Constructor Summary
DiscoveryItem()
          Constructs a DiscoveryItem object, setting the first and last heartbeat fields to the current time, and the discovery method to AUTOMATIC.
 
Method Summary
 boolean equals(java.lang.Object comparison)
          Decides if a given object is identical to this DiscoveryItem.
 int getCommandPort()
          Returns the port number that this DiscoveryItem's reader uses to accept and respond to host commands over the network.
 java.lang.String getConnection()
          Returns the connection method of the reader represented by this DiscoveryItem.
 java.lang.String getDiscoveryMethod()
          Returns the method with which this DiscoveryItem's reader was discovered.
 long getFirstHeartbeat()
          Returns the time that this DiscoveryItem first registered a heartbeat signal from its reader.
 long getLastHeartbeat()
          Returns the time that this DiscoveryItem last registered a heartbeat signal from its reader.
 int getLeaseTime()
          Returns the amount of time the reader represented by this DiscoveryItem waits between sending its heartbeat messages across the network.
 java.lang.String getPassword()
          Returns the password associated with this DiscoveryItem's reader.
 AlienClass1Reader getReader()
          Instantiates a new AlienClass1Reader object, based on the attributes of this DiscoveryItem.
 java.lang.String getReaderAddress()
          Returns the address of the reader represented by this DiscoveryItem.
 java.lang.String getReaderMACAddress()
          Returns the MAC address of the reader represented by this DiscoveryItem.
 java.lang.String getReaderName()
          Returns this DiscoveryItem's ReaderName value.
 java.lang.String getReaderType()
          Returns this DiscoveryItem's ReaderType value.
 java.lang.String getReaderVersion()
          Returns this DiscoveryItem's ReaderVersion value.
 java.lang.String getUsername()
          Returns the username associated with this DiscoveryItem's reader.
 boolean setCommandPort(int commandPort)
          Sets the port number that this DiscoveryItem's reader uses to accept and respond to host commands over the network.
 boolean setCommandPort(java.lang.String commandPort)
          Sets the port number that this DiscoveryItem's reader uses to accept and respond to host commands over the network.
 boolean setConnection(java.lang.String connection)
          Sets this DiscoveryItem's connection method.
 void setDiscoveryMethod(java.lang.String discoveryMethod)
          Specifies the method with which this DiscoveryItem's reader was discovered.
 void setFirstHeartbeat(long firstHeartbeat)
          Specifies the time that this DiscoveryItem first registered a heartbeat signal from its reader.
 void setLastHeartbeat(long lastHeartbeat)
          Specifies the time that this DiscoveryItem last registered a heartbeat signal from its reader.
 boolean setLeaseTime(int leaseTime)
          Sets the amount of time that this DiscoveryItem's reader waits between sending heartbeat messages across the network.
 boolean setLeaseTime(java.lang.String leaseTime)
          Sets the amount of time that this DiscoveryItem's reader waits between sending heartbeat messages across the network.
 void setPassword(java.lang.String password)
          Specifies the password associated with this DiscoveryItem's reader.
 boolean setReaderAddress(java.lang.String readerAddress)
          Changes the reader address of this DiscoveryItem.
 boolean setReaderMACAddress(java.lang.String readerMACAddress)
          Changes the reader MAC address of this DiscoveryItem.
 boolean setReaderName(java.lang.String readerName)
          Changes this DiscoveryItem's ReaderName value.
 boolean setReaderType(java.lang.String readerType)
          Changes this DiscoveryItem's ReaderType value.
 boolean setReaderVersion(java.lang.String readerVersion)
          Changes this DiscoveryItem's ReaderVersion value.
 void setUsername(java.lang.String username)
          Specifies the username associated with this DiscoveryItem's reader.
 java.lang.String toKey()
          Generates a String that uniquely identifies this DiscoveryItem.
 java.lang.String toString()
          Generates a String that displays all of the attributes of this DiscoveryItem.
 java.lang.String toTerseString()
          Generates a String that displays ReaderName and address of this DiscoveryItem.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NETWORK

public static final java.lang.String NETWORK
Constant defining a "Network" connection method. Used in getReader() to set up the proper connection method.

See Also:
SERIAL, Constant Field Values

SERIAL

public static final java.lang.String SERIAL
Constant defining a "Serial" connection method. Used in getReader() to set up the proper connection method.

See Also:
NETWORK, Constant Field Values

AUTOMATIC

public static final java.lang.String AUTOMATIC
Constant used to specify how a reader was discovered.

See Also:
MANUAL, Constant Field Values

MANUAL

public static final java.lang.String MANUAL
Constant used to specify how a reader was discovered.

See Also:
AUTOMATIC, Constant Field Values

isUpdated

public boolean isUpdated
Flag to indicate if this discovery item has been updated with new reader info.

Constructor Detail

DiscoveryItem

public DiscoveryItem()
Constructs a DiscoveryItem object, setting the first and last heartbeat fields to the current time, and the discovery method to AUTOMATIC.

Method Detail

getReaderName

public java.lang.String getReaderName()
Returns this DiscoveryItem's ReaderName value.

Returns:
the reader's name
See Also:
setReaderName(String)

setReaderName

public boolean setReaderName(java.lang.String readerName)
Changes this DiscoveryItem's ReaderName value. This does not change the ReaderName attribute on the reader itself. Leading a trailing whitespace are trimmed off.

Parameters:
readerName - the new name of the reader in this DiscoveryItem
Returns:
true if value was changed
See Also:
getReaderName()

getReaderType

public java.lang.String getReaderType()
Returns this DiscoveryItem's ReaderType value.

Returns:
the reader's type
See Also:
setReaderType(String)

setReaderType

public boolean setReaderType(java.lang.String readerType)
Changes this DiscoveryItem's ReaderType value. This does not change the ReaderType attribute on the reader itself (which is not modifiable anyway). Leading and trainling whitespace are trimmed off.

Parameters:
readerType - the new value for the reader type
Returns:
true if value was changed
See Also:
getReaderType()

getReaderVersion

public java.lang.String getReaderVersion()
Returns this DiscoveryItem's ReaderVersion value.

Returns:
the reader's version
See Also:
setReaderVersion(String)

setReaderVersion

public boolean setReaderVersion(java.lang.String readerVersion)
Changes this DiscoveryItem's ReaderVersion value. This does not change the ReaderVersion attribute on the reader itself (which is not modifiable anyway). Leading and trainling whitespace are trimmed off.

Parameters:
readerVersion - the new value for the reader version
Returns:
true if value was changed
See Also:
getReaderVersion()

getReaderAddress

public java.lang.String getReaderAddress()
Returns the address of the reader represented by this DiscoveryItem. It is typically a COM port designation or an IP address, depending on where the reader was discovered.

Returns:
the address of this DiscoveryItem's reader
See Also:
setReaderAddress(String)

setReaderAddress

public boolean setReaderAddress(java.lang.String readerAddress)
Changes the reader address of this DiscoveryItem. This will not change the IPAddress attribute on the reader itself. Leading and trailing whitespace are stripped off.

Parameters:
readerAddress - the new Address of this DiscoveryItem
Returns:
true if value was changed
See Also:
getReaderAddress()

getReaderMACAddress

public java.lang.String getReaderMACAddress()
Returns the MAC address of the reader represented by this DiscoveryItem. This is a unique identifier of the reader's network hardware. Not all Alien readers send this information in the heartbeat.

Returns:
the MAC address of this DiscoveryItem's reader
See Also:
setReaderMACAddress(String)

setReaderMACAddress

public boolean setReaderMACAddress(java.lang.String readerMACAddress)
Changes the reader MAC address of this DiscoveryItem. This will not change the MACAddress attribute on the reader itself (which is immutable). Leading and trailing whitespace are stripped off.

Parameters:
readerMACAddress - the new MACAddress of this DiscoveryItem
Returns:
true if value was changed
See Also:
getReaderMACAddress()

getConnection

public java.lang.String getConnection()
Returns the connection method of the reader represented by this DiscoveryItem. Values are either NETWORK or SERIAL.

Returns:
the connection method of this DiscoveryItem
See Also:
setConnection(String)

setConnection

public boolean setConnection(java.lang.String connection)
Sets this DiscoveryItem's connection method. Acceptable values are typically NETWORK or AUTOMATIC. Leading and trailing whitespace are stripped off.

Parameters:
connection - the method of connecting to this DiscoveryItem's reader
Returns:
true if value was changed
See Also:
getConnection()

getCommandPort

public int getCommandPort()
Returns the port number that this DiscoveryItem's reader uses to accept and respond to host commands over the network. This is sometimes referred to as the Command Channel.

Returns:
the port number for commands
See Also:
setCommandPort(int), setCommandPort(String)

setCommandPort

public boolean setCommandPort(int commandPort)
Sets the port number that this DiscoveryItem's reader uses to accept and respond to host commands over the network. This will not change the CommandPort attribute on the reader itself.

Parameters:
commandPort - the new port for commands (as an int)
Returns:
true if value was changed
See Also:
setCommandPort(String), getCommandPort()

setCommandPort

public boolean setCommandPort(java.lang.String commandPort)
Sets the port number that this DiscoveryItem's reader uses to accept and respond to host commands over the network. This will not change the CommandPort attribute on the reader itself.

This method simply converts the command port that is passed in as a String into an integer before calling setCommandPort(int).

Parameters:
commandPort - the new port for commands (as a String)
Returns:
true if value was changed
See Also:
setCommandPort(int), getCommandPort()

getLeaseTime

public int getLeaseTime()
Returns the amount of time the reader represented by this DiscoveryItem waits between sending its heartbeat messages across the network.

Returns:
the time between heartbeats
See Also:
setLeaseTime(int), setLeaseTime(String)

setLeaseTime

public boolean setLeaseTime(int leaseTime)
Sets the amount of time that this DiscoveryItem's reader waits between sending heartbeat messages across the network. This will not change the HeartbeatTime attribute on the reader itself.

Parameters:
leaseTime - the time between heartbeats
Returns:
true if value was changed
See Also:
setLeaseTime(String), getLeaseTime()

setLeaseTime

public boolean setLeaseTime(java.lang.String leaseTime)
Sets the amount of time that this DiscoveryItem's reader waits between sending heartbeat messages across the network. This will not change the HeartbeatTime attribute on the reader itself.

This method simply converts the leaseTime that is passed in as a String into an integer before calling setLeaseTime(int).

Parameters:
leaseTime - the time between heartbeats (as a String)
Returns:
true if value was changed
See Also:
setLeaseTime(int), getLeaseTime()

getFirstHeartbeat

public long getFirstHeartbeat()
Returns the time that this DiscoveryItem first registered a heartbeat signal from its reader.

Returns:
the time of this DiscoveryItem's first heartbeat signal
See Also:
setFirstHeartbeat(long), getLastHeartbeat(), setLastHeartbeat(long)

setFirstHeartbeat

public void setFirstHeartbeat(long firstHeartbeat)
Specifies the time that this DiscoveryItem first registered a heartbeat signal from its reader.

Parameters:
firstHeartbeat - the time of the first heartbeat from this DiscoveryItem's reader
See Also:
getFirstHeartbeat(), getLastHeartbeat(), setLastHeartbeat(long)

getLastHeartbeat

public long getLastHeartbeat()
Returns the time that this DiscoveryItem last registered a heartbeat signal from its reader.

Returns:
the time of the last heartbeat from this DiscoveryItem's reader
See Also:
setLastHeartbeat(long), getFirstHeartbeat(), setFirstHeartbeat(long)

setLastHeartbeat

public void setLastHeartbeat(long lastHeartbeat)
Specifies the time that this DiscoveryItem last registered a heartbeat signal from its reader.

Parameters:
lastHeartbeat - the time of the last heartbeat
See Also:
getLastHeartbeat(), getFirstHeartbeat(), setFirstHeartbeat(long)

getUsername

public java.lang.String getUsername()
Returns the username associated with this DiscoveryItem's reader. The username is required, along with the password, to open a connection to a reader on the network.

Returns:
the username of this DiscoveryItem's reader
See Also:
setUsername(String), getPassword(), setPassword(String)

setUsername

public void setUsername(java.lang.String username)
Specifies the username associated with this DiscoveryItem's reader. This method will not change the Username attribute on the reader itself. The username is required, along with the password, to open a connection to a reader on the network.

Parameters:
username - the new username for this DiscoveryItem's reader
See Also:
getUsername(), getPassword(), setPassword(String)

getPassword

public java.lang.String getPassword()
Returns the password associated with this DiscoveryItem's reader. The password is required, along with the username, to open a connection to a reader on the network.

Returns:
the password for this DiscoveryItem's reader
See Also:
setPassword(String), getUsername(), setUsername(String)

setPassword

public void setPassword(java.lang.String password)
Specifies the password associated with this DiscoveryItem's reader. This method will not change the Password attribute on the reader itself. The password is required, along with the username, to open a connection to a reader on the network.

Parameters:
password - the new password for this DiscoveryItem's reader
See Also:
getPassword(), getUsername(), setUsername(String)

getDiscoveryMethod

public java.lang.String getDiscoveryMethod()
Returns the method with which this DiscoveryItem's reader was discovered. If the reader was found with a DiscoveryListenerService, then the method is AUTOMATIC, otherwise it should be MANUAL.

Returns:
the method used to discover the reader

setDiscoveryMethod

public void setDiscoveryMethod(java.lang.String discoveryMethod)
Specifies the method with which this DiscoveryItem's reader was discovered. Readers found with one of the DiscoveryListenerServices are considered to be AUTOMATIC, while readers created manually are MANUAL.

Parameters:
discoveryMethod - the method used to discover the reader

toKey

public java.lang.String toKey()
Generates a String that uniquely identifies this DiscoveryItem. It is used for comparison purposes to determine if a discovered reader may have already been discovered.

If the MACAddress is known, then the hash is ,. Otherwise, the hash is

,.

Returns:
a string key to represent this DiscoveryItem for comparison purposes

toString

public java.lang.String toString()
Generates a String that displays all of the attributes of this DiscoveryItem.

Returns:
a string representation of this item

toTerseString

public java.lang.String toTerseString()
Generates a String that displays ReaderName and address of this DiscoveryItem.

Returns:
a terse string representation of this item

equals

public boolean equals(java.lang.Object comparison)
Decides if a given object is identical to this DiscoveryItem. It compares each of their MAC Addresses (or IP addresses, if MAC addresses aren't there) and connection modes, returning truefalse otherwise.

Parameters:
comparison - object to compare with - to be cast into a DiscoveryItem
Returns:
true if equal, false otherwise

getReader

public AlienClass1Reader getReader()
                            throws AlienDiscoveryUnknownReaderException
Instantiates a new AlienClass1Reader object, based on the attributes of this DiscoveryItem. If the readerType contains the phrase "Class BPT", then the reader will be created as an AlienClassBPTReader. The new reader object's connection method will be set according to the DiscoveryItem's connection attribute.

Returns:
an AlienClass1Reader with address given by this DiscoveryItem's address
Throws:
AlienDiscoveryUnknownReaderException - if the readerType is an unknown value