net.sf.adf.agent
Class AID

java.lang.Object
  extended by net.sf.adf.agent.AID
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

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

Acording to FIPA00023 an Agent Identifier (AID) identifies an agent through an extensible collection of parameter-value pairs.

An AID comprises:

The parameter values of an AID can be edited or modified by an agent, for example, to update the sequence of name resolution servers or transport addresses in an AID. However, the name parameter can only be changed by the agent to whom the AID belongs.

Only the name property is mandatory in an AID.

See Also:
FIPA Agent Management Specification, Serialized Form

Constructor Summary
AID(java.lang.String name, boolean isGUID)
          Constructs a new AID with the name given by the first argument.
 
Method Summary
 java.lang.Object clone()
          Creates and returns a copy of this agent identifier.
 int compareTo(java.lang.Object o)
          Compares this agent identifier with another agent identifier.
 boolean equals(java.lang.Object o)
          Indicates whether some other agent identifier is equivalent to this one.
 java.util.List<java.net.URI> getAddresses()
          A transport address is a physical address at which an agent can be contacted and is usually specific to a Message Transport Protocol.
 java.lang.String getHap()
           
 java.lang.String getLocalName()
           
 java.lang.String getName()
          The name of the agent is a globally unique identifier that can be used as a unique referring expression of the agent.
static java.lang.String getPlatformID()
          The value of the platform identifier is appended to local names after a "@" character to obtain globally unique identifiers out of a local names.
 java.util.List<AID> getResolvers()
          Note: No agent may contain itself as a resolver.
 java.util.Properties getUserDefinedProperties()
           
 int hashCode()
          Hash code.
 void setLocalName(java.lang.String localName)
          This method sets the name of an agent by receiveing just a local name.
 void setName(java.lang.String globalName)
          The name of the agent is a globally unique identifier that can be used as a unique referring expression of the agent.
static void setPlatformID(java.lang.String id)
          The value of the platform identifier is appended to local names after a "@" character to obtain globally unique identifiers out of a local names.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AID

public AID(java.lang.String name,
           boolean isGUID)

Constructs a new AID with the name given by the first argument.

Parameters:
name - A name for this agent.
isGUID - Should be true when the name agument is a globally unique identifier for this agent and false when name is a local name.
Method Detail

clone

public java.lang.Object clone()

Creates and returns a copy of this agent identifier.

Overrides:
clone in class java.lang.Object
Returns:
An agent identifier that is equal but does not share state with this agent identifier.

compareTo

public int compareTo(java.lang.Object o)
Compares this agent identifier with another agent identifier. The order is given by the lexicographical order of the names, ignoring case.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Another AID to be compared with this AID.
Returns:
a negative integer, zero, or a positive integer as this AID is less than, equal to, or greater than the specified object.

equals

public boolean equals(java.lang.Object o)

Indicates whether some other agent identifier is equivalent to this one. Two AIDs are considered to be equivalent if their name parameters are the same, ignoring case.

Overrides:
equals in class java.lang.Object
Returns:
true if the the argument o is an agent identifier that has the same name as this agent identifier, ignoring case.

getAddresses

public java.util.List<java.net.URI> getAddresses()

A transport address is a physical address at which an agent can be contacted and is usually specific to a Message Transport Protocol. A given agent may support many methods of communication and can put multiple transport address values in the addresses parameter of an AID.

Note: According to FIPA the syntax of a transport addresses is the same as for a URL given in [RFC2396]. However the this poses unnecessary restrictions on the format of the address. ADF uses java.net.URIs as transport address, but if FIPA conformance is desired their use should be restricted to valid URLs only.

Returns:
A java.util.List containing the transport addresses where the agent can be contacted. The order in the list implies a preference relation of the agent to receive messages over that address.
See Also:
Uniform Resource Identifiers (URI): Generic Syntax

getHap

public java.lang.String getHap()
Returns:
The HAP of the agent or null if the name of this agent identifier is not of the form "local-name@platform-name"

getLocalName

public java.lang.String getLocalName()
Returns:
The local name of the agent (without the HAP).

getName

public java.lang.String getName()

The name of the agent is a globally unique identifier that can be used as a unique referring expression of the agent.

Returns:
The globaly unique name of this agent.

getPlatformID

public static final java.lang.String getPlatformID()

The value of the platform identifier is appended to local names after a "@" character to obtain globally unique identifiers out of a local names.

Returns:
A globally unique identifier for this platform.

getResolvers

public java.util.List<AID> getResolvers()
Note: No agent may contain itself as a resolver.

Returns:
A java.util.List containing the agents where name resolution services for the agent can be contacted. The order in the list implies a preference in the list of resolvers.

getUserDefinedProperties

public java.util.Properties getUserDefinedProperties()

hashCode

public int hashCode()
Hash code. This method returns an hash code in such a way that two AID objects with equal names or with names differing only in case have the same hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this AID object.

setLocalName

public void setLocalName(java.lang.String localName)

This method sets the name of an agent by receiveing just a local name. The globally unique identifier for this platform as returned by getPlatformID is appended after a "@" character to obtain a globally unique identifier.

Parameters:
localName - A local name for this agent.

setName

public void setName(java.lang.String globalName)

The name of the agent is a globally unique identifier that can be used as a unique referring expression of the agent. This method allows the setting of this GUID so extra care must be taken.

Parameters:
globalName - A globally unique name for this agent.

setPlatformID

public static final void setPlatformID(java.lang.String id)

The value of the platform identifier is appended to local names after a "@" character to obtain globally unique identifiers out of a local names.

Parameters:
id - A globally unique identifier for this platform.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
The textual representation of this agent identifier.
See Also:
FIPA Communicative Act Library Specification