View Javadoc

1   /*
2    * #%L
3    * prolobjectlink-jpi-jtrolog
4    * %%
5    * Copyright (C) 2012 - 2018 WorkLogic Project
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as
9    * published by the Free Software Foundation, either version 2.1 of the
10   * License, or (at your option) any later version.
11   * 
12   * This program 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
15   * GNU General Lesser Public License for more details.
16   * 
17   * You should have received a copy of the GNU General Lesser Public
18   * License along with this program.  If not, see
19   * <http://www.gnu.org/licenses/lgpl-2.1.html>.
20   * #L%
21   */
22  package jTrolog.terms;
23  
24  /**
25   * @author ivar.orstavik@hist.no
26   */
27  @SuppressWarnings({ "serial" })
28  public class WrapVar extends Var implements Wrapper {
29  
30  	Var basis;
31  	int context;
32  	String[] nameNumbers;
33  
34  	public WrapVar(Var var, int renameVarID) {
35  		if (var instanceof WrapVar)
36  			throw new RuntimeException("building a WrapVar from another WrapVar");
37  		basis = var;
38  		context = renameVarID;
39  	}
40  
41  	public boolean equals(Object t) {
42  		return t instanceof WrapVar && context == ((WrapVar) t).context && basis.equals(((WrapVar) t).basis);
43  	}
44  
45  	public int hashCode() {
46  		return basis.hashCode() + context * 100;
47  	}
48  
49  	public boolean isAnonymous() {
50  		return basis.isAnonymous();
51  	}
52  
53  	public String toString() {
54  		return basis.toString();
55  	}
56  
57  	public String toStringSmall() {
58  		return basis.toStringSmall();
59  	}
60  
61  	public int getContext() {
62  		return context;
63  	}
64  
65  	public Term getBasis() {
66  		return basis;
67  	}
68  }