6
import java.io.Serializable;
11
public final class NetConnectionLocation
13
implements Serializable
16
* The SUID representing this class
18
private static final long serialVersionUID = 1L;
21
* The NodeID portion of the location
23
private final NodeID nodeID;
26
* The vconnn portion of the location
28
private final int vconnn;
31
* Creates a new NetConnectionLocation
34
* The NodeID part of the location
36
* The vconnn part of the location
38
public NetConnectionLocation(NodeID aNodeID, int aVConnN)
40
this.nodeID = aNodeID;
41
this.vconnn = aVConnN;
45
* Gets the NodeID part of the location
47
* @return The NodeID part of the NetConnectionLocation
49
public NodeID getNodeID()
55
* Gets the NodeAddress part of the location
57
* @return The NodeAddress part of the NetConnectionLocation
59
public NodeAddress getNodeAddress()
61
return this.nodeID.getNodeAddress();
65
* Gets the vconnn part of the location
67
* @return The VConnN part of the NetConnectionLocation
69
public int getVConnN()
75
* Converts the NetConnectionLocation object into a string representation of the form nconnl://[NodeID]/[VConnN]
77
* @return The String form of the NetConnectionLocation
79
public String toString()
81
return "nconnl://" + this.nodeID.toString() + "/" + this.vconnn;
85
* Converts the string form of a NetConnectionLocation back into its object form
88
* The string representation of a NetConnectionLocation
89
* @return A new NetConnectionLocation created from the String representation
91
public static NetConnectionLocation parse(String str)
93
if (str.equalsIgnoreCase("null"))
95
if (str.startsWith("nconnl://"))
97
String toParse = str.substring(6);
98
String[] addressBits = toParse.split("/");
99
NodeID nodeID = NodeID.parse(addressBits[0]);
100
int vcn = Integer.parseInt(addressBits[1]);
101
return new NetConnectionLocation(nodeID, vcn);
103
throw new IllegalArgumentException("String is not a string form of a NetConnectionLocation");