com.agentfactory.cldc
Class AgentName

java.lang.Object
  extended by com.agentfactory.cldc.AgentName

public class AgentName
extends java.lang.Object

This class represents the name of an agent. It provides support for the name to be updated to a unqiue value and for checking whether the name matches a wild card representation.

Author:
Conor Muldoon

Field Summary
static char DELIM
           
 
Constructor Summary
AgentName(FOS nm, java.lang.String appVal, Platform plat)
          Creates a new instance of AgentName
AgentName(java.lang.String s, java.lang.String a)
          Creates a new instance of AgentName
 
Method Summary
 void addName(java.lang.String[] array, int i)
          Adds a string represenation of the name to the array at the specified index.
 void addToTable(java.util.Hashtable table, AgentRunnable agent)
          Adds the AgentRunnable to the hash table using the functor of the first order structure representation of the agent name as the key.
 void appendName(java.lang.StringBuffer buffer)
          Appends the name to the specified string buffer.
 boolean equals(java.lang.Object o)
           
 java.lang.Object getFromTable(java.util.Hashtable table)
          Obtains an object from the hash table using the functor of the first order structure representation of the agent name as the key.
 int hashCode()
          The hash code of the name.
 boolean isUnique()
          Tests whether this is a unique name.
 boolean isWild()
          Tests whether this name contains the wild card symbol *.
 void update(FOS fos)
          Updates the name with a unique value.
 boolean wildEquals(AgentName an)
          Checks whether this agent name matches the specified agent name that contains a wild card.
 void write(java.io.DataOutputStream out)
          Writes the name to a data output stream.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELIM

public static final char DELIM
See Also:
Constant Field Values
Constructor Detail

AgentName

public AgentName(FOS nm,
                 java.lang.String appVal,
                 Platform plat)
Creates a new instance of AgentName

Parameters:
nm - a first order structure representation of the agent name.
appVal - the application name.
plat - the platform the agent is operating on.

AgentName

public AgentName(java.lang.String s,
                 java.lang.String a)
Creates a new instance of AgentName

Parameters:
s - A string representation of the agent name.
a - the application name.
Method Detail

isUnique

public boolean isUnique()
Tests whether this is a unique name. A name is considered unique if it has been obtained from the uniqne name server, therefore if the name is unique on the local platform but has not been obtained from the unique name server, this method will return false (even though it will be unqiue locally).

Returns:
true if the name is unique, false otherwise.

addName

public void addName(java.lang.String[] array,
                    int i)
Adds a string represenation of the name to the array at the specified index.

Parameters:
array - the array the name is to be added to.
i - the index at which the name should be added.

hashCode

public int hashCode()
The hash code of the name.

Overrides:
hashCode in class java.lang.Object

addToTable

public void addToTable(java.util.Hashtable table,
                       AgentRunnable agent)
Adds the AgentRunnable to the hash table using the functor of the first order structure representation of the agent name as the key.

Parameters:
table - the table the name is to be added.
agent - the AgentRunnable that is to be added.

getFromTable

public java.lang.Object getFromTable(java.util.Hashtable table)
Obtains an object from the hash table using the functor of the first order structure representation of the agent name as the key.

Parameters:
table - the table the object is to be obtained from.
Returns:
the object that maps to the functor.

write

public void write(java.io.DataOutputStream out)
           throws java.io.IOException
Writes the name to a data output stream.

Parameters:
out - the stream to write the name to.
Throws:
java.io.IOException - if there is an I/O error.

appendName

public void appendName(java.lang.StringBuffer buffer)
Appends the name to the specified string buffer.

Parameters:
buffer - the string buffer the name is to be appended.

isWild

public boolean isWild()
Tests whether this name contains the wild card symbol *.

Returns:
true if the name contains the character *, false otherwise.

wildEquals

public boolean wildEquals(AgentName an)
Checks whether this agent name matches the specified agent name that contains a wild card. For example, if the agent name was Alice and the wild card was Al*, this method would return true. It would also return true for Alf. It would not return true for Bob.

Parameters:
an - the wild card name that this name is being compared to.
Returns:
true if the this name matches the wild card name, false otherwise.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

update

public void update(FOS fos)
Updates the name with a unique value.

Parameters:
fos - a first order structure representation of the unique value.