View Javadoc
1   /*
2    * Copyright 2006 Ralf Joachim
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package org.exolab.javasource;
17  
18  /**
19   * JType sub-class for java primitives.
20   * 
21   * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
22   * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
23   * @since 1.1
24   */
25  public final class JPrimitiveType extends JType {
26      //--------------------------------------------------------------------------
27  
28      /** Only populated for primitive types and indicates the wrapper Object class
29       *  name for this primitive type. */
30      private String _wrapperName;
31  
32      //--------------------------------------------------------------------------
33  
34      /**
35       * Creates a new JPrimitiveType for a primitive with the given name and wrapper name.
36       * This constructor is protected so it can only be used by the primitives defined at JType.
37       *
38       * @param name The name of the type.
39       * @param wrapperName The name of the wrapper Object type for this primitive type.
40       */
41      protected JPrimitiveType(final String name, final String wrapperName) {
42          super(name);
43          
44          _wrapperName = wrapperName;
45      }
46  
47      //--------------------------------------------------------------------------
48  
49      /**
50       * Return the name of the wrapper object for a primitive type, null for
51       * non-primitive types.
52       *
53       * @return The name of the wrapper object for a primitive type, null for
54       *         non-primitive types.
55       */
56      public String getWrapperName() {
57          return _wrapperName;
58      }
59  
60      /**
61       * {@inheritDoc}
62       * <br/>
63       * Returns the String representation of this JType.
64       */
65      public String toString() {
66          return getName();
67      }
68  
69      //--------------------------------------------------------------------------
70  }