org.datanucleus.store.mapped.scostore
Class AbstractMapStore

java.lang.Object
  extended by org.datanucleus.store.mapped.scostore.BaseContainerStore
      extended by org.datanucleus.store.mapped.scostore.AbstractMapStore
All Implemented Interfaces:
MapStore, Store
Direct Known Subclasses:
FKMapStore, JoinMapStore

public abstract class AbstractMapStore
extends BaseContainerStore
implements MapStore

Abstract representation of the backing store for a Map.


Field Summary
protected  boolean iterateUsingDiscriminator
          Flag to set whether the iterator statement will use a discriminator or not.
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  java.lang.String keyType
          Type of the key.
protected  AbstractClassMetaData kmd
          Metadata for the keys (if persistable).
protected  DatastoreContainerObject mapTable
          Table storing the map relation.
protected  AbstractMapStoreSpecialization specialization
           
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  DatastoreClass valueTable
          Table storing the values.
protected  java.lang.String valueType
          Type of the value.
protected  AbstractClassMetaData vmd
          Metadata for the values (if persistable).
 
Fields inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowNulls, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
AbstractMapStore(StoreManager storeMgr, AbstractMapStoreSpecialization specialization)
          Constructor.
 
Method Summary
 boolean containsKey(ObjectProvider sm, java.lang.Object key)
          Method to check if a key exists in the Map.
 boolean containsValue(ObjectProvider sm, java.lang.Object value)
          Method to check if a value exists in the Map.
 java.lang.Object get(ObjectProvider sm, java.lang.Object key)
          Method to return the value for a key.
 JavaTypeMapping getKeyMapping()
           
 java.lang.String getKeyType()
          Accessor for the key type for storing in this Map.
 AbstractClassMetaData getKmd()
           
 DatastoreContainerObject getMapTable()
           
protected abstract  java.lang.Object getValue(ObjectProvider sm, java.lang.Object key)
          Method to retrieve a value from the Map given the key.
 JavaTypeMapping getValueMapping()
           
 java.lang.String getValueType()
          Accessor for the value type for storing in this Map.
 AbstractClassMetaData getVmd()
           
 boolean isValuesAreEmbedded()
           
 boolean isValuesAreSerialised()
           
 boolean keysAreEmbedded()
          Accessor for whether the keys are embedded or not.
 boolean keysAreSerialised()
          Accessor for whether the keys are serialised or not.
 void putAll(ObjectProvider sm, java.util.Map m)
          Method to put all elements from a Map into our Map.
 boolean updateEmbeddedKey(ObjectProvider sm, java.lang.Object key, int fieldNumber, java.lang.Object newValue)
          Method to update a field of an embedded key.
 boolean updateEmbeddedValue(ObjectProvider sm, java.lang.Object value, int fieldNumber, java.lang.Object newValue)
          Method to update a field of an embedded key.
protected  boolean validateKeyForReading(ObjectProvider sm, java.lang.Object key)
          Utility to validate a key is ok for reading.
protected  void validateKeyForWriting(ObjectProvider sm, java.lang.Object key)
          Utility to validate a key is ok for writing (present in the datastore).
protected  void validateKeyType(ClassLoaderResolver clr, java.lang.Object key)
          Utility to validate the type of a key for storing in the Map.
protected  boolean validateValueForReading(ObjectProvider sm, java.lang.Object value)
          Utility to validate a value is ok for reading.
protected  void validateValueForWriting(ObjectProvider sm, java.lang.Object value)
          Utility to validate a value is ok for writing (present in the datastore).
protected  void validateValueType(ClassLoaderResolver clr, java.lang.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.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.MapStore
clear, entrySetStore, keySetStore, put, remove, valueSetStore
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 

Field Detail

iterateUsingDiscriminator

protected boolean iterateUsingDiscriminator
Flag to set whether the iterator statement will use a discriminator or not.


mapTable

protected DatastoreContainerObject mapTable
Table storing the map relation. May be join table, or key table, or value table.


valueTable

protected DatastoreClass valueTable
Table storing the values.


kmd

protected AbstractClassMetaData kmd
Metadata for the keys (if persistable).


vmd

protected AbstractClassMetaData vmd
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 java.lang.String keyType
Type of the key.


valueType

protected java.lang.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.


specialization

protected final AbstractMapStoreSpecialization specialization
Constructor Detail

AbstractMapStore

public AbstractMapStore(StoreManager storeMgr,
                        AbstractMapStoreSpecialization specialization)
Constructor.

Parameters:
storeMgr - Manager for the store
specialization - Specialisation for this datastore
Method Detail

keysAreEmbedded

public boolean keysAreEmbedded()
Accessor for whether the keys are embedded or not. If they are PC instances then returns false;

Specified by:
keysAreEmbedded in interface MapStore
Returns:
Whether the keys are embedded

keysAreSerialised

public boolean keysAreSerialised()
Accessor for whether the keys are serialised or not. If they are PC instances then returns false;

Specified by:
keysAreSerialised in interface MapStore
Returns:
Whether the keys are serialised

valuesAreEmbedded

public boolean valuesAreEmbedded()
Accessor for whether the values are embedded or not. If they are PC instances then returns false;

Specified by:
valuesAreEmbedded in interface MapStore
Returns:
Whether the values are embedded

valuesAreSerialised

public boolean valuesAreSerialised()
Accessor for whether the values are serialised or not. If they are PC instances then returns false;

Specified by:
valuesAreSerialised in interface MapStore
Returns:
Whether the values are serialised

getKeyType

public java.lang.String getKeyType()
Accessor for the key type for storing in this Map.

Specified by:
getKeyType in interface MapStore
Returns:
The type of the key

getValueType

public java.lang.String getValueType()
Accessor for the value type for storing in this Map. Types inherited from this (base) type can also be stored as values.

Specified by:
getValueType in interface MapStore
Returns:
The type of the value (base class).

containsKey

public boolean containsKey(ObjectProvider sm,
                           java.lang.Object key)
Method to check if a key exists in the Map.

Specified by:
containsKey in interface MapStore
Parameters:
sm - State Manager for the map
key - The key to check for.
Returns:
Whether the key exists in the Map.

containsValue

public boolean containsValue(ObjectProvider sm,
                             java.lang.Object value)
Method to check if a value exists in the Map.

Specified by:
containsValue in interface MapStore
Parameters:
sm - State Manager for the map
value - The value to check for.
Returns:
Whether the value exists in the Map.

get

public java.lang.Object get(ObjectProvider sm,
                            java.lang.Object key)
Method to return the value for a key.

Specified by:
get in interface MapStore
Parameters:
sm - State Manager for the Map.
key - The key of the object to retrieve.
Returns:
The value for this key.

putAll

public void putAll(ObjectProvider sm,
                   java.util.Map m)
Method to put all elements from a Map into our Map.

Specified by:
putAll in interface MapStore
Parameters:
sm - State Manager for the Map
m - The Map to add

validateKeyType

protected void validateKeyType(ClassLoaderResolver clr,
                               java.lang.Object key)
Utility to validate the type of a key for storing in the Map.

Parameters:
clr - The ClassLoaderResolver
key - The key to check.

validateValueType

protected void validateValueType(ClassLoaderResolver clr,
                                 java.lang.Object value)
Utility to validate the type of a value for storing in the Map.

Parameters:
clr - The ClassLoaderResolver
value - The value to check.

validateKeyForReading

protected boolean validateKeyForReading(ObjectProvider sm,
                                        java.lang.Object key)
Utility to validate a key is ok for reading.

Parameters:
sm - State Manager for the map.
key - The key to check.
Returns:
Whether it is validated.

validateValueForReading

protected boolean validateValueForReading(ObjectProvider sm,
                                          java.lang.Object value)
Utility to validate a value is ok for reading.

Parameters:
sm - State Manager for the map.
value - The value to check.
Returns:
Whether it is validated.

validateKeyForWriting

protected void validateKeyForWriting(ObjectProvider sm,
                                     java.lang.Object key)
Utility to validate a key is ok for writing (present in the datastore).

Parameters:
sm - State Manager for the map.
key - The key to check.

validateValueForWriting

protected void validateValueForWriting(ObjectProvider sm,
                                       java.lang.Object value)
Utility to validate a value is ok for writing (present in the datastore).

Parameters:
sm - State Manager for the map.
value - The value to check.

getValue

protected abstract java.lang.Object getValue(ObjectProvider sm,
                                             java.lang.Object key)
                                      throws java.util.NoSuchElementException
Method to retrieve a value from the Map given the key.

Parameters:
sm - State Manager for the map.
key - The key to retrieve the value for.
Returns:
The value for this key
Throws:
java.util.NoSuchElementException - if the value for the key was not found

updateEmbeddedKey

public boolean updateEmbeddedKey(ObjectProvider sm,
                                 java.lang.Object key,
                                 int fieldNumber,
                                 java.lang.Object newValue)
Method to update a field of an embedded key.

Specified by:
updateEmbeddedKey in interface MapStore
Parameters:
sm - State Manager of the owner
key - The key to update
fieldNumber - The number of the field to update
newValue - The new value
Returns:
Whether the element was modified

updateEmbeddedValue

public boolean updateEmbeddedValue(ObjectProvider sm,
                                   java.lang.Object value,
                                   int fieldNumber,
                                   java.lang.Object newValue)
Method to update a field of an embedded key.

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

getValueMapping

public JavaTypeMapping getValueMapping()

getKeyMapping

public JavaTypeMapping getKeyMapping()

isValuesAreEmbedded

public boolean isValuesAreEmbedded()

isValuesAreSerialised

public boolean isValuesAreSerialised()

getMapTable

public DatastoreContainerObject getMapTable()

getKmd

public AbstractClassMetaData getKmd()

getVmd

public AbstractClassMetaData getVmd()


Copyright © 2011. All Rights Reserved.