View Javadoc

    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  package org.codehaus.activemq.service;
    19
    20  import java.io.Externalizable;
    21  import java.io.IOException;
    22  import java.io.ObjectInput;
    23  import java.io.ObjectOutput;
    24
    25  /***
    26   * Represents a durable subscribers subscription entry which contains
    27   * details of the subscription and the subscriber's unique ID
    28   *
    29   * @version $Revision: 1.3 $
    30   */
    31  public class SubscriberEntry implements Externalizable {
    32      private static final long serialVersionUID = -5754338187296859149L;
    33
    34      private int subscriberID;
    35      private String clientID;
    36      private String consumerName;
    37      private String destination;
    38      private String selector;
    39
    40      public SubscriberEntry() {
    41      }
    42
    43      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    44          subscriberID = in.readInt();
    45          clientID = in.readUTF();
    46          consumerName = in.readUTF();
    47          destination = in.readUTF();
    48          selector = readNullableUTF(in);
    49      }
    50
    51      public void writeExternal(ObjectOutput out) throws IOException {
    52          out.writeInt(subscriberID);
    53          out.writeUTF(clientID);
    54          out.writeUTF(consumerName);
    55          out.writeUTF(destination);
    56          writeNullableUTF(out,selector);
    57      }
    58
    59      static public String readNullableUTF(ObjectInput in) throws IOException, ClassNotFoundException {
    60          if( in.readBoolean() ) {
    61              return in.readUTF();
    62          } else {
    63              return null;
    64          }
    65      }
    66
    67      static public void writeNullableUTF(ObjectOutput out, String value) throws IOException {
    68          if( value==null ) {
    69              out.writeBoolean(false);
    70          } else {
    71              out.writeBoolean(true);
    72              out.writeUTF(value);
    73          }
    74      }
    75
    76      public String toString() {
    77          return super.toString() + "[clientID: " + clientID + " consumerName: " + consumerName
    78                  + " destination: " + destination + " selector: " + selector + "]";
    79      }
    80
    81      // Properties
    82      //-------------------------------------------------------------------------
    83      public String getClientID() {
    84          return clientID;
    85      }
    86
    87      public void setClientID(String clientID) {
    88          this.clientID = clientID;
    89      }
    90
    91      public String getConsumerName() {
    92          return consumerName;
    93      }
    94
    95      public void setConsumerName(String consumerName) {
    96          this.consumerName = consumerName;
    97      }
    98
    99      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 }