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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999- 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. * or the Apache License Version 2.0.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. */
  16. package javassist;
  17. /**
  18. * An instance of <code>CtPrimitiveType</code> represents a primitive type.
  19. * It is obtained from <code>CtClass</code>.
  20. */
  21. public final class CtPrimitiveType extends CtClass {
  22. private char descriptor;
  23. private String wrapperName;
  24. private String getMethodName;
  25. private String mDescriptor;
  26. private int returnOp;
  27. private int arrayType;
  28. private int dataSize;
  29. CtPrimitiveType(String name, char desc, String wrapper,
  30. String methodName, String mDesc, int opcode, int atype,
  31. int size) {
  32. super(name);
  33. descriptor = desc;
  34. wrapperName = wrapper;
  35. getMethodName = methodName;
  36. mDescriptor = mDesc;
  37. returnOp = opcode;
  38. arrayType = atype;
  39. dataSize = size;
  40. }
  41. /**
  42. * Returns <code>true</code> if this object represents a primitive
  43. * Java type: boolean, byte, char, short, int, long, float, double,
  44. * or void.
  45. */
  46. @Override
  47. public boolean isPrimitive() { return true; }
  48. /**
  49. * Returns the modifiers for this type.
  50. * For decoding, use <code>javassist.Modifier</code>.
  51. *
  52. * @see Modifier
  53. */
  54. @Override
  55. public int getModifiers() {
  56. return Modifier.PUBLIC | Modifier.FINAL;
  57. }
  58. /**
  59. * Returns the descriptor representing this type.
  60. * For example, if the type is int, then the descriptor is I.
  61. */
  62. public char getDescriptor() { return descriptor; }
  63. /**
  64. * Returns the name of the wrapper class.
  65. * For example, if the type is int, then the wrapper class is
  66. * <code>java.lang.Integer</code>.
  67. */
  68. public String getWrapperName() { return wrapperName; }
  69. /**
  70. * Returns the name of the method for retrieving the value
  71. * from the wrapper object.
  72. * For example, if the type is int, then the method name is
  73. * <code>intValue</code>.
  74. */
  75. public String getGetMethodName() { return getMethodName; }
  76. /**
  77. * Returns the descriptor of the method for retrieving the value
  78. * from the wrapper object.
  79. * For example, if the type is int, then the method descriptor is
  80. * <code>()I</code>.
  81. */
  82. public String getGetMethodDescriptor() { return mDescriptor; }
  83. /**
  84. * Returns the opcode for returning a value of the type.
  85. * For example, if the type is int, then the returned opcode is
  86. * <code>javassit.bytecode.Opcode.IRETURN</code>.
  87. */
  88. public int getReturnOp() { return returnOp; }
  89. /**
  90. * Returns the array-type code representing the type.
  91. * It is used for the newarray instruction.
  92. * For example, if the type is int, then this method returns
  93. * <code>javassit.bytecode.Opcode.T_INT</code>.
  94. */
  95. public int getArrayType() { return arrayType; }
  96. /**
  97. * Returns the data size of the primitive type.
  98. * If the type is long or double, this method returns 2.
  99. * Otherwise, it returns 1.
  100. */
  101. public int getDataSize() { return dataSize; }
  102. }