Source code: org/activemq/message/CleanupConnectionInfo.java
1 /**
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18
19 package org.activemq.message;
20
21 /**
22 * Denotes an object that can be serialized/deserailized using a Packet Reader/Writer
23 */
24
25 public class CleanupConnectionInfo extends AbstractPacket {
26
27 private String clientId;
28 private short sessionId;
29
30 /**
31 * Return the type of Packet
32 *
33 * @return integer representation of the type of Packet
34 */
35
36 public int getPacketType() {
37 return CLEANUP_CONNECTION_INFO;
38 }
39
40
41 /**
42 * Test for equality
43 *
44 * @param obj object to test
45 * @return true if equivalent
46 */
47 public boolean equals(Object obj) {
48 boolean result = false;
49 if (obj != null && obj instanceof CleanupConnectionInfo) {
50 CleanupConnectionInfo info = (CleanupConnectionInfo) obj;
51 result = this.clientId.equals(info.clientId) && this.sessionId == info.sessionId;
52 }
53 return result;
54 }
55
56 /**
57 * @return hash code for instance
58 */
59 public int hashCode() {
60 if (cachedHashCode == -1){
61 String hashCodeStr = clientId + sessionId;
62 cachedHashCode = hashCodeStr.hashCode();
63 }
64 return cachedHashCode;
65 }
66
67
68
69 /**
70 * @return Returns the sessionId.
71 */
72 public short getSessionId() {
73 return sessionId;
74 }
75
76 /**
77 * @param sessionId The sessionId to set.
78 */
79 public void setSessionId(short sessionId) {
80 this.sessionId = sessionId;
81 }
82
83
84 /**
85 * @return Returns the clientId.
86 */
87 public String getClientId() {
88 return this.clientId;
89 }
90
91 /**
92 * @param newClientId The clientId to set.
93 */
94 public void setClientId(String newClientId) {
95 this.clientId = newClientId;
96 }
97
98 public String toString() {
99 return super.toString() + " ClenaupConnectionAndSessionInfo{ " +
100 "clientId = '" + clientId + "' " +
101 ", sessionId = '" + sessionId + "' " +
102 " }";
103 }
104 }