PageRenderTime 38ms CodeModel.GetById 25ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/jboss-as-7.1.1.Final/jacorb/src/main/java/org/jboss/as/jacorb/rmi/PrimitiveAnalysis.java

#
Java | 81 lines | 39 code | 10 blank | 32 comment | 20 complexity | e6d872acc75862fedec981a719bbd2b9 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
 1/*
 2 * JBoss, Home of Professional Open Source.
 3 * Copyright 2008, Red Hat Middleware LLC, and individual contributors
 4 * as indicated by the @author tags. See the copyright.txt file in the
 5 * distribution for a 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 */
22package org.jboss.as.jacorb.rmi;
23
24
25import org.jboss.as.jacorb.JacORBMessages;
26
27/**
28 * Analysis class for primitive types.
29 * <p/>
30 * Routines here are conforming to the "Java(TM) Language to IDL Mapping
31 * Specification", version 1.1 (01-06-07).
32 *
33 * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
34 */
35public class PrimitiveAnalysis extends ClassAnalysis {
36
37    public static final PrimitiveAnalysis voidAnalysis = new PrimitiveAnalysis(Void.TYPE, "void", "void");
38    public static final PrimitiveAnalysis booleanAnalysis = new PrimitiveAnalysis(Boolean.TYPE, "boolean", "boolean");
39    public static final PrimitiveAnalysis charAnalysis = new PrimitiveAnalysis(Character.TYPE, "wchar", "char");
40    public static final PrimitiveAnalysis byteAnalysis = new PrimitiveAnalysis(Byte.TYPE, "octet", "byte");
41    public static final PrimitiveAnalysis shortAnalysis = new PrimitiveAnalysis(Short.TYPE, "short", "short");
42    public static final PrimitiveAnalysis intAnalysis = new PrimitiveAnalysis(Integer.TYPE, "long", "int");
43    public static final PrimitiveAnalysis longAnalysis = new PrimitiveAnalysis(Long.TYPE, "long_long", "long");
44    public static final PrimitiveAnalysis floatAnalysis = new PrimitiveAnalysis(Float.TYPE, "float", "float");
45    public static final PrimitiveAnalysis doubleAnalysis = new PrimitiveAnalysis(Double.TYPE, "double", "double");
46
47    private PrimitiveAnalysis(final Class cls, final String idlName, final String javaName) {
48        super(cls, idlName, javaName);
49    }
50
51
52    /**
53     * Get a singleton instance representing one of the primitive types.
54     */
55    public static PrimitiveAnalysis getPrimitiveAnalysis(final Class cls) {
56        if (cls == null)
57            throw JacORBMessages.MESSAGES.cannotAnalyzeNullClass();
58
59        if (cls == Void.TYPE)
60            return voidAnalysis;
61        if (cls == Boolean.TYPE)
62            return booleanAnalysis;
63        if (cls == Character.TYPE)
64            return charAnalysis;
65        if (cls == Byte.TYPE)
66            return byteAnalysis;
67        if (cls == Short.TYPE)
68            return shortAnalysis;
69        if (cls == Integer.TYPE)
70            return intAnalysis;
71        if (cls == Long.TYPE)
72            return longAnalysis;
73        if (cls == Float.TYPE)
74            return floatAnalysis;
75        if (cls == Double.TYPE)
76            return doubleAnalysis;
77
78        throw JacORBMessages.MESSAGES.notAPrimitive(cls.getName());
79    }
80
81}