Methods Summary |
---|
public boolean | addInto(java.lang.Object key, java.lang.Object value, java.lang.Object container, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Add key, value pair into container which implements the Map interface.
try {
((Map)container).put(key, value);
} catch (ClassCastException ex1) {
throw QueryException.cannotAddElement(key, container, ex1);
}
return true;
|
public boolean | addInto(java.lang.Object element, java.lang.Object container, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Add element into container which implements the Map interface. Not used since key is not obtained from the object
throw ValidationException.operationNotSupported("addInto(Object element, Object container, Session session)");
|
public java.lang.Object | buildContainerFromVector(java.util.Vector vector, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Return a container populated with the contents of the specified Vector.
Map container = (Map)containerInstance(vector.size());
AbstractRecord row;
for (Enumeration e = vector.elements(); e.hasMoreElements();) {
row = (AbstractRecord)e.nextElement();
Object key = row.get(keyField);
Object value = row.get(valueField);
if (getKeyConverter() != null) {
key = getKeyConverter().convertDataValueToObjectValue(key, session);
}
if (getValueConverter() != null) {
value = getValueConverter().convertDataValueToObjectValue(value, session);
}
if (key != null) {
container.put(key, value);
}
}
return container;
|
public void | clear(java.lang.Object container)INTERNAL:
Remove all the elements from container.
try {
((Map)container).clear();
} catch (UnsupportedOperationException ex) {
throw QueryException.methodNotValid(container, "clear()");
}
|
public boolean | compareContainers(java.lang.Object firstObjectMap, java.lang.Object secondObjectMap)INTERNAL:
Return true if keys are the same. False otherwise
if (sizeFor(firstObjectMap) != sizeFor(secondObjectMap)) {
return false;
}
for (Object firstIterator = iteratorFor(firstObjectMap); hasNext(firstIterator);) {
Object key = next(firstIterator);
if (!((Map)firstObjectMap).get(key).equals(((Map)secondObjectMap).get(key))) {
return false;
}
}
return true;
|
public boolean | compareKeys(java.lang.Object sourceValue, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Return true if keys are the same in the source as the backup. False otherwise
in the case of readonly compare against the original
Object backUpVersion = null;
//CR 4172
if (((UnitOfWorkImpl)session).isClassReadOnly(sourceValue.getClass())) {
backUpVersion = ((UnitOfWorkImpl)session).getOriginalVersionOfObject(sourceValue);
} else {
backUpVersion = ((UnitOfWorkImpl)session).getBackupClone(sourceValue);
}
return (keyFrom(backUpVersion, session).equals(keyFrom(sourceValue, session)));
|
protected boolean | contains(java.lang.Object element, java.lang.Object container)INTERNAL:
Return the true if element exists in container.
return ((Map)container).containsValue(element);
|
public java.lang.Class | getInterfaceType()
return ClassConstants.Map_Class;
|
public oracle.toplink.essentials.mappings.converters.Converter | getKeyConverter()
return keyConverter;
|
public oracle.toplink.essentials.mappings.converters.Converter | getValueConverter()
return valueConverter;
|
public boolean | isDirectMapPolicy()
return true;
|
public boolean | isValidContainer(java.lang.Object container)INTERNAL:
Validate the container type.
// PERF: Use instanceof which is inlined, not isAssignable which is very inefficent.
return container instanceof Map;
|
public java.lang.Object | iteratorFor(java.lang.Object container)INTERNAL:
Return an Iterator for the given container.
if (((Map)container).keySet() == null) {
return null;
}
return ((Map)container).keySet().iterator();
|
public java.lang.Object | iteratorForValue(java.lang.Object container)INTERNAL:
Return an Iterator for the given container.
if (((Map)container).values() == null) {
return null;
}
return ((Map)container).values().iterator();
|
public boolean | removeFrom(java.lang.Object key, java.lang.Object element, java.lang.Object container, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Remove element from container which implements the Map interface.
try {
Object returnValue = null;
if (key != null) {
returnValue = ((Map)container).remove(key);
} else {
returnValue = ((Map)container).remove(keyFrom(element, session));
}
if (returnValue == null) {
return false;
} else {
return true;
}
} catch (UnsupportedOperationException ex) {
throw QueryException.methodNotValid(container, "remove(Object element)");
}
|
public boolean | removeFromWithIdentity(java.lang.Object element, java.lang.Object container, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Remove element from container which implements the Map interface.
boolean found = false;
Vector knownKeys = new Vector(1);
try {
Iterator iterator = ((Map)container).keySet().iterator();
while (iterator.hasNext()) {
Object key = iterator.next();
if (((Map)container).get(key) == element) {
knownKeys.addElement(key);
found = true;
}
}
if (found) {
for (int index = 0; index < knownKeys.size(); ++index) {
((Map)container).remove(knownKeys.elementAt(index));
}
}
return found;
} catch (UnsupportedOperationException ex) {
throw QueryException.methodNotValid(container, "remove(Object element)");
}
|
public void | setKeyConverter(oracle.toplink.essentials.mappings.converters.Converter keyConverter)
this.keyConverter = keyConverter;
|
public void | setKeyField(oracle.toplink.essentials.internal.helper.DatabaseField field)
keyField = field;
|
public void | setValueConverter(oracle.toplink.essentials.mappings.converters.Converter valueConverter)
this.valueConverter = valueConverter;
|
public void | setValueField(oracle.toplink.essentials.internal.helper.DatabaseField field)
valueField = field;
|
public int | sizeFor(java.lang.Object container)INTERNAL:
Return the size of container.
return ((Map)container).size();
|
public void | validateElementAndRehashIfRequired(java.lang.Object sourceValue, java.lang.Object targetMap, oracle.toplink.essentials.internal.sessions.AbstractSession session, java.lang.Object targetVersionOfSource)INTERNAL:
If the key has changed, remove the element and add it back into the target.
if (session.isUnitOfWork()) {
//this must be a unit of work at this point
Object backupValue = ((UnitOfWorkImpl)session).getBackupClone(sourceValue);
if (!keyFrom(backupValue, session).equals(keyFrom(sourceValue, session))) {
//the key has been changed. Remove the old value and put back the new one
removeFrom(backupValue, targetMap, session);
addInto(targetVersionOfSource, targetMap, session);
}
}
|
public java.lang.Object | valueFromKey(java.lang.Object key, java.lang.Object container)INTERNAL:
Return an value of the key from container
return ((Map)container).get(key);
|