01: /*
02: * Copyright (C) Chaperon. All rights reserved.
03: * -------------------------------------------------------------------------
04: * This software is published under the terms of the Apache Software License
05: * version 1.1, a copy of which has been included with this distribution in
06: * the LICENSE file.
07: */
08:
09: package net.sourceforge.chaperon.process.extended;
10:
11: import net.sourceforge.chaperon.model.extended.Pattern;
12:
13: /**
14: * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
15: * @version CVS $Id: LookaheadReduceAction.java,v 1.1 2004/01/04 16:49:12 benedikta Exp $
16: */
17: public class LookaheadReduceAction extends ReduceAction {
18: public final char minimum;
19: public final char maximum;
20:
21: public LookaheadReduceAction(char minimum, char maximum,
22: String symbol, int length) {
23: super (symbol, length);
24:
25: this .minimum = minimum;
26: this .maximum = maximum;
27: }
28:
29: public LookaheadReduceAction(char minimum, char maximum,
30: Pattern pattern, int length) {
31: super (pattern, length);
32:
33: this .minimum = minimum;
34: this .maximum = maximum;
35: }
36:
37: public boolean contains(char c) {
38: return (minimum <= c) && (c <= maximum);
39: }
40:
41: public boolean equals(Object o) {
42: if (o instanceof LookaheadReduceAction) {
43: LookaheadReduceAction reduceAction = (LookaheadReduceAction) o;
44:
45: if (symbol != null)
46: return (minimum == reduceAction.minimum)
47: && (maximum == reduceAction.maximum)
48: && (symbol.equals(reduceAction.symbol))
49: && (length == reduceAction.length);
50:
51: return (minimum == reduceAction.minimum)
52: && (maximum == reduceAction.maximum)
53: && (pattern == reduceAction.pattern)
54: && (length == reduceAction.length);
55: }
56:
57: return false;
58: }
59: }
|