org.avis.client
Class Subscription

java.lang.Object
  extended by org.avis.client.Subscription

public final class Subscription
extends Object

A subscription to notifications from an Elvin connection.

Author:
Matthew Phillips
See Also:
Elvin.subscribe(String, Keys, SecureMode), addListener(NotificationListener)

Method Summary
 boolean acceptInsecure()
          True if ALLOW_INSECURE_DELIVERY is enabled.
 void addListener(NotificationListener listener)
          Add a listener for notifications matched by this subscription.
 Elvin elvin()
          The elvin connection that created this subscription.
static String escapeField(String field)
          Escape illegal characters in a field name for use in a subscription expression.
static String escapeString(String string)
          Escape illegal characters in a string value for use in a subscription expression.
 boolean hasListeners()
          True if any listeners are in the listener list.
 boolean isActive()
          Test if this subscription is still able to receive notifications.
 Keys keys()
          The keys used to receive secure notifications.
 void remove()
          Remove this subscription (unsubscribe).
 void removeListener(NotificationListener listener)
          Remove a previously added listener.
 SecureMode secureMode()
          The secure mode specified for receipt of notifications.
 void setKeys(Keys newKeys)
          Change the keys used for receiving secure notifications.
 void setSecureMode(SecureMode newMode)
          Change the subscription's secure delivery requirement.
 void setSubscriptionExpr(String newSubscriptionExpr)
          Change the subscription expression.
 String subscriptionExpr()
          The subscription expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

remove

public void remove()
            throws IOException
Remove this subscription (unsubscribe). May be called more than once. Unlike the other methods on this class, this may be called on a subscription for a connection that has been closed without generating an error, since such a subscription is effectively removed anyway.

Throws:
IOException - if a network error occurs.

elvin

public Elvin elvin()
The elvin connection that created this subscription.


isActive

public boolean isActive()
Test if this subscription is still able to receive notifications. A subscription is inactive after a remove() or when its underlying connection is closed.


subscriptionExpr

public String subscriptionExpr()
The subscription expression.


setSubscriptionExpr

public void setSubscriptionExpr(String newSubscriptionExpr)
                         throws IOException,
                                InvalidSubscriptionException
Change the subscription expression.

Throws:
IOException - if the subscription is invalid or if a network error occurs.
InvalidSubscriptionException - if the subscription expression is invalid.

secureMode

public SecureMode secureMode()
The secure mode specified for receipt of notifications.


setSecureMode

public void setSecureMode(SecureMode newMode)
                   throws IOException
Change the subscription's secure delivery requirement.

Parameters:
newMode - The secure delivery mode.
Throws:
IOException - if an IO error occurs during the operation.

acceptInsecure

public boolean acceptInsecure()
True if ALLOW_INSECURE_DELIVERY is enabled.

See Also:
secureMode()

keys

public Keys keys()
The keys used to receive secure notifications.


setKeys

public void setKeys(Keys newKeys)
             throws IOException
Change the keys used for receiving secure notifications.

Throws:
IOException

addListener

public void addListener(NotificationListener listener)
Add a listener for notifications matched by this subscription.

See Also:
Elvin.addNotificationListener(GeneralNotificationListener)

removeListener

public void removeListener(NotificationListener listener)
Remove a previously added listener.


hasListeners

public boolean hasListeners()
True if any listeners are in the listener list.

See Also:
addListener(NotificationListener)

escapeField

public static String escapeField(String field)
Escape illegal characters in a field name for use in a subscription expression. This can be useful when constructing subscription expressions dynamically.

Parameters:
field - The string to use as a field name.
Returns:
The escaped version of field, guaranteed to be a valid field name.
See Also:
escapeString(String)

escapeString

public static String escapeString(String string)
Escape illegal characters in a string value for use in a subscription expression. This can be useful when constructing subscription expressions dynamically.

Parameters:
string - A string that will occur within single or double quotes in a subscription expression.
Returns:
The escaped version of string, guaranteed to be a valid to occur inside a string expression.
See Also:
escapeField(String)


Copyright © 2008 Matthew Phillips. All Rights Reserved.