public class Constant extends Object implements Unifiable
Unifiable
.
The class has a static attribute to differentiate constants of the same
names, even if they will be unified if they have the same name.Modifier and Type | Field and Description |
---|---|
private int |
id |
private static int |
nextId |
private String |
printName |
Constructor and Description |
---|
Constant()
Constructor of the class.
|
Constant(String printName)
Constructor of the class.
|
Modifier and Type | Method and Description |
---|---|
String |
getName()
Gets the name of the constant.
|
Constant |
replaceVariables(SubstitutionSet s)
Replaces all the variables in the constant according to the specified
bindings.
|
Constant |
standardizeVariablesApart(Hashtable<Variable,Variable> newVars)
Standardizes the variables in order to be sure that there won't be any
variable clashes.
|
String |
toString()
Returns the constant under the form of:
"constantName_id".
|
SubstitutionSet |
unify(Unifiable expr,
SubstitutionSet s)
Unifies the constant with the specified
expr expression
given the bindings s . |
private String printName
private static int nextId
private int id
public Constant()
public Constant(String printName)
printName
- the name of the constant.public String getName()
getName
in interface Unifiable
null
if there is
no one.Unifiable.getName()
public Constant replaceVariables(SubstitutionSet s)
This method is recursive over all PCExpression
implementations.
This is a terminal case.
replaceVariables
in interface PCExpression
s
- the SubstitutionSet
that contains the bindings of the
variables so far.Constant
object representing the constant.PCExpression.replaceVariables(model.SubstitutionSet)
public Constant standardizeVariablesApart(Hashtable<Variable,Variable> newVars)
This method is recursive over all PCExpression
implementations.
This is a terminal case.
standardizeVariablesApart
in interface PCExpression
newVars
- is a parameter to save over the recursion all the variable
replacements done so far.Constant
object representing the standardized constant.PCExpression.standardizeVariablesApart(java.util.Hashtable)
public SubstitutionSet unify(Unifiable expr, SubstitutionSet s)
expr
expression
given the bindings s
. This tries to get or add bindings in order
to make logically equivalent the constant and the specified
expression.
This method is recursive over all Unifiable
implementations.
unify
in interface Unifiable
expr
- an expression to unify with the constant.s
- the SubstitutionSet
object representing the bindings
so far and/or the constraints applied.SubstitutionSet
object that contains all the bindings
needed to unify the constant to the specified expression.Unifiable.unify(Unifiable, SubstitutionSet)
public String toString()
toString
in class Object
Object.toString()