1 30 package com.tc.asm.util; 31 32 import com.tc.asm.AnnotationVisitor; 33 import com.tc.asm.Attribute; 34 import com.tc.asm.FieldVisitor; 35 36 39 public class CheckFieldAdapter implements FieldVisitor { 40 41 private FieldVisitor fv; 42 43 private boolean end; 44 45 public CheckFieldAdapter(final FieldVisitor fv) { 46 this.fv = fv; 47 } 48 49 public AnnotationVisitor visitAnnotation(final String desc, boolean visible) 50 { 51 checkEnd(); 52 CheckMethodAdapter.checkDesc(desc, false); 53 return new CheckAnnotationAdapter(fv.visitAnnotation(desc, visible)); 54 } 55 56 public void visitAttribute(final Attribute attr) { 57 checkEnd(); 58 if (attr == null) { 59 throw new IllegalArgumentException ("Invalid attribute (must not be null)"); 60 } 61 fv.visitAttribute(attr); 62 } 63 64 public void visitEnd() { 65 checkEnd(); 66 end = true; 67 fv.visitEnd(); 68 } 69 70 private void checkEnd() { 71 if (end) { 72 throw new IllegalStateException ("Cannot call a visit method after visitEnd has been called"); 73 } 74 } 75 } 76 | Popular Tags |