01: package persistence.antlr.debug;
02:
03: public class ParserMatchEvent extends GuessingEvent {
04: // NOTE: for a mismatch on type STRING, the "text" is used as the lookahead
05: // value. Normally "value" is this
06: public static int TOKEN = 0;
07: public static int BITSET = 1;
08: public static int CHAR = 2;
09: 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 target;
15: private int value;
16: private String text;
17:
18: public ParserMatchEvent(Object source) {
19: super (source);
20: }
21:
22: public ParserMatchEvent(Object source, int type, int value,
23: Object target, String text, int guessing, boolean inverse,
24: boolean matched) {
25: super (source);
26: setValues(type, value, target, text, guessing, inverse, matched);
27: }
28:
29: public Object getTarget() {
30: return target;
31: }
32:
33: public String getText() {
34: return text;
35: }
36:
37: public int getValue() {
38: return value;
39: }
40:
41: public boolean isInverse() {
42: return inverse;
43: }
44:
45: public boolean isMatched() {
46: return matched;
47: }
48:
49: void setInverse(boolean inverse) {
50: this .inverse = inverse;
51: }
52:
53: void setMatched(boolean matched) {
54: this .matched = matched;
55: }
56:
57: void setTarget(Object target) {
58: this .target = target;
59: }
60:
61: void setText(String text) {
62: this .text = text;
63: }
64:
65: void setValue(int value) {
66: this .value = value;
67: }
68:
69: /** This should NOT be called from anyone other than ParserEventSupport! */
70: void setValues(int type, int value, Object target, String text,
71: int guessing, boolean inverse, boolean matched) {
72: super .setValues(type, guessing);
73: setValue(value);
74: setTarget(target);
75: setInverse(inverse);
76: setMatched(matched);
77: setText(text);
78: }
79:
80: public String toString() {
81: return "ParserMatchEvent [" + (isMatched() ? "ok," : "bad,")
82: + (isInverse() ? "NOT " : "")
83: + (getType() == TOKEN ? "token," : "bitset,")
84: + getValue() + "," + getTarget() + "," + getGuessing()
85: + "]";
86: }
87: }
|