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