|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.events.observable.ModificationHandler org.apache.commons.events.observable.standard.StandardModificationHandler
public class StandardModificationHandler
The standard implementation of a ModificationHandler
that
sends standard JavaBean style events to listeners.
The information gathered by this implementation is all that is available
as parameters or return values.
In addition, the size
method is used on the collection.
All objects used are the real objects from the method calls, not clones.
Each listener can be filtered. There are separate filters for pre and post modification events.
Nested Class Summary | |
---|---|
protected static class |
StandardModificationHandler.PostHolder
|
protected static class |
StandardModificationHandler.PreHolder
|
Nested classes/interfaces inherited from class org.apache.commons.events.observable.ModificationHandler |
---|
ModificationHandler.SetViewHandler, ModificationHandler.SubListHandler |
Field Summary | |
---|---|
protected static StandardModificationHandler.PostHolder[] |
EMPTY_POST_HOLDERS
A reusable empty holders array. |
protected static StandardModificationHandler.PreHolder[] |
EMPTY_PRE_HOLDERS
A reusable empty holders array. |
static ModificationHandlerFactory |
FACTORY
The singleton factory |
protected StandardModificationHandler.PostHolder[] |
postHolder
The event listeners. |
protected int |
postMask
The event mask as to which event types to send on post events. |
protected StandardModificationHandler.PreHolder[] |
preHolder
The event listeners. |
protected int |
preMask
The event mask as to which event types to send on pre events. |
protected int |
preSize
Temporary store for the size. |
Constructor Summary | |
---|---|
StandardModificationHandler()
Constructor the creates the handler but leaves it invalid. |
|
StandardModificationHandler(StandardPreModificationListener pre,
int preMask,
StandardPostModificationListener post,
int postMask)
Constructor the creates the handler but leaves it invalid. |
Method Summary | |
---|---|
void |
addPostModificationListener(Object listener)
Adds a listener to the handler for post modification events. |
void |
addPostModificationListener(StandardPostModificationListener listener,
int mask)
Adds a post listener to the list held in the handler. |
void |
addPreModificationListener(Object listener)
Adds a listener to the handler for pre modification events. |
void |
addPreModificationListener(StandardPreModificationListener listener,
int mask)
Adds a pre listener to the list held in the handler. |
protected void |
calculatePostMask()
Calculate the combined masks. |
protected void |
calculatePreMask()
Calculate the combined masks. |
protected void |
firePostEvent(int type,
int index,
Object object,
int repeat,
Object previous,
ObservableCollection view,
int viewOffset)
Sends the post event to the listeners. |
protected boolean |
firePreEvent(int type,
int index,
Object object,
int repeat,
Object previous,
ObservableCollection view,
int viewOffset)
Sends the pre event to the listeners. |
Object[] |
getPostModificationListeners()
Gets an array of all the post listeners active in the handler. |
Object[] |
getPreModificationListeners()
Gets an array of all the pre listeners active in the handler. |
protected void |
postClear()
Send an event after clear() is called. |
protected void |
postEvent(boolean modified,
int type,
int index,
Object object,
int repeat,
Object previous,
ObservableCollection view,
int viewOffset)
Handles the post event. |
protected boolean |
preEvent(int type,
int index,
Object object,
int repeat,
Object previous,
ObservableCollection view,
int viewOffset)
Handles the pre event. |
void |
removePostModificationListener(Object listener)
Removes a post listener to the list held in the handler. |
void |
removePreModificationListener(Object listener)
Removes a pre listener to the list held in the handler. |
void |
setPostModificationListenerMask(StandardPostModificationListener listener,
int mask)
Sets the masks of a listener. |
void |
setPreModificationListenerMask(StandardPreModificationListener listener,
int mask)
Sets the masks of a listener. |
Methods inherited from class org.apache.commons.events.observable.ModificationHandler |
---|
createHeadSetHandler, createSubListHandler, createSubSetHandler, createTailSetHandler, getBaseCollection, getObservedCollection, getRootHandler, getViewOffset, postAdd, postAddAll, postAddAllIndexed, postAddIndexed, postAddIterated, postAddNCopies, postRemove, postRemoveAll, postRemoveIndexed, postRemoveIterated, postRemoveNCopies, postRemoveNext, postRetainAll, postSetIndexed, postSetIterated, preAdd, preAddAll, preAddAllIndexed, preAddIndexed, preAddIterated, preAddNCopies, preClear, preRemove, preRemoveAll, preRemoveIndexed, preRemoveIterated, preRemoveNCopies, preRemoveNext, preRetainAll, preSetIndexed, preSetIterated, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final ModificationHandlerFactory FACTORY
protected static final StandardModificationHandler.PreHolder[] EMPTY_PRE_HOLDERS
protected static final StandardModificationHandler.PostHolder[] EMPTY_POST_HOLDERS
protected int preMask
protected int postMask
protected StandardModificationHandler.PreHolder[] preHolder
protected StandardModificationHandler.PostHolder[] postHolder
protected int preSize
Constructor Detail |
---|
public StandardModificationHandler()
The handler can only be used after it has been properly initialized.
This is normally done automatically by
ObservableCollection.decorate(Collection, Object)
.
public StandardModificationHandler(StandardPreModificationListener pre, int preMask, StandardPostModificationListener post, int postMask)
The handler can only be used after it has been properly initialized.
This is normally done automatically by
ObservableCollection.decorate(Collection, Object)
.
pre
- the pre listenerpreMask
- the mask for the pre listenerpost
- the post listenerpostMask
- the mask for the post listenerMethod Detail |
---|
public Object[] getPreModificationListeners()
All listeners will be instances of StandardPreModificationListener.
getPreModificationListeners
in class ModificationHandler
public void addPreModificationListener(Object listener)
No error occurs if the listener is null
.
addPreModificationListener
in class ModificationHandler
listener
- the listener to add, may be null (ignored)
ClassCastException
- if the listener is not a StandardPreModificationListenerpublic void addPreModificationListener(StandardPreModificationListener listener, int mask)
No error occurs if the listener is null
.
listener
- the listener to add, may be null (ignored)mask
- the mask for events (0 for none, -1 for all)public void removePreModificationListener(Object listener)
No error occurs if the listener is not in the list or the type of the listener is incorrect. The listener is matched using ==.
removePreModificationListener
in class ModificationHandler
listener
- the listener to remove, may be null (ignored)public void setPreModificationListenerMask(StandardPreModificationListener listener, int mask)
No error occurs if the listener is not in the list. The listener is matched using ==.
listener
- the listener to change, may be nullmask
- the new mask (0 for none, -1 for all)protected void calculatePreMask()
public Object[] getPostModificationListeners()
All listeners will be instances of StandardModificationListener.
getPostModificationListeners
in class ModificationHandler
public void addPostModificationListener(Object listener)
No error occurs if the listener is null
.
addPostModificationListener
in class ModificationHandler
listener
- the listener to add, may be null (ignored)
ClassCastException
- if the listener is not a StandardPreModificationListenerpublic void addPostModificationListener(StandardPostModificationListener listener, int mask)
No error occurs if the listener is null
.
listener
- the listener to add, may be null (ignored)mask
- the mask for events (0 for none, -1 for all)public void removePostModificationListener(Object listener)
No error occurs if the listener is not in the list or the type of the listener is incorrect. The listener is matched using ==.
removePostModificationListener
in class ModificationHandler
listener
- the listener to remove, may be null (ignored)public void setPostModificationListenerMask(StandardPostModificationListener listener, int mask)
No error occurs if the listener is not in the list. The listener is matched using ==.
listener
- the listener to change, may be nullmask
- the new mask (0 for none, -1 for all)protected void calculatePostMask()
protected boolean preEvent(int type, int index, Object object, int repeat, Object previous, ObservableCollection view, int viewOffset)
preEvent
in class ModificationHandler
type
- the event type to sendindex
- the index where the change starts, the method param or derivedobject
- the object that will be added/removed/set, the method param or derivedrepeat
- the number of repeats of the add/remove, the method param or derivedprevious
- the previous value that will be removed/replaced, must exist in collview
- the view collection that the change was actioned on, null if no viewviewOffset
- the offset of the subList view, -1 if unknown
protected boolean firePreEvent(int type, int index, Object object, int repeat, Object previous, ObservableCollection view, int viewOffset)
type
- the event type to sendindex
- the index where the change starts, the method param or derivedobject
- the object that will be added/removed/set, the method param or derivedrepeat
- the number of repeats of the add/remove, the method param or derivedprevious
- the previous value that will be removed/replaced, must exist in collview
- the view collection that the change was actioned on, null if no viewviewOffset
- the offset of the subList view, -1 if unknown
protected void postEvent(boolean modified, int type, int index, Object object, int repeat, Object previous, ObservableCollection view, int viewOffset)
postEvent
in class ModificationHandler
modified
- true if the method succeeded in changing the collectiontype
- the event type to sendindex
- the index where the change starts, the method param or derivedobject
- the object that was added/removed/set, the method param or derivedrepeat
- the number of repeats of the add/remove, the method param or derivedprevious
- the previous value that was removed/replace, must have existed in collview
- the view collection that the change was actioned on, null if no viewviewOffset
- the offset of the subList view, -1 if unknownprotected void firePostEvent(int type, int index, Object object, int repeat, Object previous, ObservableCollection view, int viewOffset)
type
- the event type to sendindex
- the index where the change starts, the method param or derivedobject
- the object that was added/removed/set, the method param or derivedrepeat
- the number of repeats of the add/remove, the method param or derivedprevious
- the previous value that was removed/replace, must have existed in collview
- the view collection that the change was actioned on, null if no viewviewOffset
- the offset of the subList view, -1 if unknownprotected void postClear()
Override to only send event if something actually cleared.
postClear
in class ModificationHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |