001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.iiop.rmi;
023:
024: import org.omg.CORBA.Any;
025:
026: /**
027: * Analysis class for primitive types.
028: *
029: * Routines here are conforming to the "Java(TM) Language to IDL Mapping
030: * Specification", version 1.1 (01-06-07).
031: *
032: * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
033: * @version $Revision: 57194 $
034: */
035: public class PrimitiveAnalysis extends ClassAnalysis {
036: // Constants -----------------------------------------------------
037:
038: // Attributes ----------------------------------------------------
039:
040: // Static --------------------------------------------------------
041:
042: /**
043: * Get a singleton instance representing one of the peimitive types.
044: */
045: static public PrimitiveAnalysis getPrimitiveAnalysis(Class cls) {
046: if (cls == null)
047: throw new IllegalArgumentException("Null class");
048:
049: if (cls == Void.TYPE)
050: return voidAnalysis;
051: if (cls == Boolean.TYPE)
052: return booleanAnalysis;
053: if (cls == Character.TYPE)
054: return charAnalysis;
055: if (cls == Byte.TYPE)
056: return byteAnalysis;
057: if (cls == Short.TYPE)
058: return shortAnalysis;
059: if (cls == Integer.TYPE)
060: return intAnalysis;
061: if (cls == Long.TYPE)
062: return longAnalysis;
063: if (cls == Float.TYPE)
064: return floatAnalysis;
065: if (cls == Double.TYPE)
066: return doubleAnalysis;
067:
068: throw new IllegalArgumentException("Not a primitive type: "
069: + cls.getName());
070: }
071:
072: public static PrimitiveAnalysis voidAnalysis = new PrimitiveAnalysis(
073: Void.TYPE, "void", "void");
074: public static PrimitiveAnalysis booleanAnalysis = new PrimitiveAnalysis(
075: Boolean.TYPE, "boolean", "boolean");
076: public static PrimitiveAnalysis charAnalysis = new PrimitiveAnalysis(
077: Character.TYPE, "wchar", "char");
078: public static PrimitiveAnalysis byteAnalysis = new PrimitiveAnalysis(
079: Byte.TYPE, "octet", "byte");
080: public static PrimitiveAnalysis shortAnalysis = new PrimitiveAnalysis(
081: Short.TYPE, "short", "short");
082: public static PrimitiveAnalysis intAnalysis = new PrimitiveAnalysis(
083: Integer.TYPE, "long", "int");
084: public static PrimitiveAnalysis longAnalysis = new PrimitiveAnalysis(
085: Long.TYPE, "long_long", "long");
086: public static PrimitiveAnalysis floatAnalysis = new PrimitiveAnalysis(
087: Float.TYPE, "float", "float");
088: public static PrimitiveAnalysis doubleAnalysis = new PrimitiveAnalysis(
089: Double.TYPE, "double", "double");
090:
091: // Constructors --------------------------------------------------
092:
093: private PrimitiveAnalysis(Class cls, String idlName, String javaName) {
094: super (cls, idlName, javaName);
095: }
096:
097: // Public --------------------------------------------------------
098:
099: // Package protected ---------------------------------------------
100:
101: // Protected -----------------------------------------------------
102:
103: // Private -------------------------------------------------------
104:
105: }
|