|
Glassfish example source code file (RelationshipElementImpl.java)
The Glassfish RelationshipElementImpl.java source code/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/*
* RelationshipElementImpl.java
*
* Created on March 2, 2000, 6:21 PM
*/
package com.sun.jdo.api.persistence.model.jdo.impl;
import java.beans.PropertyVetoException;
import com.sun.jdo.api.persistence.model.ModelException;
import com.sun.jdo.api.persistence.model.ModelVetoException;
import com.sun.jdo.api.persistence.model.jdo.RelationshipElement;
import com.sun.jdo.spi.persistence.utility.JavaTypeHelper;
/* TODO:
1. upper and lower bound defaults/ get method constraints based on field
type (whether it's a collection or nullable etc.); pseudo-code:
defaults:
boolean isCollection =
boolean isNullable =
_lowerBound = (isNullable) ? 0 : 1;
_upperBound = (isCollection) ? Integer.MAX_VALUE : 1);
getElement/CollectionClass:
return (isCollection) ? element/collectionClass : null;
2. What is the default for Collection Class?
*/
/**
*
* @author raccah
* @version %I%
*/
public class RelationshipElementImpl extends PersistenceFieldElementImpl
implements RelationshipElement.Impl
{
/** Update action of the relationship element. */
private int _updateAction;
/** Delete action of the relationship element. */
private int _deleteAction;
/** Flag indicating whether this relationship element should prefetch. */
private boolean _isPrefetch;
/** Lower cardinality bound of the relationship element. */
private int _lowerBound;
/** Upper cardinality bound of the relationship element. */
private int _upperBound;
/** Collection lass of the relationship element. */
private String _collectionClass;
/** Element class of the relationship element. */
private String _elementClass;
/** Relative name of the inverse relationship. */
private String _inverseRelationshipName;
/** Create new RelationshipElementImpl with no corresponding name. This
* constructor should only be used for cloning and archiving.
*/
public RelationshipElementImpl ()
{
this(null);
}
/** Creates new RelationshipElementImpl with the corresponding name
* @param name the name of the element
*/
public RelationshipElementImpl (String name)
{
super(name);
_updateAction = RelationshipElement.NONE_ACTION;
_deleteAction = RelationshipElement.NONE_ACTION;
_isPrefetch = false;
_lowerBound = 0;
_upperBound = Integer.MAX_VALUE;
}
/** Get the update action for this relationship element.
* @return the update action, one of
* {@link RelationshipElement#NONE_ACTION},
* {@link RelationshipElement#NULLIFY_ACTION},
* {@link RelationshipElement#RESTRICT_ACTION},
* {@link RelationshipElement#CASCADE_ACTION}, or
* {@link RelationshipElement#AGGREGATE_ACTION}. The default is
* NONE_ACTION.
*/
public int getUpdateAction () { return _updateAction; }
/** Set the update action for this relationship element.
* @param action - an integer indicating the update action, one of:
* {@link RelationshipElement#NONE_ACTION},
* {@link RelationshipElement#NULLIFY_ACTION},
* {@link RelationshipElement#RESTRICT_ACTION},
* {@link RelationshipElement#CASCADE_ACTION}, or
* {@link RelationshipElement#AGGREGATE_ACTION}
* @exception ModelException if impossible
*/
public void setUpdateAction (int action) throws ModelException
{
Integer old = new Integer(getUpdateAction());
Integer newAction = new Integer(action);
try
{
fireVetoableChange(PROP_UPDATE_ACTION, old, newAction);
_updateAction = action;
firePropertyChange(PROP_UPDATE_ACTION, old, newAction);
}
catch (PropertyVetoException e)
{
throw new ModelVetoException(e);
}
}
/** Get the delete action for this relationship element.
* @return the delete action, one of
* {@link RelationshipElement#NONE_ACTION},
* {@link RelationshipElement#NULLIFY_ACTION},
* {@link RelationshipElement#RESTRICT_ACTION},
* {@link RelationshipElement#CASCADE_ACTION}, or
* {@link RelationshipElement#AGGREGATE_ACTION}. The default is
* NONE_ACTION.
*/
public int getDeleteAction () { return _deleteAction; }
/** Set the delete action for this relationship element.
* @param action - an integer indicating the delete action, one of:
* {@link RelationshipElement#NONE_ACTION},
* {@link RelationshipElement#NULLIFY_ACTION},
* {@link RelationshipElement#RESTRICT_ACTION},
* {@link RelationshipElement#CASCADE_ACTION}, or
* {@link RelationshipElement#AGGREGATE_ACTION}
* @exception ModelException if impossible
*/
public void setDeleteAction (int action) throws ModelException
{
Integer old = new Integer(getDeleteAction());
Integer newAction = new Integer(action);
try
{
fireVetoableChange(PROP_DELETE_ACTION, old, newAction);
_deleteAction = action;
firePropertyChange(PROP_DELETE_ACTION, old, newAction);
}
catch (PropertyVetoException e)
{
throw new ModelVetoException(e);
}
}
/** Determines whether this relationship element should prefetch or not.
* @return <code>true if the relationship should prefetch,
* <code>false otherwise. The default is
Other Glassfish examples (source code examples)Here is a short list of links related to this Glassfish RelationshipElementImpl.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.