Save This Page
Home » jdo2-model-2.3-ea-src » org.apache.jdo.impl.model.java » [javadoc | source]
    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    * An instance of class NullType represents the type of the null expression
   24    * in Java. It is compatible to all reference types.
   25    * 
   26    * @author Michael Bouschen
   27    * @since JDO 1.0.1
   28    */
   29   public class NullType
   30       extends AbstractJavaType
   31   {
   32       /** The singleton NullType instance. */
   33       public static final NullType nullType = new NullType();
   34   
   35       /** 
   36        * Creates new a NullType instance. This constructor should not be 
   37        * called directly; instead, the singleton instance  {@link #nullType}
   38        * should be used. 
   39        */
   40       protected NullType() {}
   41   
   42       /** 
   43        * Returns true if this JavaType is compatible with the specified
   44        * JavaType. This implementation returns <code>true</code>, if the
   45        * specified javaType is a not a primitive type, because the type of
   46        * null is compatiple with all reference types.
   47        * @param javaType the type this JavaType is checked with.
   48        * @return <code>true</code> if this is compatible with the specified
   49        * type; <code>false</code> otherwise.
   50        */
   51       public boolean isCompatibleWith(JavaType javaType)
   52       {
   53           return !javaType.isPrimitive();
   54       }
   55       
   56       /** 
   57        * Returns the name of the type.  
   58        * @return type name
   59        */
   60       public String getName()
   61       {
   62           return "<null type>"; //NOI18N
   63       }
   64   
   65   }

Save This Page
Home » jdo2-model-2.3-ea-src » org.apache.jdo.impl.model.java » [javadoc | source]