Package jade.core
Class AID
- java.lang.Object
-
- jade.core.AID
-
- All Implemented Interfaces:
Comparable,Serializable,Serializable,Comparable
- Direct Known Subclasses:
OntoAID
public class AID extends Object implements Comparable, Serializable
This class represents a JADE Agent Identifier. JADE internal agent tables use this class to record agent names and addresses.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringAGENT_CLASSNAMEKey to retrieve the agent class name as a user defined slot of the AID included in the AMSAgentDescription registered with the AMS.static StringCLONE_ORIGINATORKey to retrieve the name of the originator agent in case the agent represented by this AID was clonedstatic charHAP_SEPARATORstatic booleanISGUIDconstant to be used in the constructor of the AIDstatic booleanISLOCALNAMEconstant to be used in the constructor of the AID
-
Constructor Summary
Constructors Constructor Description AID()Constructs an Agent-Identifier whose slot name is set to an empty stringAID(String guid)Deprecated.This constructor might generate a wrong AID, if the passed parameter is not a guid (globally unique identifier), but the local name of an agent (e.g.AID(String name, boolean isGUID)Constructor for an Agent-identifier
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAddresses(String url)This method permits to add a transport address where the agent can be contacted.voidaddResolvers(AID aid)This method permits to add the AID of a resolver (an agent where name resolution services for the agent can be contacted)voidaddUserDefinedSlot(String key, String value)To add a user defined slot (a pair key, value).voidclearAllAddresses()To remove all addresses of the agentvoidclearAllResolvers()To remove all resolvers.Objectclone()Clone the AID object.intcompareTo(Object o)Comparison operation.static StringcreateGUID(String localName, String platformName)booleanequals(Object o)Equality operation.String[]getAddressesArray()Returns an array of string containing all the addresses of the agentIteratorgetAllAddresses()Returns an iterator of all the addresses of the agent.IteratorgetAllResolvers()Returns an iterator of all the resolvers.PropertiesgetAllUserDefinedSlot()Returns the user-defined slots as properties.StringgetHap()Returns the HAP of the agent or null if the GUID of thisAIDis not of the form@ StringgetLocalName()Returns the local name of the agent (without the HAP).StringgetName()This method returns the name of the agent.AID[]getResolversArray()Returns an array containing all the AIDs of the resolvers.inthashCode()Hash code.booleanremoveAddresses(String url)To remove a transport address.booleanremoveResolvers(AID aid)To remove a resolver.booleanremoveUserDefinedSlot(String key)To remove a user defined slot.voidsetLocalName(String n)This method permits to set the symbolic name of an agent.voidsetName(String n)This method permits to set the symbolic name of an agent.StringtoString()Converts this agent identifier into a readable string.
-
-
-
Field Detail
-
HAP_SEPARATOR
public static final char HAP_SEPARATOR
- See Also:
- Constant Field Values
-
ISGUID
public static final boolean ISGUID
constant to be used in the constructor of the AID- See Also:
- Constant Field Values
-
ISLOCALNAME
public static final boolean ISLOCALNAME
constant to be used in the constructor of the AID- See Also:
- Constant Field Values
-
AGENT_CLASSNAME
public static final String AGENT_CLASSNAME
Key to retrieve the agent class name as a user defined slot of the AID included in the AMSAgentDescription registered with the AMS.- See Also:
- Constant Field Values
-
CLONE_ORIGINATOR
public static final String CLONE_ORIGINATOR
Key to retrieve the name of the originator agent in case the agent represented by this AID was cloned- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AID
public AID()
Constructs an Agent-Identifier whose slot name is set to an empty string
-
AID
public AID(String guid)
Deprecated.This constructor might generate a wrong AID, if the passed parameter is not a guid (globally unique identifier), but the local name of an agent (e.g. "da0").Constructor for an Agent-identifier This constructor (which is deprecated), examines the name to see if the "@" chararcter is present. If so, it callsthis(name, ISGUID)otherwise it callsthis(name, ISLOCALNAME)This ensures better compatibility with JADE2.2 code.- Parameters:
guid- is the Globally Unique identifer for the agent. The slot name assumes that value in the constructed object.
-
AID
public AID(String name, boolean isGUID)
Constructor for an Agent-identifier- Parameters:
name- is the value for the slot name for the agent.isGUID- indicates if the passednameis already a globally unique identifier or not. Two constantsISGUID,ISLOCALNAMEhave also been defined for setting a value for this parameter. If the name is a local name, then the HAP (Home Agent Platform) is concatenated to the name, separated by "@".
-
-
Method Detail
-
setName
public void setName(String n)
This method permits to set the symbolic name of an agent. The passed parameter must be a GUID and not a local name.
-
setLocalName
public void setLocalName(String n)
This method permits to set the symbolic name of an agent. The passed parameter must be a local name.
-
getName
public String getName()
This method returns the name of the agent.
-
addAddresses
public void addAddresses(String url)
This method permits to add a transport address where the agent can be contacted. The address is added only if not yet present
-
removeAddresses
public boolean removeAddresses(String url)
To remove a transport address.- Parameters:
url- the address to remove- Returns:
- true if the addres has been found and removed, false otherwise.
-
clearAllAddresses
public void clearAllAddresses()
To remove all addresses of the agent
-
getAllAddresses
public Iterator getAllAddresses()
Returns an iterator of all the addresses of the agent.- See Also:
Iterator
-
addResolvers
public void addResolvers(AID aid)
This method permits to add the AID of a resolver (an agent where name resolution services for the agent can be contacted)
-
removeResolvers
public boolean removeResolvers(AID aid)
To remove a resolver.- Parameters:
aid- the AID of the resolver to remove- Returns:
- true if the resolver has been found and removed, false otherwise.
-
clearAllResolvers
public void clearAllResolvers()
To remove all resolvers.
-
getAllResolvers
public Iterator getAllResolvers()
Returns an iterator of all the resolvers.- See Also:
Iterator
-
addUserDefinedSlot
public void addUserDefinedSlot(String key, String value)
To add a user defined slot (a pair key, value).- Parameters:
key- the name of the propertyvalue- the corresponding value of the property
-
removeUserDefinedSlot
public boolean removeUserDefinedSlot(String key)
To remove a user defined slot.- Parameters:
key- the name of the property- Returns:
- true if the property has been found and removed, false otherwise
-
getAddressesArray
public String[] getAddressesArray()
Returns an array of string containing all the addresses of the agent
-
getResolversArray
public AID[] getResolversArray()
Returns an array containing all the AIDs of the resolvers.
-
getAllUserDefinedSlot
public Properties getAllUserDefinedSlot()
Returns the user-defined slots as properties.- Returns:
- all the user-defined slots as a
jade.util.leap.Propertiesjava Object. - See Also:
Properties
-
toString
public String toString()
Converts this agent identifier into a readable string.
-
equals
public boolean equals(Object o)
Equality operation. This method compares anAIDobject with another or with a JavaString. The comparison is case insensitive.- Overrides:
equalsin classObject- Parameters:
o- The Java object to compare thisAIDto.- Returns:
trueif one of the following holds:- The argument
ois anAIDobject with the same GUID in its name slot (apart from differences in case). - The argument
ois aStringthat is equal to the GUID contained in the name slot of this Agent ID (apart from differences in case).
- The argument
-
compareTo
public int compareTo(Object o)
Comparison operation. This operation imposes a total order relationship over Agent IDs.- Specified by:
compareToin interfaceComparable- Parameters:
o- AnotherAIDobject, that will be compared with the currentAID.- Returns:
- -1, 0 or 1 according to the lexicographical order of the GUID of the two agent IDs, apart from differences in case.
-
hashCode
public int hashCode()
Hash code. This method returns an hash code in such a way that twoAIDobjects with equal names or with names differing only in case have the same hash code.
-
getLocalName
public String getLocalName()
Returns the local name of the agent (without the HAP). If the agent is not local, then the method returns its GUID.
-
getHap
public String getHap()
Returns the HAP of the agent or null if the GUID of thisAIDis not of the form@
-
-