| Method from org.hibernate.collection.PersistentList Detail: |
public boolean add(Object object) {
if ( !isOperationQueueEnabled() ) {
write();
return list.add(object);
}
else {
queueOperation( new SimpleAdd(object) );
return true;
}
}
|
public void add(int index,
Object value) {
if (index< 0) {
throw new ArrayIndexOutOfBoundsException("negative index");
}
if ( !isOperationQueueEnabled() ) {
write();
list.add(index, value);
}
else {
queueOperation( new Add(index, value) );
}
}
|
public boolean addAll(Collection values) {
if ( values.size()==0 ) {
return false;
}
if ( !isOperationQueueEnabled() ) {
write();
return list.addAll(values);
}
else {
Iterator iter = values.iterator();
while ( iter.hasNext() ) {
queueOperation( new SimpleAdd( iter.next() ) );
}
return values.size() >0;
}
}
|
public boolean addAll(int index,
Collection coll) {
if ( coll.size() >0 ) {
write();
return list.addAll(index, coll);
}
else {
return false;
}
}
|
public void beforeInitialize(CollectionPersister persister,
int anticipatedSize) {
this.list = ( List ) persister.getCollectionType().instantiate( anticipatedSize );
}
|
public void clear() {
if ( isClearQueueEnabled() ) {
queueOperation( new Clear() );
}
else {
initialize( true );
if ( ! list.isEmpty() ) {
list.clear();
dirty();
}
}
}
|
public boolean contains(Object object) {
Boolean exists = readElementExistence(object);
return exists==null ?
list.contains(object) :
exists.booleanValue();
}
|
public boolean containsAll(Collection coll) {
read();
return list.containsAll(coll);
}
|
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
int length = list.size();
Serializable[] result = new Serializable[length];
for ( int i=0; i< length; i++ ) {
result[i] = persister.getElementType().disassemble( list.get(i), getSession(), null );
}
return result;
}
|
public boolean empty() {
return list.isEmpty();
}
|
public Iterator entries(CollectionPersister persister) {
return list.iterator();
}
|
public boolean entryExists(Object entry,
int i) {
return entry!=null;
}
|
public boolean equals(Object other) {
read();
return list.equals(other);
}
|
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
Type elementType = persister.getElementType();
List sn = (List) getSnapshot();
if ( sn.size()!=this.list.size() ) return false;
Iterator iter = list.iterator();
Iterator sniter = sn.iterator();
while ( iter.hasNext() ) {
if ( elementType.isDirty( iter.next(), sniter.next(), getSession() ) ) return false;
}
return true;
}
|
public Object get(int index) {
if (index< 0) {
throw new ArrayIndexOutOfBoundsException("negative index");
}
Object result = readElementByIndex( new Integer(index) );
return result==UNKNOWN ? list.get(index) : result;
}
|
public Iterator getDeletes(CollectionPersister persister,
boolean indexIsFormula) throws HibernateException {
List deletes = new ArrayList();
List sn = (List) getSnapshot();
int end;
if ( sn.size() > list.size() ) {
for ( int i=list.size(); i< sn.size(); i++ ) {
deletes.add( indexIsFormula ? sn.get(i) : new Integer(i) );
}
end = list.size();
}
else {
end = sn.size();
}
for ( int i=0; i< end; i++ ) {
if ( list.get(i)==null && sn.get(i)!=null ) {
deletes.add( indexIsFormula ? sn.get(i) : new Integer(i) );
}
}
return deletes.iterator();
}
|
public Object getElement(Object entry) {
return entry;
}
|
public Object getIndex(Object entry,
int i,
CollectionPersister persister) {
return new Integer(i);
}
|
public Collection getOrphans(Serializable snapshot,
String entityName) throws HibernateException {
List sn = (List) snapshot;
return getOrphans( sn, list, entityName, getSession() );
}
|
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
EntityMode entityMode = getSession().getEntityMode();
ArrayList clonedList = new ArrayList( list.size() );
Iterator iter = list.iterator();
while ( iter.hasNext() ) {
Object deepCopy = persister.getElementType()
.deepCopy( iter.next(), entityMode, persister.getFactory() );
clonedList.add( deepCopy );
}
return clonedList;
}
|
public Object getSnapshotElement(Object entry,
int i) {
final List sn = (List) getSnapshot();
return sn.get(i);
}
|
public int hashCode() {
read();
return list.hashCode();
}
|
public int indexOf(Object value) {
read();
return list.indexOf(value);
}
|
public void initializeFromCache(CollectionPersister persister,
Serializable disassembled,
Object owner) throws HibernateException {
Serializable[] array = ( Serializable[] ) disassembled;
int size = array.length;
beforeInitialize( persister, size );
for ( int i = 0; i < size; i++ ) {
list.add( persister.getElementType().assemble( array[i], getSession(), owner ) );
}
}
|
public boolean isEmpty() {
return readSize() ? getCachedSize()==0 : list.isEmpty();
}
|
public boolean isSnapshotEmpty(Serializable snapshot) {
return ( (Collection) snapshot ).isEmpty();
}
|
public boolean isWrapper(Object collection) {
return list==collection;
}
|
public Iterator iterator() {
read();
return new IteratorProxy( list.iterator() );
}
|
public int lastIndexOf(Object value) {
read();
return list.lastIndexOf(value);
}
|
public ListIterator listIterator() {
read();
return new ListIteratorProxy( list.listIterator() );
}
|
public ListIterator listIterator(int index) {
read();
return new ListIteratorProxy( list.listIterator(index) );
}
|
public boolean needsInserting(Object entry,
int i,
Type elemType) throws HibernateException {
final List sn = (List) getSnapshot();
return list.get(i)!=null && ( i >= sn.size() || sn.get(i)==null );
}
|
public boolean needsUpdating(Object entry,
int i,
Type elemType) throws HibernateException {
final List sn = (List) getSnapshot();
return i< sn.size() && sn.get(i)!=null && list.get(i)!=null &&
elemType.isDirty( list.get(i), sn.get(i), getSession() );
}
|
public Object readFrom(ResultSet rs,
CollectionPersister persister,
CollectionAliases descriptor,
Object owner) throws HibernateException, SQLException {
Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
//pad with nulls from the current last element up to the new index
for ( int i = list.size(); i< =index; i++) {
list.add(i, null);
}
list.set(index, element);
return element;
}
|
public boolean remove(Object value) {
Boolean exists = isPutQueueEnabled() ? readElementExistence(value) : null;
if ( exists == null ) {
initialize( true );
if ( list.remove( value ) ) {
dirty();
return true;
}
else {
return false;
}
}
else if ( exists.booleanValue() ) {
queueOperation( new SimpleRemove(value) );
return true;
}
else {
return false;
}
}
|
public Object remove(int index) {
if (index< 0) {
throw new ArrayIndexOutOfBoundsException("negative index");
}
Object old = isPutQueueEnabled() ?
readElementByIndex( new Integer(index) ) : UNKNOWN;
if ( old==UNKNOWN ) {
write();
return list.remove(index);
}
else {
queueOperation( new Remove(index, old) );
return old;
}
}
|
public boolean removeAll(Collection coll) {
if ( coll.size() >0 ) {
initialize( true );
if ( list.removeAll( coll ) ) {
dirty();
return true;
}
else {
return false;
}
}
else {
return false;
}
}
|
public boolean retainAll(Collection coll) {
initialize( true );
if ( list.retainAll( coll ) ) {
dirty();
return true;
}
else {
return false;
}
}
|
public Object set(int index,
Object value) {
if (index< 0) {
throw new ArrayIndexOutOfBoundsException("negative index");
}
Object old = isPutQueueEnabled() ? readElementByIndex( new Integer(index) ) : UNKNOWN;
if ( old==UNKNOWN ) {
write();
return list.set(index, value);
}
else {
queueOperation( new Set(index, value, old) );
return old;
}
}
|
public int size() {
return readSize() ? getCachedSize() : list.size();
}
|
public List subList(int from,
int to) {
read();
return new ListProxy( list.subList(from, to) );
}
|
public Object[] toArray() {
read();
return list.toArray();
}
|
public Object[] toArray(Object[] array) {
read();
return list.toArray(array);
}
|
public String toString() {
read();
return list.toString();
}
|