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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. public boolean isPrimitive() { return true; }
  47. /**
  48. * Returns the modifiers for this type.
  49. * For decoding, use <code>javassist.Modifier</code>.
  50. *
  51. * @see Modifier
  52. */
  53. public int getModifiers() {
  54. return Modifier.PUBLIC | Modifier.FINAL;
  55. }
  56. /**
  57. * Returns the descriptor representing this type.
  58. * For example, if the type is int, then the descriptor is I.
  59. */
  60. public char getDescriptor() { return descriptor; }
  61. /**
  62. * Returns the name of the wrapper class.
  63. * For example, if the type is int, then the wrapper class is
  64. * <code>java.lang.Integer</code>.
  65. */
  66. public String getWrapperName() { return wrapperName; }
  67. /**
  68. * Returns the name of the method for retrieving the value
  69. * from the wrapper object.
  70. * For example, if the type is int, then the method name is
  71. * <code>intValue</code>.
  72. */
  73. public String getGetMethodName() { return getMethodName; }
  74. /**
  75. * Returns the descriptor of the method for retrieving the value
  76. * from the wrapper object.
  77. * For example, if the type is int, then the method descriptor is
  78. * <code>()I</code>.
  79. */
  80. public String getGetMethodDescriptor() { return mDescriptor; }
  81. /**
  82. * Returns the opcode for returning a value of the type.
  83. * For example, if the type is int, then the returned opcode is
  84. * <code>javassit.bytecode.Opcode.IRETURN</code>.
  85. */
  86. public int getReturnOp() { return returnOp; }
  87. /**
  88. * Returns the array-type code representing the type.
  89. * It is used for the newarray instruction.
  90. * For example, if the type is int, then this method returns
  91. * <code>javassit.bytecode.Opcode.T_INT</code>.
  92. */
  93. public int getArrayType() { return arrayType; }
  94. /**
  95. * Returns the data size of the primitive type.
  96. * If the type is long or double, this method returns 2.
  97. * Otherwise, it returns 1.
  98. */
  99. public int getDataSize() { return dataSize; }
  100. }