Search in sources :

Example 16 with StateManager

use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.

the class Vector method retainAll.

/**
 * Retains only the elements in this Vector that are contained in the
 * specified Collection.
 *
 * @return true if this Vector changed as a result of the call.
 * @see java.util.Vector
 */
public synchronized boolean retainAll(Collection c) {
    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;
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) Iterator(java.util.Iterator)

Example 17 with StateManager

use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.

the class Vector method set.

/**
 * Replaces the element at the specified position in this Vector with the
 * specified element.
 *
 * @param index index of element to replace.
 * @param element element to be stored at the specified position.
 * @return the element previously at the specified position.
 * @exception ArrayIndexOutOfBoundsException index out of range
 *            (index < 0 || index >= size()).
 * @exception IllegalArgumentException fromIndex > toIndex.
 * @see java.util.Vector
 */
public synchronized Object set(int index, Object element) {
    throwUnsupportedOption();
    if (element == null) {
        if (allowNulls == false) {
            throw new JDOUserException(I18NHelper.getMessage(messages, // NOI18N
            "sco.nulls_not_allowed"));
        }
        // 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", // NOI18N
        elementType.getName()), new ClassCastException(), new Object[] { element });
    }
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager) JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException)

Example 18 with StateManager

use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.

the class VersionConsistencyCacheImpl method get.

/**
 * @see VersionConsistencyCache#get
 */
public StateManager get(Class pcType, Object oid) {
    boolean logAtFinest = logger.isLoggable(Logger.FINEST);
    if (logAtFinest) {
        logger.finest(I18NHelper.getMessage(messages, // NOI18N
        "jdo.versionconsistencycacheimpl.get.entering", new Object[] { pcType, oid }));
    }
    StateManager rc = null;
    VCCache oid2sm = null;
    synchronized (pcTypeMap) {
        oid2sm = (VCCache) pcTypeMap.get(pcType);
    }
    if (null != oid2sm) {
        rc = oid2sm.get(oid);
    }
    if (logAtFinest) {
        logger.finest(I18NHelper.getMessage(messages, // NOI18N
        "jdo.versionconsistencycacheimpl.get.returning", rc));
    }
    return rc;
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager)

Example 19 with StateManager

use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.

the class VersionConsistencyCacheImpl method put.

/**
 * @see VersionConsistencyCache#put
 */
public StateManager put(Class pcType, Object oid, StateManager sm) {
    boolean logAtFinest = logger.isLoggable(Logger.FINEST);
    if (logAtFinest) {
        logger.finest(I18NHelper.getMessage(messages, // NOI18N
        "jdo.versionconsistencycacheimpl.put.entering", new Object[] { pcType, oid, sm }));
    }
    StateManager rc = null;
    VCCache oid2sm = null;
    synchronized (pcTypeMap) {
        oid2sm = (VCCache) pcTypeMap.get(pcType);
        if (null == oid2sm) {
            oid2sm = cacheFactory.create();
            pcTypeMap.put(pcType, oid2sm);
        }
    }
    rc = oid2sm.put(oid, sm);
    if (logAtFinest) {
        logger.finest(I18NHelper.getMessage(messages, // NOI18N
        "jdo.versionconsistencycacheimpl.put.returning", rc));
    }
    return rc;
}
Also used : StateManager(com.sun.jdo.spi.persistence.support.sqlstore.StateManager)

Example 20 with StateManager

use of com.sun.jdo.spi.persistence.support.sqlstore.StateManager in project Payara by payara.

the class ArrayList method add.

/**
 * Appends the specified element to the end of this ArrayList.
 *
 * @param o element to be appended to this ArrayList.
 * @return true (as per the general contract of Collection.add).
 * @see java.util.ArrayList
 */
public 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)

Aggregations

StateManager (com.sun.jdo.spi.persistence.support.sqlstore.StateManager)36 JDOUserException (com.sun.jdo.api.persistence.support.JDOUserException)14 Iterator (java.util.Iterator)14 PersistenceManager (com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager)10 ArrayList (java.util.ArrayList)1