org.datanucleus.store.mapped.scostore
Class MapValueSetStore

java.lang.Object
  extended by org.datanucleus.store.mapped.scostore.BaseContainerStore
      extended by org.datanucleus.store.mapped.scostore.ElementContainerStore
          extended by org.datanucleus.store.mapped.scostore.AbstractCollectionStore
              extended by org.datanucleus.store.mapped.scostore.AbstractSetStore
                  extended by org.datanucleus.store.mapped.scostore.MapValueSetStore
All Implemented Interfaces:
CollectionStoreQueryable, CollectionStore, SetStore, Store

public abstract class MapValueSetStore
extends AbstractSetStore

Representation of the backing store for the values of a Map. This is used where the user calls Map.values() and then wants to perform some operation on the resulting Collection. The values for a Map can be stored in several ways. There are the following possibilities


Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
ElementContainerStore.ElementInfo
 
Field Summary
protected  JavaTypeMapping keyMapping
           
protected  MapStore mapStore
           
 
Fields inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
clr, containerTable, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, emd, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, specialization
 
Fields inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowsNull, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
MapValueSetStore(DatastoreClass mapTable, AbstractMemberMetaData ownerMmd, JavaTypeMapping ownerMapping, JavaTypeMapping valueMapping, MapStore mapStore, ClassLoaderResolver clr, AbstractSetStoreSpecialization specialization)
          Constructor where either the key is stored in the value table or the value is stored in the key table.
MapValueSetStore(DatastoreContainerObject mapTable, AbstractMemberMetaData ownerMmd, JavaTypeMapping ownerMapping, JavaTypeMapping keyMapping, JavaTypeMapping valueMapping, MapStore mapStore, ClassLoaderResolver clr, AbstractSetStoreSpecialization specialization)
          Constructor where a join table is used to store the map relation.
 
Method Summary
 boolean add(StateManager sm, java.lang.Object element, int size)
          Method to add a value to the Map.
 boolean addAll(StateManager sm, java.util.Collection elements, int size)
          Method to add entries to the Map.
protected abstract  boolean canClear()
           
 void clear(StateManager sm)
          Method to clear the map.
 ScalarExpression joinElementsTo(QueryExpression stmt, QueryExpression qs, JavaTypeMapping ownerMapping, LogicSetExpression te, DatastoreIdentifier setRangeVar, java.lang.Class filteredElementType, ScalarExpression elmExpr, DatastoreIdentifier elementRangeVar, boolean existsQuery)
          Method used in queries when contains() has been invoked.
protected abstract  boolean remove(StateManager sm, java.lang.Object element)
           
 boolean remove(StateManager sm, java.lang.Object element, int size, boolean allowDependentField)
          Method to remove a value from the Map.
 boolean removeAll(StateManager sm, java.util.Collection elements, int size)
          Method to remove values from the map via the value collection.
 
Methods inherited from class org.datanucleus.store.mapped.scostore.AbstractSetStore
iterator
 
Methods inherited from class org.datanucleus.store.mapped.scostore.AbstractCollectionStore
contains, getExistsSubquery, getSizeSubquery, update, updateEmbeddedElement
 
Methods inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
getContainerTable, getElementInfo, getElementInformationForClass, getElementMapping, getElementType, getEmd, getOrderMapping, getRelationDiscriminatorMapping, getRelationDiscriminatorValue, hasOrderMapping, isElementsAreEmbedded, isElementsAreSerialised, size, validateElementForReading, validateElementForWriting, validateElementType
 
Methods inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowsBatching, getDatastoreAdapter, getOwnerMapping, 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
contains, getElementType, hasOrderMapping, size, update, updateEmbeddedElement
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 

Field Detail

mapStore

protected final MapStore mapStore

keyMapping

protected final JavaTypeMapping keyMapping
Constructor Detail

MapValueSetStore

public MapValueSetStore(DatastoreContainerObject mapTable,
                        AbstractMemberMetaData ownerMmd,
                        JavaTypeMapping ownerMapping,
                        JavaTypeMapping keyMapping,
                        JavaTypeMapping valueMapping,
                        MapStore mapStore,
                        ClassLoaderResolver clr,
                        AbstractSetStoreSpecialization specialization)
Constructor where a join table is used to store the map relation.

Parameters:
mapTable - Table used by the map
ownerMmd - Metadata for the owning field/property
ownerMapping - the owner mapping
keyMapping - the key mapping
valueMapping - the value mapping
mapStore - Store used by the map
clr - The ClassLoaderResolver
specialization - the specialisation

MapValueSetStore

public MapValueSetStore(DatastoreClass mapTable,
                        AbstractMemberMetaData ownerMmd,
                        JavaTypeMapping ownerMapping,
                        JavaTypeMapping valueMapping,
                        MapStore mapStore,
                        ClassLoaderResolver clr,
                        AbstractSetStoreSpecialization specialization)
Constructor where either the key is stored in the value table or the value is stored in the key table.

Parameters:
mapTable - Table storing the map relation (key or value table)
ownerMmd - FieldMetaData for the owning "map" field
ownerMapping - Mapping to the owner from this table
valueMapping - Mapping for this table to the value
mapStore - Store used by the map.
clr - The ClassLoaderResolver
specialization - the specialization
Method Detail

add

public boolean add(StateManager sm,
                   java.lang.Object element,
                   int size)
Method to add a value to the Map. Not supported.

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

addAll

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

Specified by:
addAll in interface CollectionStore
Overrides:
addAll in class AbstractSetStore
Parameters:
sm - State Manager for the owner
elements - The values to add
size - Current size of set (if known). Not used by sets
Returns:
Whether it was added correctly.

remove

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

Specified by:
remove in interface CollectionStore
Overrides:
remove in class AbstractSetStore
Parameters:
sm - State Manager for the owner
element - The value to remove
size - Current size
allowDependentField - Whether to allow any cascade deletes caused by this removal
Returns:
Whether it was removed correctly.

removeAll

public boolean removeAll(StateManager sm,
                         java.util.Collection elements,
                         int size)
Method to remove values from the map via the value collection.

Specified by:
removeAll in interface CollectionStore
Overrides:
removeAll in class AbstractSetStore
Parameters:
sm - StateManager for the owner
elements - Collection of elements to remove
size - Current size of collection if known. -1 if not known
Returns:
Whether the database was updated

clear

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

Specified by:
clear in interface CollectionStore
Overrides:
clear in class ElementContainerStore
Parameters:
sm - StateManager for the owner

canClear

protected abstract boolean canClear()

remove

protected abstract boolean remove(StateManager sm,
                                  java.lang.Object element)

joinElementsTo

public ScalarExpression joinElementsTo(QueryExpression stmt,
                                       QueryExpression qs,
                                       JavaTypeMapping ownerMapping,
                                       LogicSetExpression te,
                                       DatastoreIdentifier setRangeVar,
                                       java.lang.Class filteredElementType,
                                       ScalarExpression elmExpr,
                                       DatastoreIdentifier elementRangeVar,
                                       boolean existsQuery)
Description copied from interface: CollectionStoreQueryable
Method used in queries when contains() has been invoked.

Parameters:
stmt - The Query Statement
qs - the parent Query Statement. If there is no parent, "parentStmt" must be equals to "stmt".
ownerMapping - the mapping for the owner
te - Table Expression for the owner
setRangeVar - Alias for the "Collection" table.
filteredElementType - The Class Type for the filtered element
elmExpr - The Expression for the element
elementRangeVar - The SQL alias to assign to the element table expression
existsQuery - Whether this is joining for an EXISTS query
Returns:
expression to the join


Copyright © 2010. All Rights Reserved.