JXTA

net.jxta.util
Interface SimpleSelectable

All Known Subinterfaces:
Messenger
All Known Implementing Classes:
AbstractMessenger, AbstractSimpleSelectable, AsyncChannelMessenger, ChannelMessenger, Message, SimpleSelector, ThreadedMessenger

public interface SimpleSelectable

This the interface that all selectable objects expose.

Applications programmers should treat this API as temporary, for now.

A SimpleSelectable object can register SimpleSelector objects so that they are notified whenever this object chooses to report a change.

SimpleSelectors are SimpleSelectable, therefore selectors can be selected.

The change notification interface used to notify a selector is actually specified in SimpleSelectable. As a result, certain implementations may also allow to register SimpleSelectables that are not Selectors. Selectors themselves do not allow that.

See Also:
SimpleSelector, AbstractSimpleSelectable

Nested Class Summary
static class SimpleSelectable.IdentityReference
          A simple reference object that can be put in a map instead of the one it refers to.
 
Method Summary
 SimpleSelectable.IdentityReference getIdentityReference()
           
 void itemChanged(SimpleSelectable changedObject)
          This method is invoked when the given selectable object has changed.
 void register(SimpleSelector s)
          Registers the given selector with this selectable object.
 void unregister(SimpleSelector s)
          Unregisters the given selector, so that it is no-longer notified when this object changes.
 

Method Detail

getIdentityReference

SimpleSelectable.IdentityReference getIdentityReference()
Returns:
A canonical IdentityReference for this object. A given SimpleSelectable always provides the same IdentityReference object. An IdentityReference must never overload hashCode() or equals() in a way that could make different objects be equal or that could provide different results from invocation to invocation.

register

void register(SimpleSelector s)
Registers the given selector with this selectable object. This always causes one change event for this object to be reported through the selector. As a result, when selecting for a condition, it is not necessary to verify whether it has already happened or not; the next call to select will be able to detect it.

Parameters:
s - The SimpleSelector to register

unregister

void unregister(SimpleSelector s)
Unregisters the given selector, so that it is no-longer notified when this object changes.

Parameters:
s - The SimpleSelector to unregister

itemChanged

void itemChanged(SimpleSelectable changedObject)
This method is invoked when the given selectable object has changed. This permits to cascade selectable objects, so that one reports a change when the other changes, without having to select it. This also permits implementation of this interface by delegating its implementation to a utility class.

An implementation may do what it wants about it. For example, a SimpleSelector will report the change to SimpleSelector.select() and invoke AbstractSimpleSelectable.notifyChange() thereby reporting its own change to cascaded selectors. Other implementations may only invoke AbstractSimpleSelectable.notifyChange() or may perform more complex tasks.

Parameters:
changedObject - the object that has changed.
See Also:
AbstractSimpleSelectable

JXSE