PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 0ms 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. */
  22. package org.jboss.as.jacorb.rmi;
  23. import org.jboss.as.jacorb.JacORBMessages;
  24. /**
  25. * Analysis class for primitive types.
  26. * <p/>
  27. * Routines here are conforming to the "Java(TM) Language to IDL Mapping
  28. * Specification", version 1.1 (01-06-07).
  29. *
  30. * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
  31. */
  32. public class PrimitiveAnalysis extends ClassAnalysis {
  33. public static final PrimitiveAnalysis voidAnalysis = new PrimitiveAnalysis(Void.TYPE, "void", "void");
  34. public static final PrimitiveAnalysis booleanAnalysis = new PrimitiveAnalysis(Boolean.TYPE, "boolean", "boolean");
  35. public static final PrimitiveAnalysis charAnalysis = new PrimitiveAnalysis(Character.TYPE, "wchar", "char");
  36. public static final PrimitiveAnalysis byteAnalysis = new PrimitiveAnalysis(Byte.TYPE, "octet", "byte");
  37. public static final PrimitiveAnalysis shortAnalysis = new PrimitiveAnalysis(Short.TYPE, "short", "short");
  38. public static final PrimitiveAnalysis intAnalysis = new PrimitiveAnalysis(Integer.TYPE, "long", "int");
  39. public static final PrimitiveAnalysis longAnalysis = new PrimitiveAnalysis(Long.TYPE, "long_long", "long");
  40. public static final PrimitiveAnalysis floatAnalysis = new PrimitiveAnalysis(Float.TYPE, "float", "float");
  41. public static final PrimitiveAnalysis doubleAnalysis = new PrimitiveAnalysis(Double.TYPE, "double", "double");
  42. private PrimitiveAnalysis(final Class cls, final String idlName, final String javaName) {
  43. super(cls, idlName, javaName);
  44. }
  45. /**
  46. * Get a singleton instance representing one of the primitive types.
  47. */
  48. public static PrimitiveAnalysis getPrimitiveAnalysis(final Class cls) {
  49. if (cls == null)
  50. throw JacORBMessages.MESSAGES.cannotAnalyzeNullClass();
  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. throw JacORBMessages.MESSAGES.notAPrimitive(cls.getName());
  70. }
  71. }