1 30 package org.objectweb.asm.util; 31 32 import org.objectweb.asm.AnnotationVisitor; 33 import org.objectweb.asm.Attribute; 34 import org.objectweb.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( 50 final String desc, 51 final boolean visible) 52 { 53 checkEnd(); 54 CheckMethodAdapter.checkDesc(desc, false); 55 return new CheckAnnotationAdapter(fv.visitAnnotation(desc, visible)); 56 } 57 58 public void visitAttribute(final Attribute attr) { 59 checkEnd(); 60 if (attr == null) { 61 throw new IllegalArgumentException ("Invalid attribute (must not be null)"); 62 } 63 fv.visitAttribute(attr); 64 } 65 66 public void visitEnd() { 67 checkEnd(); 68 end = true; 69 fv.visitEnd(); 70 } 71 72 private void checkEnd() { 73 if (end) { 74 throw new IllegalStateException ("Cannot call a visit method after visitEnd has been called"); 75 } 76 } 77 } 78 | Popular Tags |