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.

AnnotationElementValueGen.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* *******************************************************************
  2. * Copyright (c) 2004 IBM
  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 - initial implementation {date}
  11. * ******************************************************************/
  12. package org.aspectj.apache.bcel.generic.annotation;
  13. import java.io.DataOutputStream;
  14. import java.io.IOException;
  15. import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValue;
  16. import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
  17. import org.aspectj.apache.bcel.generic.ConstantPoolGen;
  18. public class AnnotationElementValueGen extends ElementValueGen {
  19. // For annotation element values, this is the annotation
  20. private AnnotationGen a;
  21. public AnnotationElementValueGen(AnnotationGen a,ConstantPoolGen cpool) {
  22. super(ANNOTATION,cpool);
  23. this.a = a;
  24. }
  25. public AnnotationElementValueGen(int type, AnnotationGen annotation, ConstantPoolGen cpool) {
  26. super(type,cpool);
  27. if (type != ANNOTATION)
  28. throw new RuntimeException("Only element values of type annotation can be built with this ctor");
  29. this.a = annotation;
  30. }
  31. public AnnotationElementValueGen(AnnotationElementValue value, ConstantPoolGen cpool,boolean copyPoolEntries) {
  32. super(ANNOTATION,cpool);
  33. a = new AnnotationGen(value.getAnnotation(),cpool,copyPoolEntries);
  34. }
  35. public void dump(DataOutputStream dos) throws IOException {
  36. dos.writeByte(type); // u1 type of value (ANNOTATION == '@')
  37. a.dump(dos);
  38. }
  39. public String stringifyValue() {
  40. throw new RuntimeException("Not implemented yet");
  41. }
  42. /**
  43. * Return immutable variant of this AnnotationElementValueGen
  44. */
  45. public ElementValue getElementValue() {
  46. return new AnnotationElementValue(this.type,a.getAnnotation(),cpGen.getConstantPool());
  47. }
  48. public AnnotationGen getAnnotation() { return a;}
  49. }