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 package org.activemq.service;
019
020 import java.io.Externalizable;
021 import java.io.IOException;
022 import java.io.ObjectInput;
023 import java.io.ObjectOutput;
024
025 /**
026 * Represents a durable subscribers subscription entry which contains
027 * details of the subscription and the subscriber's unique ID
028 *
029 * @version $Revision: 1.1.1.1 $
030 */
031 public class SubscriberEntry implements Externalizable {
032 private static final long serialVersionUID = -5754338187296859149L;
033
034 private int subscriberID;
035 private String clientID;
036 private String consumerName;
037 private String destination;
038 private String selector;
039
040 public SubscriberEntry() {
041 }
042
043 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
044 subscriberID = in.readInt();
045 clientID = in.readUTF();
046 consumerName = in.readUTF();
047 destination = in.readUTF();
048 selector = readNullableUTF(in);
049 }
050
051 public void writeExternal(ObjectOutput out) throws IOException {
052 out.writeInt(subscriberID);
053 out.writeUTF(clientID);
054 out.writeUTF(consumerName);
055 out.writeUTF(destination);
056 writeNullableUTF(out,selector);
057 }
058
059 static public String readNullableUTF(ObjectInput in) throws IOException, ClassNotFoundException {
060 if( in.readBoolean() ) {
061 return in.readUTF();
062 } else {
063 return null;
064 }
065 }
066
067 static public void writeNullableUTF(ObjectOutput out, String value) throws IOException {
068 if( value==null ) {
069 out.writeBoolean(false);
070 } else {
071 out.writeBoolean(true);
072 out.writeUTF(value);
073 }
074 }
075
076 public String toString() {
077 return super.toString() + "[clientID: " + clientID + " consumerName: " + consumerName
078 + " destination: " + destination + " selector: " + selector + "]";
079 }
080
081 // Properties
082 //-------------------------------------------------------------------------
083 public String getClientID() {
084 return clientID;
085 }
086
087 public void setClientID(String clientID) {
088 this.clientID = clientID;
089 }
090
091 public String getConsumerName() {
092 return consumerName;
093 }
094
095 public void setConsumerName(String consumerName) {
096 this.consumerName = consumerName;
097 }
098
099 public String getDestination() {
100 return destination;
101 }
102
103 public void setDestination(String destination) {
104 this.destination = destination;
105 }
106
107 public String getSelector() {
108 return selector;
109 }
110
111 public void setSelector(String selector) {
112 this.selector = selector;
113 }
114
115 public int getSubscriberID() {
116 return subscriberID;
117 }
118
119 public void setSubscriberID(int subscriberID) {
120 this.subscriberID = subscriberID;
121 }
122 }