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.

AnnotationValue.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 abstract class AnnotationValue {
  14. protected int valueKind;
  15. public static final int STRING = 's';
  16. public static final int ENUM_CONSTANT = 'e';
  17. public static final int CLASS = 'c';
  18. public static final int ANNOTATION = '@';
  19. public static final int ARRAY = '[';
  20. public static final int PRIMITIVE_INT = 'I';
  21. public static final int PRIMITIVE_BYTE = 'B';
  22. public static final int PRIMITIVE_CHAR = 'C';
  23. public static final int PRIMITIVE_DOUBLE = 'D';
  24. public static final int PRIMITIVE_FLOAT = 'F';
  25. public static final int PRIMITIVE_LONG = 'J';
  26. public static final int PRIMITIVE_SHORT = 'S';
  27. public static final int PRIMITIVE_BOOLEAN = 'Z';
  28. public abstract String stringify();
  29. public AnnotationValue(int kind) {
  30. valueKind = kind;
  31. }
  32. public static String whatKindIsThis(int kind) {
  33. switch (kind) {
  34. case PRIMITIVE_BYTE: // byte
  35. return "byte";
  36. case PRIMITIVE_CHAR: // char
  37. return "char";
  38. case PRIMITIVE_DOUBLE: // double
  39. return "double";
  40. case PRIMITIVE_FLOAT: // float
  41. return "float";
  42. case PRIMITIVE_INT: // int
  43. return "int";
  44. case PRIMITIVE_LONG: // long
  45. return "long";
  46. case PRIMITIVE_SHORT: // short
  47. return "short";
  48. case PRIMITIVE_BOOLEAN: // boolean
  49. return "boolean";
  50. case 's': // String
  51. return "string";
  52. case 'e': // Enum constant
  53. return "enum";
  54. case 'c': // Class
  55. return "class";
  56. case '@': // Annotation
  57. return "annotation";
  58. case '[': // Array
  59. return "array";
  60. default:
  61. throw new RuntimeException("Dont know what this is : " + kind);
  62. }
  63. }
  64. }