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 String
containsValueStmt
protected boolean
iterateUsingDiscriminator
Flag to set whether the iterator statement will use a discriminator or not.protected org.datanucleus.metadata.AbstractClassMetaData
keyCmd
Metadata for the keys (if persistable).protected JavaTypeMapping
keyMapping
Mapping to the key from the mapTable.protected boolean
keysAreEmbedded
Whether the keys are embedded.protected boolean
keysAreSerialised
Whether the keys are serialised.protected String
keyType
Type of the key.protected org.datanucleus.metadata.AbstractClassMetaData
valueCmd
Metadata for the values (if persistable).protected JavaTypeMapping
valueMapping
Mapping to the value from the mapTable.protected boolean
valuesAreEmbedded
Whether the values are embedded.protected boolean
valuesAreSerialised
Whether the values are serialised.protected String
valueType
Type 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 boolean
containsKey(org.datanucleus.state.DNStateManager sm, Object key)
boolean
containsValue(org.datanucleus.state.DNStateManager sm, Object value)
V
get(org.datanucleus.state.DNStateManager sm, Object key)
protected static String
getContainsValueStmt(JavaTypeMapping ownerMapping, JavaTypeMapping valueMapping, Table mapTable)
Generate statement to check if a value is contained in the Map.org.datanucleus.metadata.AbstractClassMetaData
getKeyClassMetaData()
JavaTypeMapping
getKeyMapping()
protected abstract V
getValue(org.datanucleus.state.DNStateManager sm, Object key)
Method to retrieve a value from the Map given the key.org.datanucleus.metadata.AbstractClassMetaData
getValueClassMetaData()
JavaTypeMapping
getValueMapping()
boolean
keysAreEmbedded()
Accessor for whether the keys are embedded or not.boolean
keysAreSerialised()
Accessor for whether the keys are serialised or not.void
putAll(org.datanucleus.state.DNStateManager sm, Map<? extends K,? extends V> m)
protected boolean
validateKeyForReading(org.datanucleus.state.DNStateManager sm, Object key)
Utility to validate a key is ok for reading.protected void
validateKeyForWriting(org.datanucleus.state.DNStateManager ownerSM, Object key)
Utility to validate a key is ok for writing (present in the datastore).protected void
validateKeyType(org.datanucleus.ClassLoaderResolver clr, Object key)
Utility to validate the type of a key for storing in the Map.protected boolean
validateValueForReading(org.datanucleus.state.DNStateManager sm, Object value)
Utility to validate a value is ok for reading.protected void
validateValueForWriting(org.datanucleus.state.DNStateManager ownerSM, Object value)
Utility to validate a value is ok for writing (present in the datastore).protected void
validateValueType(org.datanucleus.ClassLoaderResolver clr, Object value)
Utility to validate the type of a value for storing in the Map.boolean
valuesAreEmbedded()
Accessor for whether the values are embedded or not.boolean
valuesAreSerialised()
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.
-
-