KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > DurableSubscriptionID


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mq;
23
24 import java.io.Serializable JavaDoc;
25
26 /**
27  * @author Norbert Lataille (Norbert.Lataille@m4x.org)
28  * @author Hiram Chirino (Cojonudo14@hotmail.com)
29  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
30  * @version $Revision: 37459 $
31  */

32 public class DurableSubscriptionID implements Serializable JavaDoc
33 {
34    // Constants -----------------------------------------------------
35

36    /** The serialVersionUID */
37    private static final long serialVersionUID = 2293499797647000970L;
38    
39    // Attributes ----------------------------------------------------
40

41    /** The clientID */
42    String JavaDoc clientID;
43    /** The subscriptionName */
44    String JavaDoc subscriptionName;
45    /** The selector */
46    String JavaDoc selector;
47
48    // Static --------------------------------------------------------
49

50    // Constructors --------------------------------------------------
51

52    /**
53     * Create a new DurableSubscriptionID
54     *
55     * @param id the client id
56     * @param subName the subscription name
57     * @param selector the selector
58     */

59    
60    public DurableSubscriptionID(String JavaDoc id, String JavaDoc subName, String JavaDoc selector)
61    {
62       this.clientID = id;
63       this.subscriptionName = subName;
64       this.selector = selector;
65    }
66    
67    // Public --------------------------------------------------------
68

69    /**
70     * Set the client id
71     *
72     * @param newClientID the client id
73     */

74    public void setClientID(String JavaDoc newClientID)
75    {
76       clientID = newClientID;
77    }
78
79    /**
80     * Set the subscription name
81     *
82     * @param newSubscriptionName the subscription name
83     */

84    public void setSubscriptionName(java.lang.String JavaDoc newSubscriptionName)
85    {
86       subscriptionName = newSubscriptionName;
87    }
88
89    /**
90     * Get the client id
91     *
92     * @return the client id
93     */

94    public String JavaDoc getClientID()
95    {
96       return clientID;
97    }
98
99    /**
100     * Get the subscription name
101     *
102     * @return the subscription name
103     */

104    public String JavaDoc getSubscriptionName()
105    {
106       return subscriptionName;
107    }
108    /**
109     * Gets the selector.
110     *
111     * @return the selector
112     */

113    public String JavaDoc getSelector()
114    {
115       if (selector == null || selector.trim().length() == 0)
116          return null;
117       return selector;
118    }
119
120    /**
121     * Sets the selector.
122     *
123     * @param selector The selector to set
124     */

125    public void setSelector(String JavaDoc selector)
126    {
127       this.selector = selector;
128    }
129    
130    // Object overrides ----------------------------------------------
131

132    public boolean equals(Object JavaDoc obj)
133    {
134       try
135       {
136          DurableSubscriptionID o = (DurableSubscriptionID) obj;
137          return o.clientID.equals(clientID) && o.subscriptionName.equals(subscriptionName);
138       }
139       catch (Throwable JavaDoc e)
140       {
141          return false;
142       }
143    }
144    
145    public int hashCode()
146    {
147       return Integer.MIN_VALUE + clientID.hashCode() + subscriptionName.hashCode();
148    }
149
150    public String JavaDoc toString()
151    {
152       StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(100);
153       buffer.append("DurableSubscription[clientId=").append(clientID);
154       buffer.append(" name=").append(subscriptionName);
155       buffer.append(" selector=").append(selector);
156       buffer.append(']');
157       return buffer.toString();
158    }
159    
160    // Package protected ---------------------------------------------
161

162    // Protected -----------------------------------------------------
163

164    // Private -------------------------------------------------------
165

166    // Inner classes -------------------------------------------------
167
}
Popular Tags