Propchange: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/JavaModel.mdl ------------------------------------------------------------------------------ svn:executable = *
Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/JavaModelFactory.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/JavaModelFactory.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/JavaModelFactory.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/JavaModelFactory.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,91 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.java; + +import org.apache.jdo.model.ModelException; +import org.apache.jdo.model.ModelFatalException; + +/** + * The JavaModelFactory is the interface to use to obtain JavaModel + * instances. It defines methods to create and retrieve JavaModel + * instances. Furthermore it defines a convenience method to retrieve a + * JavaType by an implementation specific type description. + * + * @author Michael Bouschen + * @since JDO 1.0.1 + */ +public interface JavaModelFactory +{ + /** + * Creates a new empty JavaModel instance. A factory implementation may + * use the specified key when caching the new JavaModel instance. + * <p> + * Each JavaModelFactory imposes its own restrictions for the keys to + * cache JavaModel instances. Some implementations will allow only keys + * of a certain type. Some implementations will prohibit + * <code>null</code> keys. Attempting to use an ineligible key will + * result in a [EMAIL PROTECTED] org.apache.jdo.model.ModelException}. This means + * the specified key is of an inappropriate type for this + * JavaModelFactory or if the key is <code>null</code> and this + * JavaModelFactory does not support <code>null</code> keys. + * @param key the key that may be used to cache the returned JavaModel + * instance. + * @return a new JavaModel instance. + * @exception ModelException if impossible; the key is of an + * inappropriate type or the key is <code>null</code> and this + * JavaModelFactory does not support <code>null</code> keys. + */ + public JavaModel createJavaModel(Object key) + throws ModelException; + + /** + * Returns the JavaModel instance for the specified key. + * <p> + * The method throws a [EMAIL PROTECTED] org.apache.jdo.model.ModelFatalException}, + * if the specified key is of an inappropriate type for this + * JavaModelFactory or if the key is <code>null</code> and this + * JavaModelFactory does not support <code>null</code> keys. + * @param key the key used to cache the returned JavaModel instance. + * @return a JavaModel instance for the specified key. + * @exception ModelFatalException the key is of an inappropriate type + * or the key is <code>null</code> and this JavaModelFactory does not + * support <code>null</code> keys. + */ + public JavaModel getJavaModel(Object key) + throws ModelFatalException; + + /** + * Returns a JavaType instance for the specified type description + * (optional operation). This method is a convenience method and a + * short cut for <code>getJavaModel(key).getJavaType(typeName)</code>. + * If the factory supports this method, it needs to be able to get the + * key for the JavaModel lookup and the type name for the JavaType + * lookup from the specified typeDesc. An example for such an type + * description is the java.lang.Class instance in the runtime + * environment. + * <p> + * The method throws a [EMAIL PROTECTED] org.apache.jdo.model.ModelFatalException}, + * if this factory does not support this short cut or if it does not + * support the specified type description. + * @param typeDesc the type description. + * @return a JavaType instance for the specified type. + * @exception ModelFatalException this factory does not support this + * short cut or does not support the specified type description. + */ + public JavaType getJavaType(Object typeDesc) + throws ModelFatalException; +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/JavaType.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/JavaType.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/JavaType.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/JavaType.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,286 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.java; + +import org.apache.jdo.model.ModelFatalException; +import org.apache.jdo.model.jdo.JDOClass; + + +/** + * A JavaType instance represents a type as defined in the Java + * language. The interface defines interrogative methods to check whether a + * type is primitive, an interface or array, is a JDO supported collection + * or map, is a value or trackable class, is a persistence capable class, + * etc. Furthermore it defines methods to get detailed information about + * the type such as name, modifiers, superclass and the JDO meta data if + * this type represent a persistence capable class. + * <p> + * Different environments (runtime, enhancer, development) will have + * different JavaType implementations to provide answers to the various + * methods. + * + * @author Michael Bouschen + * @since JDO 1.0.1 + */ +public interface JavaType +{ + /** + * Returns <code>true</code> if this JavaType represents a primitive + * type. + * <p> + * There are eight primitive types: <code>boolean</code>, + * <code>byte</code>, <code>short</code>, <code>int</code>, + * <code>long</code>, <code>char</code>, + * <code>float</code>, <code>double</code>. + * @return <code>true</code> if this JavaType represents a primitive + * type; <code>false</code> otherwise. + */ + public boolean isPrimitive(); + + /** + * Returns <code>true</code> if this JavaType represents an integral + * type. + * <p> + * There are five are integral types: <code>byte</code>, + * <code>short</code>, <code>int</code>, <code>long</code>, and + * <code>char</code>. + * @return <code>true</code> if this JavaType represents an integral + * type; <code>false</code> otherwise. + */ + public boolean isIntegral(); + + /** + * Returns <code>true</code> if this JavaType represents a floating + * point type. + * <p> + * There are two are floating point types: + * <code>float</code> and <code>double</code>. + * @return <code>true</code> if this JavaType represents a floating + * point type; <code>false</code> otherwise. + */ + public boolean isFloatingPoint(); + + /** + * Determines if this JavaType object represents an interface type. + * @return <code>true</code> if this object represents an interface type; + * <code>false</code> otherwise. + */ + public boolean isInterface(); + + /** + * Determines if this JavaType object represents an array type. + * @return <code>true</code> if this object represents an array type; + * <code>false</code> otherwise. + */ + public boolean isArray(); + + /** + * Returns <code>true</code> if this JavaType represents a Java wrapper + * class type. + * <p> + * There are eight Java wrapper class types: + * <code>java.lang.Boolean</code>, <code>java.lang.Byte</code>, + * <code>java.lang.Short</code>, <code>java.lang.Integer</code>, + * <code>java.lang.Long</code>, <code>java.lang.Character</code>, + * <code>java.lang.Float</code>, <code>java.lang.Double</code>. + * @return <code>true</code> if this JavaType represents a Java wrapper + * class type; <code>false</code> otherwise. + */ + public boolean isWrapperClass(); + + /** + * Returns <code>true</code> if this JavaType represents a JDO + * supported collection type. The JDO specification allows the + * following collection interfaces and classes as types of persistent + * fields (see section 6.4.3 Persistent fields): + * <ul> + * <li><code>java.util.Collection</code>, <code>java.util.Set</code>, + * <code>java.util.List</code> + * <li><code>java.util.HashSet</code>, <code>java.util.TreeSet</code> + * <li><code>java.util.ArrayList</code>, <code>java.util.LinkedList</code> + * <li><code>java.util.Vector</code>, <code>java.util.Stack</code> + * </ul> + * @return <code>true</code> if this JavaType represents a JDO + * supported collection; <code>false</code> otherwise. + */ + public boolean isJDOSupportedCollection(); + + /** + * Returns <code>true</code> if this JavaType represents a JDO + * supported map type. The JDO specification allows the + * following map interfaces and classes as types of persistent + * fields (see section 6.4.3 Persistent fields): + * <ul> + * <li><code>java.util.Map</code> + * <li><code>java.util.HashMap</code>, <code>java.util.TreeMap</code> + * <li> <code>java.util.Hashtable</code>, <code>java.util.Properties</code> + * </ul> + * @return <code>true</code> if this JavaType represents a JDO + * supported map; <code>false</code> otherwise. + */ + public boolean isJDOSupportedMap(); + + /** + * Returns <code>true</code> if this JavaType represents a trackable + * Java class. A JDO implementation may replace a persistent field of + * a trackable type with an assignment compatible instance of its own + * implementation of this type which notifies the owning FCO of any + * change of this field. + * <p> + * The following types are trackable types: + * <ul> + * <li>JDO supported collection types + * <li>JDO supported map types + * <li><code>java.util.Date</code>, <code>java.sql.Date</code>, + * <code>java.sql.Time</code>, <code>java.sql.Timestamp</code> + * <li><code>java.util.BitSet</code> + * </ul> + * @return <code>true</code> if this JavaType represents a trackable + * Java class, <code>false</code> otherwise. + */ + public boolean isTrackable(); + + /** + * Returns <code>true</code> if this JavaType represents a type whose + * values may be treated as values rather than references during + * storing. A value type is either a primitive type or a type a JDO + * implementation may treat as SCO and the type is not one the + * following types: array, JDO supported collection and JDO supported + * map. + * <p> + * The following classes are value types: + * <ul> + * <li>primitive types + * <li>Java wrapper class types + * <li><code>java.lang.Number</code>, <code>java.lang.String</code> + * <li><code>java.util.Locale</code> + * <li><code>java.math.BigDecimal</code>, <code>java.math.BigInteger</code> + * <li><code>java.util.Date</code>, <code>java.sql.Date</code>, + * <code>java.sql.Time</code>, <code>java.sql.Timestamp</code> + * <li><code>java.util.BitSet</code> + * </ul> + * @return <code>true</code> if this JavaType represents a value type; + * <code>false</code> otherwise. + */ + public boolean isValue(); + + /** + * Returns <code>true</code> if this JavaType represents an orderable + * type as specified in JDO. + * <p> + * The following types are orderable: + * <ul> + * <li>primitive types except <code>boolean</code> + * <li>Java wrapper class types except <code>java.lang.Boolean</code> + * <li><code>java.lang.String</code> + * <li><code>java.math.BigDecimal</code>, <code>java.math.BigInteger</code> + * <li><code>java.util.Date</code>, <code>java.sql.Date</code>, + * <code>java.sql.Time</code>, <code>java.sql.Timestamp</code> + * </ul> + * Note, this method does not check whether this JavaType implements + * the Comparable interface. + * @return <code>true</code> if this JavaType represents an orderable + * type; <code>false</code> otherwise. + */ + public boolean isOrderable(); + + /** + * Returns <code>true</code> if this JavaType represents a persistence + * capable class. + * <p> + * A [EMAIL PROTECTED] org.apache.jdo.model.ModelFatalException} indicates a + * problem accessing the JDO meta data for this JavaType. + * @return <code>true</code> if this JavaType represents a persistence + * capable class; <code>false</code> otherwise. + * @exception ModelFatalException if there is a problem accessing the + * JDO metadata + */ + public boolean isPersistenceCapable() + throws ModelFatalException; + + /** + * Returns true if this JavaType is compatible with the specified + * JavaType. + * @param javaType the type this JavaType is checked with. + * @return <code>true</code> if this is compatible with the specified + * type; <code>false</code> otherwise. + */ + public boolean isCompatibleWith(JavaType javaType); + + /** + * Returns the name of the type. If this type represents a class or + * interface, the name is fully qualified. + * @return type name + */ + public String getName(); + + /** + * Returns the Java language modifiers for the field represented by + * this JavaType, as an integer. The java.lang.reflect.Modifier class + * should be used to decode the modifiers. + * @return the Java language modifiers for this JavaType + */ + public int getModifiers(); + + /** + * Returns the JavaType representing the superclass of the entity + * represented by this JavaType. If this JavaType represents either the + * Object class, an interface, a primitive type, or <code>void</code>, + * then <code>null</code> is returned. If this object represents an + * array class then the JavaType instance representing the Object class + * is returned. + * @return the superclass of the class represented by this JavaType. + */ + public JavaType getSuperclass(); + + /** + * Returns the JDOClass instance if this JavaType represents a + * persistence capable class. The method returns <code>null</code>, + * if this JavaType does not represent a persistence capable class. + * <p> + * A [EMAIL PROTECTED] org.apache.jdo.model.ModelFatalException} indicates a + * problem accessing the JDO meta data for this JavaType. + * @return the JDOClass instance if this JavaType represents a + * persistence capable class; <code>null</code> otherwise. + * @exception ModelFatalException if there is a problem accessing the + * JDO metadata + */ + public JDOClass getJDOClass() + throws ModelFatalException; + + /** + * Returns the JavaType representing the component type of an array. + * If this JavaType does not represent an array type this method + * returns <code>null</code>. + * @return the JavaType representing the component type of this + * JavaType if this class is an array; <code>null</code> otherwise. + */ + public JavaType getArrayComponentType(); + + /** + * Returns a JavaField instance that reflects the field with the + * specified name of the class or interface represented by this + * JavaType instance. The method returns <code>null</code>, if the + * class or interface (or one of its superclasses) does not have a + * field with that name. + * @param name the name of the field + * @return the JavaField instance for the specified field in this class + * or <code>null</code> if there is no such field. + */ + public JavaField getJavaField(String name); + +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/package.html URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/package.html?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/package.html (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/java/package.html Fri Mar 18 17:02:29 2005 @@ -0,0 +1,28 @@ +<!-- + Copyright 2005 The Apache Software Foundation. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<html> +<head> +<title>JavaModel API package.</title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> +</head> + +<body bgcolor="#FFFFFF"> +<p>This package defines the JavaModel API. + It provides interfaces for environment independent (development, enhancer, + runtime) Java metadata access. +</body> +</html> Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOArray.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOArray.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOArray.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOArray.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,58 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +import org.apache.jdo.model.ModelException; +import org.apache.jdo.model.java.JavaType; + + +/** + * A JDOArray instance represents the JDO relationship metadata + * of a array relationship field. + * + * @author Michael Bouschen + */ +public interface JDOArray + extends JDORelationship +{ + /** + * Determines whether the values of the elements should be stored + * if possible as part of the instance instead of as their own instances + * in the datastore. + * @return <code>true</code> if the elements should be stored as part of + * the instance; <code>false</code> otherwise + */ + public boolean isEmbeddedElement(); + + /** + * Set whether the values of the elements should be stored + * if possible as part of the instance instead of as their own instances + * in the datastore. + * @param embeddedElement flag indicating whether the elements should be + * stored as part of the instance + * @exception ModelException if impossible + */ + public void setEmbeddedElement(boolean embeddedElement) + throws ModelException; + + /** + * Get the type representation of the array component type. + * @return the array component type + */ + public JavaType getElementType(); + +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOClass.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOClass.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOClass.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOClass.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,488 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +import org.apache.jdo.model.ModelException; +import org.apache.jdo.model.java.JavaType; + + +/** + * A JDOClass instance represents the JDO metadata of a persistence-capable + * class. + * + * @author Michael Bouschen + * @version 1.1 + */ +public interface JDOClass + extends JDOMember +{ + /** + * Get the JDO identity type of this JDOClass. + * The identity type of the least-derived persistence-capable class defines + * the identity type for all persistence-capable classes that extend it. + * The identity type of the least-derived persistence-capable class is + * defaulted to [EMAIL PROTECTED] JDOIdentityType#APPLICATION} if objectid-class is + * specified, and [EMAIL PROTECTED] JDOIdentityType#DATASTORE}, if not. + * @return the JDO identity type, one of + * [EMAIL PROTECTED] JDOIdentityType#APPLICATION}, + * [EMAIL PROTECTED] JDOIdentityType#DATASTORE}, or + * [EMAIL PROTECTED] JDOIdentityType#NONDURABLE} + */ + public int getIdentityType(); + + /** + * Set the object identity type of this JDOClass. + * @param identityType an integer indicating the JDO identity type, one of: + * [EMAIL PROTECTED] JDOIdentityType#APPLICATION}, + * [EMAIL PROTECTED] JDOIdentityType#DATASTORE}, or + * [EMAIL PROTECTED] JDOIdentityType#NONDURABLE} + * @exception ModelException if impossible + */ + public void setIdentityType(int identityType) + throws ModelException; + + /** + * Get the JavaType representation of the object identity class + * (primary key class) for this JDOClass. + * @return the JavaType representation of the object identity class. + */ + public JavaType getObjectIdClass(); + + /** + * Set the JavaType representation of the object identity class + * (primary key class) for this JDOClass. + * @param objectIdClass the JavaType representation of the + * object identity class. + * @exception ModelException if impossible + */ + public void setObjectIdClass(JavaType objectIdClass) + throws ModelException; + + /** + * Get the fully qualified name of the object identity class + * (primary key class) declared for this JDOClass. + * Please note, this method returns a non null class name, only if the + * JDO metadata defines an objectIdClass for exactly the pc class + * represented by this JDOClass. If there is no objectIdClass defines for + * this JDOClass, but any of the pc-superclasses defines an objectIdClass, + * this method returns <code>null</code>. This is different from method + * [EMAIL PROTECTED] #getObjectIdClass} which returns a non-null value, if the + * superclass defines a objectIdClass. + * @return the name of the object identity class. + */ + public String getDeclaredObjectIdClassName(); + + /** + * Set the fully qualified name of the object identity class + * (primary key class) declared for this JDOClass. + * @param declaredObjectIdClassName the name of the object identity class + * @exception ModelException if impossible + */ + public void setDeclaredObjectIdClassName(String declaredObjectIdClassName) + throws ModelException; + + /** + * Determines whether an extent must be managed for the + * persistence-capable class described by this JDOClass. + * @return <code>true</true> if this class must manage an extent; + * <code>false</code> otherwise + */ + public boolean requiresExtent(); + + /** + * Set whether an extent must be managed for the + * persistence-capable class described by this JDOClass. + * @param requiresExtent <code>true</code> if this class must manage + * an extent; <code>false</code> otherwise + * @exception ModelException if impossible + */ + public void setRequiresExtent(boolean requiresExtent) + throws ModelException; + + /** + * Get the fully qualified class name of the persistence-capable superclass + * of the persistence-capable class described by this JDOClass. If this + * class does not have a persistence-capable superclass then + * <code>null</code> is returned. + * @return the fully qualified name of the persistence-capable superclass + * or <code>null</code> if there is no persistence-capable superclass + */ + public String getPersistenceCapableSuperclassName(); + + /** + * Set the fully qualified class name of the persistence-capable superclass + * of the persistence-capable class described by this JDOClass. + * @param pcSuperclassName the fully qualified name of the + * persistence-capable superclass + * @exception ModelException if impossible + */ + public void setPersistenceCapableSuperclassName(String pcSuperclassName) + throws ModelException; + + /** + * Provides the JavaType representaion corresponding to this JDOClass. + * <p> + * Note the difference between Object.getClass) and this method. The + * former returns the class of the object in hand, this returns the class + * of the object represented by this meta data. + * @return the JavaType object corresponding to this JDOClass. + */ + public JavaType getJavaType(); + + /** + * Set the JavaType representation corresponding to this JDOClass. + * @param javaType the JavaType representation for this JDOClass. + * @exception ModelException if impossible + */ + public void setJavaType(JavaType javaType) + throws ModelException; + + /** + * Remove the supplied member from the collection of members maintained by + * this JDOClass. + * @param member the member to be removed + * @exception ModelException if impossible + */ + public void removeDeclaredMember(JDOMember member) + throws ModelException; + + /** + * Returns the collection of JDOMember instances declared by this JDOClass + * in form of an array. + * @return the members declared by this JDOClass + */ + public JDOMember[] getDeclaredMembers(); + + /** + * Returns the declaring JDOModel of this JDOClass. + * @return the JDOModel that owns this JDOClass + */ + public JDOModel getDeclaringModel(); + + /** + * Set the declaring JDOModel for this JDOClass. + * @param model the declaring JDOModel of this JDOClass + */ + public void setDeclaringModel(JDOModel model); + + /** + * Returns the JDOClass instance for the persistence-capable superclass + * of this JDOClass. If this class does not have a persistence-capable + * superclass then <code>null</code> is returned. + * @return the JDClass instance of the persistence-capable superclass + * or <code>null</code> if there is no persistence-capable superclass + */ + public JDOClass getPersistenceCapableSuperclass(); + + /** + * Set the JDOClass for the persistence-capable superclass + * of this JDOClass. + * @param pcSuperclass the JDClass instance of the persistence-capable + * superclass + * @exception ModelException if impossible + */ + public void setPersistenceCapableSuperclass(JDOClass pcSuperclass) + throws ModelException; + + /** + * Returns the JDOPackage instance corresponding to the package name + * of this JDOClass. + * @return the JDOPackage instance of this JDOClass. + */ + public JDOPackage getJDOPackage(); + + /** + * Sets the JDOPackage instance corresponding to the package name + * of this JDOClass. + * @param jdoPackage the JDOPackage of this JDOClass. + */ + public void setJDOPackage(JDOPackage jdoPackage); + + /** + * This method returns a JDOField instance for the field with the specified + * name. If this JDOClass already declares such a field, the existing + * JDOField instance is returned. Otherwise, it creates a new JDOField + * instance, sets its declaringClass and returns the new instance. + * @param name the name of the field + * @exception ModelException if impossible + */ + public JDOField createJDOField(String name) + throws ModelException; + + /** + * This method returns a JDOClass instance representing an inner class of + * this JDOClass If this JDOClass already declares such an inner class, + * the existing JDOClass instance is returned. Otherwise, it creates a new + * JDOClass instance, sets its declaringClass and returns the new instance. + * @param name the name of the inner class + * @exception ModelException if impossible + */ + public JDOClass createJDOClass(String name) + throws ModelException; + + /** + * Returns the collection of JDOClass instances declared by this JDOClass. + * @return the classes declared by this JDOClass + */ + public JDOClass[] getDeclaredClasses(); + + /** + * Returns the collection of JDOField instances declared by this JDOClass + * in the form of an array. This does not include inherited fields. + * @return the fields declared by this JDOClass + */ + public JDOField[] getDeclaredFields(); + + /** + * Returns the collection of managed JDOField instances declared by this + * JDOClass in the form of an array. The returned array does not include + * inherited fields. A field is a managed field, if it has the + * persistence-modifier [EMAIL PROTECTED] PersistenceModifier#PERSISTENT} or + * [EMAIL PROTECTED] PersistenceModifier#TRANSACTIONAL}. The position of the fields + * in the returned array equals their relative field number as returned by + * [EMAIL PROTECTED] JDOField#getRelativeFieldNumber()}. The following holds true for + * any field in the returned array: + * <ul> + * <li> <code>getDeclaredManagedFields()[i].getRelativeFieldNumber() + * == i</code> + * <li> <code>getDeclaredManagedFields()[field.getRelativeFieldNumber()] + * == field</code> + * </ul> + * @return the managed fields declared by this JDOClass + */ + public JDOField[] getDeclaredManagedFields(); + + /** + * Returns the collection of managed JDOField instances of this JDOClass + * in the form of an array. The returned array includes inherited fields. + * A field is a managed field, if it has the persistence-modifier + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT} or + * [EMAIL PROTECTED] PersistenceModifier#TRANSACTIONAL}. The position of the fields + * in the returned array equals their absolute field number as returned by + * [EMAIL PROTECTED] JDOField#getFieldNumber()}. The following holds true for any + * field in the returned array: + * <ul> + * <li> <code>getManagedFields()[i].getFieldNumber() == i</code> + * <li> <code>getManagedFields()[field.getFieldNumber()] == field</code> + * </ul> + * @return the managed fields of this JDOClass + */ + public JDOField[] getManagedFields(); + + /** + * Returns the collection of persistent JDOField instances of this JDOClass + * in the form of an array. The returned array includes inherited fields. + * A field is a persistent field, if it has the persistence-modifier + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT}. + * Please note, the position of the fields in the returned array might not + * equal their absolute field number as returned by + * [EMAIL PROTECTED] JDOField#getFieldNumber()}. + * @return the persistent fields of this JDOClass + */ + public JDOField[] getPersistentFields(); + + /** + * Returns the collection of identifying fields of this JDOClass in the form + * of an array. The method returns the JDOField instances defined as + * primary key fields (see [EMAIL PROTECTED] JDOField#isPrimaryKey}). + * @return the identifying fields of this JDOClass + */ + public JDOField[] getPrimaryKeyFields(); + + /** + * Returns the collection of persistent relationship fields of this JDOClass + * in the form of an array. The method returns the JDOField instances + * defined as relationship (method [EMAIL PROTECTED] JDOField#getRelationship} returns + * a non null value) and having the persistence-modifier + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT}. + * @return the persistent relationship fields of this JDOClass + */ + public JDOField[] getPersistentRelationshipFields(); + + /** + * Returns the collection of default fetch group fields of this JDOClass + * in the form of an array. The method returns the JDOField instances + * defined as part of the default fetch group + * (method [EMAIL PROTECTED] JDOField#isDefaultFetchGroup} returns <code>true</code>. + * @return the default fetch group fields of this JDOClass + * @since 1.1 + */ + public JDOField[] getDefaultFetchGroupFields(); + + /** + * Returns an array of absolute field numbers of the managed fields of this + * JDOClass. The returned array includes field numbers of inherited fields. + * A field is a managed field, if it has the persistence-modifier + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT} or + * [EMAIL PROTECTED] PersistenceModifier#TRANSACTIONAL}. + * Only managed fields have a valid field number, thus the field number in + * the returned array equals its index: + * <br> + * <code>getManagedFields()[i] == i</code> + */ + public int[] getManagedFieldNumbers(); + + /** + * Returns an array of absolute field numbers of the persistent fields of + * this JDOClass. The returned array includes field numbers of inherited + * fields. A persistent field has the persistence-modifier + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT}. + */ + public int[] getPersistentFieldNumbers(); + + /** + * Returns an array of absolute field numbers of the identifying fields + * of this JDOClass. A field number is included in the returned array, + * iff the corresponding JDOField instance is defined as primary key field + * (see [EMAIL PROTECTED] JDOField#isPrimaryKey}). + * @return array of numbers of the identifying fields + */ + public int[] getPrimaryKeyFieldNumbers(); + + /** + * Returns an array of absolute field numbers of the non identifying, + * persistent fields of this JDOClass. A field number is included in the + * returned array, iff the corresponding JDOField instance is persistent and + * not a not a primary key field (see [EMAIL PROTECTED] JDOField#isPrimaryKey}). + * A field is a persistent field, if it has the persistence-modifier + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT} or + * (see [EMAIL PROTECTED] JDOField#getPersistenceModifier}). + * @return array of numbers of the non identifying, persistent fields + */ + public int[] getPersistentNonPrimaryKeyFieldNumbers(); + + /** + * Returns an array of absolute field numbers of persistent relationship + * fields of this JDOClass. A field number is included in the returned + * array, iff the corresponding JDOField instance is a relationship (method + * [EMAIL PROTECTED] JDOField#getRelationship} returns a non null value) and has the + * persistence-modifier [EMAIL PROTECTED] PersistenceModifier#PERSISTENT}. + * @return the field numbers of the persistent relationship fields + */ + public int[] getPersistentRelationshipFieldNumbers(); + + /** + * Returns an array of absolute field numbers of persistent, serializable + * fields of this JDOClass. A field number is included in the returned + * array, iff the corresponding JDOField instance is serializable (method + * [EMAIL PROTECTED] JDOField#isSerializable} returns <code>true</code>) and has the + * persistence-modifier [EMAIL PROTECTED] PersistenceModifier#PERSISTENT}. + * @return the field numbers of serializable fields + */ + public int[] getPersistentSerializableFieldNumbers(); + + /** + * Returns JDOField metadata for a particular managed field specified by + * field name. It returns <code>null</code> if the specified name does not + * denote a managed field of this JDOClass. The field name may be + * unqualified and or qualified (see [EMAIL PROTECTED] #getField(String fieldName)}). + * @param fieldName the name of the managed field for which field metadata + * is needed. + * @return JDOField metadata for the managed field or <code>null</code> + * if there is no such field. + */ + public JDOField getManagedField(String fieldName); + + /** + * Returns JDOField metadata for a particular field specified by field name. + * It returns <code>null</code> if the specified name does not denote a + * field of this JDOClass. + * <p> + * The method supports lookup by unqualified and by qualified field name. + * <ul> + * <li> In the case of an unqualified field name the method starts checking + * this JDOClass for a field with the specified name. If this class does not + * define such a field, it checks the inheritance hierarchy starting with + * its direct persistence-capable superclass. The method finds the first + * field with the specified name in a bootom-up lookup of the inheritance + * hierarchy. Hidden fields are not visible. + * <li> In the case of a qualified field name the method assumes a fully + * qualified class name (called qualifier class) as the field qualifier. + * The qualifier class must be a either this class or a persistence-capable + * superclass (direct or indirect) of this class. Then the method searches + * the field definition in the inheritance hierarchy staring with the + * qualifier class. Any field declarations with the same name in subclasses + * of the qualifier class are not considered. This form allows accessing + * fields hidden by subclasses. The method returns <code>null</code> if the + * qualifier class does not denote a valid class or if the qualifier class + * is not a persistence-capable superclass of this class. + * </ul> + * @param fieldName the unqualified or qualified name of field for which + * field metadata is needed. + * @return JDOField metadata for the field or <code>null</code> + * if there is no such field. + */ + public JDOField getField(String fieldName); + + /** + * Provides metadata for a particular field specified by the absolute field + * number. The field number must be a valid absolute field number for this + * JDOClass: <code>0 <= fieldNumber < this.getManagedFields().length</code> + * If the field number is valid the returned JDoField instance denotes a + * managed field, meaning the field has the persistence-modifier + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT} or + * [EMAIL PROTECTED] PersistenceModifier#TRANSACTIONAL}. If the field number is not + * valid then the method returns <code>null</code>. + * @param fieldNumber the number for which field metadata is needed. + * @return JDOField metadata for the field or <code>null</code> + * if there is no such field. + */ + public JDOField getField(int fieldNumber); + + /** + * Returns JDOField metadata for a particular declared field specified by + * field name. Please note, the method does not return inherited fields. + * The field name must not be qualified by a class name. The method returns + * <code>null</code> if the field name does not denote a field declared by + * JDOClass. + * @param fieldName the unqualified name of field for which field metadata + * is needed. + * @return JDOField metadata for the field or <code>null</code> + * if there is no such field declared by this JDOClass. + */ + public JDOField getDeclaredField(String fieldName); + + /** + * Returns the number of managed fields declared in this class. + * This does not include inherited fields. + * @return number of declared fields in the Class represented by this + * JDOClass + */ + public int getDeclaredManagedFieldCount(); + + /** + * Returns the number of inherited fields for this class. + * @return number of inherited fields + */ + public int getInheritedManagedFieldCount(); + + /** + * Returns the package name including a terminating dot if this class has a + * package. The method returns the empty string if this class is in the + * default package. + * @return package prefix for this class. + */ + public String getPackagePrefix(); + + /** + * Returns the least-derived (topmost) persistence-capable class in the + * hierarchy of this JDOClass. It returns this JDOClass if it has no + * persistence-capable superclass. + * @return the topmost persistence-capable class in the hierarchy. + */ + public JDOClass getPersistenceCapableRootClass(); +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOCollection.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOCollection.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOCollection.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOCollection.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,80 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +import org.apache.jdo.model.ModelException; +import org.apache.jdo.model.java.JavaType; + + +/** + * A JDOCollection instance represents the JDO relationship metadata + * of a collection relationship field. + * + * @author Michael Bouschen + */ +public interface JDOCollection + extends JDORelationship +{ + /** + * Determines whether the values of the elements should be stored if + * possible as part of the instance instead of as their own instances + * in the datastore. + * @return <code>true</code> if the elements should be stored as part of + * the instance; <code>false</code> otherwise + */ + public boolean isEmbeddedElement(); + + /** + * Set whether the values of the elements should be stored if possible as + * part of the instance instead of as their own instances in the datastore. + * @param embeddedElement <code>true</code> if elements should be stored + * as part of the instance + * @exception ModelException if impossible + */ + public void setEmbeddedElement(boolean embeddedElement) + throws ModelException; + + /** + * Get the type representation of the collection elements. + * @return the element type + */ + public JavaType getElementType(); + + /** + * Set the type representation of the collection elements. + * @param elementType the type representation of the collection elements + * @exception ModelException if impossible + */ + public void setElementType(JavaType elementType) + throws ModelException; + + /** + * Get the type of collection elements as string. + * @return the element type as string + */ + public String getElementTypeName(); + + /** + * Set string representation of the type of collection elements. + * @param elementTypeName a string representation of the type of elements in + * the collection. + * @exception ModelException if impossible + */ + public void setElementTypeName(String elementTypeName) + throws ModelException; + +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOElement.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOElement.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOElement.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOElement.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,87 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +import java.beans.PropertyChangeListener; +import java.beans.VetoableChangeListener; + +import org.apache.jdo.model.ModelException; + +/** + * This is the super interface for JDO metadata elements, + * such as JDOClass, JDOField and JDORelationship. + * + * @author Michael Bouschen + */ +public interface JDOElement +{ + /** + * Remove the supplied vendor extension from the collection of extensions + * maintained by this JDOElement. + * @exception ModelException if impossible + */ + public void removeJDOExtension(JDOExtension vendorExtension) + throws ModelException; + + /** + * Returns the collection of vendor extensions for this JDOElement + * in the form of an array. + * @return the vendor extensions for this JDOClass + */ + public JDOExtension[] getJDOExtensions(); + + /** + * Creates a new JDOExtension instance and attaches it to the specified + * JDOElement object. + * @exception ModelException if impossible + */ + public JDOExtension createJDOExtension() + throws ModelException; + + /** + * Add a property change listener. + * @param l the listener to add + * @exception ModelException if impossible + */ + public void addPropertyChangeListener(PropertyChangeListener l) + throws ModelException; + + /** + * Remove a property change listener. + * @param l the listener to remove + * @exception ModelException if impossible + */ + public void removePropertyChangeListener(PropertyChangeListener l) + throws ModelException; + + /** + * Add a vetoable change listener. + * @param l the listener to add + * @exception ModelException if impossible + */ + public void addVetoableChangeListener(VetoableChangeListener l) + throws ModelException; + + /** + * Remove a vetoable change listener. + * @param l the listener to remove + * @exception ModelException if impossible + */ + public void removeVetoableChangeListener(VetoableChangeListener l) + throws ModelException; + +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOExtension.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOExtension.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOExtension.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOExtension.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,63 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +import org.apache.jdo.model.ModelException; + +/** + * A JDOExtension instance represents a JDO vendor specific extension. + * + * @author Michael Bouschen + */ +public interface JDOExtension +{ + /** + * Returns the vendor name of this vendor extension. + */ + public String getVendorName(); + + /** + * Sets the vendor name for this vendor extension. + * @exception ModelException if impossible + */ + public void setVendorName(String vendorName) + throws ModelException; + + /** + * Returns the key of this vendor extension. + */ + public String getKey(); + + /** + * Sets the key for this vendor extension. + * @exception ModelException if impossible + */ + public void setKey(String key) + throws ModelException; + + /** + * Returns the value of this vendor extension. + */ + public Object getValue(); + + /** + * Sets the value for this vendor extension. + * @exception ModelException if impossible + */ + public void setValue(Object value) + throws ModelException; +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOField.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOField.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOField.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOField.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,285 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +import org.apache.jdo.model.ModelException; +import org.apache.jdo.model.java.JavaField; +import org.apache.jdo.model.java.JavaType; + + +/** + * A JDOField instance represents the JDO metadata of a managed field + * of a persistence-capable class. + * + * @author Michael Bouschen + */ +public interface JDOField + extends JDOMember +{ + /** + * Get the persistence modifier of this JDOField. + * @return the persistence modifier, one of + * [EMAIL PROTECTED] PersistenceModifier#UNSPECIFIED}, + * [EMAIL PROTECTED] PersistenceModifier#NONE}, + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT}, + * [EMAIL PROTECTED] PersistenceModifier#TRANSACTIONAL}, + * [EMAIL PROTECTED] PersistenceModifier#POSSIBLY_PERSISTENT}. + */ + public int getPersistenceModifier(); + + /** + * Set the persistence modifier for this JDOField. + * @param persistenceModifier an integer indicating the persistence + * modifier, one of: [EMAIL PROTECTED] PersistenceModifier#UNSPECIFIED}, + * [EMAIL PROTECTED] PersistenceModifier#NONE}, + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT}, + * [EMAIL PROTECTED] PersistenceModifier#TRANSACTIONAL}, + * [EMAIL PROTECTED] PersistenceModifier#POSSIBLY_PERSISTENT}. + * @exception ModelException if impossible + */ + public void setPersistenceModifier (int persistenceModifier) + throws ModelException; + + /** + * Determines whether this JDOField is a key field or not. + * @return <code>true</code> if the field is a key field, + * <code>false</code> otherwise + */ + public boolean isPrimaryKey(); + + /** + * Set whether this JDOField is a key field or not. + * @param primaryKey if <code>true</code>, the JDOField is marked + * as a key field; otherwise, it is not + * @exception ModelException if impossible + */ + public void setPrimaryKey(boolean primaryKey) + throws ModelException; + + /** + * Gets the null value treatment indicator of this JDOField. + * @return the null value treatment of this JDOField, one of + * [EMAIL PROTECTED] NullValueTreatment#NONE}, [EMAIL PROTECTED] NullValueTreatment#EXCEPTION} or + * [EMAIL PROTECTED] NullValueTreatment#DEFAULT} + */ + public int getNullValueTreatment(); + + /** + * Sets the null value treatment indicator for this JDOField. + * @param nullValueTreament an integer indicating the null value treatment, + * one of: [EMAIL PROTECTED] NullValueTreatment#NONE}, + * [EMAIL PROTECTED] NullValueTreatment#EXCEPTION} or + * [EMAIL PROTECTED] NullValueTreatment#DEFAULT} + * @exception ModelException if impossible + */ + public void setNullValueTreatment(int nullValueTreament) + throws ModelException; + + /** + * Determines whether this JDOField is part of the default fetch group or + * not. + * @return <code>true</code> if the field is part of the default fetch + * group, <code>false</code> otherwise + */ + public boolean isDefaultFetchGroup(); + + /** + * Set whether this JDOField is part of the default fetch group or not. + * @param defaultFetchGroup if <code>true</code>, the JDOField is marked + * as beeing part of the default fetch group; otherwise, it is not + * @exception ModelException if impossible + */ + public void setDefaultFetchGroup(boolean defaultFetchGroup) + throws ModelException; + + /** + * Determines whether the field should be stored if possible as part of + * the instance instead of as its own instance in the datastore. + * @return <code>true</code> if the field is stored as part of the instance; + * <code>false</code> otherwise + */ + public boolean isEmbedded(); + + /** + * Set whether the field should be stored if possible as part of + * the instance instead of as its own instance in the datastore. + * @param embedded <code>true</code> if the field is stored as part of the + * instance; <code>false</code> otherwise + * @exception ModelException if impossible + */ + public void setEmbedded(boolean embedded) + throws ModelException; + + /** + * Determines whether this JDOField is serializable or not. + * @return <code>true</code> if the field is serializable, + * <code>false</code> otherwise + */ + public boolean isSerializable(); + + /** + * Set whether this JDOField is serializable or not. + * @param serializable if <code>true</code>, the JDOField is serializable; + * otherwise, it is not + * @exception ModelException if impossible + */ + public void setSerializable(boolean serializable) + throws ModelException; + + /** + * Get the corresponding Java field representation for this JDOField. + * @return the corresponding Java field representation + */ + public JavaField getJavaField(); + + /** + * Sets the corresponding Java field representation for this JDOField. + * @param javaField the corresponding Java field representation + * @exception ModelException if impossible + */ + public void setJavaField (JavaField javaField) + throws ModelException; + + /** + * Get the relationship information for this JDOField. The method + * returns null if the field is not part of a relationship + * (e.g. it is a primitive type field). + * @return relationship info of this JDOField or <code>null</code> if + * this JDOField is not a relationship + */ + public JDORelationship getRelationship(); + + /** + * Set the relationship information for this JDOField. + * @param relationship the JDORelationship instance + * @exception ModelException if impossible + */ + public void setRelationship(JDORelationship relationship) + throws ModelException; + + /** + * Creates and returns a new JDOReference instance. + * This method automatically binds the new JDOReference to this JDOField. + * It throws a ModelException, if this JDOField is already bound to + * another JDORelationship instance. Otherwise the following holds true: + * <ul> + * <li> Method [EMAIL PROTECTED] #getRelationship} returns the new created instance + * <li> <code>this.getRelationship().getDeclaringField() == this</code> + * </ul> + * @return a new JDOReference instance bound to this JDOField + * @exception ModelException if impossible + */ + public JDOReference createJDOReference() + throws ModelException; + + /** + * Creates and returns a new JDOCollection instance. + * This method automatically binds the new JDOCollection to this JDOField. + * It throws a ModelException, if this JDOField is already bound to + * another JDORelationship instance. Otherwise the following holds true: + * <ul> + * <li> Method [EMAIL PROTECTED] #getRelationship} returns the new created instance + * <li> <code>this.getRelationship().getDeclaringField() == this</code> + * </ul> + * @return a new JDOCollection instance bound to this JDOField + * @exception ModelException if impossible + */ + public JDOCollection createJDOCollection() + throws ModelException; + + /** + * Creates and returns a new JDOArray instance. + * This method automatically binds the new JDOArray to this JDOField. + * It throws a ModelException, if this JDOField is already bound to + * another JDORelationship instance. Otherwise the following holds true: + * <ul> + * <li> Method [EMAIL PROTECTED] #getRelationship} returns the new created instance + * <li> <code>this.getRelationship().getDeclaringField() == this</code> + * </ul> + * @return a new JDOArray instance bound to this JDOField + * @exception ModelException if impossible + */ + public JDOArray createJDOArray() + throws ModelException; + + /** + * Creates and returns a new JDOMap instance. + * This method automatically binds the new JDOMap to this JDOField. + * It throws a ModelException, if this JDOField is already bound to + * another JDORelationship instance. Otherwise the following holds true: + * <ul> + * <li> Method [EMAIL PROTECTED] #getRelationship} returns the new created instance + * <li> <code>this.getRelationship().getDeclaringField() == this</code> + * </ul> + * @return a new JDOMap instance bound to this JDOField + * @exception ModelException if impossible + */ + public JDOMap createJDOMap() + throws ModelException; + + /** + * Convenience method to check the persistence modifier from this JDOField. + * @return <code>true</code> if this field has the + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT} modifier; <code>false</code> + * otherwise + */ + public boolean isPersistent(); + + /** + * Convenience method to check the persistence modifier from this JDOField. + * @return <code>true</code> if this field has the + * [EMAIL PROTECTED] PersistenceModifier#TRANSACTIONAL} modifier; <code>false</code> + * otherwise + */ + public boolean isTransactional(); + + /** + * Convenience method to check the persistence modifier from this JDOField. + * A field is a managed field, if it has the persistence-modifier + * [EMAIL PROTECTED] PersistenceModifier#PERSISTENT} or + * [EMAIL PROTECTED] PersistenceModifier#TRANSACTIONAL}. + * @return <code>true</code> if this field is a managed field; + * <code>false</code> otherwise + */ + public boolean isManaged(); + + /** + * Convenience method to check whether this field is a relationship field. + * @return <code>true</code> if this field is a relationship; + * <code>false</code> otherwise + */ + public boolean isRelationship(); + + /** + * Get the JavaType representation of the type of the field. + * @return JavaType representation of the type of this field. + */ + public JavaType getType(); + + /** + * Returns the absolute field number of this JDOField. + * @return the absolute field number + */ + public int getFieldNumber(); + + /** + * Returns the relative field number of this JDOField. + * @return the relative field number + */ + public int getRelativeFieldNumber(); + +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOIdentityType.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOIdentityType.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOIdentityType.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOIdentityType.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,79 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +/** + * This interface provides constants denoting the identity type + * of a persistence-capable class. + * + * @author Michael Bouschen + */ +public class JDOIdentityType +{ + /** Constant representing an unspecified jdo identity */ + public static final int UNSPECIFIED = 0; + + /** Constant representing jdo identity managed by the database. */ + public static final int DATASTORE = 1; + + /** Constant representing jdo identity managed by the application. */ + public static final int APPLICATION = 2; + + /** Constant representing unmanaged jdo identity. */ + public static final int NONDURABLE = 4; + + /** + * Returns a string representation of the specified identity type constant. + * @param jdoIdentityType the JDO identity type, one of + * [EMAIL PROTECTED] #APPLICATION}, [EMAIL PROTECTED] #DATASTORE}, or [EMAIL PROTECTED] #NONDURABLE} + * @return the string representation of the JDOIdentityType constant + */ + public static String toString(int jdoIdentityType) { + switch ( jdoIdentityType) { + case DATASTORE : + return "datastore"; //NOI18N + case APPLICATION : + return "application"; //NOI18N + case NONDURABLE: + return "nondurable"; //NOI18N + default: + return "UNSPECIFIED"; //NOI18N + } + } + + /** + * Returns the JDOIdentityType constant, one of [EMAIL PROTECTED] #APPLICATION}, + * [EMAIL PROTECTED] #DATASTORE}, or [EMAIL PROTECTED] #NONDURABLE} for the specified string. + * @param jdoIdentityType the string representation of the + * JDO identity type + * @return the JDO identity type + **/ + public static int toJDOIdentityType(String jdoIdentityType) + { + if ((jdoIdentityType == null) || (jdoIdentityType.length() == 0)) + return UNSPECIFIED; + + if ("datastore".equals(jdoIdentityType)) //NOI18N + return DATASTORE; + else if ("application".equals(jdoIdentityType)) //NOI18N + return APPLICATION; + else if ("nondurable".equals(jdoIdentityType)) //NOI18N + return NONDURABLE; + else + return UNSPECIFIED; + } +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOMap.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOMap.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOMap.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOMap.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,124 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +import org.apache.jdo.model.ModelException; +import org.apache.jdo.model.java.JavaType; + + +/** + * A JDOMap instance represents the JDO relationship metadata + * (the treatment of keys and values) of a map relationship field. + * + * @author Michael Bouschen + */ +public interface JDOMap + extends JDORelationship +{ + /** + * Determines whether the keys of the map should be stored if possible as + * part of the instance instead of as their own instances in the datastore. + * @return <code>true</code> if the keys are stored as part of this instance; + * <code>false</code> otherwise + */ + public boolean isEmbeddedKey(); + + /** + * Set whether the keys of the map should be stored if possible as part + * of the instance instead of as their own instances in the datastore. + * @param embeddedKey <code>true</code> if the keys are stored as part of + * this instance; <code>false</code> otherwise + * @exception ModelException if impossible + */ + public void setEmbeddedKey(boolean embeddedKey) + throws ModelException; + + /** + * Get the type representation of the keys for this JDOMap. + * @return the type of the keys of this JDOMap + */ + public JavaType getKeyType(); + + /** + * Set the type representation of the keys for this JDOMap. + * @param keyType the type representation of the keys + * @exception ModelException if impossible + */ + public void setKeyType(JavaType keyType) + throws ModelException; + + /** + * Get the string representation of the type of the keys for this JDOMap. + * @return the key type as string + */ + public String getKeyTypeName(); + + /** + * Set string representation of the type of the keys for this JDOMap. + * @param keyTypeName the name of the key type + * @exception ModelException if impossible + */ + public void setKeyTypeName(String keyTypeName) + throws ModelException; + + /** + * Determines whether the values of the map should be stored if possible as + * part of the instance instead of as their own instances in the datastore. + * @return <code>true</code> if the values are stored as part of this + * instance; <code>false</code> otherwise + */ + public boolean isEmbeddedValue(); + + /** + * Set whether the values of the map should be stored if possible as part + * of the instance instead of as their own instances in the datastore. + * @param embeddedValue <code>true</code> if the values are stored as part + * of this instance; <code>false</code> otherwise + * @exception ModelException if impossible + */ + public void setEmbeddedValue(boolean embeddedValue) + throws ModelException; + + /** + * Get the type representation of the values for this JDOMap. + * @return the type of the values of this JDOMap + */ + public JavaType getValueType(); + + /** + * Set the type representation of the values for this JDOMap. + * @param valueType the type representation of the values + * @exception ModelException if impossible + */ + public void setValueType(JavaType valueType) + throws ModelException; + + /** + * Get the string representation of the type of the values for this JDOMap. + * @return the key value as string + */ + public String getValueTypeName(); + + /** + * Set string representation of the type of the values for this JDOMap. + * @param valueTypeName the name of the value type + * @exception ModelException if impossible + */ + public void setValueTypeName(String valueTypeName) + throws ModelException; + +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOMember.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOMember.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOMember.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOMember.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,59 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +import org.apache.jdo.model.ModelException; + +/** + * This is the super interface for named JDO metadata elements, + * such as JDOClass and JDOField. + * + * @author Michael Bouschen + */ +public interface JDOMember + extends JDOElement, Comparable +{ + /** + * Returns the name of this JDOMember. + * @return the name + */ + public String getName(); + + /** + * Sets the name of this JDOMember. + * @param name the name + * @exception ModelException if impossible + */ + public void setName(String name) + throws ModelException; + + /** + * Get the declaring class of this JDOMember. + * @return the class that owns this JDOMember, or <code>null</code> + * if the element is not attached to any class + */ + public JDOClass getDeclaringClass(); + + /** + * Set the declaring class of this JDOMember. + * @param declaringClass the declaring class of this member element + * @exception ModelException if impossible + */ + public void setDeclaringClass(JDOClass declaringClass) + throws ModelException; + +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOModel.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOModel.java?view=auto&rev=158176 ============================================================================== --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOModel.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOModel.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,162 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.model.jdo; + +import org.apache.jdo.model.ModelException; +import org.apache.jdo.model.java.JavaModel; +import org.apache.jdo.model.java.JavaType; + + +/** + * A JDOModel instance bundles a number of JDOClass instances used by an + * application. It provides factory methods to create and retrieve JDOClass + * instances. A fully qualified class name must be unique within a JDOModel + * instance. The model supports multiple classes having the same fully qualified + * name by different JDOModel instances. + * + * @author Michael Bouschen + */ +public interface JDOModel + extends JDOElement +{ + /** + * The method returns a JDOClass instance for the specified package name. + * If this JDOModel contains the corresponding JDOPackage instance, + * the existing instance is returned. Otherwise, it creates a new JDOPackage + * instance and returns the new instance. + * @param packageName the name of the JDOPackage instance + * to be returned + * @return a JDOPackage instance for the specified package name + * @exception ModelException if impossible + */ + public JDOPackage createJDOPackage(String packageName) + throws ModelException; + + /** + * The method returns the JDOPackage instance for the specified package + * name, if present. The method returns <code>null</code> if it cannot + * find a JDOPackage instance for the specified name. + * @param packageName the name of the JDOPackage instance + * to be returned + * @return a JDOPackage instance for the specified package name + * or <code>null</code> if not present + */ + public JDOPackage getJDOPackage(String packageName); + + /** + * Returns the collection of JDOPackage instances declared by this JDOModel + * in the format of an array. + * @return the packages declared by this JDOModel + */ + public JDOPackage[] getDeclaredPackages(); + + /** + * The method returns a JDOClass instance for the specified fully qualified + * class name. If this JDOModel contains the corresponding JDOClass instance, + * the existing instance is returned. Otherwise, it creates a new JDOClass + * instance, sets its declaringModel and returns the new instance. + * <p> + * Invoking this method is method is equivalent to + * <code>createJDOClass(className, true)</code>. + * @param className the fully qualified class name of the JDOClass instance + * to be returned + * @return a JDOClass instance for the specified class name + * @exception ModelException if impossible + */ + public JDOClass createJDOClass(String className) + throws ModelException; + + /** + * The method returns a JDOClass instance for the specified fully qualified + * class name. If this JDOModel contains the corresponding JDOClass instance, + * the existing instance is returned. Otherwise, if the flag loadXMLMetadata + * is set to <code>true</code> the method tries to find the JDOClass + * instance by reading the XML metadata. If it could not be found the method + * creates a new JDOClass instance, sets its declaringModel and returns the + * instance. + * @param className the fully qualified class name of the JDOClass instance + * to be returned + * @param loadXMLMetadata indicated whether to read XML metatdata or not + * @return a JDOClass instance for the specified class name + * @exception ModelException if impossible + */ + public JDOClass createJDOClass(String className, boolean loadXMLMetadata) + throws ModelException; + + /** + * The method returns the JDOClass instance for the specified fully + * qualified class name if present. The method returns <code>null</code> + * if it cannot find a JDOClass instance for the specified name. + * <p> + * Invoking this method is equivalent to + * <code>getJDOClass(className, true)</code>. + * @param className the fully qualified class name of the JDOClass instance + * to be returned + * @return a JDOClass instance for the specified class name + * or <code>null</code> if not present + */ + public JDOClass getJDOClass(String className); + + /** + * The method returns the JDOClass instance for the specified fully + * qualified class name if present. If the flag loadXMLMetadata is set + * to <code>true</code> the method tries to find the JDOClass instance by + * reading the XML metadata. The method returns null if it cannot find a + * JDOClass instance for the specified name. + * @param className the fully qualified class name of the JDOClass instance + * to be returned + * @param loadXMLMetadata indicate whether to read XML metatdata or not + * @return a JDOClass instance for the specified class name + * or <code>null</code> if not present + */ + public JDOClass getJDOClass(String className, boolean loadXMLMetadata); + + /** + * Returns the collection of JDOClass instances declared by this JDOModel + * in the format of an array. + * @return the classes declared by this JDOModel + */ + public JDOClass[] getDeclaredClasses(); + + /** + * Returns the JavaModel bound to this JDOModel instance. + * @return the JavaModel + */ + public JavaModel getJavaModel(); + + /** + * Sets the JavaModel for this JDOModel instance. + * @param javaModel the JavaModel + */ + public void setJavaModel(JavaModel javaModel); + + /** + * Returns the parent JDOModel instance of this JDOModel. + * @return the parent JDOModel + */ + public JDOModel getParent(); + + /** + * This method returns the JDOClass instance that defines the specified type + * as its objectId class. In the case of an inheritance hierarchy it returns + * the top most persistence-capable class of the hierarchy (see + * [EMAIL PROTECTED] JDOClass#getPersistenceCapableSuperclass}). + * @param objectIdClass the type representation of the ObjectId class + * @return the JDOClass defining the specified class as ObjectId class + */ + public JDOClass getJDOClassForObjectIdClass(JavaType objectIdClass); +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOModel.jpg URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOModel.jpg?view=auto&rev=158176 ============================================================================== Binary file - no diff available. Propchange: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOModel.jpg ------------------------------------------------------------------------------ svn:executable = * Propchange: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/model/jdo/JDOModel.jpg ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream