KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > chaperon > model > symbol > Nonterminal


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.model.symbol;
10
11 /**
12  * This class represent a nonterminal symbol.
13  *
14  * @author <a HREF="mailto:stephan@apache.org">Stephan Michels</a>
15  * @version CVS $Id: Nonterminal.java,v 1.5 2003/12/09 19:55:53 benedikta Exp $
16  */

17 public class Nonterminal extends Symbol
18 {
19   /**
20    * Create a nonterminal symbol.
21    *
22    * @param name Name of the symbol.
23    */

24   public Nonterminal(String JavaDoc name)
25   {
26     super(name);
27   }
28
29   /**
30    * Returns a hash code value for the symbol.
31    *
32    * @return Hash code value for the symbol.
33    */

34   public int hashCode()
35   {
36     return name.hashCode()<<(1+1);
37   }
38
39   /**
40    * Compares the with another symbol.
41    *
42    * @param o Another object
43    *
44    * @return True, if the symbol are equal.
45    */

46   public boolean equals(Object JavaDoc o)
47   {
48     if (o==this)
49       return true;
50
51     if ((o!=null) && (o instanceof Nonterminal))
52     {
53       Symbol symbol = (Nonterminal)o;
54
55       return symbol.name.equals(name);
56     }
57
58     return false;
59   }
60 }
61
Popular Tags