Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jeops/rete/PairIntReteNode.java


1   package jeops.rete;
2   
3   /*
4    * JEOPS - The Java Embedded Object Production System
5    * Copyright (c) 2000   Carlos Figueira Filho
6    *
7    * This library is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU Lesser General Public
9    * License as published by the Free Software Foundation; either
10   * version 2.1 of the License, or (at your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this library; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20   *
21   * Contact: Carlos Figueira Filho (csff@cin.ufpe.br)
22   */
23  
24  /**
25   * Auxiliar class used to group pairs of integers and rete nodes.
26   *
27   * @author Carlos Figueira Filho (<a href="mailto:csff@cin.ufpe.br">csff@cin.ufpe.br</a>)
28   * @version 1.0   13 Jul 2000
29   */
30  class PairIntReteNode {
31  
32    /**
33     * The integer value.
34     */
35    private int intValue;
36    
37    /**
38     * The rete node.
39     */
40    private ReteNode node;
41    
42    /**
43     * Class constructor.
44     *
45     * @param intValue the integer value.
46     * @param node the rete node.
47     */
48    public PairIntReteNode(int intValue, ReteNode node) {
49      this.intValue = intValue;
50      this.node = node;
51    }
52    /**
53     * Compares the given object with this one.
54     *
55     * @return <code>true</code> if they are the same object;
56     *          <code>false</code> otherwise.
57     */
58    public boolean equals(Object obj) {
59      if (obj instanceof PairIntReteNode) {
60        PairIntReteNode tmp = (PairIntReteNode) obj;
61        return (tmp.intValue == intValue && tmp.node.equals(node));
62      }
63      return false;
64    }
65    /**
66     * Returns the integer value of this pair.
67     *
68     * @return the integer value of this pair.
69     */
70    public int getIntValue() {
71      return intValue;
72    }
73    /**
74     * Returns the rete node of this pair.
75     *
76     * @return the rete node of this pair.
77     */
78    public ReteNode getNode() {
79      return node;
80    }
81    /**
82     * Returns a hash code for this object.
83     *
84     * @return a hash code for this object.
85     */
86    public int hashCode() {
87      return intValue + node.hashCode();
88    }
89    /**
90     * Returns a string representation of this object. Useful
91     * for debugging.
92     *
93     * @return a string representation of this object.
94     */
95    public String toString() {
96      return ("Pair["+intValue+","+node+"]");
97    }
98  }