1 46 package org.mr.core.net; 47 48 import java.io.IOException ; 49 50 import org.mr.core.util.byteable.Byteable; 51 import org.mr.core.util.byteable.ByteableInputStream; 52 import org.mr.core.util.byteable.ByteableOutputStream; 53 import org.mr.core.util.byteable.ByteableRegistry; 54 55 56 public class Link implements Byteable { 57 58 String protocolType; 59 String localName; 60 String localIP; 61 int localPort; 62 long numberOfMsg; 63 long numberOfBytes; 64 65 String remoteName; 66 String remoteIP; 67 int remotePort; 68 private long fiveMinMessages; 69 private long fiveMinBytes; 70 71 72 public Link(){ 73 74 } 75 76 77 public Link(String protocolType, 78 String localName,String localIP,int localPort, 79 String remoteName,String remoteIP,int remotePort, 80 long numberOfMsg, long numberOfBytes, long fiveMinMessages, 81 long fiveMinBytes) 82 { 83 this.protocolType = protocolType; 84 this.localName = localName; 85 this.localIP = localIP; 86 this.localPort = localPort; 87 88 this.remoteName = remoteName; 89 this.remoteIP = remoteIP; 90 this.remotePort = remotePort; 91 this.numberOfMsg = numberOfMsg; 92 this.numberOfBytes = numberOfBytes; 93 this.fiveMinMessages = fiveMinMessages; 94 this.fiveMinBytes = fiveMinBytes; 95 } 96 99 public int getLocalPort() { 100 return localPort; 101 } 102 103 106 public void setLocalPort(int localPort) { 107 this.localPort = localPort; 108 } 109 110 113 public String getRemoteIP() { 114 return remoteIP; 115 } 116 117 120 public void setRemoteIP(String remoteIP) { 121 this.remoteIP = remoteIP; 122 } 123 124 127 public String getRemoteName() { 128 return remoteName; 129 } 130 131 134 public void setRemoteName(String remoteName) { 135 this.remoteName = remoteName; 136 } 137 138 141 public int getRemotePort() { 142 return remotePort; 143 } 144 145 148 public void setRemotePort(int remotePort) { 149 this.remotePort = remotePort; 150 } 151 152 155 public String getProtocolType() { 156 return protocolType; 157 } 158 159 162 public void setProtocolType(String type) { 163 this.protocolType = type; 164 } 165 166 167 168 public void setNumOfMsg (long num){ 169 numberOfMsg = num; 170 } 171 172 public void setNumOfBytes (long num){ 173 numberOfBytes = num; 174 } 175 176 177 public long getNumOfMsg(){ 178 return numberOfMsg; 179 } 180 181 public long getNumOfBytes(){ 182 return numberOfBytes; 183 } 184 185 186 187 public String toString() { 188 StringBuffer buf = new StringBuffer (); 189 buf.append(protocolType).append(","); 190 buf.append(localName).append(",").append(localIP).append(","). 191 append(localPort).append(","); 192 buf.append(remoteName).append(",").append(remoteIP).append(","). 193 append(remotePort).append(","); 194 buf.append(numberOfMsg).append(",").append(numberOfBytes).append(","). 195 append(fiveMinMessages).append(",").append(fiveMinBytes); 196 197 return buf.toString(); 198 } 199 200 public String getByteableName() { 202 return "org.mr.api.console.gui.Link"; 203 } 204 205 public void toBytes(ByteableOutputStream out) throws IOException { 206 out.writeASCIIString(this.protocolType); 207 out.writeASCIIString(this.localName); 208 out.writeASCIIString(this.localIP); 209 out.writeInt(this.localPort); 210 out.writeASCIIString(this.remoteName); 211 out.writeASCIIString(this.remoteIP); 212 out.writeInt(this.remotePort); 213 out.writeLong(this.numberOfMsg); 214 out.writeLong(this.numberOfBytes); 215 out.writeLong(this.fiveMinMessages); 216 out.writeLong(this.fiveMinBytes); 217 } 218 219 public Byteable createInstance(ByteableInputStream in) throws IOException { 220 Link l = new Link(); 221 l.protocolType = in.readASCIIString(); 222 l.localName = in.readASCIIString(); 223 l.localIP = in.readASCIIString(); 224 l.localPort = in.readInt(); 225 l.remoteName = in.readASCIIString(); 226 l.remoteIP = in.readASCIIString(); 227 l.remotePort = in.readInt(); 228 l.numberOfMsg = in.readLong(); 229 l.numberOfBytes = in.readLong(); 230 l.fiveMinMessages = in.readLong(); 231 l.fiveMinBytes = in.readLong(); 232 233 return l; 234 } 235 236 public void registerToByteableRegistry() { 237 ByteableRegistry.registerByteableFactory(getByteableName(), this); 238 } 239 240 public static void register() { 241 Link l = new Link(); 242 l.registerToByteableRegistry(); 243 } 244 247 public String getLocalName() { 248 return localName; 249 } 250 253 public void setLocalName(String localName) { 254 this.localName = localName; 255 } 256 259 public String getLocalIP() { 260 return localIP; 261 } 262 265 public void setLocalIP(String localIP) { 266 this.localIP = localIP; 267 } 268 271 public long getFiveMinBytes() { 272 return fiveMinBytes; 273 } 274 277 public long getFiveMinMessages() { 278 return fiveMinMessages; 279 } 280 } | Popular Tags |