madkit.kernel
Class AgentAddress

java.lang.Object
  extended by madkit.kernel.AgentAddress
All Implemented Interfaces:
java.io.Serializable

public class AgentAddress
extends java.lang.Object
implements java.io.Serializable

This class describe the unique identifiers used in the MadKit kernel. An identifier created with this class is guaranteed to be unique. This class has been designed to be extended and subclassed in the future to handle various address type (FIPA, CORBA, MAF, JNA, ...). The syntax in this actual class is MadKit-specific.

Version:
1.3 - 23/03/2007
Author:
Olivier Gutknecht, Fabien Michel, Saber Mansour
See Also:
Serialized Form

Constructor Summary
AgentAddress(AgentAddress anAddress)
          Instantiates a new agent address.
AgentAddress(java.lang.String def)
          Attempts to define an AgentAddress from a string representation (MadKit syntax).
AgentAddress(java.lang.String n, KernelAddress k)
          Define a new AgentAddress.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compare two instances of AgentAddress.
 KernelAddress getKernel()
          returns the address of the kernel on which the agent is currently running.
 int getLocalID()
          The discriminating part of an AgentAddress.
 java.lang.String getName()
          Returns current agent name.
 int hashCode()
           
 boolean isLocal()
          Check is this address is a local address.
 java.lang.String toString()
          Returns a string representation of the AgentAddress (with MadKit syntax).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AgentAddress

public AgentAddress(java.lang.String n,
                    KernelAddress k)
Define a new AgentAddress.

Parameters:
n - agent name
k - local kernel address

AgentAddress

public AgentAddress(AgentAddress anAddress)
Instantiates a new agent address.

Parameters:
anAddress - the address

AgentAddress

public AgentAddress(java.lang.String def)
             throws InvalidAddressException
Attempts to define an AgentAddress from a string representation (MadKit syntax). The official format is "mka:a,b@k" ("a" an agent name, "b" agent ID, "k" a kernel address)

Parameters:
def - string representation or agent name
Throws:
InvalidAddressException - if the string cannot be parsed
Method Detail

toString

public java.lang.String toString()
Returns a string representation of the AgentAddress (with MadKit syntax).

Overrides:
toString in class java.lang.Object
Returns:
the string

isLocal

public boolean isLocal()
Check is this address is a local address.

Returns:
true, if checks if is local

equals

public boolean equals(java.lang.Object o)
Compare two instances of AgentAddress.

Overrides:
equals in class java.lang.Object
Parameters:
o - other agent address (can be void)
Returns:
true, if equals

getName

public java.lang.String getName()
Returns current agent name.

Returns:
the name

getLocalID

public int getLocalID()
The discriminating part of an AgentAddress.

Returns:
the local id

getKernel

public KernelAddress getKernel()
returns the address of the kernel on which the agent is currently running.

Returns:
the kernel address

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © Madkit Team (O. Gutknecht, J. Ferber, F. Michel et al.) All Rights Reserved.