KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > chaperon > process > extended > LookaheadReduceAction


1 /*
2  * Copyright (C) Chaperon. All rights reserved.
3  * -------------------------------------------------------------------------
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE file.
7  */

8
9 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 {
19   public final char minimum;
20   public final char maximum;
21
22   public LookaheadReduceAction(char minimum, char maximum, String JavaDoc symbol, int length)
23   {
24     super(symbol, length);
25
26     this.minimum = minimum;
27     this.maximum = maximum;
28   }
29
30   public LookaheadReduceAction(char minimum, char maximum, Pattern pattern, int length)
31   {
32     super(pattern, length);
33
34     this.minimum = minimum;
35     this.maximum = maximum;
36   }
37
38   public boolean contains(char c)
39   {
40     return (minimum<=c) && (c<=maximum);
41   }
42
43   public boolean equals(Object JavaDoc o)
44   {
45     if (o instanceof LookaheadReduceAction)
46     {
47       LookaheadReduceAction reduceAction = (LookaheadReduceAction)o;
48
49       if (symbol!=null)
50         return (minimum==reduceAction.minimum) && (maximum==reduceAction.maximum) &&
51                (symbol.equals(reduceAction.symbol)) && (length==reduceAction.length);
52
53       return (minimum==reduceAction.minimum) && (maximum==reduceAction.maximum) &&
54              (pattern==reduceAction.pattern) && (length==reduceAction.length);
55     }
56
57     return false;
58   }
59 }
60
Popular Tags