Package com.sun.jdo.api.persistence.support

Examples of com.sun.jdo.api.persistence.support.JDOUserException


        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});
  }

    }
View Full Code Here


     * @see java.util.ArrayList
     */ 
    public boolean add(Object o) {
  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});
  }
    }   
View Full Code Here

     * @see java.util.ArrayList
     */ 
    public void add(int index, Object element) {
  if (allowNulls == false && element == null)
        {
                throw new JDOUserException(I18NHelper.getMessage(messages,
                        "sco.nulls_not_allowed")); // NOI18N
        }

        if (elementType == null || elementType.isAssignableFrom(element.getClass()))
        {
    // Mark the field as dirty
    StateManager stateManager = this.makeDirty();
       
                super.add(index, element);
                if (removed.remove(element) == false)
                        added.add(element);

    // Apply updates
    this.applyUpdates(stateManager, true);
 
        } else {
                throw new JDOUserException(I18NHelper.getMessage(messages,
                                "sco.classcastexception", elementType.getName()), // NOI18N
         new ClassCastException(), new Object[] {element});
        }

    }
View Full Code Here

     * @see java.util.ArrayList
     */ 
    public boolean addAll(Collection c) {
  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
View Full Code Here

     * @see java.util.ArrayList 
     */  
    public boolean addAll(int index, Collection c) {
  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
View Full Code Here

     * is not to be checked.
     */
    public void setOwner(Object owner, String fieldName, Class elementType) {

        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;
View Full Code Here

                        FieldDesc fieldDesc = originalPlan.config.
                                getField(((ConstraintFieldName) fieldNode).name);

                        if (!(fieldDesc instanceof LocalFieldDesc)) {
                            throw new JDOUserException(I18NHelper.getMessage(messages,
                                    "core.generic.notinstanceof", // NOI18N
                                    fieldDesc.getClass().getName(),
                                    "LocalFieldDesc")); // NOI18N
                        }

                        consFieldDesc = new ConstraintFieldDesc((LocalFieldDesc) fieldDesc,
                                originalPlan, 1);
                    } else if (fieldNode instanceof ConstraintFieldDesc) {
                        consFieldDesc = (ConstraintFieldDesc) fieldNode;
                    } else {
                        throw new JDOUserException(I18NHelper.getMessage(messages,
                                "core.generic.notinstanceof", // NOI18N
                                fieldNode.getClass().getName(),
                                "ConstraintFieldName/ConstraintFieldDesc")); // NOI18N
                    }
View Full Code Here

        return this;
    }

    protected void assertTransaction(boolean transactionActive) {
        if (!transactionActive) {
            throw new JDOUserException(I18NHelper.getMessage(messages,
                    "jdo.lifecycle.xactnotactive")); // NOI18N
        }
    }
View Full Code Here

        updateAction = ActionDesc.LOG_DESTROY;
        stateType = AP_NEW_FLUSHED_PENDING;
    }

    public LifeCycleState transitionDeletePersistent() {
        throw new JDOUserException(I18NHelper.getMessage(messages,
                "jdo.lifecycle.deleted.accessField")); // NOI18N
    }
View Full Code Here

    }

    public LifeCycleState transitionReadField(boolean optimisitic, boolean nontransactonalRead,
                                              boolean transactionActive) {
        // Cannot read a deleted object
        throw new JDOUserException(I18NHelper.getMessage(messages,
                "jdo.lifecycle.deleted.accessField")); // NOI18N
    }
View Full Code Here

TOP

Related Classes of com.sun.jdo.api.persistence.support.JDOUserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.