Methods Summary |
---|
public synchronized boolean | add(java.lang.Object o)Appends the specified element to the end of this Vector.
if (allowNulls == false && o == null)
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.nulls_not_allowed")); // NOI18N
}
if (elementType == null || elementType.isAssignableFrom(o.getClass()))
{
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
if (removed.remove(o) == false)
added.add(o);
boolean modified = super.add(o);
// Apply updates
this.applyUpdates(stateManager, modified);
return modified;
} else {
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.classcastexception", elementType.getName()), // NOI18N
new ClassCastException(), new Object[] {o});
}
|
public void | add(int index, java.lang.Object element)Inserts the specified element at the specified position in this Vector.
this.insertElementAt(element, index);
|
public synchronized boolean | addAll(java.util.Collection c)Appends all of the elements in the specified Collection to the end of
this Vector, in the order that they are returned by the specified
Collection's Iterator.
if (allowNulls == false && c.contains(null))
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.nulls_not_allowed")); // NOI18N
}
java.util.Vector errc = new java.util.Vector();
if (elementType != null)
{
// iterate the collection and make a list of wrong elements.
Iterator i = c.iterator();
while (i.hasNext())
{
Object o = i.next();
if (!elementType.isAssignableFrom(o.getClass()))
errc.add(o);
}
}
if (errc != null && errc.size() > 0)
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.classcastexception", elementType.getName()), // NOI18N
new ClassCastException(), errc.toArray());
}
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
removed.removeAll(c);
added.addAll(c);
boolean modified = super.addAll(c);
// Apply updates
this.applyUpdates(stateManager, modified);
return modified;
|
public synchronized boolean | addAll(int index, java.util.Collection c)Inserts all of the elements in in the specified Collection into this
Vector at the specified position. Shifts the element currently at
that position (if any) and any subsequent elements to the right
(increases their indices). The new elements will appear in the Vector
in the order that they are returned by the specified Collection's
iterator.
if (allowNulls == false && c.contains(null))
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.nulls_not_allowed")); // NOI18N
}
java.util.Vector errc = new java.util.Vector();
if (elementType != null)
{
// iterate the collection and make a list of wrong elements.
Iterator i = c.iterator();
while (i.hasNext())
{
Object o = i.next();
if (!elementType.isAssignableFrom(o.getClass()))
errc.add(o);
}
}
if (errc != null && errc.size() > 0)
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.classcastexception", elementType.getName()), // NOI18N
new ClassCastException(), errc.toArray());
}
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
removed.removeAll(c);
added.addAll(c);
boolean modified = super.addAll(index, c);
// Apply updates
this.applyUpdates(stateManager, modified);
return modified;
|
public void | addAllInternal(java.util.Collection c)Adds a Collection to the list without recording changes
super.addAll(c);
|
public synchronized void | addElement(java.lang.Object obj)Adds the specified component to the end of this vector,
increasing its size by one.
if (allowNulls == false && obj == null)
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.nulls_not_allowed")); // NOI18N
}
if (elementType == null || elementType.isAssignableFrom(obj.getClass()))
{
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
super.addElement(obj);
if (removed.remove(obj) == false)
added.add(obj);
// Apply updates
this.applyUpdates(stateManager, true);
} else {
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.classcastexception", elementType.getName()), // NOI18N
new ClassCastException(), new Object[] {obj});
}
|
public void | addInternal(java.lang.Object o)Adds an object to the list without recording changes
super.addElement(o);
|
public void | addToBaseCollection(java.lang.Object o)
super.add(o);
|
public void | applyDeferredUpdates(java.util.Collection c)
super.addAll(c);
|
public void | applyUpdates(com.sun.jdo.spi.persistence.support.sqlstore.StateManager sm, boolean modified)Apply changes (can be a no-op)
if (modified && sm != null)
{
sm.applyUpdates(fieldName, this);
}
|
public void | clear()Removes all of the elements from this Vector. The Vector will
be empty after this call returns (unless it throws an exception).
this.removeAllElements();
|
public void | clearInternal()Clears Collection without notifing the owner
//Cannot call super.clear() as it internally calls removeAllElements()
// which causes marking field as dirty.
int s = super.size() - 1;
// Need to loop backwards to avoid resetting size of the collection
for (int i = s; i > -1; i--)
{
super.removeElementAt(i);
}
this.reset();
|
public java.lang.Object | clone()Creates and returns a copy of this object.
Mutable Second Class Objects are required to provide a public
clone method in order to allow for copying PersistenceCapable
objects. In contrast to Object.clone(), this method must not throw a
CloneNotSupportedException.
Vector obj = (Vector)super.clone();
obj.unsetOwner();
return obj;
|
public java.lang.Object | cloneInternal()Creates and returns a copy of this object without resetting the owner and field value.
return super.clone();
|
public java.util.Collection | getAdded()Returns added collection
return (Collection)added;
|
public java.lang.String | getFieldName()Returns the field name
return this.fieldName;
|
public java.lang.Object | getOwner()Returns the owner object of the SCO instance
return this.owner;
|
public java.util.Collection | getRemoved()Returns removed collection
return (Collection)removed;
|
public synchronized void | insertElementAt(java.lang.Object obj, int index)Inserts the specified object as a component in this vector at the
specified index .
if (allowNulls == false && obj == null)
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.nulls_not_allowed")); // NOI18N
}
if (elementType == null || elementType.isAssignableFrom(obj.getClass()))
{
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
super.insertElementAt(obj, index);
if (removed.remove(obj) == false)
added.add(obj);
// Apply updates
this.applyUpdates(stateManager, true);
} else {
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.classcastexception", elementType.getName()), // NOI18N
new ClassCastException(), new Object[] {obj});
}
|
public boolean | isDeferred()
return false;
|
public com.sun.jdo.spi.persistence.support.sqlstore.StateManager | makeDirty()Marks object dirty
if (owner != null)
{
StateManager stateManager = owner.jdoGetStateManager();
if (stateManager != null)
{
stateManager.makeDirty(fieldName);
}
return stateManager;
}
return null;
|
public void | markDeferred()
|
public boolean | remove(java.lang.Object o)Removes the first occurrence of the specified element in this Vector
If the Vector does not contain the element, it is unchanged.
return this.removeElement(o);
|
public synchronized java.lang.Object | remove(int index)Removes the element at the specified position in this Vector.
shifts any subsequent elements to the left (subtracts one from their
indices). Returns the element that was removed from the Vector.
throwUnsupportedOption();
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
Object obj = super.remove(index);
if (added.remove(obj) == false)
removed.add(obj);
// Apply updates
this.applyUpdates(stateManager, true);
return obj;
|
public synchronized boolean | removeAll(java.util.Collection c)Removes from this Vector all of its elements that are contained in the
specified Collection.
boolean modified = false;
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
Iterator e = c.iterator();
while (e.hasNext()) {
Object o = e.next();
if(super.contains(o)) {
removeInternal(o);
if (added.remove(o) == false)
removed.add(o);
modified = true;
}
}
// Apply updates
this.applyUpdates(stateManager, modified);
return modified;
|
public synchronized void | removeAllElements()Removes all components from this vector and sets its size to zero.
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
for (Iterator iter = super.iterator(); iter.hasNext();) {
Object o = iter.next();
if (added.remove(o) == false)
removed.add(o);
}
added.clear();
super.removeAllElements();
// Apply updates
this.applyUpdates(stateManager, true);
|
public void | removeAllInternal(java.util.Collection c)Removes from this collection without recording changes
super.removeAll(c);
|
public synchronized boolean | removeElement(java.lang.Object obj)Removes the first (lowest-indexed) occurrence of the argument
from this vector.
// Because java.util.Vector.removeElement(Object) calls internally removeElementAt(int)
// which is not supported, we cannot rely on jdk. We need to process remove here.
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
int i = super.indexOf(obj);
if (i > -1) {
super.removeElementAt(i);
if (added.remove(obj) == false)
removed.add(obj);
// Apply updates
this.applyUpdates(stateManager, true);
return true;
}
return false;
|
public synchronized void | removeElementAt(int index)Deletes the component at the specified index.
throwUnsupportedOption();
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
Object obj = super.elementAt(index);
super.removeElementAt(index);
if (added.remove(obj) == false)
removed.add(obj);
// Apply updates
this.applyUpdates(stateManager, true);
|
public void | removeInternal(java.lang.Object o)Removes an element without notifing the owner
int i = super.indexOf(o);
super.remove(i);
|
public void | reset()Cleans removed and added lists
added.clear();
removed.clear();
|
public synchronized boolean | retainAll(java.util.Collection c)Retains only the elements in this Vector that are contained in the
specified Collection.
boolean modified = false;
java.util.Vector v = new java.util.Vector();
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
for (Iterator iter = super.iterator(); iter.hasNext();)
{
Object o = iter.next();
if (!c.contains(o))
{
v.add(o);
if (added.remove(o) == false)
removed.add(o);
modified = true;
}
}
// Now remove the rest (stored in "v")
for (Iterator iter = v.iterator(); iter.hasNext();)
{
removeInternal(iter.next());
}
// Apply updates
this.applyUpdates(stateManager, modified);
return modified;
|
public synchronized java.lang.Object | set(int index, java.lang.Object element)Replaces the element at the specified position in this Vector with the
specified element.
throwUnsupportedOption();
if (element == null)
{
if (allowNulls == false)
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.nulls_not_allowed")); // NOI18N
}
// It is actualy remove
return this.remove(index);
}
if (elementType == null || elementType.isAssignableFrom(element.getClass()))
{
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
Object o = super.set(index, element);
if (added.remove(o) == false)
removed.add(o);
if (removed.remove(element) == false)
added.add(element);
// Apply updates
this.applyUpdates(stateManager, true);
return o;
} else {
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.classcastexception", elementType.getName()), // NOI18N
new ClassCastException(), new Object[] {element});
}
|
public synchronized void | setElementAt(java.lang.Object obj, int index)Sets the component at the specified index of this
vector to be the specified object. The previous component at that
position is discarded.
throwUnsupportedOption();
if (obj == null)
{
if (allowNulls == false)
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.nulls_not_allowed")); // NOI18N
}
// It is actualy remove
this.removeElementAt(index);
}
if (elementType == null || elementType.isAssignableFrom(obj.getClass()))
{
// Mark the field as dirty
StateManager stateManager = this.makeDirty();
Object o = super.elementAt(index);
super.setElementAt(obj, index);
if (added.remove(o) == false)
removed.add(o);
if (removed.remove(obj) == false)
added.add(obj);
// Apply updates
this.applyUpdates(stateManager, true);
} else {
throw new JDOUserException(I18NHelper.getMessage(messages,
"sco.classcastexception", elementType.getName()), // NOI18N
new ClassCastException(), new Object[] {obj});
}
|
public void | setOwner(java.lang.Object owner, java.lang.String fieldName, java.lang.Class elementType)Set the owner if this instance is not owned.
if (this.owner != null) {
throw new JDOUserException(I18NHelper.getMessage(
messages1, "core.statemanager.anotherowner"), // NOI18N
new Object[]{this.owner, this.fieldName});
}
if (owner instanceof PersistenceCapable) {
this.owner = (PersistenceCapable)owner;
this.fieldName = fieldName;
this.elementType = elementType;
}
|
private void | throwUnsupportedOption()Throw JDOUnsupportedOptionException
// Index operation that changes the underline collection
// is not supported in 2_beta. Bug 4370474
throw new JDOUnsupportedOptionException(I18NHelper.getMessage(messages,
"sco.not_supported")); //NOI18N
|
public void | unsetOwner()Nullifies references to the owner Object and Field
this.owner = null;
this.fieldName = null;
this.elementType = null;
added.clear();
removed.clear();
|