001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 019 package org.activemq.message; 020 021 /** 022 * Denotes an object that can be serialized/deserailized using a Packet Reader/Writer 023 */ 024 025 public class CleanupConnectionInfo extends AbstractPacket { 026 027 private String clientId; 028 private short sessionId; 029 030 /** 031 * Return the type of Packet 032 * 033 * @return integer representation of the type of Packet 034 */ 035 036 public int getPacketType() { 037 return CLEANUP_CONNECTION_INFO; 038 } 039 040 041 /** 042 * Test for equality 043 * 044 * @param obj object to test 045 * @return true if equivalent 046 */ 047 public boolean equals(Object obj) { 048 boolean result = false; 049 if (obj != null && obj instanceof CleanupConnectionInfo) { 050 CleanupConnectionInfo info = (CleanupConnectionInfo) obj; 051 result = this.clientId.equals(info.clientId) && this.sessionId == info.sessionId; 052 } 053 return result; 054 } 055 056 /** 057 * @return hash code for instance 058 */ 059 public int hashCode() { 060 if (cachedHashCode == -1){ 061 String hashCodeStr = clientId + sessionId; 062 cachedHashCode = hashCodeStr.hashCode(); 063 } 064 return cachedHashCode; 065 } 066 067 068 069 /** 070 * @return Returns the sessionId. 071 */ 072 public short getSessionId() { 073 return sessionId; 074 } 075 076 /** 077 * @param sessionId The sessionId to set. 078 */ 079 public void setSessionId(short sessionId) { 080 this.sessionId = sessionId; 081 } 082 083 084 /** 085 * @return Returns the clientId. 086 */ 087 public String getClientId() { 088 return this.clientId; 089 } 090 091 /** 092 * @param newClientId The clientId to set. 093 */ 094 public void setClientId(String newClientId) { 095 this.clientId = newClientId; 096 } 097 098 public String toString() { 099 return super.toString() + " ClenaupConnectionAndSessionInfo{ " + 100 "clientId = '" + clientId + "' " + 101 ", sessionId = '" + sessionId + "' " + 102 " }"; 103 } 104 }