KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > ParameterEntry


1 /*****************************************************************************
2  * Copyright (C) Codehaus.org. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8 /*
9  * Created on Apr 5, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

14 package jfun.yan;
15
16 import jfun.yan.function.Function;
17
18 /**
19  * This class represents a parameter in a Function object.
20  * Objects of this class may be found in the resolution trace
21  * of a YanException object to represent a frame of a parameter instantiation.
22  * <p>
23  * Codehaus.org.
24  *
25  * @author Ben Yu
26  *
27  */

28 public final class ParameterEntry implements java.io.Serializable JavaDoc {
29   private final Function f;
30   private final int pos;
31   
32   /**
33    * Create a ParameterEntry object.
34    * @param f the function.
35    * @param pos the position of the parameter.
36    */

37   public ParameterEntry(final Function f, final int pos) {
38     this.f = f;
39     this.pos = pos;
40   }
41   
42   /**
43    * Gets the function object.
44    * @return the function object.
45    */

46   public Function getFunction() {
47     return f;
48   }
49   /**
50    * Gets the ordinal position of the parameter.
51    * @return the ordinal position.
52    */

53   public int getOrdinalPosition() {
54     return pos;
55   }
56   
57   public boolean equals(Object JavaDoc obj) {
58     if(obj instanceof ParameterEntry){
59       final ParameterEntry other = (ParameterEntry)obj;
60       return pos == other.pos && f.equals(other.f);
61     }
62     else return false;
63   }
64   public int hashCode() {
65     return f.hashCode()*31+pos;
66   }
67   public String JavaDoc toString() {
68     return "parameter " + pos + " of <" + f + ">";
69   }
70 }
71
Popular Tags