Skip to main content
summaryrefslogtreecommitdiffstats
blob: 39dac8003c1721d2c6ac50978052739280b3d68c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.messaging.event.res.event;

import org.eclipse.osee.framework.jdk.core.util.AXml;

/**
 * @author Donald G. Dunne
 */
public class NetworkSender {

   private String sourceObject;
   private String sessionId;
   private String machineName;
   private String userId;
   private String machineIp;
   private String clientVersion;
   private String port;

   public NetworkSender(String sourceObject, String sessionId, String machineName, String userId, String machineIp, String port, String clientVersion) {
      this.sessionId = sessionId;
      this.sourceObject = sourceObject;
      this.machineName = machineName;
      this.userId = userId;
      this.machineIp = machineIp;
      this.port = port;
      this.clientVersion = clientVersion;
   }

   public NetworkSender(String xml) {
      fromXml(xml);
   }

   public String toXml() {
      StringBuffer sb = new StringBuffer();
      toXml(sb);
      return sb.toString();
   }

   public void toXml(StringBuffer sb) {
      sb.append(AXml.addTagData("obj", "" + sourceObject));
      sb.append(AXml.addTagData("sId", "" + sessionId));
      sb.append(AXml.addTagData("macName", "" + machineName));
      sb.append(AXml.addTagData("userId", "" + userId));
      sb.append(AXml.addTagData("macIp", "" + machineIp));
      sb.append(AXml.addTagData("port", "" + port));
      sb.append(AXml.addTagData("cVer", "" + clientVersion));
   }

   private void fromXml(String xml) {
      this.sourceObject = AXml.getTagData(xml, "obj");
      this.sessionId = AXml.getTagData(xml, "sId");
      this.machineName = AXml.getTagData(xml, "macName");
      this.userId = AXml.getTagData(xml, "userId");
      this.machineIp = AXml.getTagData(xml, "macIp");
      this.port = AXml.getTagData(xml, "port");
      this.clientVersion = AXml.getTagData(xml, "cVer");
   }

   public String getSourceObject() {
      return sourceObject;
   }

   public String getSessionId() {
      return sessionId;
   }

   public String getMachineName() {
      return machineName;
   }

   public String getUserId() {
      return userId;
   }

   public String getMachineIp() {
      return machineIp;
   }

   public String getClientVersion() {
      return clientVersion;
   }

   public String getPort() {
      return port;
   }

   @Override
   public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + ((clientVersion == null) ? 0 : clientVersion.hashCode());
      result = prime * result + ((machineIp == null) ? 0 : machineIp.hashCode());
      result = prime * result + ((machineName == null) ? 0 : machineName.hashCode());
      result = prime * result + ((port == null) ? 0 : port.hashCode());
      result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
      result = prime * result + ((sourceObject == null) ? 0 : sourceObject.hashCode());
      result = prime * result + ((userId == null) ? 0 : userId.hashCode());
      return result;
   }

   @Override
   public boolean equals(Object obj) {
      if (this == obj) return true;
      if (obj == null) return false;
      if (getClass() != obj.getClass()) return false;
      NetworkSender other = (NetworkSender) obj;
      if (clientVersion == null) {
         if (other.clientVersion != null) return false;
      } else if (!clientVersion.equals(other.clientVersion)) return false;
      if (machineIp == null) {
         if (other.machineIp != null) return false;
      } else if (!machineIp.equals(other.machineIp)) return false;
      if (machineName == null) {
         if (other.machineName != null) return false;
      } else if (!machineName.equals(other.machineName)) return false;
      if (port == null) {
         if (other.port != null) return false;
      } else if (!port.equals(other.port)) return false;
      if (sessionId == null) {
         if (other.sessionId != null) return false;
      } else if (!sessionId.equals(other.sessionId)) return false;
      if (sourceObject == null) {
         if (other.sourceObject != null) return false;
      } else if (!sourceObject.equals(other.sourceObject)) return false;
      if (userId == null) {
         if (other.userId != null) return false;
      } else if (!userId.equals(other.userId)) return false;
      return true;
   }

   public void setSessionId(String sessionId) {
      this.sessionId = sessionId;
   }

}

Back to the top