Top Description Fields Constructors Methods
org.hibernate.event.def

pack-priv Class EventCache

extends Object
implements Map
Class Inheritance
All Implemented Interfaces
java.util.Map
Imports
java.util.Map, .Set, .Iterator, .Collection, org.hibernate.util.IdentityMap, org.hibernate.AssertionFailure

EventCache is a Map implementation that can be used by an event listener to keep track of entities involved in the operation being performed. This implementation allows entities to be added to the EventCache before the operation has cascaded to that entity.

The following methods can be used by event listeners (and other classes) in the same package to add entities to an EventCache and indicate if the operation is being performed on the entity:

EventCache#put(Object entity, Object copy, boolean isOperatedOn)

The following method can be used by event listeners (and other classes) in the same package to indicate that the operation is being performed on an entity already in the EventCache: {@link EventCache#setOperatedOn(Object entity, boolean isOperatedOn)

Author
Gail Badner

Field Summary

Modifier and TypeField and Description
private Map<K, V>
private Map<K, V>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements java.util.Map.clear.

Clears the EventCache.
public boolean

Returns:

true if this EventCache contains a mapping for the specified entity
containsKey
(Object
must be non-null
entity
)

Implements java.util.Map.containsKey.

Returns true if this EventCache contains a mapping for the specified entity.
public boolean

Returns:

true if this EventCache maps one or more entities to the specified copy
containsValue
(Object
must be non-null
copy
)

Implements java.util.Map.containsValue.

Returns true if this EventCache maps one or more entities to the specified copy.
public Set<E>

Returns:

set view of the entity-to-copy mappings contained in this EventCache
entrySet
()

Implements java.util.Map.entrySet.

Returns a set view of the entity-to-copy mappings contained in this EventCache.
public Object

Returns:

the copy to which this EventCache maps the specified entity
get
(Object
must be non-null
entity
)

Implements java.util.Map.get.

Returns the copy to which this EventCache maps the specified entity.
public Map<K, V>

Returns:

the copy-entity mappings
invertMap
()

Returns the copy-entity mappings

public boolean

Returns:

true if this EventCache contains no entity-copy mappings
isEmpty
()

Implements java.util.Map.isEmpty.

Returns true if this EventCache contains no entity-copy mappings.
public boolean

Returns:

true if the listener is performing the operation on the specified entity.
isOperatedOn
(Object
must be non-null
entity
)

Returns true if the listener is performing the operation on the specified entity.

public Set<E>

Returns:

a set view of the entities contained in this EventCache
keySet
()

Implements java.util.Map.keySet.

Returns a set view of the entities contained in this EventCache
public Object

Returns:

previous copy associated with specified entity, or null if there was no mapping for entity.
put
(Object
must be non-null
entity
,
Object
must be non- null
copy
)

Implements java.util.Map.put.

Associates the specified entity with the specified copy in this EventCache;
pack-priv Object

Returns:

previous copy associated with specified entity, or null if there was no mapping for entity.
put
(Object
must be non-null
entity
,
Object
must be non- null
copy
,
boolean
indicates if the operation is performed on the entity
isOperatedOn
)

Associates the specified entity with the specified copy in this EventCache;

public void
putAll(Map<K, V>
keys and values must be non-null
map
)

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this EventCache
public Object

Returns:

previous value associated with specified entity, or null if there was no mapping for entity.
remove
(Object
must be non-null
entity
)

Implements java.util.Map.remove.

Removes the mapping for this entity from this EventCache if it is present
pack-priv void

Returns:

true if the listener is performing the operation on the specified entity
setOperatedOn
(Object
must be non-null and this EventCache must contain a mapping for this entity
entity
,
boolean isOperatedOn)

Set flag to indicate if the listener is performing the operation on the specified entity.

public int

Returns:

the number of entity-copy mappings in this EventCache
size
()

Implements java.util.Map.size.

Returns the number of entity-copy mappings in this EventCache
public Collection<E>

Returns:

a collection view of the entity copies contained in this EventCache
values
()

Implements java.util.Map.values.

Returns a collection view of the entity copies contained in this EventCache.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entityToCopyMapback to summary
private Map<K, V> entityToCopyMap
entityToOperatedOnFlagMapback to summary
private Map<K, V> entityToOperatedOnFlagMap

Constructor Detail

EventCacheback to summary
pack-priv EventCache()

Method Detail

clearback to summary
public void clear()

Implements java.util.Map.clear.

Clears the EventCache.

containsKeyback to summary
public boolean containsKey(Object entity)

Implements java.util.Map.containsKey.

Returns true if this EventCache contains a mapping for the specified entity.

Parameters
entity:Object

must be non-null

Returns:boolean

true if this EventCache contains a mapping for the specified entity

Exceptions
NullPointerException:
if entity is null
containsValueback to summary
public boolean containsValue(Object copy)

Implements java.util.Map.containsValue.

Returns true if this EventCache maps one or more entities to the specified copy.

Parameters
copy:Object

must be non-null

Returns:boolean

true if this EventCache maps one or more entities to the specified copy

Exceptions
NullPointerException:
if copy is null
entrySetback to summary
public Set<E> entrySet()

Implements java.util.Map.entrySet.

Returns a set view of the entity-to-copy mappings contained in this EventCache.

Returns:Set<E>

set view of the entity-to-copy mappings contained in this EventCache

getback to summary
public Object get(Object entity)

Implements java.util.Map.get.

Returns the copy to which this EventCache maps the specified entity.

Parameters
entity:Object

must be non-null

Returns:Object

the copy to which this EventCache maps the specified entity

Exceptions
NullPointerException:
if entity is null
invertMapback to summary
public Map<K, V> invertMap()

Returns the copy-entity mappings

Returns:Map<K, V>

the copy-entity mappings

isEmptyback to summary
public boolean isEmpty()

Implements java.util.Map.isEmpty.

Returns true if this EventCache contains no entity-copy mappings.

Returns:boolean

true if this EventCache contains no entity-copy mappings

isOperatedOnback to summary
public boolean isOperatedOn(Object entity)

Returns true if the listener is performing the operation on the specified entity.

Parameters
entity:Object

must be non-null

Returns:boolean

true if the listener is performing the operation on the specified entity.

Exceptions
NullPointerException:
if entity is null
keySetback to summary
public Set<E> keySet()

Implements java.util.Map.keySet.

Returns a set view of the entities contained in this EventCache

Returns:Set<E>

a set view of the entities contained in this EventCache

putback to summary
public Object put(Object entity, Object copy)

Implements java.util.Map.put.

Associates the specified entity with the specified copy in this EventCache;

Parameters
entity:Object

must be non-null

copy:Object

must be non- null

Returns:Object

previous copy associated with specified entity, or null if there was no mapping for entity.

Exceptions
NullPointerException:
if entity or copy is null
putback to summary
pack-priv Object put(Object entity, Object copy, boolean isOperatedOn)

Associates the specified entity with the specified copy in this EventCache;

Parameters
entity:Object

must be non-null

copy:Object

must be non- null

isOperatedOn:boolean

indicates if the operation is performed on the entity

Returns:Object

previous copy associated with specified entity, or null if there was no mapping for entity.

Exceptions
NullPointerException:
if entity or copy is null
putAllback to summary
public void putAll(Map<K, V> map)

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this EventCache

Parameters
map:Map<K, V>

keys and values must be non-null

Exceptions
NullPointerException:
if any map keys or values are null
removeback to summary
public Object remove(Object entity)

Implements java.util.Map.remove.

Removes the mapping for this entity from this EventCache if it is present

Parameters
entity:Object

must be non-null

Returns:Object

previous value associated with specified entity, or null if there was no mapping for entity.

Exceptions
NullPointerException:
if entity is null
setOperatedOnback to summary
pack-priv void setOperatedOn(Object entity, boolean isOperatedOn)

Set flag to indicate if the listener is performing the operation on the specified entity.

Parameters
entity:Object

must be non-null and this EventCache must contain a mapping for this entity

Returns:void

true if the listener is performing the operation on the specified entity

Exceptions
NullPointerException:
if entity is null
AssertionFailure:
if this EventCache does not contain a mapping for the specified entity
sizeback to summary
public int size()

Implements java.util.Map.size.

Returns the number of entity-copy mappings in this EventCache

Returns:int

the number of entity-copy mappings in this EventCache

valuesback to summary
public Collection<E> values()

Implements java.util.Map.values.

Returns a collection view of the entity copies contained in this EventCache.

Returns:Collection<E>

a collection view of the entity copies contained in this EventCache