You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CtPrimitiveType.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999-2003 Shigeru Chiba. All Rights Reserved.
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. Alternatively, the contents of this file may be used under
  8. * the terms of the GNU Lesser General Public License Version 2.1 or later.
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. */
  15. package javassist;
  16. /**
  17. * An instance of <code>CtPrimitiveType</code> represents a primitive type.
  18. * It is obtained from <code>CtClass</code>.
  19. */
  20. public final class CtPrimitiveType extends CtClass {
  21. private char descriptor;
  22. private String wrapperName;
  23. private String getMethodName;
  24. private String mDescriptor;
  25. private int returnOp;
  26. private int arrayType;
  27. private int dataSize;
  28. CtPrimitiveType(String name, char desc, String wrapper,
  29. String methodName, String mDesc, int opcode, int atype,
  30. int size) {
  31. super(name);
  32. descriptor = desc;
  33. wrapperName = wrapper;
  34. getMethodName = methodName;
  35. mDescriptor = mDesc;
  36. returnOp = opcode;
  37. arrayType = atype;
  38. dataSize = size;
  39. }
  40. /**
  41. * Returns <code>true</code> if this object represents a primitive
  42. * Java type: boolean, byte, char, short, int, long, float, double,
  43. * or void.
  44. */
  45. public boolean isPrimitive() { return true; }
  46. /**
  47. * Returns the descriptor representing this type.
  48. * For example, if the type is int, then the descriptor is I.
  49. */
  50. public char getDescriptor() { return descriptor; }
  51. /**
  52. * Returns the name of the wrapper class.
  53. * For example, if the type is int, then the wrapper class is
  54. * <code>java.lang.Integer</code>.
  55. */
  56. public String getWrapperName() { return wrapperName; }
  57. /**
  58. * Returns the name of the method for retrieving the value
  59. * from the wrapper object.
  60. * For example, if the type is int, then the method name is
  61. * <code>intValue</code>.
  62. */
  63. public String getGetMethodName() { return getMethodName; }
  64. /**
  65. * Returns the descriptor of the method for retrieving the value
  66. * from the wrapper object.
  67. * For example, if the type is int, then the method descriptor is
  68. * <code>()I</code>.
  69. */
  70. public String getGetMethodDescriptor() { return mDescriptor; }
  71. /**
  72. * Returns the opcode for returning a value of the type.
  73. * For example, if the type is int, then the returned opcode is
  74. * <code>javassit.bytecode.Opcode.IRETURN</code>.
  75. */
  76. public int getReturnOp() { return returnOp; }
  77. /**
  78. * Returns the array-type code representing the type.
  79. * It is used for the newarray instruction.
  80. * For example, if the type is int, then this method returns
  81. * <code>javassit.bytecode.Opcode.T_INT</code>.
  82. */
  83. public int getArrayType() { return arrayType; }
  84. /**
  85. * Returns the data size of the primitive type.
  86. * If the type is long or double, this method returns 2.
  87. * Otherwise, it returns 1.
  88. */
  89. public int getDataSize() { return dataSize; }
  90. }