Methods Summary |
---|
public boolean | add(java.lang.Object object)
if ( !isOperationQueueEnabled() ) {
write();
return bag.add(object);
}
else {
queueOperation( new SimpleAdd(object) );
return true;
}
|
public void | add(int i, java.lang.Object o)
write();
bag.add(i, o);
|
public boolean | addAll(java.util.Collection values)
if ( values.size()==0 ) return false;
if ( !isOperationQueueEnabled() ) {
write();
return bag.addAll(values);
}
else {
Iterator iter = values.iterator();
while ( iter.hasNext() ) {
queueOperation( new SimpleAdd( iter.next() ) );
}
return values.size()>0;
}
|
public boolean | addAll(int i, java.util.Collection c)
if ( c.size()>0 ) {
write();
return bag.addAll(i, c);
}
else {
return false;
}
|
public void | beforeInitialize(org.hibernate.persister.collection.CollectionPersister persister, int anticipatedSize)
this.bag = ( List ) persister.getCollectionType().instantiate( anticipatedSize );
|
public void | clear()
if ( isClearQueueEnabled() ) {
queueOperation( new Clear() );
}
else {
initialize( true );
if ( ! bag.isEmpty() ) {
bag.clear();
dirty();
}
}
|
public boolean | contains(java.lang.Object object)
Boolean exists = readElementExistence(object);
return exists==null ?
bag.contains(object) :
exists.booleanValue();
|
public boolean | containsAll(java.util.Collection c)
read();
return bag.containsAll(c);
|
private int | countOccurrences(java.lang.Object element, java.util.List list, org.hibernate.type.Type elementType, org.hibernate.EntityMode entityMode)
Iterator iter = list.iterator();
int result=0;
while ( iter.hasNext() ) {
if ( elementType.isSame( element, iter.next(), entityMode ) ) result++;
}
return result;
|
public java.io.Serializable | disassemble(org.hibernate.persister.collection.CollectionPersister persister)
int length = bag.size();
Serializable[] result = new Serializable[length];
for ( int i=0; i<length; i++ ) {
result[i] = persister.getElementType().disassemble( bag.get(i), getSession(), null );
}
return result;
|
public boolean | empty()
return bag.isEmpty();
|
public java.util.Iterator | entries(org.hibernate.persister.collection.CollectionPersister persister)
return bag.iterator();
|
public boolean | entryExists(java.lang.Object entry, int i)
return entry!=null;
|
public boolean | equals(java.lang.Object obj)Bag does not respect the collection API and do an
JVM instance comparison to do the equals.
The semantic is broken not to have to initialize a
collection for a simple equals() operation.
return super.equals(obj);
|
public boolean | equalsSnapshot(org.hibernate.persister.collection.CollectionPersister persister)
Type elementType = persister.getElementType();
EntityMode entityMode = getSession().getEntityMode();
List sn = (List) getSnapshot();
if ( sn.size()!=bag.size() ) return false;
Iterator iter = bag.iterator();
while ( iter.hasNext() ) {
Object elt = iter.next();
final boolean unequal = countOccurrences(elt, bag, elementType, entityMode) !=
countOccurrences(elt, sn, elementType, entityMode);
if ( unequal ) return false;
}
return true;
|
public java.lang.Object | get(int i)
read();
return bag.get(i);
|
public java.util.Iterator | getDeletes(org.hibernate.persister.collection.CollectionPersister persister, boolean indexIsFormula)
//if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
Type elementType = persister.getElementType();
EntityMode entityMode = getSession().getEntityMode();
ArrayList deletes = new ArrayList();
List sn = (List) getSnapshot();
Iterator olditer = sn.iterator();
int i=0;
while ( olditer.hasNext() ) {
Object old = olditer.next();
Iterator newiter = bag.iterator();
boolean found = false;
if ( bag.size()>i && elementType.isSame( old, bag.get(i++), entityMode ) ) {
//a shortcut if its location didn't change!
found = true;
}
else {
//search for it
//note that this code is incorrect for other than one-to-many
while ( newiter.hasNext() ) {
if ( elementType.isSame( old, newiter.next(), entityMode ) ) {
found = true;
break;
}
}
}
if (!found) deletes.add(old);
}
return deletes.iterator();
|
public java.lang.Object | getElement(java.lang.Object entry)
return entry;
|
public java.lang.Object | getIndex(java.lang.Object entry, int i, org.hibernate.persister.collection.CollectionPersister persister)
throw new UnsupportedOperationException("Bags don't have indexes");
|
public java.util.Collection | getOrphans(java.io.Serializable snapshot, java.lang.String entityName)
List sn = (List) snapshot;
return getOrphans( sn, bag, entityName, getSession() );
|
public java.io.Serializable | getSnapshot(org.hibernate.persister.collection.CollectionPersister persister)
EntityMode entityMode = getSession().getEntityMode();
ArrayList clonedList = new ArrayList( bag.size() );
Iterator iter = bag.iterator();
while ( iter.hasNext() ) {
clonedList.add( persister.getElementType().deepCopy( iter.next(), entityMode, persister.getFactory() ) );
}
return clonedList;
|
public java.lang.Object | getSnapshotElement(java.lang.Object entry, int i)
List sn = (List) getSnapshot();
return sn.get(i);
|
public int | hashCode()
return super.hashCode();
|
public int | indexOf(java.lang.Object o)
read();
return bag.indexOf(o);
|
public void | initializeFromCache(org.hibernate.persister.collection.CollectionPersister persister, java.io.Serializable disassembled, java.lang.Object owner)
Serializable[] array = (Serializable[]) disassembled;
int size = array.length;
beforeInitialize( persister, size );
for ( int i = 0; i < size; i++ ) {
Object element = persister.getElementType().assemble( array[i], getSession(), owner );
if ( element!=null ) {
bag.add( element );
}
}
|
public boolean | isEmpty()
return readSize() ? getCachedSize()==0 : bag.isEmpty();
|
public boolean | isRowUpdatePossible()
return false;
|
public boolean | isSnapshotEmpty(java.io.Serializable snapshot)
return ( (Collection) snapshot ).isEmpty();
|
public boolean | isWrapper(java.lang.Object collection)
return bag==collection;
|
public java.util.Iterator | iterator()
read();
return new IteratorProxy( bag.iterator() );
|
public int | lastIndexOf(java.lang.Object o)
read();
return bag.lastIndexOf(o);
|
public java.util.ListIterator | listIterator()
read();
return new ListIteratorProxy( bag.listIterator() );
|
public java.util.ListIterator | listIterator(int i)
read();
return new ListIteratorProxy( bag.listIterator(i) );
|
public boolean | needsInserting(java.lang.Object entry, int i, org.hibernate.type.Type elemType)
//if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
List sn = (List) getSnapshot();
final EntityMode entityMode = getSession().getEntityMode();
if ( sn.size()>i && elemType.isSame( sn.get(i), entry, entityMode ) ) {
//a shortcut if its location didn't change!
return false;
}
else {
//search for it
//note that this code is incorrect for other than one-to-many
Iterator olditer = sn.iterator();
while ( olditer.hasNext() ) {
Object old = olditer.next();
if ( elemType.isSame( old, entry, entityMode ) ) return false;
}
return true;
}
|
public boolean | needsRecreate(org.hibernate.persister.collection.CollectionPersister persister)
return !persister.isOneToMany();
|
public boolean | needsUpdating(java.lang.Object entry, int i, org.hibernate.type.Type elemType)
//if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
return false;
|
public int | occurrences(java.lang.Object o)
read();
Iterator iter = bag.iterator();
int result=0;
while ( iter.hasNext() ) {
if ( o.equals( iter.next() ) ) result++;
}
return result;
|
public java.lang.Object | readFrom(java.sql.ResultSet rs, org.hibernate.persister.collection.CollectionPersister persister, org.hibernate.loader.CollectionAliases descriptor, java.lang.Object owner)
// note that if we load this collection from a cartesian product
// the multiplicity would be broken ... so use an idbag instead
Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
if (element!=null) bag.add(element);
return element;
|
public boolean | remove(java.lang.Object o)
initialize( true );
if ( bag.remove( o ) ) {
dirty();
return true;
}
else {
return false;
}
|
public java.lang.Object | remove(int i)
write();
return bag.remove(i);
|
public boolean | removeAll(java.util.Collection c)
if ( c.size()>0 ) {
initialize( true );
if ( bag.removeAll( c ) ) {
dirty();
return true;
}
else {
return false;
}
}
else {
return false;
}
|
public boolean | retainAll(java.util.Collection c)
initialize( true );
if ( bag.retainAll( c ) ) {
dirty();
return true;
}
else {
return false;
}
|
public java.lang.Object | set(int i, java.lang.Object o)
write();
return bag.set(i, o);
|
public int | size()
return readSize() ? getCachedSize() : bag.size();
|
public java.util.List | subList(int start, int end)
read();
return new ListProxy( bag.subList(start, end) );
|
public java.lang.Object[] | toArray()
read();
return bag.toArray();
|
public java.lang.Object[] | toArray(java.lang.Object[] a)
read();
return bag.toArray(a);
|
public java.lang.String | toString()
read();
return bag.toString();
|