context.arch.subscriber
Class Subscribers

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.Vector
              extended bycontext.arch.subscriber.Subscribers
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable

public class Subscribers
extends java.util.Vector

This class maintains a list of subscribers, allows additions, removals and updates to individual subscribers. Agathe: I have changed Subscribers and Subscriber to allow the addition of the DiscovererSubscriber class. Subscriber and DiscovererSubscriber implement an interface handled by Subscribers. Agathe: modify restart subscription

Author:
Anind, Agathe
See Also:
Subscriber, Serialized Form

Field Summary
static boolean DEBUG
          Debug flag
static java.lang.String SUBSCRIBERS
          Tag used in messages
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Subscribers(MessageHandler mh, java.lang.String id)
          Basic constructor that takes an object that implements the MessageHandler interface and an id to create a logfile name from.
 
Method Summary
 void addSubscriber(AbstractSubscriber sub)
          Adds a subscriber to the subscriber list
 void addSubscriber(AbstractSubscriber sub, boolean log)
          Adds a subscriber to the subscriber list
 AbstractSubscriber getSubscriber(java.lang.String subscriptionId)
          Returns the subscriber with the given name.
 Subscriber getSubscriber(Subscriber subscriber)
          This method returns if possible the subscriber that corresponds to the arguments.
 AbstractSubscriber getSubscriberAt(int index)
          Returns the subscriber at the given index.
 java.util.Enumeration getSubscriberNames()
          Returns an enumeration containing all the subscriber names in the list
 java.util.Enumeration getSubscribers()
          Returns an enumeration containing all the subscribers in the list
static void main(java.lang.String[] arg)
           
 int numSubscribers()
          Returns the number of subscribers in the list
 boolean remove(AbstractSubscriber subToRemove)
          Remove an AbstractSubscriber
 boolean removeSubscriber(AbstractSubscriber sub)
          Removes a subscriber from the subscriber list
 boolean removeSubscriber(AbstractSubscriber sub, boolean log)
          Removes a subscriber from the subscriber list
 boolean removeSubscriber(java.lang.String subId)
          Removes a subscriber from the subscriber list
 boolean removeSubscriber(java.lang.String subId, boolean log)
          Removes a subscriber from the subscriber list
 void setBaseObjectId(java.lang.String id)
          Set the BaseObject id used to attribute the unique id for subscribers
 DataObject toDataObject()
          Converts to a DataObject.
 void updateSubscriber(AbstractSubscriber sub)
          Updates a subscriber in the subscriber list.
 void updateSubscriber(AbstractSubscriber sub, boolean log)
          Updates a subscriber in the subscriber list.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

DEBUG

public static boolean DEBUG
Debug flag


SUBSCRIBERS

public static final java.lang.String SUBSCRIBERS
Tag used in messages

See Also:
Constant Field Values
Constructor Detail

Subscribers

public Subscribers(MessageHandler mh,
                   java.lang.String id)
Basic constructor that takes an object that implements the MessageHandler interface and an id to create a logfile name from.

Method Detail

addSubscriber

public void addSubscriber(AbstractSubscriber sub)
Adds a subscriber to the subscriber list

Parameters:
sub - Subscriber object to add

addSubscriber

public void addSubscriber(AbstractSubscriber sub,
                          boolean log)
Adds a subscriber to the subscriber list

Parameters:
sub - Subscriber object to add
log - Whether to log the subscribe or not

removeSubscriber

public boolean removeSubscriber(AbstractSubscriber sub)
Removes a subscriber from the subscriber list

Parameters:
sub - Subscriber object to remove
Returns:
whether the removal was successful or not

removeSubscriber

public boolean removeSubscriber(AbstractSubscriber sub,
                                boolean log)
Removes a subscriber from the subscriber list

Parameters:
sub - Subscriber object to remove
log - Whether to log the subscribe or not
Returns:
whether the removal was successful or not

remove

public boolean remove(AbstractSubscriber subToRemove)
Remove an AbstractSubscriber

Parameters:
subToRemove -

removeSubscriber

public boolean removeSubscriber(java.lang.String subId)
Removes a subscriber from the subscriber list

Returns:
whether the removal was successful or not

removeSubscriber

public boolean removeSubscriber(java.lang.String subId,
                                boolean log)
Removes a subscriber from the subscriber list

Parameters:
log - Whether to log the subscribe or not
Returns:
whether the removal was successful or not

updateSubscriber

public void updateSubscriber(AbstractSubscriber sub)
Updates a subscriber in the subscriber list. The subscriber name is retrieved from the subscriber object and the old subscriber entry with this name is replaced by the given one.

Parameters:
sub - Subscriber object to update

updateSubscriber

public void updateSubscriber(AbstractSubscriber sub,
                             boolean log)
Updates a subscriber in the subscriber list. The subscriber name is retrieved from the subscriber object and the old subscriber entry with this name is replaced by the given one.

Parameters:
sub - Subscriber object to update
log - Whether to log the subscribe or not

getSubscriberAt

public AbstractSubscriber getSubscriberAt(int index)
Returns the subscriber at the given index. Do not assume that a given subscriber's index will stay constant throughout its lifetime. When other subscribers are added and removed, a given subscriber's index may change.

Parameters:
index - index value of the Subscriber object to retrieve

getSubscriber

public AbstractSubscriber getSubscriber(java.lang.String subscriptionId)
Returns the subscriber with the given name.

Parameters:
subscriptionId - ID of the Subscriber object to retrieve

getSubscriber

public Subscriber getSubscriber(Subscriber subscriber)
This method returns if possible the subscriber that corresponds to the arguments.

Returns:
Subscriber

getSubscribers

public java.util.Enumeration getSubscribers()
Returns an enumeration containing all the subscribers in the list


getSubscriberNames

public java.util.Enumeration getSubscriberNames()
Returns an enumeration containing all the subscriber names in the list


numSubscribers

public int numSubscribers()
Returns the number of subscribers in the list


toDataObject

public DataObject toDataObject()
Converts to a DataObject.

Returns:

setBaseObjectId

public void setBaseObjectId(java.lang.String id)
Set the BaseObject id used to attribute the unique id for subscribers

Parameters:
id -

main

public static void main(java.lang.String[] arg)