db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r171348 [2/7] - in /incubator/jdo/trunk/core20: ./ src/ src/conf/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jdo/ src/java/org/apache/jdo/impl/ src/java/org/apache/jdo/impl/model/ src/java/org/apache/jdo/impl/model/java/ src/java/org/apache/jdo/impl/model/java/reflection/ src/java/org/apache/jdo/impl/model/jdo/ src/java/org/apache/jdo/impl/model/jdo/caching/ src/java/org/apache/jdo/impl/model/jdo/util/ src/java/org/apache/jdo/impl/model/jdo/xml/ src/java/org/apache/jdo/model/ src/java/org/apache/jdo/model/java/ src/java/org/apache/jdo/model/jdo/ src/java/org/apache/jdo/util/
Date Sun, 22 May 2005 17:44:23 GMT
Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/PredefinedType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/PredefinedType.java?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/PredefinedType.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/PredefinedType.java Sun May 22 10:44:19 2005
@@ -0,0 +1,249 @@
+/*
+ * 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.impl.model.java;
+
+import java.util.*;
+import java.math.*;
+
+import org.apache.jdo.model.java.JavaType;
+
+
+/**
+ * Instances of this class represent a type that is not a persistence
+ * capable class, but is known by JDO. All JavaModel implementation will
+ * use this implementation to represnet predefined types. Predefined types
+ * include: 
+ * <ul>
+ * <li> java.lang.Object
+ * <li> void
+ * <li> primitive types
+ * <li> Java wrapper class types
+ * <li> immutable and mutable value types, such as java.lang.String,
+ * java.util.Date, etc.
+ * <li> JDO supported collection types, including their superclasses.
+ * <li> JDO supported map types, including their superclasses.
+ * </ul> 
+ * This class provides public static fields for all predefined types. These
+ * constants are convenience for direct access of a JavaType instance
+ * representing a predefined type. The class also manages a map of
+ * predefined types using the type name as key. The constructors
+ * automatically add the new created instance to this map. Please use
+ * method  {@link #getPredefinedType(String name)} to lookup a predefined
+ * type by name. Method {@link #getPredefinedTypes()} returns a view of the
+ * map of predefined types. 
+ *
+ * @author Michael Bouschen
+ * @since JDO 1.0.1
+ */
+public class PredefinedType
+    extends BaseReflectionJavaType
+{
+    /** Map of all predefined types. */
+    private static final Map predefinedTypes = new HashMap();
+
+    // ===== java.lang.Object =====
+
+    /** The JavaType instance for the class java.lang.Object. */
+    public static final PredefinedType objectType = new PredefinedType(Object.class);
+
+    // ===== void =====
+
+    /** The JavaType instance for the type void. */
+    public static final PredefinedType voidType = new PredefinedType(void.class);
+
+    // ===== primitive types ===== 
+
+    /** The JavaType instance for the primitive type boolean. */
+    public static final PrimitiveType booleanType = new PrimitiveType(boolean.class);
+    /** The JavaType instance for the integral type byte. */
+    public static final IntegralType byteType = new IntegralType(byte.class);
+    /** The JavaType instance for the integral type short. */
+    public static final IntegralType shortType = new IntegralType(short.class);
+    /** The JavaType instance for the integral type int. */
+    public static final IntegralType intType = new IntegralType(int.class);
+    /** The JavaType instance for the integral type long. */
+    public static final IntegralType longType = new IntegralType(long.class);
+    /** The JavaType instance for the integral type char. */
+    public static final IntegralType charType = new IntegralType(char.class);
+    /** The JavaType instance for the floating point type float. */
+    public static final FloatingPointType floatType = new FloatingPointType(float.class);
+    /** The JavaType instance for the floating point type double. */
+    public static final FloatingPointType doubleType = new FloatingPointType(double.class);
+
+    // ===== Value types ===== 
+
+    /** The JavaType instance for the class java.lang.Numer. */
+    public static final ValueClassType numberType = new ValueClassType(Number.class, objectType, false);
+    /** The JavaType instance for the class java.lang.String. */
+    public static final ValueClassType stringType = new ValueClassType(String.class, objectType, true);
+    /** The JavaType instance for the class java.lang.Locale. */
+    public static final ValueClassType localeType = new ValueClassType(Locale.class, objectType, false);
+    /** The JavaType instance for the class java.math.BigDecimal. */
+    public static final ValueClassType bigDecimalType = new ValueClassType(BigDecimal.class, numberType, true);
+    /** The JavaType instance for the class java.math.BigInteger. */
+    public static final ValueClassType bigIntegerType = new ValueClassType(BigInteger.class, numberType, true);
+
+    // ===== WrapperClass types ===== 
+
+    /** The JavaType instance for the class java.lang.Boolean. */
+    public static final WrapperClassType booleanClassType = new WrapperClassType(Boolean.class, objectType, false);
+    /** The JavaType instance for the class java.lang.Byte. */
+    public static final WrapperClassType byteClassType = new WrapperClassType(Byte.class, numberType, true);
+    /** The JavaType instance for the class java.lang.Short. */
+    public static final WrapperClassType shortClassType = new WrapperClassType(Short.class, numberType, true);
+    /** The JavaType instance for the class java.lang.Integer. */
+    public static final WrapperClassType integerClassType = new WrapperClassType(Integer.class, numberType, true);
+    /** The JavaType instance for the class java.lang.Long. */
+    public static final WrapperClassType longClassType = new WrapperClassType(Long.class, numberType, true);
+    /** The JavaType instance for the class java.lang.Character. */
+    public static final WrapperClassType characterClassType = new WrapperClassType(Character.class, numberType, true);
+    /** The JavaType instance for the class java.lang.Float. */
+    public static final WrapperClassType floatClassType = new WrapperClassType(Float.class, numberType, true);
+    /** The JavaType instance for the class java.lang.Double. */
+    public static final WrapperClassType doubleClassType = new WrapperClassType(Double.class, numberType, true);
+
+    // ===== Mutable value types ===== 
+
+    /** The JavaType instance for the class java.util.Date. */
+    public static final MutableValueClassType dateType = new MutableValueClassType(Date.class, objectType, true);
+    /** The JavaType instance for the class java.sql.Date. */
+    public static final MutableValueClassType sqlDateType = new MutableValueClassType(java.sql.Date.class, dateType, true);
+    /** The JavaType instance for the class java.sql.Time. */
+    public static final MutableValueClassType sqlTimeType = new MutableValueClassType(java.sql.Time.class, dateType, true);
+    /** The JavaType instance for the class java.sql.Timestamp. */
+    public static final MutableValueClassType sqlTimestampType = new MutableValueClassType(java.sql.Timestamp.class, dateType, true);
+    /** The JavaType instance for the class java.util.BitSet. */
+    public static final MutableValueClassType bitsetType = new MutableValueClassType(BitSet.class, objectType, false);
+
+    // ===== JDOSupportedCollection types ===== 
+
+    /** The JavaType instance for the interface java.util.Collection. */
+    public static final JDOSupportedCollectionType collectionType = new JDOSupportedCollectionType(Collection.class);
+    /** The JavaType instance for the interface java.util.Set. */
+    public static final JDOSupportedCollectionType setType = new JDOSupportedCollectionType(Set.class);
+    /** The JavaType instance for the interface java.util.List. */
+    public static final JDOSupportedCollectionType listType = new JDOSupportedCollectionType(List.class);
+    /** The JavaType instance for the class java.util.AbstractCollection. */
+    public static final PredefinedType abstractCollectionType = new PredefinedType(AbstractCollection.class, objectType);
+    /** The JavaType instance for the class java.util.AbstractSet. */
+    public static final PredefinedType abstractSetType = new PredefinedType(AbstractSet.class, abstractCollectionType);
+    /** The JavaType instance for the class java.util.HashSet. */
+    public static final JDOSupportedCollectionType hashSetType = new JDOSupportedCollectionType(HashSet.class, abstractSetType);
+    /** The JavaType instance for the class java.util.TreeSet. */
+    public static final JDOSupportedCollectionType treeSetType = new JDOSupportedCollectionType(TreeSet.class, abstractSetType);
+    /** The JavaType instance for the class java.util.AbstractList. */
+    public static final PredefinedType abstractListType = new PredefinedType(AbstractList.class, abstractCollectionType);
+    /** The JavaType instance for the class java.util.ArrayList. */
+    public static final JDOSupportedCollectionType arrayListType = new JDOSupportedCollectionType(ArrayList.class, abstractListType);
+    /** The JavaType instance for the class java.util.LinkedList. */
+    public static final JDOSupportedCollectionType linkedListType = new JDOSupportedCollectionType(LinkedList.class, abstractListType);
+    /** The JavaType instance for the class java.util.Vector. */
+    public static final JDOSupportedCollectionType vectorType = new JDOSupportedCollectionType(Vector.class, abstractListType);
+    /** The JavaType instance for the class java.util.Stack. */
+    public static final JDOSupportedCollectionType stackType = new JDOSupportedCollectionType(Stack.class, vectorType);
+
+    // ===== JDOSupportedMap types =====
+
+    /** The JavaType instance for the interface java.util.Map. */
+    public static final JDOSupportedMapType mapType = new JDOSupportedMapType(Map.class);
+    /** The JavaType instance for the class java.util.AbstractMap. */
+    public static final PredefinedType abstractMapType = new PredefinedType(AbstractMap.class, objectType);
+    /** The JavaType instance for the class java.util.HashMap. */
+    public static final JDOSupportedMapType hashMapType = new JDOSupportedMapType(HashMap.class, abstractMapType);
+    /** The JavaType instance for the class java.util.Dictionary. */
+    public static final PredefinedType dictionaryType = new PredefinedType(Dictionary.class, objectType);
+    /** The JavaType instance for the class java.util.Hashtable. */
+    public static final JDOSupportedMapType hashtableType = new JDOSupportedMapType(Hashtable.class, dictionaryType);
+    /** The JavaType instance for the class java.util.Properties. */
+    public static final JDOSupportedMapType propertiesType = new JDOSupportedMapType(Properties.class, hashtableType);
+    /** The JavaType instance for the class java.util.TreeMap. */
+    public static final JDOSupportedMapType treeMapType = new JDOSupportedMapType(TreeMap.class, abstractMapType);
+
+    /** 
+     * The static block sets references between the JavaType instances for
+     * primitives types and the JavaType instances for the corresponding
+     * wrapper class.
+     */
+    static
+    {
+        booleanType.setWrapperClassType(booleanClassType);
+        booleanClassType.setWrappedPrimitiveType(booleanType);
+        byteType.setWrapperClassType(byteClassType);
+        byteClassType.setWrappedPrimitiveType(byteType);
+        shortType.setWrapperClassType(shortClassType);
+        shortClassType.setWrappedPrimitiveType(shortType);
+        intType.setWrapperClassType(integerClassType);
+        integerClassType.setWrappedPrimitiveType(intType);
+        longType.setWrapperClassType(longClassType);
+        longClassType.setWrappedPrimitiveType(longType);
+        charType.setWrapperClassType(characterClassType);
+        characterClassType.setWrappedPrimitiveType(charType);
+        floatType.setWrapperClassType(floatClassType);
+        floatClassType.setWrappedPrimitiveType(floatType);
+        doubleType.setWrapperClassType(doubleClassType);
+        doubleClassType.setWrappedPrimitiveType(doubleType);
+    }
+    
+    /**
+     * Constructor taking a Class instance.
+     * It automatically adds a predefined type to the static map of all
+     * predefined types. 
+     * @param clazz the Class instance for this JavaType
+     */
+    protected PredefinedType(Class clazz)
+    {
+        this(clazz, null);
+    }
+    
+    /** 
+     * Constructor taking a Class instance and a JavaType representing the
+     * superclass of the new JavaType instance. 
+     * It automatically adds a predefined type to the static
+     * map of all predefined types.
+     * @param clazz the Class instance for this JavaType
+     * @param superclass the JavaType representing the superclass or
+     * <code>null</code> if there is no superclass.
+     */
+    protected PredefinedType(Class clazz, JavaType superclass)
+    {
+        super(clazz, superclass);
+        predefinedTypes.put(clazz.getName(), this);
+    }
+
+    /**
+     * Returns the JavaType instance for a predefined type with the
+     * specified name. The method return <code>null</code> if the specified
+     * name does not denote a predefined type. 
+     * @param name the name of the predefined type.
+     * @return the JavaType instance for the specified predefined type.
+     */
+    public static JavaType getPredefinedType(String name)
+    {
+        return (JavaType)predefinedTypes.get(name);
+    }
+
+    /** 
+     * Returns an unmodifiable view of the predefined types map. This map
+     * maps type names to JavaType instances.
+     * @return an unmodifiable view of the predefined types map.
+     */
+    public static Map getPredefinedTypes()
+    {
+        return Collections.unmodifiableMap(predefinedTypes);
+    }
+
+}

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/PrimitiveType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/PrimitiveType.java?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/PrimitiveType.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/PrimitiveType.java Sun May 22 10:44:19 2005
@@ -0,0 +1,103 @@
+/*
+ * 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.impl.model.java;
+
+import org.apache.jdo.model.java.JavaType;
+
+/**
+ * A PrimitiveType instance represents a primitive type as defined in the
+ * Java language. 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>.
+ * <p>
+ * Class PredefinedType provides public static final variables referring
+ * to the JavaType representation for primtive types.
+ * 
+ * @see PredefinedType#booleanType
+ * @see PredefinedType#byteType
+ * @see PredefinedType#shortType
+ * @see PredefinedType#intType
+ * @see PredefinedType#longType
+ * @see PredefinedType#charType
+ * @see PredefinedType#floatType
+ * @see PredefinedType#doubleType
+ *
+ * @author Michael Bouschen
+ * @since JDO 1.0.1
+ */
+public class PrimitiveType 
+    extends PredefinedType
+{
+    /** The JavaType of the corresponding Java wrapper class type. */
+    private WrapperClassType wrapperClassType;
+
+    /** 
+     * Constructor.
+     * @param clazz the Class instance representing the type
+     */
+    protected PrimitiveType(Class clazz)
+    {
+        super(clazz, null);
+    }
+
+    /** 
+     * Returns <code>true</code> if this JavaType represents a primitive
+     * type.
+     * @return <code>true</code> if this JavaTypre represents a primitive
+     * type; <code>false</code> otherwise.
+     */
+    public boolean isPrimitive() 
+    {
+        return true;
+    }
+
+    /** 
+     * Returns <code>true</code> if this JavaType represents a type whoses
+     * values may be treated as values rather than refernces during
+     * storing. 
+     * @return <code>true</code> if this JavaType represents a value type;
+     * <code>false</code> otherwise.
+     */
+    public boolean isValue() 
+    {
+        return true;
+    }
+
+    // ===== Methods not defined in JavaType =====
+
+    /** 
+     * Returns the JavaType instance of the Java wrapper class that
+     * corresponds to this primitive type.
+     * @return the JavaType of the corresponding Java wrapper class.
+     */
+    public WrapperClassType getWrapperClassType()
+    {
+        return wrapperClassType;
+    }
+    
+    /** 
+     * Sets the JavaType instance of the corresponding Java wrapper class.
+     * @param wrapperClassType the JavaType representing the corresponding
+     * Java wrapper class.
+     */
+    void setWrapperClassType(WrapperClassType wrapperClassType)
+    {
+        this.wrapperClassType = wrapperClassType;
+    }
+    
+}

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/ValueClassType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/ValueClassType.java?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/ValueClassType.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/ValueClassType.java Sun May 22 10:44:19 2005
@@ -0,0 +1,78 @@
+/*
+ * 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.impl.model.java;
+
+import org.apache.jdo.model.java.JavaType;
+
+/**
+ * A ValueClassType instance represents a class whoses values may be treated
+ * as values rather than refernces during storing. 
+ * <p>
+ * Class PredefinedType provides public static final variables referring
+ * to the JavaType representation for value class types.
+ * 
+ * @see PredefinedType#numberType
+ * @see PredefinedType#stringType
+ * @see PredefinedType#localeType 
+ * @see PredefinedType#bigDecimalType
+ * @see PredefinedType#bigIntegerType
+ *
+ * @author Michael Bouschen
+ * @since JDO 1.0.1
+ */
+public class ValueClassType 
+    extends PredefinedType
+{
+    /** The orderable property. */
+    private boolean orderable;
+
+    /** 
+     * Constructor.
+     * @param clazz the Class instance representing the type
+     * @param superclass JavaType instance representing the superclass.
+     * @param orderable flag indicating whether this type is orderable.
+     */
+    public ValueClassType(Class clazz, JavaType superclass, boolean orderable)
+    {
+        super(clazz, superclass);
+        this.orderable = orderable;
+    }
+
+    /** 
+     * Returns <code>true</code> if this JavaType represents a type whoses
+     * values may be treated as values rather than refernces during
+     * storing.
+     * @return <code>true</code> if this JavaType represents a value type;
+     * <code>false</code> otherwise.
+     */
+    public boolean isValue() 
+    {
+        return true;
+    }
+
+    /**
+     * Returns <code>true</code> if this JavaType represents an orderable
+     * type as specified by JDO.
+     * @return <code>true</code> if this JavaType represents an orderable
+     * type; <code>false</code> otherwise.
+     */
+    public boolean isOrderable()
+    {
+        return orderable;
+    }
+    
+}

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/WrapperClassType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/WrapperClassType.java?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/WrapperClassType.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/WrapperClassType.java Sun May 22 10:44:19 2005
@@ -0,0 +1,77 @@
+/*
+ * 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.impl.model.java;
+
+import org.apache.jdo.model.java.JavaType;
+
+/**
+ * A WrapperClassType instance represents a Java wrapper class type. 
+ * 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>.
+ * 
+ * <p>
+ * Class PredefinedType provides public static final variables referring
+ * to the JavaType representation for wrapper class types.
+ * 
+ * @see PredefinedType#booleanClassType
+ * @see PredefinedType#byteClassType
+ * @see PredefinedType#shortClassType
+ * @see PredefinedType#integerClassType
+ * @see PredefinedType#longClassType 
+ * @see PredefinedType#characterClassType
+ * @see PredefinedType#floatClassType
+ * @see PredefinedType#doubleClassType 
+ *
+ * @author Michael Bouschen
+ * @since JDO 1.0.1
+ */
+public class WrapperClassType 
+    extends ValueClassType
+{
+    /** */
+    private PrimitiveType wrappedPrimitiveType;
+
+    /** */
+    protected WrapperClassType(Class clazz, JavaType superclass, boolean orderable)
+    {
+        super(clazz, superclass, orderable);
+    }
+
+    /** */
+    public boolean isWrapperClass()
+    {
+        return true;
+    }
+
+    // ===== Methods not defined in JavaType =====
+
+    /** */
+    public PrimitiveType getWrappedPrimitiveType()
+    {
+        return wrappedPrimitiveType;
+    }
+    
+    /** */
+    void setWrappedPrimitiveType(PrimitiveType wrappedPrimitiveType)
+    {
+        this.wrappedPrimitiveType = wrappedPrimitiveType;
+    }
+    
+}

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/package.html
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/package.html?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/package.html (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/package.html Sun May 22 10:44:19 2005
@@ -0,0 +1,46 @@
+<!--
+ 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 core implementation package.</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</head>
+
+<body bgcolor="#ffffff">
+<p>This package contains classes that are for use across all kinds of
+  JavaModel implementations. An environment specific JavaModel implementation
+  should reuse this core functionality by providing subclasses of
+  <a href="AbstractJavaModelFactory.html">AbstractJavaModelFactory</a>,   
+  <a href="AbstractJavaModel.html">AbstractJavaModel</a>,   
+  <a href="AbstractJavaType.html">AbstractJavaType</a>, and   
+  <a href="AbstractJavaField.html">AbstractJavaField</a>. 
+</p>
+<p> A runtime JavaModel implementation should extent classes
+  <a href="ReflectionJavaType.html">ReflectionJavaType</a> and
+  <a href="ReflectionJavaField.html">ReflectionJavaField</a>, 
+  since they provide a basic implementation using Java Metadata from reflection.  
+</p>
+<p> All environment specific JavaModel implementations are not supposed to
+have their own JavaType implementation for predefined types such as primitives
+and their Java  wrapper classes, immutable and mutable value types, JDO supported
+collection  and map types. Instead class 
+<a href="PredefinedType.html">PredefinedType</a> 
+provides an environment independent implementation. 
+</p>
+<br>
+</body>
+</html>

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaField.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaField.java?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaField.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaField.java Sun May 22 10:44:19 2005
@@ -0,0 +1,130 @@
+/*
+ * 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.impl.model.java.reflection;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.lang.reflect.Field;
+
+import org.apache.jdo.impl.model.java.BaseReflectionJavaField;
+import org.apache.jdo.model.ModelFatalException;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOField;
+import org.apache.jdo.util.I18NHelper;
+
+/**
+ * A reflection based JavaField implementation used at runtime.  
+ * The implementation takes <code>java.lang.reflect.Field</code> instances
+ * to get Java related metadata about fields. 
+ * 
+ * @author Michael Bouschen
+ * @since JDO 1.1
+ */
+public class ReflectionJavaField
+    extends BaseReflectionJavaField
+{
+    /** The corresponding JDO metadata. */
+    protected JDOField jdoField;
+
+    /** I18N support */
+    private final static I18NHelper msg =  
+        I18NHelper.getInstance("org.apache.jdo.impl.model.java.Bundle"); //NOI18N
+
+    /** 
+     * Constructor for fields w/o JDO metadata. 
+     * @param field the reflection field representation.
+     * @param declaringClass the JavaType of the class that declares the field.
+     */
+    public ReflectionJavaField(Field field, JavaType declaringClass)
+    {
+        super(field, declaringClass);
+        this.type = getJavaTypeInternal(field.getType());
+    }
+    
+    /** 
+     * Constructor for fields having JDO metadata. The constructor takes
+     * the field type from the JDO metadata.
+     * @param jdoField the JDO field metadata.
+     * @param declaringClass the JavaType of the class that declares the field.
+     */
+    public ReflectionJavaField(JDOField jdoField, JavaType declaringClass)
+    {
+        this(jdoField, null, declaringClass);
+    }
+    
+    /** 
+     * Constructor for fields having JDO metadata.
+     * @param jdoField the JDO field metadata.
+     * @param type the field type.
+     * @param declaringClass the JavaType of the class that declares the field.
+     */
+    public ReflectionJavaField(JDOField jdoField, JavaType type, JavaType declaringClass)
+    {
+        super((jdoField == null) ? null : jdoField.getName(), declaringClass);
+        if (jdoField == null)
+            throw new ModelFatalException(msg.msg(
+                "ERR_InvalidNullFieldInstance", //NOI18N
+                "ReflectionJavaField.<init>")); //NOI18N
+        this.jdoField = jdoField;
+        this.type = type;
+    }
+    
+    /**
+     * Returns the JavaType representation of the field type.
+     * @return field type
+     */
+    public JavaType getType()
+    {
+        if (type == null) {
+            type = getJavaTypeInternal(getField().getType());
+        }
+        return type;
+    }
+
+    /**
+     * Returns the JDOField instance if this JavaField represents a
+     * managed field of a persistence capable class. The method returns
+     * <code>null</code>, if this JavaField does not represent a managed
+     * field. 
+     * <p>
+     * The method throws a {@link org.apache.jdo.model.ModelFatalException},
+     * if there is a problem accessing the JDO meta data for this JavaField. 
+     * @return the JDOField instance if this JavaField represents a managed
+     * field; <code>null</code> otherwise.
+     */
+    public JDOField getJDOField()
+    {
+        return jdoField;
+    }
+
+    // ===== Methods not defined in JavaField =====
+
+    /** 
+     * Returns a JavaType instance for the specified Class object. 
+     * This method provides a hook such that ReflectionJavaField subclasses can
+     * implement their own mapping of Class objects to JavaType instances. 
+     */
+    protected JavaType getJavaTypeInternal(Class clazz)
+    {
+        return ((ReflectionJavaType)getDeclaringClass()).getJavaTypeInternal(clazz);
+    }
+    
+
+    
+}
+

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaModel.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaModel.java?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaModel.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaModel.java Sun May 22 10:44:19 2005
@@ -0,0 +1,182 @@
+/*
+ * 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.impl.model.java.reflection;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.io.InputStream;
+
+import org.apache.jdo.impl.model.java.AbstractJavaModel;
+import org.apache.jdo.model.ModelFatalException;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOModel;
+import org.apache.jdo.util.I18NHelper;
+
+/**
+ * A reflection based JavaModel implementation used at runtime.  
+ * The implementation takes <code>java.lang.Class</code> and
+ * <code>java.lang.reflect.Field</code> instances to get Java related
+ * metadata about types and fields. 
+ * <p>
+ * The ReflectionJavaModel implementation will use this ClassLoader to lookup
+ * any type by name. This makes sure that the type name is unique.
+ *
+ * @author Michael Bouschen
+ * @since JDO 1.1
+ */
+public abstract class ReflectionJavaModel
+    extends AbstractJavaModel
+{
+    /** The ClassLoader instance used as key to cache this JavaModel. */
+    private final ClassLoader classLoader;
+
+    /** Flag passed to the Class.forName call. */
+    private final boolean initialize;
+
+    /** I18N support */
+    private final static I18NHelper msg =  
+        I18NHelper.getInstance("org.apache.jdo.impl.model.java.Bundle"); //NOI18N
+
+    /** Constructor taking the ClassLoader. */
+    public ReflectionJavaModel(ClassLoader classLoader) 
+    {
+        this(classLoader, true);
+    }
+    
+    /** */
+    protected ReflectionJavaModel(ClassLoader classLoader, boolean initialize)
+    {
+        super();
+        this.classLoader = classLoader;
+        this.initialize = initialize;
+    }
+
+    /** 
+     * The method returns the JavaType instance for the specified type
+     * name. A type name is unique within one JavaModel instance. The
+     * method returns <code>null</code> if this model instance does not
+     * know a type with the specified name.
+     * <p>
+     * Note, this method calls Class.forName with the wrapped ClassLoader,
+     * if it cannot find a JavaType with the specified name in the cache.
+     * @param name the name of the type
+     * @return a JavaType instance for the specified name or
+     * <code>null</code> if not present in this model instance.
+     */
+    public JavaType getJavaType(String name) 
+    {
+        synchronized (types) {
+            JavaType javaType = (JavaType)types.get(name);
+            if (javaType == null) {
+                try {
+                    // Note, if name denotes a pc class that has not been
+                    // loaded, Class.forName will load the class which
+                    // calls RegisterClassListener.registerClass.
+                    // This will create a new JavaType entry in the cache.
+                    javaType = getJavaType(Class.forName(name, initialize, 
+                                                         classLoader));
+                }
+                catch (ClassNotFoundException ex) {
+                    // cannot find class => return null
+                }
+                catch (LinkageError ex) {
+                    throw new ModelFatalException(msg.msg(
+                        "EXC_ClassLoadingError", name, ex.toString())); //NOI18N
+                }
+            }
+            return javaType;
+        }
+    }
+
+    /** 
+     * The method returns the JavaType instance for the type name of the
+     * specified class object. This is a convenience method for 
+     * <code>getJavaType(clazz.getName())</code>. The major difference
+     * between this method and getJavaType taking a type name is that this 
+     * method is supposed to return a non-<code>null<code> value. The
+     * specified class object describes an existing type.
+     * <p>
+     * Note, this implementation does not call the overloaded getJavaType
+     * method taking a String, because this would retrieve the Class
+     * instance for the specified type again. Instead, it checks the cache 
+     * directly. If not available it creates a new ReflectionJavaType using
+     * the specified class instance.
+     * @param clazz the Class instance representing the type
+     * @return a JavaType instance for the name of the specified class
+     * object or <code>null</code> if not present in this model instance.
+     */
+    public JavaType getJavaType(Class clazz)
+    {
+        String name = clazz.getName();
+        synchronized (types) {
+            JavaType javaType = (JavaType)types.get(name);
+            if (javaType == null) {
+                javaType = createJavaType(clazz);
+                types.put(name, javaType);
+            }
+            return javaType;
+        }
+    }
+
+    /**
+     * Finds a resource with a given name. A resource is some data that can
+     * be accessed by class code in a way that is independent of the
+     * location of the code. The name of a resource is a "/"-separated path
+     * name that identifies the resource. The method method opens the
+     * resource for reading and returns an InputStream. It returns 
+     * <code>null</code> if no resource with this name is found or if the
+     * caller doesn't have adequate privileges to get the resource.  
+     * <p>
+     * This implementation delegates the request to the wrapped
+     * ClassLoader. 
+     * @param resourceName the resource name
+     * @return an input stream for reading the resource, or <code>null</code> 
+     * if the resource could not be found or if the caller doesn't have
+     * adequate privileges to get the resource. 
+     */
+    public InputStream getInputStreamForResource(final String resourceName)
+    {
+        return (InputStream) AccessController.doPrivileged(
+            new PrivilegedAction () {
+                public Object run () {
+                    return classLoader.getResourceAsStream(resourceName);
+                }
+            }
+            );
+    }
+
+    // ===== Methods not defined in JavaModel =====
+
+    /** 
+     * Returns the ClassLoader wrapped by this ReflectionJavaModel instance.
+     * @return the ClassLoader
+     */
+    public ClassLoader getClassLoader()
+    {
+        return classLoader;
+    }
+
+    /** 
+     * Creates a new JavaType instance for the specified Class object.
+     * This method provides a hook such that ReflectionJavaModel subclasses
+     * can create instances of a different JavaType implementation. 
+     * @param clazz the Class instance representing the type
+     * @return a new JavaType instance
+     */
+    protected abstract JavaType createJavaType(Class clazz);
+    
+}

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaType.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaType.java?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaType.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/java/reflection/ReflectionJavaType.java Sun May 22 10:44:19 2005
@@ -0,0 +1,259 @@
+/*
+ * 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.impl.model.java.reflection;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import java.lang.reflect.Field;
+
+import org.apache.jdo.impl.model.java.PredefinedType;
+import org.apache.jdo.impl.model.java.BaseReflectionJavaField;
+import org.apache.jdo.impl.model.java.BaseReflectionJavaType;
+import org.apache.jdo.model.ModelFatalException;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.model.java.JavaModel;
+import org.apache.jdo.model.java.JavaModelFactory;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOClass;
+import org.apache.jdo.model.jdo.JDOField;
+import org.apache.jdo.model.jdo.JDOModel;
+import org.apache.jdo.util.I18NHelper;
+
+/**
+/**
+ * A reflection based JavaType implementation used at runtime.  
+ * The implementation takes <code>java.lang.Class</code> and
+ * <code>java.lang.reflect.Field</code> instances to get Java related
+ * metadata about types and fields. 
+ *
+ * @author Michael Bouschen
+ * @since JDO 1.1
+ */
+public abstract class ReflectionJavaType
+    extends BaseReflectionJavaType
+{
+    /** The JDOModel instance to lookup JDO metadata. */
+    private JDOModel jdoModel;
+
+    /** Flag indicating whether the superclass is checked already. */
+    private boolean superclassUnchecked = true;
+
+    /** Flag indicating whether the JDOClass info is retrieved already. */
+    private boolean jdoClassUnchecked = true;
+
+    /** The JDO metadata, if this type represents a pc class. */
+    private JDOClass jdoClass;
+
+    /** Map of JavaField instances, key is the field name. */
+    private Map javaFields = new HashMap();
+
+    /** I18N support */
+    private final static I18NHelper msg =  
+        I18NHelper.getInstance("org.apache.jdo.impl.model.java.Bundle"); //NOI18N
+
+    /** Constructor. */
+    public ReflectionJavaType(Class clazz, JDOModel jdoModel)
+    {
+        // Pass null as the superclass to the super call. This allows lazy
+        // evaluation of the superclass (see getSuperclass implementation).
+        super(clazz, null); 
+        this.jdoModel = jdoModel;
+    }
+
+    /**
+     * 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()
+    {
+        return clazz.isArray();
+    }
+
+    /** 
+     * Returns <code>true</code> if this JavaType represents a persistence
+     * capable class.
+     * <p>
+     * A {@link 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
+    {
+        return (getJDOClass() != null);
+    }
+
+    /** 
+     * 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 synchronized JavaType getSuperclass()
+    {
+        if (superclassUnchecked) {
+            superclassUnchecked = false;
+            superclass = getJavaTypeInternal(clazz.getSuperclass());
+        }
+        return superclass;
+    }
+
+    /**
+     * 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 {@link 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 synchronized JDOClass getJDOClass()
+        throws ModelFatalException
+    {
+        if (jdoClassUnchecked) {
+            jdoClassUnchecked = false;
+            jdoClass = jdoModel.getJDOClass(getName());
+        }
+        return jdoClass;
+    }
+ 
+    /** 
+     * 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()
+    {
+        JavaType componentType = null;
+        if (isArray()) {
+            Class componentClass = clazz.getComponentType();
+            if (componentClass != null)
+                componentType = getJavaTypeInternal(componentClass);
+        }
+        return componentType;
+    }
+
+    /**
+     * 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 fieldName 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 fieldName) 
+    { 
+        JavaField javaField = getDeclaredJavaField(fieldName);
+        if (javaField == null) {
+            // check superclass
+            JavaType superclass = getSuperclass();
+            if ((superclass != null) &&
+                (superclass != PredefinedType.objectType)) {
+                javaField = superclass.getJavaField(fieldName);
+            }
+        }
+        return javaField;
+    }
+
+    // ===== Methods not defined in JavaType =====
+
+    /**
+     * RegisterClassListener calls this method to create a ReflectionJavaField
+     * instance when processing the enhancer generated metadata.
+     * @param jdoField the JDO field metadata
+     * @param type the type of the field
+     * @return the ReflectionJavaField representation
+     */
+    public JavaField createJavaField(JDOField jdoField, JavaType type)
+    {
+        String name = jdoField.getName();
+        synchronized(javaFields) {
+            JavaField javaField = (JavaField)javaFields.get(name);
+            if (javaField != null) {
+                throw new ModelFatalException(msg.msg(
+                    "ERR_MultipleJavaField", //NOI18N
+                    "ReflectionJavaType.createJavaField", name, getName())); //NOI18N
+            }
+            javaField = new ReflectionJavaField(jdoField, type, this);
+            javaFields.put(name, javaField);
+            return javaField;
+        }
+    }
+
+    /**
+     * Returns a JavaField instance that reflects the declared 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 does not declared a field with that name. It does
+     * not check whether one of its superclasses declared such a field.
+     * @param fieldName the name of the field 
+     * @return the JavaField instance for the specified field in this class
+     */
+    public JavaField getDeclaredJavaField(String fieldName)
+    {
+        synchronized (javaFields) {
+            JavaField javaField = (JavaField)javaFields.get(fieldName);
+            if (javaField == null) {
+                JDOClass jdoClass = getJDOClass();
+                if (jdoClass != null) {
+                    // pc class => look for JDOField first
+                    JDOField jdoField = jdoClass.getDeclaredField(fieldName);
+                    if (jdoField != null) {
+                        javaField = new ReflectionJavaField(jdoField, this);
+                        javaFields.put(fieldName, javaField);
+                    }
+                }
+                
+                // if no field info check reflection
+                if (javaField == null) {
+                    Field field = ReflectionJavaField.getDeclaredFieldPrivileged(
+                        clazz, fieldName);
+                    if (field != null) {
+                        javaField = new ReflectionJavaField(field, this);
+                        javaFields.put(fieldName, javaField);
+                    }
+                }
+            }
+            return javaField;   
+        }
+    }
+
+    /** 
+     * Returns a JavaType instance for the specified Class object. 
+     * This method provides a hook such that ReflectionJavaType subclasses can
+     * implement their own mapping of Class objects to JavaType instances. 
+     */
+    protected abstract JavaType getJavaTypeInternal(Class clazz);
+    
+}

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/Bundle.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/Bundle.properties?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/Bundle.properties (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/Bundle.properties Sun May 22 10:44:19 2005
@@ -0,0 +1,84 @@
+#
+# 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.
+
+#
+# Generic messages
+#
+#NOI18N
+ERR_MissingJavaModel=Missing JavaModel.
+
+#
+# JDOModelImpl
+#
+EXC_XMLError=Error during reading XML meta data of resource ''{0}''.
+EXC_NonPCSuperclass=Superclass ''{0}'' of persistence-capable class ''{1}'' is not persistence-capable.
+EXC_MissingJDOMetadata=Missing JDO metadata for enhanced class ''{0}''.
+#NOI18N
+ERR_MultipleJDOClassInstances=JDOModelImpl.lookupXMLMetadata: muliple JDOClass instances for persistence-capable class ''{0}''.
+
+#
+# Assertion
+#
+#NOI18N
+ERR_AssertionFailed=Assertion failed: {0}
+
+#
+# JDOClassImpl
+#
+EXC_InvalidMember=Invalid member ''{0}''.
+EXC_CannotCreateJDOField=Cannot create new JDOField after field number calculation.
+EXC_CannotRemoveJDOField=Cannot remove JDOField after after field number calculation.
+EXC_CannotResolveObjectIdClass=Cannot resolve objectid-class ''{0}'' of persistence-capable class ''{1}''.
+EXC_CannotResolvePCSuperClass=Cannot resolve persistence-capable-superclass ''{0}'' of persistence-capable class ''{1}''.
+#NOI18N
+ERR_InvalidInheritedFieldNumber=JDOClassImpl.getFieldList inheritedFields.size() != inheritedFieldsCount.
+
+
+#
+# JDOFieldImpl
+#
+EXC_RelationshipAlreadyDefined=Field ''{0}'' already defined as relationship ''{1}''.
+EXC_IllegalJDOPrefix=Cannot set the persistence-modifier of field ''{0}'' to persistent or transactional. Fields whose name begins with ''jdo'' cannot be persistent or transactional.
+#NOI18N
+ERR_MissingJavaModifier=Missing java modifier of field ''{0}''.
+
+#
+# JDOCollectionImpl
+#
+EXC_CannotResolveElementType=Cannot resolve element-type ''{0}'' of collection field ''{1}'' in class ''{2}''.
+
+#
+# JDOMapImpl
+#
+EXC_CannotResolveKeyType=Cannot resolve key-type ''{0}'' of map field ''{1}'' in class ''{2}''.
+EXC_CannotResolveValueType=Cannot resolve value-type ''{0}'' of map field ''{1}'' in class ''{2}''.
+
+#
+# RuntimeJDOModelFactory
+#
+EXC_NoJDOImplHelper=Cannot get JDOImplHelper instance.
+EXC_InvalidJDOModelKey=Invalid key for runtime JDOModel lookup: expected ''java.lang.ClassLoader'' instance, found ''{0}'' instance.
+
+#
+# JDOParser
+#
+EXC_MissingJDODTD=Cannot load javax/jdo/jdo.dtd, because the file does not exist in the jdo.jar file, or the JDOParser class is not granted permission to read this file.  The metadata .xml file contained PUBLIC={0} SYSTEM={1}.
+
+#
+# JDOHandlerImpl
+#
+EXC_ModelException=Exception during model update, see nested exception for details.
+EXC_MissingPackageName=Missing name specification in <package> element.
+EXC_UnknownAttribute=Unknown {0} attribute: {1} \= {2}.

Added: incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOArrayImplDynamic.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOArrayImplDynamic.java?rev=171348&view=auto
==============================================================================
--- incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOArrayImplDynamic.java (added)
+++ incubator/jdo/trunk/core20/src/java/org/apache/jdo/impl/model/jdo/JDOArrayImplDynamic.java Sun May 22 10:44:19 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.impl.model.jdo;
+
+import org.apache.jdo.impl.model.jdo.util.TypeSupport;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.model.jdo.JDOArray;
+import org.apache.jdo.model.jdo.JDOField;
+
+/**
+ * An instance of this class represents the JDO relationship metadata 
+ * of a array relationship field. This dynamic implementation only
+ * stores property values explicitly set by setter method. 
+ *
+ * @author Michael Bouschen
+ * @since 1.1
+ * @version 1.1
+ */
+public class JDOArrayImplDynamic extends JDORelationshipImpl 
+    implements JDOArray {
+    
+    /** Property embeddedElement. */
+    protected Boolean embeddedElement;
+
+    /**
+     * 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() {
+        if (embeddedElement != null) {
+            // return embeddedElement, if explicitly set by the setter
+            return embeddedElement.booleanValue();
+        }
+        
+        // not set => calculate
+        JavaType elementType = getElementType();
+        return (elementType != null) ? 
+            TypeSupport.isEmbeddedElementType(elementType) : false;
+    }
+    
+    /**
+     * 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
+     */
+    public void setEmbeddedElement(boolean embeddedElement) {
+        this.embeddedElement = (embeddedElement ? Boolean.TRUE : Boolean.FALSE);
+    }
+
+    /** 
+     * Get the type representation of the array component type. 
+     * @return the array component type
+     */
+    public JavaType getElementType() {
+        JDOField jdoField = getDeclaringField();
+        JavaType fieldType = jdoField.getType();
+        return (fieldType != null) ? fieldType.getArrayComponentType() : null;
+    }
+
+}
+



Mime
View raw message