Class NetChannelLocation
- java.lang.Object
-
- org.jcsp.net.NetChannelLocation
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
CNSNetChannelLocation
public class NetChannelLocation extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
Instances of this class hold location information for a networked
ChannelInput
object. Instances of the class hold sufficient information for a networkedChannelOutput
object to establish a connection to the networkedChannelInput
object.Instances of this class may either be constructed by the
jcsp.net
user or by the networking infrastructure.- Author:
- Quickstone Technologies Limited
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
NetChannelLocation(NetChannelLocation other)
This is a protected constructor which takes anotherNetChannelLocation
object and "clones" it into this one.NetChannelLocation(NodeAddressID channelAddress, java.lang.String channelLabel)
Constructor which takes aNodeAddressID
on which the channel's Node is listening and the label assigned to the channel's Virtual Channel Number (VCN).NetChannelLocation(NodeID channelNode, java.lang.String channelLabel)
Constructor which takes theNodeID
of the Node hosting the networkedChannelInput
object and the label assigned to the channel's Virtual Channel Number (VCN).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkEqual(NetChannelLocation other)
This method is used by theequals(Object)
method to determine whether another object is equal to the one on which it is invoked.java.lang.Object
clone()
Returns a clone of the instance of this class.boolean
equals(java.lang.Object o)
Returns whether this object is equal to another object.NodeAddressID
getChannelAddress()
Public accessor for the channel's address, if held.java.lang.String
getChannelLabel()
Public accessor for the channel label property.NodeID
getChannelNodeID()
Public accessor for the channel label property.java.lang.String
getStringID()
Returns a String ID for thisNetChannelLocation
object.int
hashCode()
Return a hashcode for this object.boolean
refresh()
This method requests that the instance of this class refresh its information.protected void
refreshFrom(NetChannelLocation other)
This method refreshes the fields in the instance of this object to equal the fields in the supplied object.
-
-
-
Constructor Detail
-
NetChannelLocation
public NetChannelLocation(NodeID channelNode, java.lang.String channelLabel) throws java.lang.IllegalArgumentException
Constructor which takes the
NodeID
of the Node hosting the networkedChannelInput
object and the label assigned to the channel's Virtual Channel Number (VCN).- Parameters:
channelNode
- theNodeID
of the Node hosting the read end of the channel.channelLabel
- the label assigned to the channel's Virtual Channel Number (VCN).- Throws:
java.lang.IllegalArgumentException
-
NetChannelLocation
public NetChannelLocation(NodeAddressID channelAddress, java.lang.String channelLabel) throws java.lang.IllegalArgumentException
Constructor which takes a
NodeAddressID
on which the channel's Node is listening and the label assigned to the channel's Virtual Channel Number (VCN).This constructor is intended to be used by code that wishes to connect to a
ChannelInput
running on a Node to which aLink
has not yet been established. An address of the Node must be known by some means. For example, with a JCSP network running over TCP/IP, a program may prompt the user for an IP address to which to connect.- Parameters:
channelAddress
- aNodeAddressID
on which the channel's Node is listening.channelLabel
- the label assigned to the channel's VCN.- Throws:
java.lang.IllegalArgumentException
-
NetChannelLocation
protected NetChannelLocation(NetChannelLocation other) throws java.lang.IllegalArgumentException
This is a protected constructor which takes another
NetChannelLocation
object and "clones" it into this one. This allows sub-classes to adopt the field values of an instance of this class by passing a reference of it to this constructor.- Parameters:
other
- AnotherNetChannelLocation
to "clone" into this one.- Throws:
java.lang.IllegalArgumentException
- iff the parameter isnull
.
-
-
Method Detail
-
getChannelLabel
public final java.lang.String getChannelLabel()
Public accessor for the channel label property.
- Returns:
- the channel label held by the instance of this object,
if exists or else
null
.
-
getChannelAddress
public final NodeAddressID getChannelAddress()
Public accessor for the channel's address, if held.
- Returns:
- a
NodeAddressID
on which the channel's Node is listening. If the channel's Node'sNodeID
is known, then this will returnnull
.
-
getChannelNodeID
public final NodeID getChannelNodeID()
Public accessor for the channel label property.
- Returns:
- the
NodeID
of the channel's Node, if known, elsenull
.
-
refresh
public boolean refresh()
This method requests that the instance of this class refresh its information. This class does not actually do anything when this method is called, however, instances of subclasses may take the opportunity to refresh their data.
An example, of when this might be useful is if this class were extended as part of a name service that resolves names to
NetChannelLocation
objects. If a user of an instance of this extended version wanted to check that the data were still up to date, it would call this method which would then check the information with a name service.- Returns:
true
if any information has changed, otherwisefalse
.
-
getStringID
public final java.lang.String getStringID()
Returns a String ID for this
NetChannelLocation
object.This method does not need to be used by normal JCSP users.
- Returns:
- the id.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of the instance of this class. All mutable fields are also cloned.
- Overrides:
clone
in classjava.lang.Object
- Returns:
- a clone of the instance of this class.
- Throws:
java.lang.CloneNotSupportedException
-
equals
public final boolean equals(java.lang.Object o)
Returns whether this object is equal to another object.
- Overrides:
equals
in classjava.lang.Object
- Returns:
true
iff the supplied object is equal.
-
hashCode
public final int hashCode()
Return a hashcode for this object.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the
int
hash code.
-
refreshFrom
protected final void refreshFrom(NetChannelLocation other) throws java.lang.IllegalArgumentException
This method refreshes the fields in the instance of this object to equal the fields in the supplied object. Only members of the
NetChannelLocation
class are copied and not members added by sub-classes.- Parameters:
other
- AnotherNetChannelLocation
to "clone" into this one.- Throws:
java.lang.IllegalArgumentException
- iff the parameter isnull
.
-
checkEqual
protected boolean checkEqual(NetChannelLocation other)
This method is used by the
equals(Object)
method to determine whether another object is equal to the one on which it is invoked.This should be used by sub-classes as they cannot override the equals method.
- Parameters:
other
- theNetChannelLocation
object to compare with this object.- Returns:
true
if the other object is equal to this one.
-
-