use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.
the class Vector method removeElementAt.
/**
* Deletes the component at the specified index.
*
* @param index the index of the object to remove.
* @exception ArrayIndexOutOfBoundsException if the index was invalid.
* @see java.util.Vector
*/
public synchronized void removeElementAt(int 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);
}
use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.
the class Vector method removeElement.
/**
* Removes the first (lowest-indexed) occurrence of the argument
* from this vector.
*
* @param obj the component to be removed.
* @return <code>true</code> if the argument was a component of this
* vector; <code>false</code> otherwise.
* @see java.util.Vector
*/
public synchronized boolean removeElement(Object obj) {
// 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;
}
use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.
the class Vector method add.
/**
* Appends the specified element to the end of this Vector.
*
* @param o element to be appended to this Vector.
* @return true (as per the general contract of Collection.add).
* @see java.util.Vector
*/
public synchronized boolean add(Object o) {
if (allowNulls == false && o == null) {
throw new JDOUserException(I18NHelper.getMessage(messages, // NOI18N
"sco.nulls_not_allowed"));
}
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", // NOI18N
elementType.getName()), new ClassCastException(), new Object[] { o });
}
}
use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.
the class Vector method addAll.
/**
* 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.
*
* @param c elements to be inserted into this Vector.
* @see java.util.Vector
*/
public synchronized boolean addAll(Collection c) {
if (allowNulls == false && c.contains(null)) {
throw new JDOUserException(I18NHelper.getMessage(messages, // NOI18N
"sco.nulls_not_allowed"));
}
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", // NOI18N
elementType.getName()), 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;
}
use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.
the class Vector method insertElementAt.
/**
* Inserts the specified object as a component in this vector at the
* specified <code>index</code>.
*
* @param obj the component to insert.
* @param index where to insert the new component.
* @exception ArrayIndexOutOfBoundsException if the index was invalid.
* @see java.util.Vector
*/
public synchronized void insertElementAt(Object obj, int index) {
if (allowNulls == false && obj == null) {
throw new JDOUserException(I18NHelper.getMessage(messages, // NOI18N
"sco.nulls_not_allowed"));
}
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", // NOI18N
elementType.getName()), new ClassCastException(), new Object[] { obj });
}
}
Aggregations