EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql.model.query
Class ChangeSupport

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.model.query.ChangeSupport

public class ChangeSupport
extends java.lang.Object

This ChangeSupport is responsible to notifies registered listeners upon changes made to a StateObject, those changes are either a property has changed (IPropertyChangeListener) or the content of a list has changed (IListChangeListener).

Version:
2.4
Author:
Pascal Filion
Since:
2.4

Constructor Summary
ChangeSupport(StateObject source)
          Creates a new ChangeSupport.
 
Method Summary
<T> void
addItem(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, T item)
          Adds the given item as a child to the given list.
<T> void
addItems(ListHolderStateObject<T> source, java.util.List<T> list, java.lang.String listName, java.util.List<? extends T> items)
          Adds the given items as children to the given list.
 void addListChangeListener(java.lang.String listName, IListChangeListener<?> listener)
          Registers the given IListChangeListener for the specified list.
protected
<T> void
addListener(java.util.Map<java.lang.String,java.util.List<T>> listeners, java.lang.Class<?> listenerType, java.lang.String name, T listener)
          Registers the given list for the specified name.
 void addPropertyChangeListener(java.lang.String propertyName, IPropertyChangeListener<?> listener)
          Registers the given IPropertyChangeListener for the specified property.
<T> boolean
canMoveDown(java.util.List<T> list, T stateObject)
          Determines whether the given item can be moved down by one position in the list owned by its parent.
<T> boolean
canMoveUp(java.util.List<T> list, T item)
          Determines whether the given item can be moved up by one position in the list owned by its parent.
protected
<T> void
fireListChangeEvent(IListChangeEvent<T> event)
           
 void firePropertyChanged(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Notifies the IPropertyChangeListeners that have been registered with the given property name that the property has changed.
 boolean hasListChangeListeners(java.lang.String listName)
          Determines whether there are at least one IListChangeListener registered to listen for changes made to the list with the given list name.
protected  boolean hasListeners(java.util.Map<java.lang.String,?> listeners, java.lang.String name)
          Determines whether there are at least one listener registered.
 boolean hasPropertyChangeListeners(java.lang.String propertyName)
          Determines whether there are at least one IPropertyChangeListener registered to listen for changes made to the property with the given property name.
protected  void initialize(StateObject source)
          Initializes this ChangeSupport.
protected
<T> IterableListIterator<IListChangeListener<T>>
listChangeListeners(java.lang.String listName)
           
<T> void
moveDown(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, T item)
          Moves the given StateObject down by one position in the list owned by its parent.
protected
<T> void
moveItem(ListHolderStateObject<T> source, java.util.List<T> items, IListChangeEvent.EventType eventType, java.lang.String listName, T item, int oldIndex, int newIndex)
          Moves the given item from its current position to a new position in the list owned by its parent.
<T> void
moveUp(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, T item)
          Moves the given item up by one position in the list owned by its parent.
protected  IterableListIterator<IPropertyChangeListener<?>> propertyChangeListeners(java.lang.String propertyName)
           
<T> void
removeItem(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, T item)
          Removes the given item from the list of children.
<T> void
removeItems(ListHolderStateObject<T> source, java.util.List<? extends T> list, java.lang.String listName, java.util.Collection<? extends T> items)
          Removes the given items from the list of children.
 void removeListChangeListener(java.lang.String listName, IListChangeListener<?> listener)
          Unregisters the given IListChangeListener that was registered for the specified list.
protected
<T> void
removeListener(java.util.Map<java.lang.String,java.util.List<T>> listeners, java.lang.Class<?> listenerType, java.lang.String name, T listener)
          Unregisters the given listener that was registered for the specified name.
 void removePropertyChangeListener(java.lang.String propertyName, IPropertyChangeListener<?> listener)
          Unregisters the given IPropertyChangeListener that was registered for the specified property.
<T> void
replaceItem(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, int index, T item)
          Replaces the item at the given position by a new one.
<T> void
replaceItems(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, java.util.List<T> newItems)
          Replaces the given list by removing any existing items and adding the items contained in the second list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangeSupport

public ChangeSupport(StateObject source)
Creates a new ChangeSupport.

Parameters:
source - The object for which this object will take care of notifying the listeners upon changes made to the object's internal state
Throws:
java.lang.NullPointerException - The source StateObject cannot be null
Method Detail

addItem

public <T> void addItem(ListHolderStateObject<T> source,
                        java.util.List<T> items,
                        java.lang.String listName,
                        T item)
Adds the given item as a child to the given list.

Type Parameters:
T - The type of the items
Parameters:
source - The ListHolderStateObject from where the change is coming
items - The list of to which the child is added
listName - The name associated with the list
item - The child to become a child of this one

addItems

public <T> void addItems(ListHolderStateObject<T> source,
                         java.util.List<T> list,
                         java.lang.String listName,
                         java.util.List<? extends T> items)
Adds the given items as children to the given list.

Type Parameters:
T - The type of the items
Parameters:
source - The ListHolderStateObject from where the change is coming
list - The list of items to which the child is added
listName - The name associated with the list
items - The child to become children of this one

addListChangeListener

public void addListChangeListener(java.lang.String listName,
                                  IListChangeListener<?> listener)
Registers the given IListChangeListener for the specified list. The listener will be notified only when items are added, removed, moved from the list.

Parameters:
listName - The name of the list for which the listener will be notified when the content of the list has changed
listener - The listener to be notified upon changes
Throws:
java.lang.NullPointerException - IListChangeListener cannot be null
java.lang.IllegalArgumentException - The listener is already registered with the list name

addListener

protected <T> void addListener(java.util.Map<java.lang.String,java.util.List<T>> listeners,
                               java.lang.Class<?> listenerType,
                               java.lang.String name,
                               T listener)
Registers the given list for the specified name. The listener will be notified upon changes.

Parameters:
listeners - The list of listeners from which the given listener is added
listenerType - The type of the listener, which is only used in the exception's message
name - The name of the event for which the listener is registered
listener - The listener to register
Throws:
java.lang.NullPointerException - IPropertyChangeListener cannot be null
java.lang.IllegalArgumentException - The listener is already registered with the given name

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      IPropertyChangeListener<?> listener)
Registers the given IPropertyChangeListener for the specified property. The listener will be notified only for changes to the specified property.

Parameters:
propertyName - The name of the property for which the listener was registered
listener - The listener to be notified upon changes
Throws:
java.lang.NullPointerException - IPropertyChangeListener cannot be null
java.lang.IllegalArgumentException - The listener is already registered with the property name

canMoveDown

public <T> boolean canMoveDown(java.util.List<T> list,
                               T stateObject)
Determines whether the given item can be moved down by one position in the list owned by its parent.

Parameters:
list - The list used to determine if the given item can be moved down in that list
stateObject - The item that could potentially be moved down
Returns:
true if the object can be moved down by one unit; false otherwise

canMoveUp

public <T> boolean canMoveUp(java.util.List<T> list,
                             T item)
Determines whether the given item can be moved up by one position in the list owned by its parent.

Parameters:
list - The list used to determine if the given item can be moved up in that list
item - The item that could potentially be moved up
Returns:
true if the object can be moved up by one unit; false otherwise

fireListChangeEvent

protected <T> void fireListChangeEvent(IListChangeEvent<T> event)

firePropertyChanged

public void firePropertyChanged(java.lang.String propertyName,
                                java.lang.Object oldValue,
                                java.lang.Object newValue)
Notifies the IPropertyChangeListeners that have been registered with the given property name that the property has changed.

Parameters:
propertyName - The name of the property associated with the property change
oldValue - The old value of the property that changed
newValue - The new value of the property that changed

hasListChangeListeners

public boolean hasListChangeListeners(java.lang.String listName)
Determines whether there are at least one IListChangeListener registered to listen for changes made to the list with the given list name.

Parameters:
listName - The name of the list to check if it has registered listeners
Returns:
true if listeners have been registered for the given list name; false otherwise

hasListeners

protected boolean hasListeners(java.util.Map<java.lang.String,?> listeners,
                               java.lang.String name)
Determines whether there are at least one listener registered.

Parameters:
name - The name of the property or list to check if it has registered listeners
Returns:
true if listeners have been registered for the given name; false otherwise

hasPropertyChangeListeners

public boolean hasPropertyChangeListeners(java.lang.String propertyName)
Determines whether there are at least one IPropertyChangeListener registered to listen for changes made to the property with the given property name.

Parameters:
propertyName - The name of the property to check if it has registered listeners
Returns:
true if listeners have been registered for the given property name; false otherwise

initialize

protected void initialize(StateObject source)
Initializes this ChangeSupport.

Parameters:
source - The object for which this object will take care of notifying the listeners upon changes made to the object's internal state
Throws:
java.lang.NullPointerException - The source StateObject cannot be null

listChangeListeners

protected <T> IterableListIterator<IListChangeListener<T>> listChangeListeners(java.lang.String listName)

moveDown

public <T> void moveDown(ListHolderStateObject<T> source,
                         java.util.List<T> items,
                         java.lang.String listName,
                         T item)
Moves the given StateObject down by one position in the list owned by its parent.

Type Parameters:
T - The type of the items
Parameters:
source - The ListHolderStateObject from where the change is coming
items - The list of items to which the child is moved down
listName - The name associated with the list
item - The child to move down within the list

moveItem

protected <T> void moveItem(ListHolderStateObject<T> source,
                            java.util.List<T> items,
                            IListChangeEvent.EventType eventType,
                            java.lang.String listName,
                            T item,
                            int oldIndex,
                            int newIndex)
Moves the given item from its current position to a new position in the list owned by its parent.

Type Parameters:
T - The type of the items
Parameters:
source - The ListHolderStateObject from where the change is coming
items - The list of items to which the child is moved
eventType - The type describing how the item was moved (up or down)
listName - The name associated with the list
item - The child to move within the list
oldIndex - The current position of the item to move
newIndex - The new position within the list

moveUp

public <T> void moveUp(ListHolderStateObject<T> source,
                       java.util.List<T> items,
                       java.lang.String listName,
                       T item)
Moves the given item up by one position in the list owned by its parent.

Type Parameters:
T - The type of the items
Parameters:
source - The ListHolderStateObject from where the change is coming
items - The list of items to which the child is moved up
listName - The name associated with the list
item - The child to move up within the list

propertyChangeListeners

protected IterableListIterator<IPropertyChangeListener<?>> propertyChangeListeners(java.lang.String propertyName)

removeItem

public <T> void removeItem(ListHolderStateObject<T> source,
                           java.util.List<T> items,
                           java.lang.String listName,
                           T item)
Removes the given item from the list of children.

Type Parameters:
T - The type of the items
Parameters:
source - The ListHolderStateObject from where the change is coming
items - The list of item to which the child is removed
listName - The name associated with the list
item - The child to removed from the list

removeItems

public <T> void removeItems(ListHolderStateObject<T> source,
                            java.util.List<? extends T> list,
                            java.lang.String listName,
                            java.util.Collection<? extends T> items)
Removes the given items from the list of children.

Type Parameters:
T - The type of the items
Parameters:
source - The ListHolderStateObject from where the change is coming
list - The list of items to which the child is removed
listName - The name associated with the list
items - The items to removed from the list

removeListChangeListener

public void removeListChangeListener(java.lang.String listName,
                                     IListChangeListener<?> listener)
Unregisters the given IListChangeListener that was registered for the specified list. The listener will no longer be notified only when items are added, removed, moved from the list.

Parameters:
listName - The name of the list for which the listener was registered
listener - The listener to unregister
Throws:
java.lang.NullPointerException - IListChangeListener cannot be null
java.lang.IllegalArgumentException - The listener was never registered with the list name

removeListener

protected <T> void removeListener(java.util.Map<java.lang.String,java.util.List<T>> listeners,
                                  java.lang.Class<?> listenerType,
                                  java.lang.String name,
                                  T listener)
Unregisters the given listener that was registered for the specified name. The listener will no longer be notified upon changes.

Parameters:
listeners - The list of listeners from which the given listener is removed
listenerType - The type of the listener, which is only used in the exception's message
name - The name of the event for which the listener was registered
listener - The listener to unregister
Throws:
java.lang.NullPointerException - IPropertyChangeListener cannot be null
java.lang.IllegalArgumentException - The listener was never registered with the given name

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         IPropertyChangeListener<?> listener)
Unregisters the given IPropertyChangeListener that was registered for the specified property. The listener will no longer be notified when the property changes.

Parameters:
propertyName - The name of the property for which the listener was registered
listener - The listener to unregister
Throws:
java.lang.NullPointerException - IPropertyChangeListener cannot be null
java.lang.IllegalArgumentException - The listener was never registered with the property name

replaceItem

public <T> void replaceItem(ListHolderStateObject<T> source,
                            java.util.List<T> items,
                            java.lang.String listName,
                            int index,
                            T item)
Replaces the item at the given position by a new one.

Type Parameters:
T - The type of the items
Parameters:
source - The ListHolderStateObject from where the change is coming
items - The list of items to which a child is replaced
listName - The name associated with the list
index - The position of the item to replace
item - The item to replace the one at the given position

replaceItems

public <T> void replaceItems(ListHolderStateObject<T> source,
                             java.util.List<T> items,
                             java.lang.String listName,
                             java.util.List<T> newItems)
Replaces the given list by removing any existing items and adding the items contained in the second list.

Type Parameters:
T - The type of the items
Parameters:
source - The ListHolderStateObject from where the change is coming
items - The list of items to which the child is removed
listName - The name associated with the list
newItems - The items to removed from the list

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference