Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/activemq/message/SessionInfo.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 SessionInfo extends AbstractPacket {
26  
27      private String clientId;
28      private short sessionId;
29      private long startTime;
30      private boolean started;
31      private int sessionMode;
32  
33      /**
34       * @return Returns the sessionMode.
35       */
36      public int getSessionMode() {
37          return sessionMode;
38      }
39      /**
40       * @param sessionMode The sessionMode to set.
41       */
42      public void setSessionMode(int sessionMode) {
43          this.sessionMode = sessionMode;
44      }
45      /**
46       * Return the type of Packet
47       *
48       * @return integer representation of the type of Packet
49       */
50  
51      public int getPacketType() {
52          return SESSION_INFO;
53      }
54  
55  
56      /**
57       * Test for equality
58       *
59       * @param obj object to test
60       * @return true if equivalent
61       */
62      public boolean equals(Object obj) {
63          boolean result = false;
64          if (obj != null && obj instanceof SessionInfo) {
65              SessionInfo info = (SessionInfo) obj;
66              result = this.clientId.equals(info.clientId) && this.sessionId == info.sessionId;
67          }
68          return result;
69      }
70  
71      /**
72       * @return hash code for instance
73       */
74      public int hashCode() {
75          if (cachedHashCode == -1){
76              String hashCodeStr = clientId + sessionId;
77              cachedHashCode = hashCodeStr.hashCode();
78          }
79          return cachedHashCode;
80      }
81      
82  
83  
84      /**
85       * @return Returns the sessionId.
86       */
87      public short getSessionId() {
88          return sessionId;
89      }
90  
91      /**
92       * @param sessionId The sessionId to set.
93       */
94      public void setSessionId(short sessionId) {
95          this.sessionId = sessionId;
96      }
97  
98  
99      /**
100      * @return Returns the clientId.
101      */
102     public String getClientId() {
103         return this.clientId;
104     }
105 
106     /**
107      * @param newClientId The clientId to set.
108      */
109     public void setClientId(String newClientId) {
110         this.clientId = newClientId;
111     }
112 
113 
114     /**
115      * @return Returns the started.
116      */
117     public boolean isStarted() {
118         return this.started;
119     }
120 
121     /**
122      * @param flag to indicate if started
123      */
124     public void setStarted(boolean flag) {
125         this.started = flag;
126     }
127 
128     /**
129      * @return Returns the startTime.
130      */
131     public long getStartTime() {
132         return this.startTime;
133     }
134 
135     /**
136      * @param newStartTime The startTime to set.
137      */
138     public void setStartTime(long newStartTime) {
139         this.startTime = newStartTime;
140     }
141 
142     public String toString() {
143         return super.toString() + " SessionInfo{ " +
144                 "clientId = '" + clientId + "' " +
145                 ", sessionId = '" + sessionId + "' " +
146                 ", startTime = " + startTime +
147                 ", started = " + started +
148                 " }";
149     }
150 }