Methods Summary |
---|
public void | beforeInitialize(org.hibernate.persister.collection.CollectionPersister persister, int anticipatedSize)
|
public boolean | empty()
return !element.elementIterator().hasNext();
|
public java.util.Iterator | entries(org.hibernate.persister.collection.CollectionPersister persister)
final Type elementType = persister.getElementType();
String indexNode = getIndexAttributeName(persister);
List elements = element.elements( persister.getElementNodeName() );
int length = elements.size();
List result = new ArrayList(length);
for ( int i=0; i<length; i++ ) {
Element elem = (Element) elements.get(i);
Object object = elementType.fromXMLNode( elem, persister.getFactory() );
result.add( new IndexedValue( getIndex(elem, indexNode, i), object ) );
}
return result.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();
String indexNode = getIndexAttributeName(persister);
HashMap snapshot = (HashMap) getSnapshot();
List elements = element.elements( persister.getElementNodeName() );
if ( snapshot.size()!= elements.size() ) return false;
for ( int i=0; i<snapshot.size(); i++ ) {
Element elem = (Element) elements.get(i);
Object old = snapshot.get( getIndex(elem, indexNode, i) );
Object current = elementType.fromXMLNode( elem, persister.getFactory() );
if ( elementType.isDirty( old, current, getSession() ) ) return false;
}
return true;
|
public java.util.Iterator | getDeletes(org.hibernate.persister.collection.CollectionPersister persister, boolean indexIsFormula)
final Type indexType = persister.getIndexType();
HashMap snapshot = (HashMap) getSnapshot();
HashMap deletes = (HashMap) snapshot.clone();
deletes.keySet().removeAll( ( (HashMap) getSnapshot(persister) ).keySet() );
ArrayList deleteList = new ArrayList( deletes.size() );
Iterator iter = deletes.entrySet().iterator();
while ( iter.hasNext() ) {
Map.Entry me = (Map.Entry) iter.next();
final Object object = indexIsFormula ?
me.getValue() :
( (NullableType) indexType ).fromXMLString( (String) me.getKey(), persister.getFactory() );
if (object!=null) deleteList.add(object);
}
return deleteList.iterator();
|
public java.lang.Object | getElement(java.lang.Object entry)
return ( (IndexedValue) entry ).value;
|
protected static java.lang.String | getIndex(org.dom4j.Element element, java.lang.String indexNodeName, int i)
if (indexNodeName!=null) {
return element.attributeValue(indexNodeName);
}
else {
return Integer.toString(i);
}
|
public java.lang.Object | getIndex(java.lang.Object entry, int i, org.hibernate.persister.collection.CollectionPersister persister)
String index = ( (IndexedValue) entry ).index;
final Type indexType = persister.getIndexType();
return ( (NullableType) indexType ).fromXMLString( index, persister.getFactory() );
|
protected static java.lang.String | getIndexAttributeName(org.hibernate.persister.collection.CollectionPersister persister)
String node = persister.getIndexNodeName();
return node==null ? null : node.substring(1);
|
public java.util.Collection | getOrphans(java.io.Serializable snapshot, java.lang.String entityName)
//orphan delete not supported for EntityMode.DOM4J
return CollectionHelper.EMPTY_COLLECTION;
|
public java.io.Serializable | getSnapshot(org.hibernate.persister.collection.CollectionPersister persister)
final Type elementType = persister.getElementType();
String indexNode = getIndexAttributeName(persister);
List elements = element.elements( persister.getElementNodeName() );
HashMap snapshot = new HashMap( elements.size() );
for ( int i=0; i<elements.size(); i++ ) {
Element elem = (Element) elements.get(i);
Object value = elementType.fromXMLNode( elem, persister.getFactory() );
Object copy = elementType.deepCopy( value, getSession().getEntityMode(), persister.getFactory() );
snapshot.put( getIndex(elem, indexNode, i), copy );
}
return snapshot;
|
public java.lang.Object | getSnapshotElement(java.lang.Object entry, int i)
return ( (HashMap) getSnapshot() ).get( ( (IndexedValue) entry ).index );
|
public java.lang.Object | getValue()
return element;
|
public boolean | isDirectlyAccessible()
return true;
|
public boolean | isSnapshotEmpty(java.io.Serializable snapshot)
return ( (HashMap) snapshot ).isEmpty();
|
public boolean | isWrapper(java.lang.Object collection)
return element==collection;
|
public boolean | needsInserting(java.lang.Object entry, int i, org.hibernate.type.Type elementType)
HashMap snapshot = (HashMap) getSnapshot();
IndexedValue iv = (IndexedValue) entry;
return iv.value!=null && snapshot.get( iv.index )==null;
|
public boolean | needsUpdating(java.lang.Object entry, int i, org.hibernate.type.Type elementType)
HashMap snapshot = (HashMap) getSnapshot();
IndexedValue iv = (IndexedValue) entry;
Object old = snapshot.get( iv.index );
return old!=null && elementType.isDirty( old, iv.value, getSession() );
|
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 object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
final Type elementType = persister.getElementType();
final SessionFactoryImplementor factory = persister.getFactory();
String indexNode = getIndexAttributeName(persister);
Element elem = element.addElement( persister.getElementNodeName() );
elementType.setToXMLNode( elem, object, factory );
final Type indexType = persister.getIndexType();
final Object indexValue = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
final String index = ( (NullableType) indexType ).toXMLString( indexValue, factory );
setIndex(elem, indexNode, index);
return object;
|
protected static void | setIndex(org.dom4j.Element element, java.lang.String indexNodeName, java.lang.String index)
if (indexNodeName!=null) element.addAttribute(indexNodeName, index);
|