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.

ClassElementValue.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * Andy Clement - initial implementation {date}
  11. * ******************************************************************/
  12. package org.aspectj.apache.bcel.classfile.annotation;
  13. import java.io.DataOutputStream;
  14. import java.io.IOException;
  15. import org.aspectj.apache.bcel.Constants;
  16. import org.aspectj.apache.bcel.classfile.ConstantPool;
  17. import org.aspectj.apache.bcel.classfile.ConstantUtf8;
  18. public class ClassElementValue extends ElementValue {
  19. // For primitive types and string type, this points to the value entry in the cpool
  20. // For 'class' this points to the class entry in the cpool
  21. private int idx;
  22. protected ClassElementValue(int type,int idx,ConstantPool cpool) {
  23. super(type,cpool);
  24. this.idx = idx;
  25. }
  26. public int getIndex() {
  27. return idx;
  28. }
  29. public String getClassString() {
  30. ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(idx,Constants.CONSTANT_Utf8);
  31. return c.getBytes();
  32. }
  33. public String stringifyValue() {
  34. ConstantUtf8 cu8 = (ConstantUtf8)cpool.getConstant(idx,Constants.CONSTANT_Utf8);
  35. return cu8.getBytes();
  36. }
  37. public void dump(DataOutputStream dos) throws IOException {
  38. dos.writeByte(type); // u1 kind of value
  39. dos.writeShort(idx);
  40. }
  41. }