Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ClassElementValueGen.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.generic.annotation;
  13. import java.io.DataOutputStream;
  14. import java.io.IOException;
  15. import org.aspectj.apache.bcel.classfile.ConstantClass;
  16. import org.aspectj.apache.bcel.classfile.ConstantUtf8;
  17. import org.aspectj.apache.bcel.generic.ConstantPoolGen;
  18. import org.aspectj.apache.bcel.generic.ObjectType;
  19. public class ClassElementValueGen extends ElementValueGen {
  20. // For primitive types and string type, this points to the value entry in the cpool
  21. // For 'class' this points to the class entry in the cpool
  22. private int idx;
  23. protected ClassElementValueGen(int typeIdx,ConstantPoolGen cpool) {
  24. super(ElementValueGen.CLASS,cpool);
  25. this.idx = typeIdx;
  26. }
  27. public ClassElementValueGen(ObjectType t,ConstantPoolGen cpool) {
  28. super(ElementValueGen.CLASS,cpool);
  29. this.idx = cpool.addClass(t);
  30. }
  31. public int getIndex() {
  32. return idx;
  33. }
  34. public String getClassString() {
  35. ConstantClass c = (ConstantClass)getConstantPool().getConstant(idx);
  36. ConstantUtf8 utf8 = (ConstantUtf8)getConstantPool().getConstant(c.getNameIndex());
  37. return utf8.getBytes();
  38. }
  39. public String stringifyValue() {
  40. return getClassString();
  41. }
  42. public void dump(DataOutputStream dos) throws IOException {
  43. dos.writeByte(type); // u1 kind of value
  44. dos.writeShort(idx);
  45. }
  46. }