org.datanucleus.store.mapped.scostore
Class MapEntrySetStore

java.lang.Object
  extended by org.datanucleus.store.mapped.scostore.BaseContainerStore
      extended by org.datanucleus.store.mapped.scostore.MapEntrySetStore
All Implemented Interfaces:
CollectionStore, SetStore, Store

public abstract class MapEntrySetStore
extends BaseContainerStore
implements SetStore

Representation of backing store for a Map EntrySet.


Field Summary
protected  ClassLoaderResolver clr
           
protected  JavaTypeMapping keyMapping
          Mapping for the key.
protected  MapStore mapStore
          The backing store for the Map.
protected  DatastoreContainerObject mapTable
          Table containing the key and value forming the entry.
protected  JavaTypeMapping valueMapping
          Mapping for the value.
 
Fields inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowsNull, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
MapEntrySetStore(DatastoreContainerObject mapTable, AbstractMemberMetaData ownerMemberMetaData, JavaTypeMapping ownerMapping, JavaTypeMapping keyMapping, JavaTypeMapping valueMapping, MapStore mapStore, ClassLoaderResolver clr)
          Constructor for a store for the entries of a map.
 
Method Summary
 boolean add(StateManager sm, java.lang.Object element, int size)
          Method to add an entry to the Map.
 boolean addAll(StateManager sm, java.util.Collection elements, int size)
          Method to add entries to the Map.
 void clear(StateManager sm)
          Method to clear the Map.
 boolean contains(StateManager sm, java.lang.Object element)
          Method to check if an element exists in the collection.
 QueryExpression getExistsSubquery(QueryExpression stmt, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier collectionTableAlias)
          Create a subquery for the given query that joins a SetStore element table to the owner table.
 JavaTypeMapping getKeyMapping()
           
 MapStore getMapStore()
           
 JavaTypeMapping getOwnerMapping()
          Accessor for the owner mapping.
 QueryExpression getSizeSubquery(QueryExpression stmt, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier collectionTableAlias)
          Create a subquery for the size() of the collection of entries.
 JavaTypeMapping getValueMapping()
           
 boolean hasOrderMapping()
          Accessor for whether this store has an order mapping to allow for duplicates, or ordering.
abstract  java.util.Iterator iterator(StateManager sm)
          Accessor for an iterator for the entries of the Map.
 ScalarExpression joinElementsTo(QueryExpression stmt, QueryExpression qs, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier collectionTableAlias, java.lang.Class filteredElementType, ScalarExpression elmExpr, DatastoreIdentifier elementTableAlias, boolean existsQuery)
          Method used in queries when contains() has been invoked.
 boolean remove(StateManager sm, java.lang.Object element, int size, boolean allowDependentField)
          Method to remove an entry from the Map.
 boolean removeAll(StateManager sm, java.util.Collection elements, int size)
          Method to remove entries from the Map.
abstract  int size(StateManager sm)
          Accessor for the size of the Map.
 void update(StateManager sm, java.util.Collection coll)
          Method to update the collection to be the supplied collection of elements.
 boolean updateEmbeddedElement(StateManager sm, java.lang.Object element, int fieldNumber, java.lang.Object value)
          Method to update an embedded element.
protected  boolean validateElementType(java.lang.Object element)
           
 
Methods inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowsBatching, getDatastoreAdapter, getOwnerMemberMetaData, getRelationType, getStateManagerForEmbeddedPCObject, getStoreManager, isEmbeddedMapping, setOwner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.datanucleus.store.scostore.CollectionStore
getElementType
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 

Field Detail

mapTable

protected DatastoreContainerObject mapTable
Table containing the key and value forming the entry.


mapStore

protected MapStore mapStore
The backing store for the Map.


keyMapping

protected JavaTypeMapping keyMapping
Mapping for the key.


valueMapping

protected JavaTypeMapping valueMapping
Mapping for the value.


clr

protected ClassLoaderResolver clr
Constructor Detail

MapEntrySetStore

public MapEntrySetStore(DatastoreContainerObject mapTable,
                        AbstractMemberMetaData ownerMemberMetaData,
                        JavaTypeMapping ownerMapping,
                        JavaTypeMapping keyMapping,
                        JavaTypeMapping valueMapping,
                        MapStore mapStore,
                        ClassLoaderResolver clr)
Constructor for a store for the entries of a map.

Parameters:
mapTable - The table handling the relation (can be join table, or key table, or value table)
ownerMemberMetaData - Metadata for the owning field/property
ownerMapping - Mapping back to the owner from this table
keyMapping - Mapping for the key
valueMapping - Mapping for the value
mapStore - Backing store for the map
clr - ClassLoader resolver
Method Detail

hasOrderMapping

public boolean hasOrderMapping()
Accessor for whether this store has an order mapping to allow for duplicates, or ordering.

Specified by:
hasOrderMapping in interface CollectionStore
Returns:
Whether it has an order mapping.

updateEmbeddedElement

public boolean updateEmbeddedElement(StateManager sm,
                                     java.lang.Object element,
                                     int fieldNumber,
                                     java.lang.Object value)
Method to update an embedded element.

Specified by:
updateEmbeddedElement in interface CollectionStore
Parameters:
sm - State Manager of the owner
element - The element to update
fieldNumber - The number of the field to update
value - The value
Returns:
Whether the element was modified

getOwnerMapping

public JavaTypeMapping getOwnerMapping()
Accessor for the owner mapping.

Overrides:
getOwnerMapping in class BaseContainerStore
Returns:
The owner mapping

validateElementType

protected boolean validateElementType(java.lang.Object element)

iterator

public abstract java.util.Iterator iterator(StateManager sm)
Accessor for an iterator for the entries of the Map. Implemented by the subclass using whatever querying mechanism is suitable for the underlying datastore.

Specified by:
iterator in interface CollectionStore
Parameters:
sm - State manager for the owner
Returns:
The iterator

size

public abstract int size(StateManager sm)
Accessor for the size of the Map.

Specified by:
size in interface CollectionStore
Parameters:
sm - The state manager
Returns:
The size

update

public void update(StateManager sm,
                   java.util.Collection coll)
Method to update the collection to be the supplied collection of elements.

Specified by:
update in interface CollectionStore
Parameters:
sm - StateManager of the object
coll - The collection to use

contains

public boolean contains(StateManager sm,
                        java.lang.Object element)
Description copied from interface: CollectionStore
Method to check if an element exists in the collection.

Specified by:
contains in interface CollectionStore
Parameters:
sm - State Manager for the collection.
element - Element to check
Returns:
Whether the element exists in the collection.

add

public boolean add(StateManager sm,
                   java.lang.Object element,
                   int size)
Method to add an entry to the Map.

Specified by:
add in interface CollectionStore
Parameters:
sm - State Manager for the owner
element - Entry to add
size - Current size of the collection if known. -1 if not known
Returns:
Whether it was added

addAll

public boolean addAll(StateManager sm,
                      java.util.Collection elements,
                      int size)
Method to add entries to the Map.

Specified by:
addAll in interface CollectionStore
Parameters:
sm - State Manager for the owner
elements - Entries to add
size - Current size of collection (if known). -1 if not known
Returns:
Whether they were added

remove

public boolean remove(StateManager sm,
                      java.lang.Object element,
                      int size,
                      boolean allowDependentField)
Method to remove an entry from the Map.

Specified by:
remove in interface CollectionStore
Parameters:
sm - State Manager for the owner
element - Entry to remove
size - Current size of collection if known. -1 if not known
allowDependentField - Whether to allow any cascading delete actions to be fired from this removal
Returns:
Whether it was removed

removeAll

public boolean removeAll(StateManager sm,
                         java.util.Collection elements,
                         int size)
Method to remove entries from the Map.

Specified by:
removeAll in interface CollectionStore
Parameters:
sm - State Manager for the owner
elements - Entries to remove
size - Current size of collection if known. -1 if not known
Returns:
Whether they were removed

clear

public void clear(StateManager sm)
Method to clear the Map.

Specified by:
clear in interface CollectionStore
Parameters:
sm - State Manager for the owner.

getMapStore

public MapStore getMapStore()

getKeyMapping

public JavaTypeMapping getKeyMapping()

getValueMapping

public JavaTypeMapping getValueMapping()

getExistsSubquery

public QueryExpression getExistsSubquery(QueryExpression stmt,
                                         JavaTypeMapping ownerMapping,
                                         LogicSetExpression ownerTe,
                                         DatastoreIdentifier collectionTableAlias)
Create a subquery for the given query that joins a SetStore element table to the owner table. This subquery can subsequently be used in an EXISTS expression to determine whether a Collection is empty.

Parameters:
stmt - The Query Statement.
ownerMapping - the mapping for the owner.
ownerTe - Table Expression for the owner
collectionTableAlias - Alias for the "Collection" table.
Returns:
A subquery for the given query that joins a SetStore element table to the owner table.
Throws:
NucleusUserException - unsupported method

getSizeSubquery

public QueryExpression getSizeSubquery(QueryExpression stmt,
                                       JavaTypeMapping ownerMapping,
                                       LogicSetExpression ownerTe,
                                       DatastoreIdentifier collectionTableAlias)
Create a subquery for the size() of the collection of entries.

Parameters:
stmt - The Query Statement.
ownerMapping - the mapping for the owner.
ownerTe - Table Expression for the owner
collectionTableAlias - Alias for the "Collection" table.
Returns:
A subquery for the given query that joins a SetStore element table to the owner table.
Throws:
NucleusUserException - unsupported method

joinElementsTo

public ScalarExpression joinElementsTo(QueryExpression stmt,
                                       QueryExpression qs,
                                       JavaTypeMapping ownerMapping,
                                       LogicSetExpression ownerTe,
                                       DatastoreIdentifier collectionTableAlias,
                                       java.lang.Class filteredElementType,
                                       ScalarExpression elmExpr,
                                       DatastoreIdentifier elementTableAlias,
                                       boolean existsQuery)
Method used in queries when contains() has been invoked.

Parameters:
stmt - The Query Statement
ownerMapping - the mapping for the owner.
ownerTe - Table Expression for the owner
collectionTableAlias - Alias for the "Collection" table.
filteredElementType - The Class Type for the filtered element
elmExpr - The Expression for the element
elementTableAlias - The SQL alias to assign to the expression or to the element table.
Returns:
expression to the join
Throws:
NucleusUserException - unsupported method


Copyright © 2010. All Rights Reserved.