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.

AnnotationMemberValue.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 2004 Bill Burke. 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.bytecode.annotation;
  16. import javassist.bytecode.ConstPool;
  17. import java.io.IOException;
  18. /**
  19. * Nested annotation.
  20. *
  21. * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
  22. * @author Shigeru Chiba
  23. */
  24. public class AnnotationMemberValue extends MemberValue {
  25. Annotation value;
  26. /**
  27. * Constructs an annotation member. The initial value is not specified.
  28. */
  29. public AnnotationMemberValue(ConstPool cp) {
  30. this(null, cp);
  31. }
  32. /**
  33. * Constructs an annotation member. The initial value is specified by
  34. * the first parameter.
  35. */
  36. public AnnotationMemberValue(Annotation a, ConstPool cp) {
  37. super('@', cp);
  38. value = a;
  39. }
  40. /**
  41. * Obtains the value.
  42. */
  43. public Annotation getValue() {
  44. return value;
  45. }
  46. /**
  47. * Sets the value of this member.
  48. */
  49. public void setValue(Annotation newValue) {
  50. value = newValue;
  51. }
  52. /**
  53. * Obtains the string representation of this object.
  54. */
  55. public String toString() {
  56. return value.toString();
  57. }
  58. void write(AnnotationsWriter writer) throws IOException {
  59. writer.annotationValue();
  60. value.write(writer);
  61. }
  62. /**
  63. * Accepts a visitor.
  64. */
  65. public void accept(MemberValueVisitor visitor) {
  66. visitor.visitAnnotationMemberValue(this);
  67. }
  68. }