public abstract class AbstractListStore<E> extends AbstractCollectionStore<E> implements org.datanucleus.store.types.scostore.ListStore<E>
Modifier and Type | Field and Description |
---|---|
protected boolean |
indexedList
Whether the list is indexed.
|
protected String |
indexOfStmt |
protected String |
lastIndexOfStmt |
protected String |
removeAtStmt |
protected String |
shiftStmt |
containsStmt
addStmt, clearStmt, containerTable, elementCmd, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, removeStmt, sizeStmt
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr
Modifier | Constructor and Description |
---|---|
protected |
AbstractListStore(RDBMSStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(org.datanucleus.state.ObjectProvider op,
E element,
int size)
Method to add an element to the List.
|
void |
add(org.datanucleus.state.ObjectProvider op,
E element,
int index,
int size)
Method to add an element to the List.
|
boolean |
addAll(org.datanucleus.state.ObjectProvider op,
Collection<E> elements,
int size)
Method to add a collection of elements to the List.
|
boolean |
addAll(org.datanucleus.state.ObjectProvider op,
Collection<E> elements,
int index,
int size)
Method to add all elements from a Collection to the List.
|
E |
get(org.datanucleus.state.ObjectProvider op,
int index)
Method to retrieve an element from the List.
|
protected String |
getIndexOfStmt(Object element)
Generate statement for getting the index of an item.
|
protected int[] |
getIndicesOf(org.datanucleus.state.ObjectProvider op,
Collection elements)
Utility to find the indices of a collection of elements.
|
protected String |
getIndicesOfStmt(Collection elements)
Generates the statement for getting the indices of a collection of element.
|
protected String |
getLastIndexOfStmt(Object element)
Generates the statement for getting the index of the last item.
|
protected String |
getRemoveAtStmt()
Generates the statement for removing an item.
|
protected String |
getShiftStmt()
Generates the statement for shifting items.
|
int |
indexOf(org.datanucleus.state.ObjectProvider op,
Object element)
Accessor for the indexOf an object in the List.
|
protected abstract boolean |
internalAdd(org.datanucleus.state.ObjectProvider op,
int startAt,
boolean atEnd,
Collection<E> elements,
int size)
Internal method for adding an item to the List.
|
protected int |
internalIndexOf(org.datanucleus.state.ObjectProvider op,
Object element,
String stmt)
Internal method to find the index of an element.
|
protected abstract boolean |
internalRemove(org.datanucleus.state.ObjectProvider op,
Object element,
int size)
Internal method to remove the specified element from the List.
|
protected abstract void |
internalRemoveAt(org.datanucleus.state.ObjectProvider op,
int index,
int size)
Internal method to remove an object at a location from the List.
|
protected void |
internalRemoveAt(org.datanucleus.state.ObjectProvider op,
int index,
String stmt,
int size)
Internal method to remove an object at a location in the List.
|
protected int[] |
internalShift(org.datanucleus.state.ObjectProvider op,
org.datanucleus.store.connection.ManagedConnection conn,
boolean batched,
int oldIndex,
int amount,
boolean executeNow)
Method to process a "shift" statement, updating the index in the list of the specified index.
|
Iterator<E> |
iterator(org.datanucleus.state.ObjectProvider op)
Accessor for an iterator through the list elements.
|
int |
lastIndexOf(org.datanucleus.state.ObjectProvider op,
Object element)
Method to retrieve the last index of an object in the list.
|
ListIterator<E> |
listIterator(org.datanucleus.state.ObjectProvider op)
Accessor for an iterator through the list elements.
|
protected abstract ListIterator<E> |
listIterator(org.datanucleus.state.ObjectProvider op,
int startIdx,
int endIdx)
Accessor for an iterator through the list elements.
|
E |
remove(org.datanucleus.state.ObjectProvider op,
int index,
int size)
Method to remove an object at an index in the List.
|
boolean |
remove(org.datanucleus.state.ObjectProvider op,
Object element,
int size,
boolean allowDependentField)
Method to remove the specified element from the List.
|
List<E> |
subList(org.datanucleus.state.ObjectProvider op,
int startIdx,
int endIdx)
Method to retrieve a list of elements in a range.
|
contains, getRemoveStmt, getUpdateEmbeddedElementStmt, update, updateEmbeddedElement, updateEmbeddedElement
clear, getAddStmtForJoinTable, getClearStmt, getComponentInfoForElement, getContainerTable, getElementClassMetaData, getElementMapping, getRelationDiscriminatorMapping, getRelationDiscriminatorValue, getSize, getSizeStmt, hasOrderMapping, invalidateAddStmt, isElementsAreEmbedded, isElementsAreSerialised, size, usingJoinTable, validateElementForReading, validateElementForWriting, validateElementType
allowsBatching, getComponentInformationForClass, getDatastoreAdapter, getObjectProviderForEmbeddedPCObject, getOwnerMapping, getOwnerMemberMetaData, getRelationType, getStoreManager, isEmbeddedMapping, setOwner
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected boolean indexedList
protected String indexOfStmt
protected String lastIndexOfStmt
protected String removeAtStmt
protected String shiftStmt
protected AbstractListStore(RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
storeMgr
- Manager for the storeclr
- ClassLoader resolverpublic Iterator<E> iterator(org.datanucleus.state.ObjectProvider op)
iterator
in interface org.datanucleus.store.types.scostore.CollectionStore<E>
iterator
in class ElementContainerStore
op
- ObjectProvider for the container.public ListIterator<E> listIterator(org.datanucleus.state.ObjectProvider op)
listIterator
in interface org.datanucleus.store.types.scostore.ListStore<E>
op
- ObjectProvider for the container.protected abstract ListIterator<E> listIterator(org.datanucleus.state.ObjectProvider op, int startIdx, int endIdx)
op
- ObjectProvider for the container.startIdx
- The start point in the list (only for indexed lists).endIdx
- The end point in the list (only for indexed lists).public boolean add(org.datanucleus.state.ObjectProvider op, E element, int size)
add
in interface org.datanucleus.store.types.scostore.CollectionStore<E>
op
- The ObjectProviderelement
- The element to removesize
- Size of the current list (if known, -1 if not)public void add(org.datanucleus.state.ObjectProvider op, E element, int index, int size)
add
in interface org.datanucleus.store.types.scostore.ListStore<E>
element
- The element to add.index
- The location to add atop
- The ObjectProvider.public boolean addAll(org.datanucleus.state.ObjectProvider op, Collection<E> elements, int size)
addAll
in interface org.datanucleus.store.types.scostore.CollectionStore<E>
op
- The ObjectProviderelements
- The elements to removesize
- Current size of the list (if known). -1 if not knownpublic boolean addAll(org.datanucleus.state.ObjectProvider op, Collection<E> elements, int index, int size)
addAll
in interface org.datanucleus.store.types.scostore.ListStore<E>
op
- The ObjectProviderelements
- The collectionindex
- The location to add atsize
- Current size of the list (if known). -1 if not knownprotected abstract boolean internalAdd(org.datanucleus.state.ObjectProvider op, int startAt, boolean atEnd, Collection<E> elements, int size)
op
- The ObjectProviderstartAt
- The start positionatEnd
- Whether to add at the endelements
- The Collection of elements to add.size
- Current size of List (if known). -1 if not knownpublic E get(org.datanucleus.state.ObjectProvider op, int index)
get
in interface org.datanucleus.store.types.scostore.ListStore<E>
op
- ObjectProvider for the ownerindex
- The index of the element required.public int indexOf(org.datanucleus.state.ObjectProvider op, Object element)
indexOf
in interface org.datanucleus.store.types.scostore.ListStore<E>
op
- ObjectProvider for the ownerelement
- The element.public int lastIndexOf(org.datanucleus.state.ObjectProvider op, Object element)
lastIndexOf
in interface org.datanucleus.store.types.scostore.ListStore<E>
op
- ObjectProvider for the ownerelement
- The objectpublic boolean remove(org.datanucleus.state.ObjectProvider op, Object element, int size, boolean allowDependentField)
remove
in interface org.datanucleus.store.types.scostore.CollectionStore<E>
op
- ObjectProvider for the ownerelement
- The element to remove.size
- Current size of list if known. -1 if not knownallowDependentField
- Whether to allow any cascade deletes caused by this removalpublic E remove(org.datanucleus.state.ObjectProvider op, int index, int size)
remove
in interface org.datanucleus.store.types.scostore.ListStore<E>
op
- ObjectProviderindex
- The locationsize
- Current size of the list (if known). -1 if not knownprotected abstract boolean internalRemove(org.datanucleus.state.ObjectProvider op, Object element, int size)
op
- ObjectProvider of the ownerelement
- The elementsize
- Current size of list if known. -1 if not knownprotected abstract void internalRemoveAt(org.datanucleus.state.ObjectProvider op, int index, int size)
op
- ObjectProviderindex
- The index of the element to removesize
- Current list size (if known). -1 if not knownpublic List<E> subList(org.datanucleus.state.ObjectProvider op, int startIdx, int endIdx)
subList
in interface org.datanucleus.store.types.scostore.ListStore<E>
op
- ObjectProviderstartIdx
- From index (inclusive).endIdx
- To index (exclusive)protected int[] getIndicesOf(org.datanucleus.state.ObjectProvider op, Collection elements)
op
- ObjectProviderelements
- The elementsprotected int internalIndexOf(org.datanucleus.state.ObjectProvider op, Object element, String stmt)
op
- ObjectProviderelement
- The elementstmt
- The statement to find the element.protected void internalRemoveAt(org.datanucleus.state.ObjectProvider op, int index, String stmt, int size)
op
- ObjectProviderindex
- The locationstmt
- The statement to remove the element from the Listsize
- Current list size (if known). -1 if not knownprotected int[] internalShift(org.datanucleus.state.ObjectProvider op, org.datanucleus.store.connection.ManagedConnection conn, boolean batched, int oldIndex, int amount, boolean executeNow) throws MappedDatastoreException
op
- ObjectProviderconn
- The connectionbatched
- Whether the statement is batchedoldIndex
- The old indexamount
- Amount to shift by (negative means shift down)executeNow
- Whether to execute the statement now (or wait for batching)MappedDatastoreException
- Thrown if an error occursprotected String getIndexOfStmt(Object element)
SELECT INDEXCOL FROM LISTTABLE WHERE OWNERCOL=? AND ELEMENTCOL=? [AND EMBEDDEDFIELD1=? AND EMBEDDEDFIELD2=? AND ...] [AND DISTINGUISHER=?] ORDER BY INDEXCOL
element
- The element to get the index ofprotected String getLastIndexOfStmt(Object element)
SELECT INDEXCOL FROM LISTTABLE WHERE OWNERCOL=? AND ELEMENTCOL=? [AND EMBEDDEDFIELD1=? AND EMBEDDEDFIELD2=? AND ...] [AND DISTINGUISHER=?] ORDER BY INDEXCOL DESC
element
- The element to get index ofprotected String getIndicesOfStmt(Collection elements)
SELECT INDEXCOL FROM LISTTABLE WHERE (OWNERCOL=? AND ELEMENT_COL=? [AND DISTINGUISHER=?]) OR (OWNERCOL=? AND ELEMENT_COL=? [AND DISTINGUISHER=?]) OR (OWNERCOL=? AND ELEMENT_COL=? [AND DISTINGUISHER=?]) ORDER BY INDEXCOL DESC
elements
- The elements to retrieve the indices for.protected String getRemoveAtStmt()
DELETE FROM LISTTABLE WHERE OWNERCOL = ? AND INDEXCOL = ? [AND DISTINGUISHER=?]
protected String getShiftStmt()
UPDATE LISTTABLE SET INDEXCOL = ? + INDEXCOL WHERE OWNERCOL = ? AND INDEXCOL = ? [AND DISTINGUISHER=?]
Copyright © 2020. All rights reserved.