KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > iiop > rmi > PrimitiveAnalysis


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.iiop.rmi;
23
24
25 /**
26  * Analysis class for primitive types.
27  *
28  * Routines here are conforming to the "Java(TM) Language to IDL Mapping
29  * Specification", version 1.1 (01-06-07).
30  *
31  * @author <a HREF="mailto:osh@sparre.dk">Ole Husgaard</a>
32  * @version $Revision: 37459 $
33  */

34 public class PrimitiveAnalysis
35    extends ClassAnalysis
36 {
37    // Constants -----------------------------------------------------
38

39    // Attributes ----------------------------------------------------
40

41    // Static --------------------------------------------------------
42

43    /**
44     * Get a singleton instance representing one of the peimitive types.
45     */

46    static public PrimitiveAnalysis getPrimitiveAnalysis(Class JavaDoc cls)
47    {
48       if (cls == null)
49          throw new IllegalArgumentException JavaDoc("Null class");
50
51       if (cls == Void.TYPE)
52          return voidAnalysis;
53       if (cls == Boolean.TYPE)
54          return booleanAnalysis;
55       if (cls == Character.TYPE)
56          return charAnalysis;
57       if (cls == Byte.TYPE)
58          return byteAnalysis;
59       if (cls == Short.TYPE)
60          return shortAnalysis;
61       if (cls == Integer.TYPE)
62          return intAnalysis;
63       if (cls == Long.TYPE)
64          return longAnalysis;
65       if (cls == Float.TYPE)
66          return floatAnalysis;
67       if (cls == Double.TYPE)
68          return doubleAnalysis;
69
70       throw new IllegalArgumentException JavaDoc("Not a primitive type: " +
71                                          cls.getName());
72    }
73
74    public static PrimitiveAnalysis voidAnalysis = new PrimitiveAnalysis(Void.TYPE, "void", "void");
75    public static PrimitiveAnalysis booleanAnalysis = new PrimitiveAnalysis(Boolean.TYPE, "boolean", "boolean");
76    public static PrimitiveAnalysis charAnalysis = new PrimitiveAnalysis(Character.TYPE, "wchar", "char");
77    public static PrimitiveAnalysis byteAnalysis = new PrimitiveAnalysis(Byte.TYPE, "octet", "byte");
78    public static PrimitiveAnalysis shortAnalysis = new PrimitiveAnalysis(Short.TYPE, "short", "short");
79    public static PrimitiveAnalysis intAnalysis = new PrimitiveAnalysis(Integer.TYPE, "long", "int");
80    public static PrimitiveAnalysis longAnalysis = new PrimitiveAnalysis(Long.TYPE, "long_long", "long");
81    public static PrimitiveAnalysis floatAnalysis = new PrimitiveAnalysis(Float.TYPE, "float", "float");
82    public static PrimitiveAnalysis doubleAnalysis = new PrimitiveAnalysis(Double.TYPE, "double", "double");
83
84    // Constructors --------------------------------------------------
85

86    private PrimitiveAnalysis(Class JavaDoc cls, String JavaDoc idlName, String JavaDoc javaName)
87    {
88       super(cls, idlName, javaName);
89    }
90
91    // Public --------------------------------------------------------
92

93    // Package protected ---------------------------------------------
94

95    // Protected -----------------------------------------------------
96

97    // Private -------------------------------------------------------
98

99 }
100
Popular Tags