Class NetChannelLocation
- All Implemented Interfaces:
Serializable, Cloneable
- Direct Known Subclasses:
CNSNetChannelLocation, NetConnectionLocation, NotNameableNetChannelLocation
Instances of this class hold location information for a networked
ChannelInput object. Instances of the class hold sufficient
information for a networked ChannelOutput object to establish
a connection to the networked ChannelInput object.
Instances of this class may either be constructed by the
jcsp.net user or by the networking infrastructure.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate NodeAddressIDTheNodeAddressIDon which the channel's Node is listening.private StringThe label, if any, assigned to a channel's VCN.private NodeIDTheNodeIDof the channel's Node.private longThe VCN of a channel, if known. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThis is a protected constructor which takes anotherNetChannelLocationobject and "clones" it into this one.NetChannelLocation(NodeAddressID channelAddress, String channelLabel) Constructor which takes aNodeAddressIDon which the channel's Node is listening and the label assigned to the channel's Virtual Channel Number (VCN).(package private)NetChannelLocation(NodeID channelNode, long vcn) Package private constructor which takes theNodeIDof the Node hosting the networkedChannelInputobject and alongholding the VCN of the channel.NetChannelLocation(NodeID channelNode, String channelLabel) Constructor which takes theNodeIDof the Node hosting the networkedChannelInputobject and the label assigned to the channel's Virtual Channel Number (VCN). -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckEqual(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.clone()Returns a clone of the instance of this class.final booleanReturns whether this object is equal to another object.final NodeAddressIDPublic accessor for the channel's address, if held.final StringPublic accessor for the channel label property.final NodeIDPublic accessor for the channel label property.final StringReturns a String ID for thisNetChannelLocationobject.(package private) longgetVCN()Package level accessor for the channel's VCN if held.final inthashCode()Return a hashcode for this object.booleanrefresh()This method requests that the instance of this class refresh its information.protected final voidrefreshFrom(NetChannelLocation other) This method refreshes the fields in the instance of this object to equal the fields in the supplied object.(package private) voidsetLocationDetails(NodeID nodeID, long vcn) Package level mutator for the channel's actual location details.
-
Field Details
-
channelLabel
The label, if any, assigned to a channel's VCN. -
vcn
private long vcnThe VCN of a channel, if known. -
channelNode
TheNodeIDof the channel's Node. This should benullifchannelAddressis notnull. -
channelAddress
TheNodeAddressIDon which the channel's Node is listening. This should benullifchannelNodeis notnull.
-
-
Constructor Details
-
NetChannelLocation
Constructor which takes the
NodeIDof the Node hosting the networkedChannelInputobject and the label assigned to the channel's Virtual Channel Number (VCN).- Parameters:
channelNode- theNodeIDof the Node hosting the read end of the channel.channelLabel- the label assigned to the channel's Virtual Channel Number (VCN).- Throws:
IllegalArgumentException
-
NetChannelLocation
public NetChannelLocation(NodeAddressID channelAddress, String channelLabel) throws IllegalArgumentException Constructor which takes a
NodeAddressIDon 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
ChannelInputrunning on a Node to which aLinkhas 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- aNodeAddressIDon which the channel's Node is listening.channelLabel- the label assigned to the channel's VCN.- Throws:
IllegalArgumentException
-
NetChannelLocation
NetChannelLocation(NodeID channelNode, long vcn) throws IllegalArgumentException Package private constructor which takes the
NodeIDof the Node hosting the networkedChannelInputobject and alongholding the VCN of the channel.Users of the
jcsp.netpackage cannot use this constructor. It is intended to be used by the infrastructure for creating an instance of the class in order to return it to the user.When used like this, the class may seem to be the same as the
ChannelIDclass, however, this class is publicly visible outside thejcsp.net.- Parameters:
channelNode- theNodeIDof the Node hosting the read end of the channel.vcn- the VCN of the channel- Throws:
IllegalArgumentException
-
NetChannelLocation
This is a protected constructor which takes another
NetChannelLocationobject 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- AnotherNetChannelLocationto "clone" into this one.- Throws:
IllegalArgumentException- iff the parameter isnull.
-
-
Method Details
-
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 accessor for the channel's address, if held.
- Returns:
- a
NodeAddressIDon which the channel's Node is listening. If the channel's Node'sNodeIDis known, then this will returnnull.
-
getChannelNodeID
Public accessor for the channel label property.
- Returns:
- the
NodeIDof 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
NetChannelLocationobjects. 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:
trueif any information has changed, otherwisefalse.
-
getStringID
Returns a String ID for this
NetChannelLocationobject.This method does not need to be used by normal JCSP users.
- Returns:
- the id.
-
clone
Returns a clone of the instance of this class. All mutable fields are also cloned.
- Overrides:
clonein classObject- Returns:
- a clone of the instance of this class.
- Throws:
CloneNotSupportedException
-
equals
-
hashCode
-
refreshFrom
This method refreshes the fields in the instance of this object to equal the fields in the supplied object. Only members of the
NetChannelLocationclass are copied and not members added by sub-classes.- Parameters:
other- AnotherNetChannelLocationto "clone" into this one.- Throws:
IllegalArgumentException- iff the parameter isnull.
-
checkEqual
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- theNetChannelLocationobject to compare with this object.- Returns:
trueif the other object is equal to this one.
-
getVCN
long getVCN()Package level accessor for the channel's VCN if held. Users of
jcsp.netshould not have any control over VCN allocation so this accessor is not publicly accessible.- Returns:
- the VCN value held for the channel.
-
setLocationDetails
Package level mutator for the channel's actual location details. The details can only be set if the current NodeID held is null.
- Parameters:
nodeID- theNodeIDof the channel.vcn- the VCN of the channel.
-