KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > debug > ParserMatchEvent


1 package antlr.debug;
2
3 public class ParserMatchEvent extends GuessingEvent {
4     // NOTE: for a mismatch on type STRING, the "text" is used as the lookahead
5
// value. Normally "value" is this
6
public static int TOKEN=0;
7     public static int BITSET=1;
8     public static int CHAR=2;
9     public static int CHAR_BITSET=3;
10     public static int STRING=4;
11     public static int CHAR_RANGE=5;
12     private boolean inverse;
13     private boolean matched;
14     private Object JavaDoc target;
15     private int value;
16     private String JavaDoc text;
17
18
19     public ParserMatchEvent(Object JavaDoc source) {
20         super(source);
21     }
22     public ParserMatchEvent(Object JavaDoc source, int type,
23                             int value, Object JavaDoc target, String JavaDoc text, int guessing,
24                             boolean inverse, boolean matched) {
25         super(source);
26         setValues(type,value,target,text,guessing,inverse,matched);
27     }
28     public Object JavaDoc getTarget() {
29         return target;
30     }
31     public String JavaDoc getText() {
32         return text;
33     }
34     public int getValue() {
35         return value;
36     }
37     public boolean isInverse() {
38         return inverse;
39     }
40     public boolean isMatched() {
41         return matched;
42     }
43     void setInverse(boolean inverse) {
44         this.inverse = inverse;
45     }
46     void setMatched(boolean matched) {
47         this.matched = matched;
48     }
49     void setTarget(Object JavaDoc target) {
50         this.target = target;
51     }
52     void setText(String JavaDoc text) {
53         this.text = text;
54     }
55     void setValue(int value) {
56         this.value = value;
57     }
58     /** This should NOT be called from anyone other than ParserEventSupport! */
59     void setValues(int type, int value, Object JavaDoc target, String JavaDoc text, int guessing, boolean inverse, boolean matched) {
60         super.setValues(type, guessing);
61         setValue(value);
62         setTarget(target);
63         setInverse(inverse);
64         setMatched(matched);
65         setText(text);
66     }
67     public String JavaDoc toString() {
68         return "ParserMatchEvent [" +
69                (isMatched()?"ok,":"bad,") +
70                (isInverse()?"NOT ":"") +
71                (getType()==TOKEN?"token,":"bitset,") +
72                getValue() + "," + getTarget() + "," + getGuessing() + "]";
73     }
74 }
Popular Tags