org.datanucleus.store.mapped.scostore
Class ElementContainerStore

java.lang.Object
  extended by org.datanucleus.store.mapped.scostore.BaseContainerStore
      extended by org.datanucleus.store.mapped.scostore.ElementContainerStore
Direct Known Subclasses:
AbstractArrayStore, AbstractCollectionStore

public abstract class ElementContainerStore
extends BaseContainerStore

Representation of the store of an element-based container. This is used to represent either a collection or an array. There are the following types of situation that we try to cater for with respect to elements.


Nested Class Summary
 class ElementContainerStore.ElementInfo
          Inner class wrapping the information required for a valid element type.
 
Field Summary
protected  ClassLoaderResolver clr
          ClassLoader resolver.
protected  DatastoreContainerObject containerTable
          Table containing the link between owner and element.
protected  ElementContainerStore.ElementInfo[] elementInfo
          Information for the elements of this container.
protected  boolean elementIsPersistentInterface
          Whether the element is of a persistent-interface (defined using "") type.
protected  JavaTypeMapping elementMapping
          Mapping for the element.
protected  boolean elementsAreEmbedded
          Whether the elements are embedded.
protected  boolean elementsAreSerialised
          Whether the elements are serialised.
protected  java.lang.String elementType
          Type of the element.
protected  AbstractClassMetaData emd
          MetaData for the "element-type" class.
protected  boolean iterateUsingDiscriminator
          Flag to set whether the iterator statement will use a discriminator or not.
protected  JavaTypeMapping orderMapping
          Mapping for an ordering column to allow for duplicates in the container.
protected  JavaTypeMapping relationDiscriminatorMapping
          Optional mapping to distinguish elements of one collection from another when sharing the join table.
protected  java.lang.String relationDiscriminatorValue
          Value to use to discriminate between elements of this collection from others using the same join table.
protected  ElementContainerStoreSpecialization specialization
          Specialization.
 
Fields inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowsNull, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
protected ElementContainerStore(StoreManager storeMgr, ClassLoaderResolver clr, ElementContainerStoreSpecialization elementContainerStoreSpecialization)
          Constructor.
 
Method Summary
 void clear(StateManager ownerSM)
          Clear the association from owner to all elements.
 DatastoreContainerObject getContainerTable()
           
 ElementContainerStore.ElementInfo[] getElementInfo()
           
protected  ElementContainerStore.ElementInfo[] getElementInformationForClass()
          Convenience method to find the element information relating to the element type.
 JavaTypeMapping getElementMapping()
           
 java.lang.String getElementType()
          Accessor for the element type stored in this container.
 AbstractClassMetaData getEmd()
           
 JavaTypeMapping getOrderMapping()
           
 JavaTypeMapping getRelationDiscriminatorMapping()
           
 java.lang.String getRelationDiscriminatorValue()
           
 boolean hasOrderMapping()
          Accessor for whether the store has an order mapping, to allow for duplicates or ordering.
 boolean isElementsAreEmbedded()
           
 boolean isElementsAreSerialised()
           
abstract  java.util.Iterator iterator(StateManager ownerSM)
          Accessor for an iterator through the container elements.
 int size(StateManager sm)
          Method to return the size of the container.
protected  boolean validateElementForReading(StateManager sm, java.lang.Object element)
          Method to check if an element is already persistent or is persistent but managed by a different persistence manager.
protected  boolean validateElementForWriting(StateManager sm, java.lang.Object element, FieldValues fieldValues)
          Method to check if an element is already persistent, or is managed by a different Persistencemanager.
protected  boolean validateElementType(ClassLoaderResolver clr, java.lang.Object element)
          Method to validate an element against the accepted type.
 
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
 

Field Detail

iterateUsingDiscriminator

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


elementInfo

protected ElementContainerStore.ElementInfo[] elementInfo
Information for the elements of this container. When the "element-type" table is new-table, or superclass-table then there is 1 value here. When the "element-type" table uses subclass-table, or when it is a reference type then there can be multiple.


emd

protected AbstractClassMetaData emd
MetaData for the "element-type" class. Not used for reference types since no metadata is present for the declared type.


containerTable

protected DatastoreContainerObject containerTable
Table containing the link between owner and element. Not set when using FK relations.


elementMapping

protected JavaTypeMapping elementMapping
Mapping for the element.


elementType

protected java.lang.String elementType
Type of the element.


elementsAreEmbedded

protected boolean elementsAreEmbedded
Whether the elements are embedded.


elementsAreSerialised

protected boolean elementsAreSerialised
Whether the elements are serialised.


elementIsPersistentInterface

protected boolean elementIsPersistentInterface
Whether the element is of a persistent-interface (defined using "") type.


orderMapping

protected JavaTypeMapping orderMapping
Mapping for an ordering column to allow for duplicates in the container. Can also be used for ordering elements in a List/array. Can also be used where we have an embedded object and so need to form the PK with something.


relationDiscriminatorMapping

protected JavaTypeMapping relationDiscriminatorMapping
Optional mapping to distinguish elements of one collection from another when sharing the join table.


relationDiscriminatorValue

protected java.lang.String relationDiscriminatorValue
Value to use to discriminate between elements of this collection from others using the same join table.


clr

protected ClassLoaderResolver clr
ClassLoader resolver.


specialization

protected final ElementContainerStoreSpecialization specialization
Specialization.

Constructor Detail

ElementContainerStore

protected ElementContainerStore(StoreManager storeMgr,
                                ClassLoaderResolver clr,
                                ElementContainerStoreSpecialization elementContainerStoreSpecialization)
Constructor.

Parameters:
storeMgr - Manager for the store
clr - ClassLoader resolver
Method Detail

getElementInfo

public ElementContainerStore.ElementInfo[] getElementInfo()

getElementMapping

public JavaTypeMapping getElementMapping()

getOrderMapping

public JavaTypeMapping getOrderMapping()

getRelationDiscriminatorMapping

public JavaTypeMapping getRelationDiscriminatorMapping()

getRelationDiscriminatorValue

public java.lang.String getRelationDiscriminatorValue()

getContainerTable

public DatastoreContainerObject getContainerTable()

getEmd

public AbstractClassMetaData getEmd()

isElementsAreSerialised

public boolean isElementsAreSerialised()

isElementsAreEmbedded

public boolean isElementsAreEmbedded()

getElementInformationForClass

protected ElementContainerStore.ElementInfo[] getElementInformationForClass()
Convenience method to find the element information relating to the element type. Used specifically for the "element-type" of a collection/array to find the elements which have table information. Not used for reference types.

Returns:
Element information relating to the element type

hasOrderMapping

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

Returns:
Whether an order mapping is present.

getElementType

public java.lang.String getElementType()
Accessor for the element type stored in this container.

Returns:
The element type.

validateElementType

protected boolean validateElementType(ClassLoaderResolver clr,
                                      java.lang.Object element)
Method to validate an element against the accepted type.

Parameters:
clr - The ClassLoaderResolver
element - The element to validate
Returns:
Whether it is valid.

validateElementForReading

protected boolean validateElementForReading(StateManager sm,
                                            java.lang.Object element)
Method to check if an element is already persistent or is persistent but managed by a different persistence manager.

Parameters:
sm - The state manager of this owner
element - The element
Returns:
Whether it is valid for reading.

validateElementForWriting

protected boolean validateElementForWriting(StateManager sm,
                                            java.lang.Object element,
                                            FieldValues fieldValues)
Method to check if an element is already persistent, or is managed by a different Persistencemanager. If not persistent, this will persist it.

Parameters:
sm - The state manager of this owner
element - The element
fieldValues - any initial field values to use if persisting the element
Returns:
Whether the element was persisted during this call

iterator

public abstract java.util.Iterator iterator(StateManager ownerSM)
Accessor for an iterator through the container elements.

Parameters:
ownerSM - State Manager for the container.
Returns:
The Iterator

clear

public void clear(StateManager ownerSM)
Clear the association from owner to all elements. Provides cascade-delete when the elements being deleted are PC types.

Parameters:
ownerSM - State Manager for the container.

size

public int size(StateManager sm)
Method to return the size of the container.

Parameters:
sm - The state manager.
Returns:
The size.


Copyright © 2010. All Rights Reserved.