Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.model.query

public Class ChangeSupport

extends Object
Class Inheritance
Annotations
@SuppressWarnings:nls
Imports
java.util.ArrayList, .Collection, .Collections, .HashMap, .List, .Map, org.eclipse.persistence.jpa.jpql.Assert, .ExpressionTools, org.eclipse.persistence.jpa.jpql.tools.model.IListChangeEvent, .IListChangeEvent.EventType, .IListChangeListener, .IPropertyChangeListener, .ListChangeEvent, .PropertyChangeEvent, org.eclipse.persistence.jpa.jpql.utility.iterable.ListIterable, .SnapshotCloneListIterable

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).
Author
Pascal Filion
Since
2.4
Version
2.4

Field Summary

Modifier and TypeField and Description
private Map<String, List<IListChangeListener<?>>>
listChangeListeners

The list of registered listeners.

private Map<String, List<IPropertyChangeListener<?>>>
propertyChangeListeners

The list of registered listeners.

private StateObject
source

The object for which this object will take care of notifying the listeners upon changes made to the object's internal state.

Constructor Summary

AccessConstructor and Description
public
ChangeSupport(StateObject
The object for which this object will take care of notifying the listeners upon changes made to the object's internal state
source
)

Creates a new ChangeSupport.

Method Summary

Modifier and TypeMethod and Description
public <
The type of the items
T
>
void
addItem(ListHolderStateObject<T>
The ListHolderStateObject from where the change is coming
source
,
List<T>
The list of to which the child is added
items
,
String
The name associated with the list
listName
,
T
The child to become a child of this one
item
)

Adds the given item as a child to the given list.

public <
The type of the items
T
>
void
addItems(ListHolderStateObject<T>
The ListHolderStateObject from where the change is coming
source
,
List<T>
The list of items to which the child is added
list
,
String
The name associated with the list
listName
,
List<? extends T>
The child to become children of this one
items
)

Adds the given items as children to the given list.

public void
addListChangeListener(String
The name of the list for which the listener will be notified when the content of the list has changed
listName
,
IListChangeListener<?>
The listener to be notified upon changes
listener
)

Registers the given IListChangeListener for the specified list.

protected <T> void
addListener(Map<String, List<T>>
The list of listeners from which the given listener is added
listeners
,
Class<?>
The type of the listener, which is only used in the exception's message
listenerType
,
String
The name of the event for which the listener is registered
name
,
T
The listener to register
listener
)

Registers the given list for the specified name.

public void
addPropertyChangeListener(String
The name of the property for which the listener was registered
propertyName
,
IPropertyChangeListener<?>
The listener to be notified upon changes
listener
)

Registers the given IPropertyChangeListener for the specified property.

public <T> boolean

Returns:

true if the object can be moved down by one unit; false otherwise
canMoveDown
(List<T>
The list used to determine if the given item can be moved down in that list
list
,
T
The item that could potentially be moved down
stateObject
)

Determines whether the given item can be moved down by one position in the list owned by its parent.

public <T> boolean

Returns:

true if the object can be moved up by one unit; false otherwise
canMoveUp
(List<T>
The list used to determine if the given item can be moved up in that list
list
,
T
The item that could potentially be moved up
item
)

Determines whether the given item can be moved up by one position in the list owned by its parent.

protected <T> void
public void
firePropertyChanged(String
The name of the property associated with the property change
propertyName
,
Object
The old value of the property that changed
oldValue
,
Object
The new value of the property that changed
newValue
)

Notifies the IPropertyChangeListeners that have been registered with the given property name that the property has changed.

public boolean

Returns:

true if listeners have been registered for the given list name; false otherwise
hasListChangeListeners
(String
The name of the list to check if it has registered listeners
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

Returns:

true if listeners have been registered for the given name; false otherwise
hasListeners
(Map<String, ?> listeners, String
The name of the property or list to check if it has registered listeners
name
)

Determines whether there are at least one listener registered.

public boolean

Returns:

true if listeners have been registered for the given property name; false otherwise
hasPropertyChangeListeners
(String
The name of the property to check if it has registered listeners
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
The object for which this object will take care of notifying the listeners upon changes made to the object's internal state
source
)

Initializes this ChangeSupport.

protected <T> ListIterable<IListChangeListener<T>>
public <
The type of the items
T
>
void
moveDown(ListHolderStateObject<T>
The ListHolderStateObject from where the change is coming
source
,
List<T>
The list of items to which the child is moved down
items
,
String
The name associated with the list
listName
,
T
The child to move down within the list
item
)

Moves the given StateObject down by one position in the list owned by its parent.

protected <
The type of the items
T
>
void
moveItem(ListHolderStateObject<T>
The ListHolderStateObject from where the change is coming
source
,
List<T>
The list of items to which the child is moved
items
,
IListChangeEvent.EventType
The type describing how the item was moved (up or down)
eventType
,
String
The name associated with the list
listName
,
T
The child to move within the list
item
,
int
The current position of the item to move
oldIndex
,
int
The new position within the list
newIndex
)

Moves the given item from its current position to a new position in the list owned by its parent.

public <
The type of the items
T
>
void
moveUp(ListHolderStateObject<T>
The ListHolderStateObject from where the change is coming
source
,
List<T>
The list of items to which the child is moved up
items
,
String
The name associated with the list
listName
,
T
The child to move up within the list
item
)

Moves the given item up by one position in the list owned by its parent.

protected ListIterable<IPropertyChangeListener<?>>
public <
The type of the items
T
>
void
removeItem(ListHolderStateObject<T>
The ListHolderStateObject from where the change is coming
source
,
List<T>
The list of item to which the child is removed
items
,
String
The name associated with the list
listName
,
T
The child to removed from the list
item
)

Removes the given item from the list of children.

public <
The type of the items
T
>
void
removeItems(ListHolderStateObject<T>
The ListHolderStateObject from where the change is coming
source
,
List<? extends T>
The list of items to which the child is removed
list
,
String
The name associated with the list
listName
,
Collection<? extends T>
The items to removed from the list
items
)

Removes the given items from the list of children.

public void
removeListChangeListener(String
The name of the list for which the listener was registered
listName
,
IListChangeListener<?>
The listener to unregister
listener
)

Unregisters the given IListChangeListener that was registered for the specified list.

protected <T> void
removeListener(Map<String, List<T>>
The list of listeners from which the given listener is removed
listeners
,
Class<?>
The type of the listener, which is only used in the exception's message
listenerType
,
String
The name of the event for which the listener was registered
name
,
T
The listener to unregister
listener
)

Unregisters the given listener that was registered for the specified name.

public void
removePropertyChangeListener(String
The name of the property for which the listener was registered
propertyName
,
IPropertyChangeListener<?>
The listener to unregister
listener
)

Unregisters the given IPropertyChangeListener that was registered for the specified property.

public <
The type of the items
T
>
void
replaceItem(ListHolderStateObject<T>
The ListHolderStateObject from where the change is coming
source
,
List<T>
The list of items to which a child is replaced
items
,
String
The name associated with the list
listName
,
int
The position of the item to replace
index
,
T
The item to replace the one at the given position
item
)

Replaces the item at the given position by a new one.

public <
The type of the items
T
>
void
replaceItems(ListHolderStateObject<T>
The ListHolderStateObject from where the change is coming
source
,
List<T>
The list of items to which the child is removed
items
,
String
The name associated with the list
listName
,
List<T>
The items to removed from the list
newItems
)

Replaces the given list by removing any existing items and adding the items contained in the second list.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

listChangeListenersback to summary
private Map<String, List<IListChangeListener<?>>> listChangeListeners

The list of registered listeners.

propertyChangeListenersback to summary
private Map<String, List<IPropertyChangeListener<?>>> propertyChangeListeners

The list of registered listeners.

sourceback to summary
private StateObject source

The object for which this object will take care of notifying the listeners upon changes made to the object's internal state.

Constructor Detail

ChangeSupportback to summary
public ChangeSupport(StateObject source)

Creates a new ChangeSupport.

Parameters
source:StateObject

The object for which this object will take care of notifying the listeners upon changes made to the object's internal state

Exceptions
NullPointerException:
The source StateObject cannot be null

Method Detail

addItemback to summary
public <T> void addItem(ListHolderStateObject<T> source, List<T> items, String listName, T item)

Adds the given item as a child to the given list.

Parameters
<T>
The type of the items
source:ListHolderStateObject<T>

The ListHolderStateObject from where the change is coming

items:List<T>

The list of to which the child is added

listName:String

The name associated with the list

item:T

The child to become a child of this one

addItemsback to summary
public <T> void addItems(ListHolderStateObject<T> source, List<T> list, String listName, List<? extends T> items)

Adds the given items as children to the given list.

Parameters
<T>
The type of the items
source:ListHolderStateObject<T>

The ListHolderStateObject from where the change is coming

list:List<T>

The list of items to which the child is added

listName:String

The name associated with the list

items:List<? extends T>

The child to become children of this one

addListChangeListenerback to summary
public void addListChangeListener(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:String

The name of the list for which the listener will be notified when the content of the list has changed

listener:IListChangeListener<?>

The listener to be notified upon changes

Exceptions
NullPointerException:
IListChangeListener cannot be null
IllegalArgumentException:
The listener is already registered with the list name
addListenerback to summary
protected <T> void addListener(Map<String, List<T>> listeners, Class<?> listenerType, String name, T listener)

Registers the given list for the specified name. The listener will be notified upon changes.

Parameters
listeners:Map<String, List<T>>

The list of listeners from which the given listener is added

listenerType:Class<?>

The type of the listener, which is only used in the exception's message

name:String

The name of the event for which the listener is registered

listener:T

The listener to register

Exceptions
NullPointerException:
IPropertyChangeListener cannot be null
IllegalArgumentException:
The listener is already registered with the given name
addPropertyChangeListenerback to summary
public void addPropertyChangeListener(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:String

The name of the property for which the listener was registered

listener:IPropertyChangeListener<?>

The listener to be notified upon changes

Exceptions
NullPointerException:
IPropertyChangeListener cannot be null
IllegalArgumentException:
The listener is already registered with the property name
canMoveDownback to summary
public <T> boolean canMoveDown(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:List<T>

The list used to determine if the given item can be moved down in that list

stateObject:T

The item that could potentially be moved down

Returns:boolean

true if the object can be moved down by one unit; false otherwise

canMoveUpback to summary
public <T> boolean canMoveUp(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:List<T>

The list used to determine if the given item can be moved up in that list

item:T

The item that could potentially be moved up

Returns:boolean

true if the object can be moved up by one unit; false otherwise

fireListChangeEventback to summary
protected <T> void fireListChangeEvent(IListChangeEvent<T> event)
firePropertyChangedback to summary
public void firePropertyChanged(String propertyName, Object oldValue, Object newValue)

Notifies the IPropertyChangeListeners that have been registered with the given property name that the property has changed.

Parameters
propertyName:String

The name of the property associated with the property change

oldValue:Object

The old value of the property that changed

newValue:Object

The new value of the property that changed

Annotations
@SuppressWarnings:unchecked
hasListChangeListenersback to summary
public boolean hasListChangeListeners(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:String

The name of the list to check if it has registered listeners

Returns:boolean

true if listeners have been registered for the given list name; false otherwise

hasListenersback to summary
protected boolean hasListeners(Map<String, ?> listeners, String name)

Determines whether there are at least one listener registered.

Parameters
name:String

The name of the property or list to check if it has registered listeners

Returns:boolean

true if listeners have been registered for the given name; false otherwise

hasPropertyChangeListenersback to summary
public boolean hasPropertyChangeListeners(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:String

The name of the property to check if it has registered listeners

Returns:boolean

true if listeners have been registered for the given property name; false otherwise

initializeback to summary
protected void initialize(StateObject source)

Initializes this ChangeSupport.

Parameters
source:StateObject

The object for which this object will take care of notifying the listeners upon changes made to the object's internal state

Exceptions
NullPointerException:
The source StateObject cannot be null
listChangeListenersback to summary
protected <T> ListIterable<IListChangeListener<T>> listChangeListeners(String listName)
Annotations
@SuppressWarnings:unchecked, rawtypes
moveDownback to summary
public <T> void moveDown(ListHolderStateObject<T> source, List<T> items, String listName, T item)

Moves the given StateObject down by one position in the list owned by its parent.

Parameters
<T>
The type of the items
source:ListHolderStateObject<T>

The ListHolderStateObject from where the change is coming

items:List<T>

The list of items to which the child is moved down

listName:String

The name associated with the list

item:T

The child to move down within the list

moveItemback to summary
protected <T> void moveItem(ListHolderStateObject<T> source, List<T> items, IListChangeEvent.EventType eventType, 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.

Parameters
<T>
The type of the items
source:ListHolderStateObject<T>

The ListHolderStateObject from where the change is coming

items:List<T>

The list of items to which the child is moved

eventType:IListChangeEvent.EventType

The type describing how the item was moved (up or down)

listName:String

The name associated with the list

item:T

The child to move within the list

oldIndex:int

The current position of the item to move

newIndex:int

The new position within the list

moveUpback to summary
public <T> void moveUp(ListHolderStateObject<T> source, List<T> items, String listName, T item)

Moves the given item up by one position in the list owned by its parent.

Parameters
<T>
The type of the items
source:ListHolderStateObject<T>

The ListHolderStateObject from where the change is coming

items:List<T>

The list of items to which the child is moved up

listName:String

The name associated with the list

item:T

The child to move up within the list

propertyChangeListenersback to summary
protected ListIterable<IPropertyChangeListener<?>> propertyChangeListeners(String propertyName)
removeItemback to summary
public <T> void removeItem(ListHolderStateObject<T> source, List<T> items, String listName, T item)

Removes the given item from the list of children.

Parameters
<T>
The type of the items
source:ListHolderStateObject<T>

The ListHolderStateObject from where the change is coming

items:List<T>

The list of item to which the child is removed

listName:String

The name associated with the list

item:T

The child to removed from the list

removeItemsback to summary
public <T> void removeItems(ListHolderStateObject<T> source, List<? extends T> list, String listName, Collection<? extends T> items)

Removes the given items from the list of children.

Parameters
<T>
The type of the items
source:ListHolderStateObject<T>

The ListHolderStateObject from where the change is coming

list:List<? extends T>

The list of items to which the child is removed

listName:String

The name associated with the list

items:Collection<? extends T>

The items to removed from the list

removeListChangeListenerback to summary
public void removeListChangeListener(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:String

The name of the list for which the listener was registered

listener:IListChangeListener<?>

The listener to unregister

Exceptions
NullPointerException:
IListChangeListener cannot be null
IllegalArgumentException:
The listener was never registered with the list name
removeListenerback to summary
protected <T> void removeListener(Map<String, List<T>> listeners, Class<?> listenerType, 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:Map<String, List<T>>

The list of listeners from which the given listener is removed

listenerType:Class<?>

The type of the listener, which is only used in the exception's message

name:String

The name of the event for which the listener was registered

listener:T

The listener to unregister

Exceptions
NullPointerException:
IPropertyChangeListener cannot be null
IllegalArgumentException:
The listener was never registered with the given name
removePropertyChangeListenerback to summary
public void removePropertyChangeListener(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:String

The name of the property for which the listener was registered

listener:IPropertyChangeListener<?>

The listener to unregister

Exceptions
NullPointerException:
IPropertyChangeListener cannot be null
IllegalArgumentException:
The listener was never registered with the property name
replaceItemback to summary
public <T> void replaceItem(ListHolderStateObject<T> source, List<T> items, String listName, int index, T item)

Replaces the item at the given position by a new one.

Parameters
<T>
The type of the items
source:ListHolderStateObject<T>

The ListHolderStateObject from where the change is coming

items:List<T>

The list of items to which a child is replaced

listName:String

The name associated with the list

index:int

The position of the item to replace

item:T

The item to replace the one at the given position

replaceItemsback to summary
public <T> void replaceItems(ListHolderStateObject<T> source, List<T> items, String listName, List<T> newItems)

Replaces the given list by removing any existing items and adding the items contained in the second list.

Parameters
<T>
The type of the items
source:ListHolderStateObject<T>

The ListHolderStateObject from where the change is coming

items:List<T>

The list of items to which the child is removed

listName:String

The name associated with the list

newItems:List<T>

The items to removed from the list