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.

SimpleAnnotationValue.java 2.8KB

15 years ago
3 years ago
15 years ago
14 years ago
15 years ago
14 years ago
15 years ago
14 years ago
15 years ago
14 years ago
15 years ago
14 years ago
15 years ago
3 years ago
15 years ago
14 years ago
3 years ago
14 years ago
15 years ago
14 years ago
3 years ago
15 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* *******************************************************************
  2. * Copyright (c) 2006 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Andy Clement IBM initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver;
  13. public class SimpleAnnotationValue extends AnnotationValue {
  14. public SimpleAnnotationValue(int kind) {
  15. super(kind);
  16. }
  17. public SimpleAnnotationValue(int kind, Object value) {
  18. super(kind);
  19. switch (kind) {
  20. case AnnotationValue.PRIMITIVE_BYTE:
  21. theByte = ((Byte) value).byteValue();
  22. break;
  23. case AnnotationValue.PRIMITIVE_CHAR:
  24. theChar = ((Character) value).charValue();
  25. break;
  26. case AnnotationValue.PRIMITIVE_INT:
  27. theInt = ((Integer) value).intValue();
  28. break;
  29. case AnnotationValue.STRING:
  30. theString = (String) value;
  31. break;
  32. case AnnotationValue.PRIMITIVE_DOUBLE:
  33. theDouble = ((Double) value).doubleValue();
  34. break;
  35. case AnnotationValue.PRIMITIVE_FLOAT:
  36. theFloat = ((Float) value).floatValue();
  37. break;
  38. case AnnotationValue.PRIMITIVE_LONG:
  39. theLong = ((Long) value).longValue();
  40. break;
  41. case AnnotationValue.PRIMITIVE_SHORT:
  42. theShort = ((Short) value).shortValue();
  43. break;
  44. case AnnotationValue.PRIMITIVE_BOOLEAN:
  45. theBoolean = ((Boolean) value).booleanValue();
  46. break;
  47. default:
  48. throw new BCException("Not implemented for this kind: " + whatKindIsThis(kind));
  49. }
  50. }
  51. private byte theByte;
  52. private char theChar;
  53. private int theInt;
  54. private String theString;
  55. private double theDouble;
  56. private float theFloat;
  57. private long theLong;
  58. private short theShort;
  59. private boolean theBoolean;
  60. public void setValueString(String s) {
  61. theString = s;
  62. }
  63. public void setValueByte(byte b) {
  64. theByte = b;
  65. }
  66. public void setValueChar(char c) {
  67. theChar = c;
  68. }
  69. public void setValueInt(int i) {
  70. theInt = i;
  71. }
  72. @Override
  73. public String stringify() {
  74. switch (valueKind) {
  75. case 'B': // byte
  76. return Byte.toString(theByte);
  77. case 'C': // char
  78. return new Character(theChar).toString();
  79. case 'D': // double
  80. return Double.toString(theDouble);
  81. case 'F': // float
  82. return Float.toString(theFloat);
  83. case 'I': // int
  84. return Integer.toString(theInt);
  85. case 'J': // long
  86. return Long.toString(theLong);
  87. case 'S': // short
  88. return Short.toString(theShort);
  89. case 'Z': // boolean
  90. return Boolean.valueOf(theBoolean).toString();
  91. case 's': // String
  92. return theString;
  93. default:
  94. throw new BCException("Do not understand this kind: " + valueKind);
  95. }
  96. }
  97. @Override
  98. public String toString() {
  99. return stringify();
  100. }
  101. }