diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
| commit | 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch) | |
| tree | 5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/entity/proxy/ProxyMessage.java | |
| parent | 036cbdba66f804743c4c838ed598d6972c4b3e17 (diff) | |
More code cleanup:
Refactored Entity Proxy Subscription to handle generics better
Rewrote RemoteMap to use TreeMap instead of the internal array for
order. It now sorts its keys by number if they parse, else as strings.
Removed a no-longer-in-progress outcome form class
Diffstat (limited to 'source/com/c2kernel/entity/proxy/ProxyMessage.java')
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/entity/proxy/ProxyMessage.java | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/source/com/c2kernel/entity/proxy/ProxyMessage.java b/source/com/c2kernel/entity/proxy/ProxyMessage.java index 66f1f34..b312a44 100755..100644 --- a/source/com/c2kernel/entity/proxy/ProxyMessage.java +++ b/source/com/c2kernel/entity/proxy/ProxyMessage.java @@ -18,24 +18,24 @@ import com.c2kernel.common.InvalidDataException; **************************************************************************/
public class ProxyMessage {
-
+
// special server message paths
- public static final String BYEPATH = "bye";
+ public static final String BYEPATH = "bye";
public static final String ADDPATH = "add";
public static final String DELPATH = "del";
public static final String PINGPATH = "ping";
public static final boolean ADDED = false;
public static final boolean DELETED = true;
public static final int NA = -1;
-
- static ProxyMessage byeMessage = new ProxyMessage(NA, BYEPATH, ADDED);
- static ProxyMessage pingMessage = new ProxyMessage(NA, PINGPATH, ADDED);
-
+
+ static ProxyMessage byeMessage = new ProxyMessage(NA, BYEPATH, ADDED);
+ static ProxyMessage pingMessage = new ProxyMessage(NA, PINGPATH, ADDED);
+
private int sysKey = NA;
private String path = "";
private String server = null;
private boolean state = ADDED;
-
+
public ProxyMessage() {
super();
}
@@ -45,7 +45,7 @@ public class ProxyMessage { setPath(path);
setState(state);
}
-
+
public ProxyMessage(String line) throws InvalidDataException, IOException {
if (line == null)
throw new IOException("Null proxy message");
@@ -56,10 +56,10 @@ public class ProxyMessage { path = tok.nextToken();
if (path.startsWith("-")) {
state = DELETED;
- path = path.substring(1);
+ path = path.substring(1);
}
}
-
+
public ProxyMessage(DatagramPacket packet) throws InvalidDataException, IOException {
this(new String(packet.getData()));
}
@@ -67,7 +67,7 @@ public class ProxyMessage { public int getSysKey() {
return sysKey;
}
-
+
public void setSysKey(int sysKey) {
this.sysKey = sysKey;
}
@@ -75,30 +75,31 @@ public class ProxyMessage { public String getPath() {
return path;
}
-
+
public void setPath(String newPath) {
this.path = newPath;
}
-
+
public boolean getState() {
return state;
}
-
+
public void setState(boolean state) {
this.state = state;
}
-
- public String toString() {
- return sysKey+":"+(state?"-":"")+path;
+
+ @Override
+ public String toString() {
+ return sysKey+":"+(state?"-":"")+path;
}
public DatagramPacket getPacket(ProxySubscriber host) {
return getPacket(host.getHost(), host.getPort());
}
-
+
public DatagramPacket getPacket(InetAddress host, int port) {
byte[] packetString = toString().getBytes();
return new DatagramPacket(packetString, packetString.length, host, port);
- }
+ }
public String getServer() {
return server;
|
