Methods Summary |
---|
public void | add(int index, java.lang.Object element)
write();
beforeAdd(index);
values.add(index, element);
|
public boolean | add(java.lang.Object o)
write();
values.add(o);
return true;
|
public boolean | addAll(int index, java.util.Collection c)
if ( c.size() > 0 ) {
Iterator iter = c.iterator();
while ( iter.hasNext() ) {
add( index++, iter.next() );
}
return true;
}
else {
return false;
}
|
public boolean | addAll(java.util.Collection c)
if ( c.size()> 0 ) {
write();
return values.addAll(c);
}
else {
return false;
}
|
public void | afterRowInsert(org.hibernate.persister.collection.CollectionPersister persister, java.lang.Object entry, int i)
//TODO: if we are using identity columns, fetch the identifier
|
private void | beforeAdd(int index)
for ( int i=index; i<values.size(); i++ ) {
identifiers.put( new Integer(i+1), identifiers.get( new Integer(i) ) );
}
identifiers.remove( new Integer(index) );
|
public void | beforeInitialize(org.hibernate.persister.collection.CollectionPersister persister, int anticipatedSize)
identifiers = anticipatedSize <= 0 ? new HashMap() : new HashMap( anticipatedSize + 1 + (int)( anticipatedSize * .75f ), .75f );
values = anticipatedSize <= 0 ? new ArrayList() : new ArrayList( anticipatedSize );
|
private void | beforeRemove(int index)
Object removedId = identifiers.get( new Integer(index) );
int last = values.size()-1;
for ( int i=index; i<last; i++ ) {
Object id = identifiers.get( new Integer(i+1) );
if ( id==null ) {
identifiers.remove( new Integer(i) );
}
else {
identifiers.put( new Integer(i), id );
}
}
identifiers.put( new Integer(last), removedId );
|
public void | clear()
initialize( true );
if ( ! values.isEmpty() || ! identifiers.isEmpty() ) {
values.clear();
identifiers.clear();
dirty();
}
|
public boolean | contains(java.lang.Object o)
read();
return values.contains(o);
|
public boolean | containsAll(java.util.Collection c)
read();
return values.containsAll(c);
|
public java.io.Serializable | disassemble(org.hibernate.persister.collection.CollectionPersister persister)
Serializable[] result = new Serializable[ values.size() * 2 ];
int i=0;
for (int j=0; j< values.size(); j++) {
Object value = values.get(j);
result[i++] = persister.getIdentifierType().disassemble( identifiers.get( new Integer(j) ), getSession(), null );
result[i++] = persister.getElementType().disassemble( value, getSession(), null );
}
return result;
|
public boolean | empty()
return values.isEmpty();
|
public java.util.Iterator | entries(org.hibernate.persister.collection.CollectionPersister persister)
return values.iterator();
|
public boolean | entryExists(java.lang.Object entry, int i)
return entry!=null;
|
public boolean | equalsSnapshot(org.hibernate.persister.collection.CollectionPersister persister)
Type elementType = persister.getElementType();
Map snap = (Map) getSnapshot();
if ( snap.size()!= values.size() ) return false;
for ( int i=0; i<values.size(); i++ ) {
Object value = values.get(i);
Object id = identifiers.get( new Integer(i) );
if (id==null) return false;
Object old = snap.get(id);
if ( elementType.isDirty( old, value, getSession() ) ) return false;
}
return true;
|
public java.lang.Object | get(int index)
read();
return values.get(index);
|
public java.util.Iterator | getDeletes(org.hibernate.persister.collection.CollectionPersister persister, boolean indexIsFormula)
Map snap = (Map) getSnapshot();
List deletes = new ArrayList( snap.keySet() );
for ( int i=0; i<values.size(); i++ ) {
if ( values.get(i)!=null ) deletes.remove( identifiers.get( new Integer(i) ) );
}
return deletes.iterator();
|
public java.lang.Object | getElement(java.lang.Object entry)
return entry;
|
public java.lang.Object | getIdentifier(java.lang.Object entry, int i)
return identifiers.get( new Integer(i) );
|
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)
Map sn = (Map) snapshot;
return getOrphans( sn.values(), values, entityName, getSession() );
|
public java.io.Serializable | getSnapshot(org.hibernate.persister.collection.CollectionPersister persister)
EntityMode entityMode = getSession().getEntityMode();
HashMap map = new HashMap( values.size() );
Iterator iter = values.iterator();
int i=0;
while ( iter.hasNext() ) {
Object value = iter.next();
map.put(
identifiers.get( new Integer(i++) ),
persister.getElementType().deepCopy(value, entityMode, persister.getFactory())
);
}
return map;
|
public java.lang.Object | getSnapshotElement(java.lang.Object entry, int i)
Map snap = (Map) getSnapshot();
Object id = identifiers.get( new Integer(i) );
return snap.get(id);
|
public int | indexOf(java.lang.Object o)
read();
return values.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+=2 ) {
identifiers.put(
new Integer(i/2),
persister.getIdentifierType().assemble( array[i], getSession(), owner )
);
values.add( persister.getElementType().assemble( array[i+1], getSession(), owner ) );
}
|
public boolean | isEmpty()
return readSize() ? getCachedSize()==0 : values.isEmpty();
|
public boolean | isSnapshotEmpty(java.io.Serializable snapshot)
return ( (Map) snapshot ).isEmpty();
|
public boolean | isWrapper(java.lang.Object collection)
return values==collection;
|
public java.util.Iterator | iterator()
read();
return new IteratorProxy( values.iterator() );
|
public int | lastIndexOf(java.lang.Object o)
read();
return values.lastIndexOf(o);
|
public java.util.ListIterator | listIterator()
read();
return new ListIteratorProxy( values.listIterator() );
|
public java.util.ListIterator | listIterator(int index)
read();
return new ListIteratorProxy( values.listIterator(index) );
|
public boolean | needsInserting(java.lang.Object entry, int i, org.hibernate.type.Type elemType)
Map snap = (Map) getSnapshot();
Object id = identifiers.get( new Integer(i) );
return entry!=null && ( id==null || snap.get(id)==null );
|
public boolean | needsUpdating(java.lang.Object entry, int i, org.hibernate.type.Type elemType)
if (entry==null) return false;
Map snap = (Map) getSnapshot();
Object id = identifiers.get( new Integer(i) );
if (id==null) return false;
Object old = snap.get(id);
return old!=null && elemType.isDirty( old, entry, getSession() );
|
public void | preInsert(org.hibernate.persister.collection.CollectionPersister persister)
Iterator iter = values.iterator();
int i=0;
while ( iter.hasNext() ) {
Object entry = iter.next();
Integer loc = new Integer(i++);
if ( !identifiers.containsKey(loc) ) { //TODO: native ids
Serializable id = persister.getIdentifierGenerator().generate( getSession(), entry );
identifiers.put(loc, id);
}
}
|
public java.lang.Object | readFrom(java.sql.ResultSet rs, org.hibernate.persister.collection.CollectionPersister persister, org.hibernate.loader.CollectionAliases descriptor, java.lang.Object owner)
Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
Object old = identifiers.put(
new Integer( values.size() ),
persister.readIdentifier( rs, descriptor.getSuffixedIdentifierAlias(), getSession() )
);
if ( old==null ) values.add(element); //maintain correct duplication if loaded in a cartesian product
return element;
|
public boolean | remove(java.lang.Object o)
initialize( true );
int index = values.indexOf(o);
if (index>=0) {
beforeRemove(index);
values.remove(index);
dirty();
return true;
}
else {
return false;
}
|
public java.lang.Object | remove(int index)
write();
beforeRemove(index);
return values.remove(index);
|
public boolean | removeAll(java.util.Collection c)
if ( c.size() > 0 ) {
boolean result = false;
Iterator iter = c.iterator();
while ( iter.hasNext() ) {
if ( remove( iter.next() ) ) result=true;
}
return result;
}
else {
return false;
}
|
public boolean | retainAll(java.util.Collection c)
initialize( true );
if ( values.retainAll( c ) ) {
dirty();
return true;
}
else {
return false;
}
|
public java.lang.Object | set(int index, java.lang.Object element)
write();
return values.set(index, element);
|
public int | size()
return readSize() ? getCachedSize() : values.size();
|
public java.util.List | subList(int fromIndex, int toIndex)
read();
return new ListProxy( values.subList(fromIndex, toIndex) );
|
public java.lang.Object[] | toArray()
read();
return values.toArray();
|
public java.lang.Object[] | toArray(java.lang.Object[] a)
read();
return values.toArray(a);
|