001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mq;
023:
024: import java.io.Serializable;
025:
026: /**
027: * @author Norbert Lataille (Norbert.Lataille@m4x.org)
028: * @author Hiram Chirino (Cojonudo14@hotmail.com)
029: * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
030: * @version $Revision: 57198 $
031: */
032: public class DurableSubscriptionID implements Serializable {
033: // Constants -----------------------------------------------------
034:
035: /** The serialVersionUID */
036: private static final long serialVersionUID = 2293499797647000970L;
037:
038: // Attributes ----------------------------------------------------
039:
040: /** The clientID */
041: String clientID;
042: /** The subscriptionName */
043: String subscriptionName;
044: /** The selector */
045: String selector;
046:
047: // Static --------------------------------------------------------
048:
049: // Constructors --------------------------------------------------
050:
051: /**
052: * Create a new DurableSubscriptionID
053: *
054: * @param id the client id
055: * @param subName the subscription name
056: * @param selector the selector
057: */
058:
059: public DurableSubscriptionID(String id, String subName,
060: String selector) {
061: this .clientID = id;
062: this .subscriptionName = subName;
063: this .selector = selector;
064: }
065:
066: // Public --------------------------------------------------------
067:
068: /**
069: * Set the client id
070: *
071: * @param newClientID the client id
072: */
073: public void setClientID(String newClientID) {
074: clientID = newClientID;
075: }
076:
077: /**
078: * Set the subscription name
079: *
080: * @param newSubscriptionName the subscription name
081: */
082: public void setSubscriptionName(java.lang.String newSubscriptionName) {
083: subscriptionName = newSubscriptionName;
084: }
085:
086: /**
087: * Get the client id
088: *
089: * @return the client id
090: */
091: public String getClientID() {
092: return clientID;
093: }
094:
095: /**
096: * Get the subscription name
097: *
098: * @return the subscription name
099: */
100: public String getSubscriptionName() {
101: return subscriptionName;
102: }
103:
104: /**
105: * Gets the selector.
106: *
107: * @return the selector
108: */
109: public String getSelector() {
110: if (selector == null || selector.trim().length() == 0)
111: return null;
112: return selector;
113: }
114:
115: /**
116: * Sets the selector.
117: *
118: * @param selector The selector to set
119: */
120: public void setSelector(String selector) {
121: this .selector = selector;
122: }
123:
124: // Object overrides ----------------------------------------------
125:
126: public boolean equals(Object obj) {
127: try {
128: DurableSubscriptionID o = (DurableSubscriptionID) obj;
129: return o.clientID.equals(clientID)
130: && o.subscriptionName.equals(subscriptionName);
131: } catch (Throwable e) {
132: return false;
133: }
134: }
135:
136: public int hashCode() {
137: return Integer.MIN_VALUE + clientID.hashCode()
138: + subscriptionName.hashCode();
139: }
140:
141: public String toString() {
142: StringBuffer buffer = new StringBuffer(100);
143: buffer.append("DurableSubscription[clientId=").append(clientID);
144: buffer.append(" name=").append(subscriptionName);
145: buffer.append(" selector=").append(selector);
146: buffer.append(']');
147: return buffer.toString();
148: }
149:
150: // Package protected ---------------------------------------------
151:
152: // Protected -----------------------------------------------------
153:
154: // Private -------------------------------------------------------
155:
156: // Inner classes -------------------------------------------------
157: }
|