1 7 8 package jas; 9 10 import java.io.*; 11 import java.util.*; 12 13 public class AnnotationAttr { 14 15 AsciiCP type; 16 ArrayList list = new ArrayList(); 17 18 void resolve(ClassEnv e){ 19 e.addCPItem(type); 20 if (list != null){ 21 Iterator it = list.iterator(); 22 while (it.hasNext()){ 23 ((ElemValPair)it.next()).resolve(e); 24 } 25 } 26 } 27 28 32 public AnnotationAttr(String type, ArrayList elems) { this.type = new AsciiCP(type); 34 this.list = elems; 35 } 36 37 public AnnotationAttr() { } 39 40 public void setType(String type){ 41 this.type = new AsciiCP(type); 42 } 43 44 public void addElemValPair(ElemValPair pair){ 45 list.add(pair); 46 } 47 48 int size(){ 49 int i = 4; 50 if (list != null){ 51 Iterator it = list.iterator(); 52 while (it.hasNext()){ 53 i += ((ElemValPair)it.next()).size(); 54 } 55 } 56 return i; 57 } 58 59 60 void write(ClassEnv e, DataOutputStream out) 61 throws IOException, jasError 62 { 63 64 out.writeShort(e.getCPIndex(type)); 65 if (list == null){ 66 out.writeShort(0); 67 } 68 else { 69 out.writeShort(list.size()); } 71 if (list != null){ 72 Iterator it = list.iterator(); 73 while (it.hasNext()){ 74 ((ElemValPair)it.next()).write(e, out); 75 } 76 } 77 } 78 } 79 | Popular Tags |