org.uacalc.terms
Class NonVariableTerm

java.lang.Object
  extended by org.uacalc.terms.NonVariableTerm
All Implemented Interfaces:
Term

public class NonVariableTerm
extends java.lang.Object
implements Term


Field Summary
static java.lang.String COMMA
           
static java.lang.String LEFT_PAR
           
static java.lang.String RIGHT_PAR
           
 
Constructor Summary
NonVariableTerm(OperationSymbol opSym, java.util.List<Term> children)
           
 
Method Summary
 int depth()
          The depth of the term tree.
 boolean equals(java.lang.Object obj)
           
 java.lang.Object eval(Algebra alg, java.util.Map map)
          The evaluation of this term in an algebra using map as the variable assignment.
 java.util.List<Term> getChildren()
          A list of terms which are the immediate children.
 java.util.List<Variable> getVariableList()
          The list of variables in the order they appear in the term.
 int hashCode()
           
 TermOperation interpretation(SmallAlgebra alg)
          The operation obtained from this term using the variables in the order they occur.
 Operation interpretation(SmallAlgebra alg, java.util.List<Variable> varlist, boolean all)
          The interpretation of this term in an algebra; that is, the operation on alg corresponding to this term.
 int intEval(Algebra alg, java.util.Map map)
          The int evaluation of this term in an algebra using map as the variable assignment.
 boolean isaVariable()
           
 OperationSymbol leadingOperationSymbol()
          The leading operation symbol or null if this term is a variable.
 int length()
          The length of the term.
static Term makeConstantTerm(OperationSymbol sym)
          A static method to make a constant term from an operation symbol.
 Term substitute(java.util.Map<Variable,Term> map)
          Replace some of the variables with terms.
 java.lang.String toString()
          A reasonably good printout of the term.
 java.lang.StringBuffer writeStringBuffer(java.lang.StringBuffer sb)
          This is really an efficiency helper for toString.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT_PAR

public static final java.lang.String LEFT_PAR
See Also:
Constant Field Values

RIGHT_PAR

public static final java.lang.String RIGHT_PAR
See Also:
Constant Field Values

COMMA

public static final java.lang.String COMMA
See Also:
Constant Field Values
Constructor Detail

NonVariableTerm

public NonVariableTerm(OperationSymbol opSym,
                       java.util.List<Term> children)
Method Detail

makeConstantTerm

public static Term makeConstantTerm(OperationSymbol sym)
A static method to make a constant term from an operation symbol.

Parameters:
sym -
Returns:

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isaVariable

public boolean isaVariable()
Specified by:
isaVariable in interface Term

leadingOperationSymbol

public OperationSymbol leadingOperationSymbol()
The leading operation symbol or null if this term is a variable.

Specified by:
leadingOperationSymbol in interface Term

getChildren

public java.util.List<Term> getChildren()
A list of terms which are the immediate children.

Specified by:
getChildren in interface Term

eval

public java.lang.Object eval(Algebra alg,
                             java.util.Map map)
The evaluation of this term in an algebra using map as the variable assignment.

Specified by:
eval in interface Term

intEval

public int intEval(Algebra alg,
                   java.util.Map map)
Description copied from interface: Term
The int evaluation of this term in an algebra using map as the variable assignment.

Specified by:
intEval in interface Term

interpretation

public Operation interpretation(SmallAlgebra alg,
                                java.util.List<Variable> varlist,
                                boolean all)
Description copied from interface: Term
The interpretation of this term in an algebra; that is, the operation on alg corresponding to this term. The varlist, a list of Variable's, specifies the order. If useAll is true, variables that are not explicit in this term are still used.
For example, suppose the term is (z*y)*z, and varlist is (x, y, z). If useAll is true, the resulting operation will have arity 3 and be independent of its first variable. Otherwise it will be a 2 place operation with y as the first variable and z as the second.

Specified by:
interpretation in interface Term
Parameters:
alg - the Algebra
varlist - the list of variables
all - if true, use all the variables in varlist
Returns:
the term operation

interpretation

public TermOperation interpretation(SmallAlgebra alg)
Description copied from interface: Term
The operation obtained from this term using the variables in the order they occur.
For example, suppose the term is (z*y)*z. The result will be a 2 place operation with z as the first variable and y as the second.

Specified by:
interpretation in interface Term
Parameters:
alg - the Algebra
Returns:
the term operation
See Also:
#interpretation(Algebra,List,boolean)

getVariableList

public java.util.List<Variable> getVariableList()
Description copied from interface: Term
The list of variables in the order they appear in the term.

Specified by:
getVariableList in interface Term

length

public int length()
Description copied from interface: Term
The length of the term. A variable has length 1.

Specified by:
length in interface Term

depth

public int depth()
Description copied from interface: Term
The depth of the term tree. A variable has depth 0.

Specified by:
depth in interface Term

substitute

public Term substitute(java.util.Map<Variable,Term> map)
Description copied from interface: Term
Replace some of the variables with terms.

Specified by:
substitute in interface Term
Parameters:
map - a map for the substitution
Returns:

toString

public java.lang.String toString()
Description copied from interface: Term
A reasonably good printout of the term.

Specified by:
toString in interface Term
Overrides:
toString in class java.lang.Object

writeStringBuffer

public java.lang.StringBuffer writeStringBuffer(java.lang.StringBuffer sb)
Description copied from interface: Term
This is really an efficiency helper for toString. It returns the StringBuffer as a convenience.

Specified by:
writeStringBuffer in interface Term


Copyright 2003 Ralph Freese. All Rights Reserved.