KickJava   Java API By Example, From Geeks To Geeks.

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


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: GotoAction.java,v 1.1 2004/01/04 16:49:12 benedikta Exp $
16  */

17 public class GotoAction
18 {
19   public final String JavaDoc symbol;
20   public final Pattern pattern;
21   public final State state;
22
23   public GotoAction(String JavaDoc symbol, State state)
24   {
25     if (symbol==null)
26       throw new IllegalArgumentException JavaDoc("Symbol is null");
27
28     if (state==null)
29       throw new IllegalArgumentException JavaDoc("State is null");
30
31     this.symbol = symbol;
32     this.pattern = null;
33     this.state = state;
34   }
35
36   public GotoAction(Pattern pattern, State state)
37   {
38     if (pattern==null)
39       throw new IllegalArgumentException JavaDoc("Pattern is null");
40
41     if (state==null)
42       throw new IllegalArgumentException JavaDoc("State is null");
43
44     this.symbol = null;
45     this.pattern = pattern;
46     this.state = state;
47   }
48
49   public boolean equals(Object JavaDoc o)
50   {
51     if (o instanceof GotoAction)
52     {
53       GotoAction gotoAction = (GotoAction)o;
54
55       if (symbol!=null)
56         return (gotoAction.symbol!=null) && symbol.equals(gotoAction.symbol);
57
58       return (pattern==gotoAction.pattern);
59     }
60
61     return false;
62   }
63 }
64
Popular Tags