| Method from org.hibernate.collection.PersistentMap Detail: |
public void beforeInitialize(CollectionPersister persister,
int anticipatedSize) {
this.map = ( Map ) persister.getCollectionType().instantiate( anticipatedSize );
}
|
public void clear() {
if ( isClearQueueEnabled() ) {
queueOperation( new Clear() );
}
else {
initialize( true );
if ( ! map.isEmpty() ) {
dirty();
map.clear();
}
}
}
|
public boolean containsKey(Object key) {
Boolean exists = readIndexExistence(key);
return exists==null ? map.containsKey(key) : exists.booleanValue();
}
|
public boolean containsValue(Object value) {
Boolean exists = readElementExistence(value);
return exists==null ?
map.containsValue(value) :
exists.booleanValue();
}
|
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
Serializable[] result = new Serializable[ map.size() * 2 ];
Iterator iter = map.entrySet().iterator();
int i=0;
while ( iter.hasNext() ) {
Map.Entry e = (Map.Entry) iter.next();
result[i++] = persister.getIndexType().disassemble( e.getKey(), getSession(), null );
result[i++] = persister.getElementType().disassemble( e.getValue(), getSession(), null );
}
return result;
}
|
public boolean empty() {
return map.isEmpty();
}
|
public Iterator entries(CollectionPersister persister) {
return map.entrySet().iterator();
}
|
public boolean entryExists(Object entry,
int i) {
return ( (Map.Entry) entry ).getValue()!=null;
}
|
public Set entrySet() {
read();
return new EntrySetProxy( map.entrySet() );
}
|
public boolean equals(Object other) {
read();
return map.equals(other);
}
|
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
Type elementType = persister.getElementType();
Map xmap = (Map) getSnapshot();
if ( xmap.size()!=this.map.size() ) return false;
Iterator iter = map.entrySet().iterator();
while ( iter.hasNext() ) {
Map.Entry entry = (Map.Entry) iter.next();
if ( elementType.isDirty( entry.getValue(), xmap.get( entry.getKey() ), getSession() ) ) return false;
}
return true;
}
|
public Object get(Object key) {
Object result = readElementByIndex(key);
return result==UNKNOWN ? map.get(key) : result;
}
|
public Iterator getDeletes(CollectionPersister persister,
boolean indexIsFormula) throws HibernateException {
List deletes = new ArrayList();
Iterator iter = ( (Map) getSnapshot() ).entrySet().iterator();
while ( iter.hasNext() ) {
Map.Entry e = (Map.Entry) iter.next();
Object key = e.getKey();
if ( e.getValue()!=null && map.get(key)==null ) {
deletes.add( indexIsFormula ? e.getValue() : key );
}
}
return deletes.iterator();
}
|
public Object getElement(Object entry) {
return ( (Map.Entry) entry ).getValue();
}
|
public Object getIndex(Object entry,
int i,
CollectionPersister persister) {
return ( (Map.Entry) entry ).getKey();
}
|
public Collection getOrphans(Serializable snapshot,
String entityName) throws HibernateException {
Map sn = (Map) snapshot;
return getOrphans( sn.values(), map.values(), entityName, getSession() );
}
|
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
EntityMode entityMode = getSession().getEntityMode();
HashMap clonedMap = new HashMap( map.size() );
Iterator iter = map.entrySet().iterator();
while ( iter.hasNext() ) {
Map.Entry e = (Map.Entry) iter.next();
final Object copy = persister.getElementType()
.deepCopy( e.getValue(), entityMode, persister.getFactory() );
clonedMap.put( e.getKey(), copy );
}
return clonedMap;
}
|
public Object getSnapshotElement(Object entry,
int i) {
final Map sn = (Map) getSnapshot();
return sn.get( ( (Map.Entry) entry ).getKey() );
}
|
public int hashCode() {
read();
return map.hashCode();
}
|
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+=2 ) {
map.put(
persister.getIndexType().assemble( array[i], getSession(), owner ),
persister.getElementType().assemble( array[i+1], getSession(), owner )
);
}
}
|
public boolean isEmpty() {
return readSize() ? getCachedSize()==0 : map.isEmpty();
}
|
public boolean isSnapshotEmpty(Serializable snapshot) {
return ( (Map) snapshot ).isEmpty();
}
|
public boolean isWrapper(Object collection) {
return map==collection;
}
|
public Set keySet() {
read();
return new SetProxy( map.keySet() );
}
|
public boolean needsInserting(Object entry,
int i,
Type elemType) throws HibernateException {
final Map sn = (Map) getSnapshot();
Map.Entry e = (Map.Entry) entry;
return e.getValue()!=null && sn.get( e.getKey() )==null;
}
|
public boolean needsUpdating(Object entry,
int i,
Type elemType) throws HibernateException {
final Map sn = (Map) getSnapshot();
Map.Entry e = (Map.Entry) entry;
Object snValue = sn.get( e.getKey() );
return e.getValue()!=null &&
snValue!=null &&
elemType.isDirty( snValue, e.getValue(), getSession() );
}
|
public Object put(Object key,
Object value) {
if ( isPutQueueEnabled() ) {
Object old = readElementByIndex( key );
if ( old != UNKNOWN ) {
queueOperation( new Put( key, value, old ) );
return old;
}
}
initialize( true );
Object old = map.put( key, value );
// would be better to use the element-type to determine
// whether the old and the new are equal here; the problem being
// we do not necessarily have access to the element type in all
// cases
if ( value != old ) {
dirty();
}
return old;
}
|
public void putAll(Map puts) {
if ( puts.size() >0 ) {
initialize( true );
Iterator itr = puts.entrySet().iterator();
while ( itr.hasNext() ) {
Map.Entry entry = ( Entry ) itr.next();
put( entry.getKey(), entry.getValue() );
}
}
}
|
public Object readFrom(ResultSet rs,
CollectionPersister persister,
CollectionAliases descriptor,
Object owner) throws HibernateException, SQLException {
Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
if ( element!=null ) map.put(index, element);
return element;
}
|
public Object remove(Object key) {
if ( isPutQueueEnabled() ) {
Object old = readElementByIndex( key );
queueOperation( new Remove( key, old ) );
return old;
}
else {
// TODO : safe to interpret "map.remove(key) == null" as non-dirty?
initialize( true );
if ( map.containsKey( key ) ) {
dirty();
}
return map.remove( key );
}
}
|
public int size() {
return readSize() ? getCachedSize() : map.size();
}
|
public String toString() {
read();
return map.toString();
}
|
public Collection values() {
read();
return new SetProxy( map.values() );
}
|