org.hibernate.collection
Class PersistentList

java.lang.Object
  extended by org.hibernate.collection.AbstractPersistentCollection
      extended by org.hibernate.collection.PersistentList
All Implemented Interfaces:
Serializable, Iterable, Collection, List, PersistentCollection

public class PersistentList
extends AbstractPersistentCollection
implements List

A persistent wrapper for a java.util.List. Underlying collection is an ArrayList.

Author:
Gavin King
See Also:
ArrayList, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.hibernate.collection.AbstractPersistentCollection
AbstractPersistentCollection.DelayedOperation
 
Field Summary
protected  List list
           
 
Fields inherited from class org.hibernate.collection.AbstractPersistentCollection
UNKNOWN
 
Constructor Summary
PersistentList()
           
PersistentList(SessionImplementor session)
           
PersistentList(SessionImplementor session, List list)
           
 
Method Summary
 void add(int index, Object value)
           
 boolean add(Object object)
           
 boolean addAll(Collection values)
           
 boolean addAll(int index, Collection coll)
           
 void beforeInitialize(CollectionPersister persister, int anticipatedSize)
          Called before any elements are read into the collection, allowing appropriate initializations to occur.
 void clear()
           
 boolean contains(Object object)
           
 boolean containsAll(Collection coll)
           
 Serializable disassemble(CollectionPersister persister)
          Disassemble the collection, ready for the cache
 boolean empty()
          Is the initialized collection empty?
 Iterator entries(CollectionPersister persister)
          Iterate all collection entries, during update of the database
 boolean entryExists(Object entry, int i)
          Does an element exist at this entry in the collection?
 boolean equals(Object other)
           
 boolean equalsSnapshot(CollectionPersister persister)
          Does the current state exactly match the snapshot?
 Object get(int index)
           
 Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
          Get all the elements that need deleting
 Object getElement(Object entry)
          Get the value of the given collection entry
 Object getIndex(Object entry, int i, CollectionPersister persister)
          Get the index of the given collection entry
 Collection getOrphans(Serializable snapshot, String entityName)
          get all "orphaned" elements
 Serializable getSnapshot(CollectionPersister persister)
          Return a new snapshot of the current state of the collection
 Object getSnapshotElement(Object entry, int i)
          Get the snapshot value of the given collection entry
 int hashCode()
           
 int indexOf(Object value)
           
 void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
          Read the state of the collection from a disassembled cached value
 boolean isEmpty()
           
 boolean isSnapshotEmpty(Serializable snapshot)
          Is the snapshot empty?
 boolean isWrapper(Object collection)
          Is this the wrapper for the given underlying collection instance?
 Iterator iterator()
           
 int lastIndexOf(Object value)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 boolean needsInserting(Object entry, int i, Type elemType)
          Do we need to insert this element?
 boolean needsUpdating(Object entry, int i, Type elemType)
          Do we need to update this element?
 Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
          Read a row from the JDBC result set
 Object remove(int index)
           
 boolean remove(Object value)
           
 boolean removeAll(Collection coll)
           
 boolean retainAll(Collection coll)
           
 Object set(int index, Object value)
           
 int size()
           
 List subList(int from, int to)
           
 Object[] toArray()
           
 Object[] toArray(Object[] array)
           
 String toString()
           
 
Methods inherited from class org.hibernate.collection.AbstractPersistentCollection
afterInitialize, afterRowInsert, beginRead, clearDirty, dirty, endRead, forceInitialization, getCachedSize, getIdentifier, getKey, getOrphans, getOwner, getQueuedOrphans, getRole, getSession, getSnapshot, getStoredSnapshot, getValue, hasQueuedOperations, initialize, isClearQueueEnabled, isDirectlyAccessible, isDirty, isOperationQueueEnabled, isPutQueueEnabled, isRowUpdatePossible, isUnreferenced, needsRecreate, performQueuedOperations, postAction, preInsert, queuedAdditionIterator, queueOperation, read, readElementByIndex, readElementExistence, readIndexExistence, readSize, setCurrentSession, setDirectlyAccessible, setInitialized, setOwner, setSnapshot, unsetSession, wasInitialized, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

list

protected List list
Constructor Detail

PersistentList

public PersistentList(SessionImplementor session)

PersistentList

public PersistentList(SessionImplementor session,
                      List list)

PersistentList

public PersistentList()
Method Detail

getSnapshot

public Serializable getSnapshot(CollectionPersister persister)
                         throws HibernateException
Description copied from interface: PersistentCollection
Return a new snapshot of the current state of the collection

Specified by:
getSnapshot in interface PersistentCollection
Throws:
HibernateException

getOrphans

public Collection getOrphans(Serializable snapshot,
                             String entityName)
                      throws HibernateException
Description copied from class: AbstractPersistentCollection
get all "orphaned" elements

Specified by:
getOrphans in interface PersistentCollection
Specified by:
getOrphans in class AbstractPersistentCollection
Throws:
HibernateException

equalsSnapshot

public boolean equalsSnapshot(CollectionPersister persister)
                       throws HibernateException
Description copied from interface: PersistentCollection
Does the current state exactly match the snapshot?

Specified by:
equalsSnapshot in interface PersistentCollection
Throws:
HibernateException

isSnapshotEmpty

public boolean isSnapshotEmpty(Serializable snapshot)
Description copied from interface: PersistentCollection
Is the snapshot empty?

Specified by:
isSnapshotEmpty in interface PersistentCollection

beforeInitialize

public void beforeInitialize(CollectionPersister persister,
                             int anticipatedSize)
Description copied from interface: PersistentCollection
Called before any elements are read into the collection, allowing appropriate initializations to occur.

Specified by:
beforeInitialize in interface PersistentCollection
Parameters:
persister - The underlying collection persister.
anticipatedSize - The anticipated size of the collection after initilization is complete.

isWrapper

public boolean isWrapper(Object collection)
Description copied from interface: PersistentCollection
Is this the wrapper for the given underlying collection instance?

Specified by:
isWrapper in interface PersistentCollection

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface List
See Also:
List.size()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List
See Also:
List.isEmpty()

contains

public boolean contains(Object object)
Specified by:
contains in interface Collection
Specified by:
contains in interface List
See Also:
List.contains(Object)

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List
See Also:
List.iterator()

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
See Also:
List.toArray()

toArray

public Object[] toArray(Object[] array)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
See Also:
List.toArray(Object[])

add

public boolean add(Object object)
Specified by:
add in interface Collection
Specified by:
add in interface List
See Also:
List.add(Object)

remove

public boolean remove(Object value)
Specified by:
remove in interface Collection
Specified by:
remove in interface List
See Also:
List.remove(Object)

containsAll

public boolean containsAll(Collection coll)
Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List
See Also:
List.containsAll(Collection)

addAll

public boolean addAll(Collection values)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface List
See Also:
List.addAll(Collection)

addAll

public boolean addAll(int index,
                      Collection coll)
Specified by:
addAll in interface List
See Also:
List.addAll(int, Collection)

removeAll

public boolean removeAll(Collection coll)
Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface List
See Also:
List.removeAll(Collection)

retainAll

public boolean retainAll(Collection coll)
Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface List
See Also:
List.retainAll(Collection)

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface List
See Also:
List.clear()

get

public Object get(int index)
Specified by:
get in interface List
See Also:
List.get(int)

set

public Object set(int index,
                  Object value)
Specified by:
set in interface List
See Also:
List.set(int, Object)

add

public void add(int index,
                Object value)
Specified by:
add in interface List
See Also:
List.add(int, Object)

remove

public Object remove(int index)
Specified by:
remove in interface List
See Also:
List.remove(int)

indexOf

public int indexOf(Object value)
Specified by:
indexOf in interface List
See Also:
List.indexOf(Object)

lastIndexOf

public int lastIndexOf(Object value)
Specified by:
lastIndexOf in interface List
See Also:
List.lastIndexOf(Object)

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List
See Also:
List.listIterator()

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List
See Also:
List.listIterator(int)

subList

public List subList(int from,
                    int to)
Specified by:
subList in interface List
See Also:
List.subList(int, int)

empty

public boolean empty()
Description copied from class: AbstractPersistentCollection
Is the initialized collection empty?

Specified by:
empty in interface PersistentCollection
Specified by:
empty in class AbstractPersistentCollection

toString

public String toString()
Overrides:
toString in class Object

readFrom

public Object readFrom(ResultSet rs,
                       CollectionPersister persister,
                       CollectionAliases descriptor,
                       Object owner)
                throws HibernateException,
                       SQLException
Description copied from interface: PersistentCollection
Read a row from the JDBC result set

Specified by:
readFrom in interface PersistentCollection
Throws:
HibernateException
SQLException

entries

public Iterator entries(CollectionPersister persister)
Description copied from interface: PersistentCollection
Iterate all collection entries, during update of the database

Specified by:
entries in interface PersistentCollection

initializeFromCache

public void initializeFromCache(CollectionPersister persister,
                                Serializable disassembled,
                                Object owner)
                         throws HibernateException
Description copied from interface: PersistentCollection
Read the state of the collection from a disassembled cached value

Specified by:
initializeFromCache in interface PersistentCollection
Throws:
HibernateException

disassemble

public Serializable disassemble(CollectionPersister persister)
                         throws HibernateException
Description copied from interface: PersistentCollection
Disassemble the collection, ready for the cache

Specified by:
disassemble in interface PersistentCollection
Throws:
HibernateException

getDeletes

public Iterator getDeletes(CollectionPersister persister,
                           boolean indexIsFormula)
                    throws HibernateException
Description copied from interface: PersistentCollection
Get all the elements that need deleting

Specified by:
getDeletes in interface PersistentCollection
Throws:
HibernateException

needsInserting

public boolean needsInserting(Object entry,
                              int i,
                              Type elemType)
                       throws HibernateException
Description copied from interface: PersistentCollection
Do we need to insert this element?

Specified by:
needsInserting in interface PersistentCollection
Throws:
HibernateException

needsUpdating

public boolean needsUpdating(Object entry,
                             int i,
                             Type elemType)
                      throws HibernateException
Description copied from interface: PersistentCollection
Do we need to update this element?

Specified by:
needsUpdating in interface PersistentCollection
Throws:
HibernateException

getIndex

public Object getIndex(Object entry,
                       int i,
                       CollectionPersister persister)
Description copied from interface: PersistentCollection
Get the index of the given collection entry

Specified by:
getIndex in interface PersistentCollection
persister - it was more elegant before we added this...

getElement

public Object getElement(Object entry)
Description copied from interface: PersistentCollection
Get the value of the given collection entry

Specified by:
getElement in interface PersistentCollection

getSnapshotElement

public Object getSnapshotElement(Object entry,
                                 int i)
Description copied from interface: PersistentCollection
Get the snapshot value of the given collection entry

Specified by:
getSnapshotElement in interface PersistentCollection

equals

public boolean equals(Object other)
Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class Object

entryExists

public boolean entryExists(Object entry,
                           int i)
Description copied from interface: PersistentCollection
Does an element exist at this entry in the collection?

Specified by:
entryExists in interface PersistentCollection


Copyright © 2009 Hibernate.org. All Rights Reserved.