Raptor.LogicParser.Formula
Class Var

java.lang.Object
  extended by Raptor.LogicParser.Formula.Term
      extended by Raptor.LogicParser.Formula.Var
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Var
extends Term

The Var (a Variable)
Extends abstract class Term.

See Also:
Serialized Form

Constructor Summary
Var(java.lang.String pName)
          Constructs a Var(A variable)
 
Method Summary
 void addToSignature(PanSignature pSignature)
          This method adds this Var to the Variable List of the passed PanSignature IF it is not already in the signature.
 boolean clashes(Atom pAtom)
          Returns true if the passed Atom clashes with this Var
An Atom clashes with a Var if they have the same name.
 java.lang.String clashes(PanSignature pSignature)
          Returns a String of error message if this Var clashes with the passed PanSignature.
A Var clashes with a PanSignature if it clashes with any of its Predicates,Constants,Functions or Variables.
If this Var does not clash with the Signature, it is added to the Variable list of the signature and an empty String is returned.
 boolean clashes(Term pTerm)
          Returns true if the passed Term(Constant/Function/Var) clashes with this Var.
A Var clashes with a Term if they have the same name.
 Var clone()
          Returns a copy(clone) of this Var.
 java.lang.String display()
          Returns a String to display the Var.
 boolean equals(Term pTerm)
          Returns true if the passed Term is equal to this Var.
A Term is equal to a Var if it is a Var and they have the same name.
 java.lang.String getName()
          Returns the name of the Var.
 boolean isIn(PanSignature pSignature)
          Returns true if this Var is in the Variable list of the passed PanSignature.
 Term regenerate()
          Returns a copy of the Term which can be saved as part of the copy made for the undo function.
 void setVars(Var pVar)
          This method adds Var v to the list of variables this Variable is bound to.
This will help the parser to prevent having nested variables.
I.e.
 Term sub(Term pTermX, Term pTermY)
          Substitutes all the occurences of Term x by Term y.
 
Methods inherited from class Raptor.LogicParser.Formula.Term
concatNoDup, getVars, isIn, isInVars
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Var

public Var(java.lang.String pName)
Constructs a Var(A variable)

Parameters:
pName - String of the name fo the variable
Method Detail

getName

public java.lang.String getName()
Returns the name of the Var.

Specified by:
getName in class Term

sub

public Term sub(Term pTermX,
                Term pTermY)
Substitutes all the occurences of Term x by Term y.

Specified by:
sub in class Term
Parameters:
pTermX - represents the Term to be substituted.
pTermY - represents the Term used to substitute the Term x

display

public java.lang.String display()
Returns a String to display the Var.

Specified by:
display in class Term

equals

public boolean equals(Term pTerm)
Returns true if the passed Term is equal to this Var.
A Term is equal to a Var if it is a Var and they have the same name.

Overrides:
equals in class Term
Parameters:
pTerm - Term represents the Term it is to be compared against.

isIn

public boolean isIn(PanSignature pSignature)
Returns true if this Var is in the Variable list of the passed PanSignature.

Specified by:
isIn in class Term
Parameters:
pSignature - PanSignature represents the signature it is to be searched in.

setVars

public void setVars(Var pVar)
This method adds Var v to the list of variables this Variable is bound to.
This will help the parser to prevent having nested variables.
I.e. this variable will not be able to have the same name as the previous variables it is nested in.

Specified by:
setVars in class Term
Parameters:
pVar - Var represents the Var to be added to the list of this Var's variables.

clone

public Var clone()
Returns a copy(clone) of this Var.

Specified by:
clone in class Term

clashes

public boolean clashes(Atom pAtom)
Returns true if the passed Atom clashes with this Var
An Atom clashes with a Var if they have the same name.

Parameters:
pAtom - Atom represents the Atom to be compared against.

clashes

public boolean clashes(Term pTerm)
Returns true if the passed Term(Constant/Function/Var) clashes with this Var.
A Var clashes with a Term if they have the same name.

Parameters:
pTerm - Term Represents the Term to be compared against.

clashes

public java.lang.String clashes(PanSignature pSignature)
Returns a String of error message if this Var clashes with the passed PanSignature.
A Var clashes with a PanSignature if it clashes with any of its Predicates,Constants,Functions or Variables.
If this Var does not clash with the Signature, it is added to the Variable list of the signature and an empty String is returned.

Specified by:
clashes in class Term
Parameters:
pSignature - PanSignature Represents the signature to be compared against.

addToSignature

public void addToSignature(PanSignature pSignature)
This method adds this Var to the Variable List of the passed PanSignature IF it is not already in the signature.

Specified by:
addToSignature in class Term
Parameters:
pSignature - PanSignature represents the signature to add this Formula to.

regenerate

public Term regenerate()
Returns a copy of the Term which can be saved as part of the copy made for the undo function.