Class AbstractMapStore<K,V>
- java.lang.Object
-
- org.datanucleus.store.rdbms.scostore.BaseContainerStore
-
- org.datanucleus.store.rdbms.scostore.AbstractMapStore<K,V>
-
- All Implemented Interfaces:
org.datanucleus.store.types.scostore.MapStore<K,V>,org.datanucleus.store.types.scostore.Store
- Direct Known Subclasses:
FKMapStore,JoinMapStore
public abstract class AbstractMapStore<K,V> extends BaseContainerStore implements org.datanucleus.store.types.scostore.MapStore<K,V>
Abstract representation of the backing store for a Map.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringcontainsValueStmtprotected booleaniterateUsingDiscriminatorFlag to set whether the iterator statement will use a discriminator or not.protected org.datanucleus.metadata.AbstractClassMetaDatakeyCmdMetadata for the keys (if persistable).protected JavaTypeMappingkeyMappingMapping to the key from the mapTable.protected booleankeysAreEmbeddedWhether the keys are embedded.protected booleankeysAreSerialisedWhether the keys are serialised.protected StringkeyTypeType of the key.protected org.datanucleus.metadata.AbstractClassMetaDatavalueCmdMetadata for the values (if persistable).protected JavaTypeMappingvalueMappingMapping to the value from the mapTable.protected booleanvaluesAreEmbeddedWhether the values are embedded.protected booleanvaluesAreSerialisedWhether the values are serialised.protected StringvalueTypeType of the value.-
Fields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr
-
-
Constructor Summary
Constructors Constructor Description AbstractMapStore(RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(org.datanucleus.state.DNStateManager sm, Object key)booleancontainsValue(org.datanucleus.state.DNStateManager sm, Object value)Vget(org.datanucleus.state.DNStateManager sm, Object key)protected static StringgetContainsValueStmt(JavaTypeMapping ownerMapping, JavaTypeMapping valueMapping, Table mapTable)Generate statement to check if a value is contained in the Map.org.datanucleus.metadata.AbstractClassMetaDatagetKeyClassMetaData()JavaTypeMappinggetKeyMapping()protected abstract VgetValue(org.datanucleus.state.DNStateManager sm, Object key)Method to retrieve a value from the Map given the key.org.datanucleus.metadata.AbstractClassMetaDatagetValueClassMetaData()JavaTypeMappinggetValueMapping()booleankeysAreEmbedded()Accessor for whether the keys are embedded or not.booleankeysAreSerialised()Accessor for whether the keys are serialised or not.voidputAll(org.datanucleus.state.DNStateManager sm, Map<? extends K,? extends V> m)protected booleanvalidateKeyForReading(org.datanucleus.state.DNStateManager sm, Object key)Utility to validate a key is ok for reading.protected voidvalidateKeyForWriting(org.datanucleus.state.DNStateManager ownerSM, Object key)Utility to validate a key is ok for writing (present in the datastore).protected voidvalidateKeyType(org.datanucleus.ClassLoaderResolver clr, Object key)Utility to validate the type of a key for storing in the Map.protected booleanvalidateValueForReading(org.datanucleus.state.DNStateManager sm, Object value)Utility to validate a value is ok for reading.protected voidvalidateValueForWriting(org.datanucleus.state.DNStateManager ownerSM, Object value)Utility to validate a value is ok for writing (present in the datastore).protected voidvalidateValueType(org.datanucleus.ClassLoaderResolver clr, Object value)Utility to validate the type of a value for storing in the Map.booleanvaluesAreEmbedded()Accessor for whether the values are embedded or not.booleanvaluesAreSerialised()Accessor for whether the values are serialised or not.-
Methods inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowsBatching, getComponentInformationForClass, 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
-
-
-
-
Field Detail
-
iterateUsingDiscriminator
protected boolean iterateUsingDiscriminator
Flag to set whether the iterator statement will use a discriminator or not.
-
keyCmd
protected org.datanucleus.metadata.AbstractClassMetaData keyCmd
Metadata for the keys (if persistable).
-
valueCmd
protected org.datanucleus.metadata.AbstractClassMetaData valueCmd
Metadata for the values (if persistable).
-
keyMapping
protected JavaTypeMapping keyMapping
Mapping to the key from the mapTable.
-
valueMapping
protected JavaTypeMapping valueMapping
Mapping to the value from the mapTable.
-
keyType
protected String keyType
Type of the key.
-
valueType
protected String valueType
Type of the value.
-
keysAreEmbedded
protected boolean keysAreEmbedded
Whether the keys are embedded.
-
keysAreSerialised
protected boolean keysAreSerialised
Whether the keys are serialised.
-
valuesAreEmbedded
protected boolean valuesAreEmbedded
Whether the values are embedded.
-
valuesAreSerialised
protected boolean valuesAreSerialised
Whether the values are serialised.
-
containsValueStmt
protected String containsValueStmt
-
-
Constructor Detail
-
AbstractMapStore
public AbstractMapStore(RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
-
-
Method Detail
-
getValueMapping
public JavaTypeMapping getValueMapping()
-
getKeyMapping
public JavaTypeMapping getKeyMapping()
-
getKeyClassMetaData
public org.datanucleus.metadata.AbstractClassMetaData getKeyClassMetaData()
-
getValueClassMetaData
public org.datanucleus.metadata.AbstractClassMetaData getValueClassMetaData()
-
keysAreEmbedded
public boolean keysAreEmbedded()
Accessor for whether the keys are embedded or not. If they are PC instances then returns false;
-
keysAreSerialised
public boolean keysAreSerialised()
Accessor for whether the keys are serialised or not. If they are PC instances then returns false;
-
valuesAreEmbedded
public boolean valuesAreEmbedded()
Accessor for whether the values are embedded or not. If they are PC instances then returns false;
-
valuesAreSerialised
public boolean valuesAreSerialised()
Accessor for whether the values are serialised or not. If they are PC instances then returns false;
-
containsKey
public boolean containsKey(org.datanucleus.state.DNStateManager sm, Object key)
-
containsValue
public boolean containsValue(org.datanucleus.state.DNStateManager sm, Object value)
-
putAll
public void putAll(org.datanucleus.state.DNStateManager sm, Map<? extends K,? extends V> m)
-
validateKeyType
protected void validateKeyType(org.datanucleus.ClassLoaderResolver clr, Object key)Utility to validate the type of a key for storing in the Map.- Parameters:
clr- The ClassLoaderResolverkey- The key to check.
-
validateValueType
protected void validateValueType(org.datanucleus.ClassLoaderResolver clr, Object value)Utility to validate the type of a value for storing in the Map.- Parameters:
clr- The ClassLoaderResolvervalue- The value to check.
-
validateKeyForReading
protected boolean validateKeyForReading(org.datanucleus.state.DNStateManager sm, Object key)Utility to validate a key is ok for reading.- Parameters:
sm- StateManager for the map.key- The key to check.- Returns:
- Whether it is validated.
-
validateValueForReading
protected boolean validateValueForReading(org.datanucleus.state.DNStateManager sm, Object value)Utility to validate a value is ok for reading.- Parameters:
sm- StateManager for the map.value- The value to check.- Returns:
- Whether it is validated.
-
validateKeyForWriting
protected void validateKeyForWriting(org.datanucleus.state.DNStateManager ownerSM, Object key)Utility to validate a key is ok for writing (present in the datastore).- Parameters:
ownerSM- StateManager for the owner of the mapkey- The key to check.
-
validateValueForWriting
protected void validateValueForWriting(org.datanucleus.state.DNStateManager ownerSM, Object value)Utility to validate a value is ok for writing (present in the datastore).- Parameters:
ownerSM- StateManager for the owner of the mapvalue- The value to check.
-
getValue
protected abstract V getValue(org.datanucleus.state.DNStateManager sm, Object key) throws NoSuchElementException
Method to retrieve a value from the Map given the key.- Parameters:
sm- StateManager for the map.key- The key to retrieve the value for.- Returns:
- The value for this key
- Throws:
NoSuchElementException- if the value for the key was not found
-
getContainsValueStmt
protected static String getContainsValueStmt(JavaTypeMapping ownerMapping, JavaTypeMapping valueMapping, Table mapTable)
Generate statement to check if a value is contained in the Map.SELECT OWNERCOL FROM MAPTABLE WHERE OWNERCOL=? AND VALUECOL = ?
- Parameters:
ownerMapping- the owner mappingvalueMapping- the value mappingmapTable- the map table- Returns:
- Statement to check if a value is contained in the Map.
-
-