Search in sources :

Example 16 with JDOUserException

use of com.sun.jdo.api.persistence.support.JDOUserException in project Payara by payara.

the class Vector method setElementAt.

/**
 * ------------------Public Methods----------------
 */
/**
 * Sets the component at the specified <code>index</code> of this
 * vector to be the specified object. The previous component at that
 * position is discarded.<p>
 *
 * @param      obj     what the component is to be set to.
 * @param      index   the specified index.
 * @exception  ArrayIndexOutOfBoundsException  if the index was invalid.
 * @see java.util.Vector
 */
public synchronized void setElementAt(Object obj, int index) {
    throwUnsupportedOption();
    if (obj == null) {
        if (allowNulls == false) {
            throw new JDOUserException(I18NHelper.getMessage(messages, // NOI18N
            "sco.nulls_not_allowed"));
        }
        // 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", // NOI18N
        elementType.getName()), new ClassCastException(), new Object[] { obj });
    }
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException)

Example 17 with JDOUserException

use of com.sun.jdo.api.persistence.support.JDOUserException 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 });
    }
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException)

Example 18 with JDOUserException

use of com.sun.jdo.api.persistence.support.JDOUserException 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;
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) Iterator(java.util.Iterator) JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException)

Example 19 with JDOUserException

use of com.sun.jdo.api.persistence.support.JDOUserException 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 });
    }
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException)

Example 20 with JDOUserException

use of com.sun.jdo.api.persistence.support.JDOUserException in project Payara by payara.

the class TransactionImpl method commitComplete.

/**
 * Lower-level complete-commit method - phase 2.
 *
 * State transition:
 *        STATUS_PREPARED        starting state
 *        STATUS_COMMITTING    starting to do final phase
 *        commitResources()        maybe one-phase
 *        STATUS_COMMITTED
 *        afterCompletion()    no longer active
 *
 * For exceptions see commit() method.
 */
private void commitComplete() {
    if (this.tracing)
        // NOI18N
        this.traceCallInfo("commitComplete", TRACE_ONE_PHASE, null);
    // 
    if (this.status == Status.STATUS_ROLLING_BACK) {
        // st);
        this.setStatus(Status.STATUS_ROLLING_BACK);
        internalRollback();
    } else if (this.status == Status.STATUS_PREPARED) {
        this.setStatus(Status.STATUS_COMMITTING);
        internalCommit();
    } else {
        throw new JDOUserException(I18NHelper.getMessage(messages, // NOI18N
        "transaction.transactionimpl.commitprepare.wrongstatus", // NOI18N
        "commitComplete", // NOI18N
        "STATUS_PREPARED", this.statusString(this.status)));
    }
}
Also used : JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException)

Aggregations

JDOUserException (com.sun.jdo.api.persistence.support.JDOUserException)20 StateManager (com.sun.jdo.spi.persistence.support.sqlstore.StateManager)14 Iterator (java.util.Iterator)6 PersistenceManager (com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager)2 ArrayList (java.util.ArrayList)2 ConversionException (com.sun.jdo.api.persistence.mapping.ejb.ConversionException)1 ModelException (com.sun.jdo.api.persistence.model.ModelException)1 JDODataStoreException (com.sun.jdo.api.persistence.support.JDODataStoreException)1 JDOException (com.sun.jdo.api.persistence.support.JDOException)1 JDOFatalInternalException (com.sun.jdo.api.persistence.support.JDOFatalInternalException)1 JDOUnsupportedOptionException (com.sun.jdo.api.persistence.support.JDOUnsupportedOptionException)1 GeneratorException (com.sun.jdo.spi.persistence.support.ejb.codegen.GeneratorException)1 EJBQLException (com.sun.jdo.spi.persistence.support.ejb.ejbqlc.EJBQLException)1 com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint (com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint)1 java.io (java.io)1 File (java.io.File)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 Collection (java.util.Collection)1 DBException (org.netbeans.modules.dbschema.DBException)1