drm.agentbase
Class Address
java.lang.Object
|
+--drm.agentbase.Address
- All Implemented Interfaces:
- java.io.Serializable
- public class Address
- extends java.lang.Object
- implements java.io.Serializable
This is for addressing all entities, ie agents and bases.
The main component is the name which is guaranteed not to be null
or empty.
- See Also:
- Serialized Form
Field Summary |
java.lang.String |
name
The name of the agent. |
int |
port
The port on which the base is listening. |
Constructor Summary |
Address(java.net.InetAddress host,
int port,
java.lang.String name)
Constructs an address for a possibly remote agent or base. |
Address(java.lang.String name)
Constructs an address for a local agent. |
Method Summary |
boolean |
equals(java.lang.Object o)
Must return true if and only if the object o is an Address
and it addresses the same entity. |
java.net.InetAddress |
getHost()
|
int |
hashCode()
Since we override Object.equals(), we need a new hashCode that is
consistent with it. |
boolean |
isLocal()
Returns true if this address does not contain a physical address,
only a name. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
port
public final int port
- The port on which the base is listening.
name
public final java.lang.String name
- The name of the agent.
Address
public Address(java.lang.String name)
- Constructs an address for a local agent.
Address
public Address(java.net.InetAddress host,
int port,
java.lang.String name)
- Constructs an address for a possibly remote agent or base.
- Throws:
java.lang.IllegalArgumentException
- If name is null or empty, or if port is
not positive when the host is not null.
getHost
public java.net.InetAddress getHost()
isLocal
public boolean isLocal()
- Returns true if this address does not contain a physical address,
only a name.
equals
public boolean equals(java.lang.Object o)
- Must return true if and only if the object o is an Address
and it addresses the same entity. That is if the name fields
equal, since names are supposed to be unique. If both names
are null returns true although it is an illegal state for a
name to be null.
- Overrides:
equals
in class java.lang.Object
hashCode
public int hashCode()
- Since we override Object.equals(), we need a new hashCode that is
consistent with it.
- Overrides:
hashCode
in class java.lang.Object
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object