View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software 
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License.
16   */
17  
18  package org.apache.jdo.impl.model.java;
19  
20  import org.apache.jdo.model.java.JavaType;
21  
22  /***
23   * A PrimitiveType instance represents a primitive type as defined in the
24   * Java language. There are eight primitive types: <code>boolean</code>,
25   * <code>byte</code>, <code>short</code>, <code>int</code>,
26   * <code>long</code>, <code>char</code>, 
27   * <code>float</code>, <code>double</code>.
28   * <p>
29   * Class PredefinedType provides public static final variables referring
30   * to the JavaType representation for primtive types.
31   * 
32   * @see PredefinedType#booleanType
33   * @see PredefinedType#byteType
34   * @see PredefinedType#shortType
35   * @see PredefinedType#intType
36   * @see PredefinedType#longType
37   * @see PredefinedType#charType
38   * @see PredefinedType#floatType
39   * @see PredefinedType#doubleType
40   *
41   * @author Michael Bouschen
42   * @since JDO 1.0.1
43   */
44  public class PrimitiveType 
45      extends PredefinedType
46  {
47      /*** The JavaType of the corresponding Java wrapper class type. */
48      private WrapperClassType wrapperClassType;
49  
50      /*** 
51       * Constructor.
52       * @param clazz the Class instance representing the type
53       */
54      protected PrimitiveType(Class clazz)
55      {
56          super(clazz, null);
57      }
58  
59      /*** 
60       * Returns <code>true</code> if this JavaType represents a primitive
61       * type.
62       * @return <code>true</code> if this JavaTypre represents a primitive
63       * type; <code>false</code> otherwise.
64       */
65      public boolean isPrimitive() 
66      {
67          return true;
68      }
69  
70      /*** 
71       * Returns <code>true</code> if this JavaType represents a type whoses
72       * values may be treated as values rather than refernces during
73       * storing. 
74       * @return <code>true</code> if this JavaType represents a value type;
75       * <code>false</code> otherwise.
76       */
77      public boolean isValue() 
78      {
79          return true;
80      }
81  
82      // ===== Methods not defined in JavaType =====
83  
84      /*** 
85       * Returns the JavaType instance of the Java wrapper class that
86       * corresponds to this primitive type.
87       * @return the JavaType of the corresponding Java wrapper class.
88       */
89      public WrapperClassType getWrapperClassType()
90      {
91          return wrapperClassType;
92      }
93      
94      /*** 
95       * Sets the JavaType instance of the corresponding Java wrapper class.
96       * @param wrapperClassType the JavaType representing the corresponding
97       * Java wrapper class.
98       */
99      void setWrapperClassType(WrapperClassType wrapperClassType)
100     {
101         this.wrapperClassType = wrapperClassType;
102     }
103     
104 }