1
2
3
4 package joeq.Class;
5
6 import java.util.Arrays;
7 import java.util.Iterator;
8 import jwutil.collections.AppendIterator;
9
10
11
12
13
14 public interface jq_FieldVisitor {
15
16 void visitStaticField(jq_StaticField m);
17 void visitInstanceField(jq_InstanceField m);
18 void visitField(jq_Field m);
19
20 class EmptyVisitor implements jq_FieldVisitor {
21 public void visitStaticField(jq_StaticField m) {}
22 public void visitInstanceField(jq_InstanceField m) {}
23 public void visitField(jq_Field m) {}
24 }
25
26 class DeclaredFieldVisitor extends jq_TypeVisitor.EmptyVisitor {
27 final jq_FieldVisitor mv; boolean trace;
28 public DeclaredFieldVisitor(jq_FieldVisitor mv) { this.mv = mv; }
29 public DeclaredFieldVisitor(jq_FieldVisitor mv, boolean trace) { this.mv = mv; this.trace = trace; }
30 public void visitClass(jq_Class k) {
31 if (trace) System.out.println(k.toString());
32 Iterator it = new AppendIterator(Arrays.asList(k.getDeclaredStaticFields()).iterator(),
33 Arrays.asList(k.getDeclaredInstanceFields()).iterator());
34 while (it.hasNext()) {
35 jq_Field m = (jq_Field)it.next();
36 m.accept(mv);
37 }
38 }
39 }
40
41 }
42