Package org.esa.snap.core.jexp
Class Term
java.lang.Object
org.esa.snap.core.jexp.Term
- Direct Known Subclasses:
 Term.Call,Term.Const,Term.Op,Term.Ref
The abstract 
Term class is an in-memory representation of an
 element within an arbitrary expression tree. The class defines a number of
 concrete Term implementations each representing either an
 an atomic leave (number constant, symbol reference) or a node
 (e.g. binary operator, function call) within an expression tree.
  Instances of this class are normally created using an expression parser
 which implements the  interface.
 The Parser class provides a default
 implementation of such a parser.ParserImpl
- Version:
 - $Revision$ $Date$
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe numerical ADD operation: n-term+n-termstatic final classThe logical AND operation: b-term&&b-termstatic final classThe bitwise AND operation: i-term&i-termstatic final classThe assignment operation variable-ref-term=termstatic classstatic classAn abstract binary (= 2 operands) operation.static classAn abstract binary (= 2 operands) operation with a return type ofint.static classAn abstract binary (= 2 operands) operation with a numeric return type.static final classA call of a (or reference to a).Functionstatic final classThe conditional operation b-term?term:termstatic classA boolean constant, e.g.static final classA boolean constant, e.g.static final classA floating point constant, e.g.static final classAn integer constant, e.g.static classstatic final classThe numerical DIV operation: n-term/n-termstatic final classThe boolean EQ operation: b-term==b-termstatic final classThe double EQ operation: d-term==d-termstatic final classThe integer EQ operation: i-term==i-termstatic final classThe double GE operation: d-term>=d-termstatic final classThe integer GE operation: i-term>=i-termstatic final classThe double GT operation: d-term>d-termstatic final classThe integer GT operation: i-term>i-termstatic final classThe double LE operation: d-term<=d-termstatic final classThe integer LE operation: i-term<=i-termstatic final classThe double LT operation: d-term<d-termstatic final classThe integer LT operation: i-term<i-termstatic final classThe numerical MOD (modulo) operation: n-term%n-termstatic final classThe numerical MUL operation: n-term*n-termstatic final classThe numerical NEG operation:-d-termstatic final classThe boolean NEQ operation: b-term!=b-termstatic final classThe double NEQ operation: d-term!=d-termstatic final classThe integer NEQ operation: i-term!=i-termstatic final classThe logical NOT operation!b-termstatic final classThe bitwise NOT operation:~i-termstatic classAn abstract operation.static final classThe logical OR operation: b-term||b-termstatic final classThe bitwise OR operation: i-term¦i-termstatic final classA reference to a.Symbolstatic final classThe numerical SUB operation: n-term-n-termstatic classAn abstract unary (= 1 operand) operation.static classAn abstract unary (= 1 operand) operation with return type ofboolean.static classAn abstract unary (= 1 operand) operation with return type ofint.static classAn abstract unary (= 1 operand) operation with a numeric return type.static final classThe bitwise XOR operation: i-term^i-term - 
Field Summary
Fields - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionabstract <T> Taccept(TermVisitor<T> visitor) Visitor support.abstract intabstract booleanEvaluates this term to abooleanvalue.abstract doubleEvaluates this term to adoublevalue.abstract intEvaluates this term to anintvalue.Evaluates this term to aStringvalue.Term[]Returns an array of terms which are children of this term.abstract intGets the term's "natural" return type.final booleanisB()Tests whether or not this term "naturally" returns aboolean.abstract booleanisConst()final booleanisD()Tests whether or not this term "naturally" returns adouble.final booleanisI()Tests whether or not this term "naturally" returns anint.final booleanisN()Tests whether or not this term "naturally" returns a numeric value.final booleanisS()Tests whether or not this term returns aString.abstract intpre()static booleantoB(double value) Converts adoubleto aboolean.static booleantoB(int value) Converts anintto aboolean.static doubletoD(boolean value) Converts abooleanto andouble.static inttoI(boolean value) Converts abooleanto anint.static inttoI(double value) Converts adoubleto anint.static StringtoS(boolean value) Converts abooleanto aString.static StringtoS(double value) Converts adoubleto aString.static StringtoS(int value) Converts aintegerto aString.abstract StringtoString()Returns a string representation of this term which can be used for debugging. 
- 
Field Details
- 
TYPE_B
public static final int TYPE_BThe ID for thebooleantype.- See Also:
 
 - 
TYPE_I
public static final int TYPE_IThe ID for theinttype.- See Also:
 
 - 
TYPE_D
public static final int TYPE_DThe ID for thedoubletype.- See Also:
 
 - 
TYPE_S
public static final int TYPE_SThe ID for thestringtype.- See Also:
 
 
 - 
 - 
Constructor Details
- 
Term
public Term() 
 - 
 - 
Method Details
- 
getRetType
public abstract int getRetType()Gets the term's "natural" return type.- Returns:
 - the type, should always be one of the 
TYPE_X constants defined in this class. 
 - 
evalB
Evaluates this term to abooleanvalue.- Parameters:
 context- the application dependant environment.- Returns:
 - a 
booleanvalue - Throws:
 EvalException- if the evaluation fails
 - 
evalI
Evaluates this term to anintvalue.- Parameters:
 env- the application dependant environment.- Returns:
 - an 
intvalue - Throws:
 EvalException- if the evaluation fails
 - 
evalD
Evaluates this term to adoublevalue.- Parameters:
 env- the application dependant environment.- Returns:
 - a 
doublevalue - Throws:
 EvalException- if the evaluation fails
 - 
accept
Visitor support.- Parameters:
 visitor- A visitor.
 - 
evalS
Evaluates this term to aStringvalue. The default implementation simply returns the value oftoString().- Parameters:
 env- the application dependant environment.- Returns:
 - a 
Stringvalue - Throws:
 EvalException- if the evaluation fails
 - 
getChildren
Returns an array of terms which are children of this term.- Returns:
 - an array of terms, never 
nullbut can be empty 
 - 
toString
Returns a string representation of this term which can be used for debugging. - 
isB
public final boolean isB()Tests whether or not this term "naturally" returns aboolean.- Returns:
 trueif so
 - 
isI
public final boolean isI()Tests whether or not this term "naturally" returns anint.- Returns:
 trueif so
 - 
isD
public final boolean isD()Tests whether or not this term "naturally" returns adouble.- Returns:
 trueif so
 - 
isN
public final boolean isN()Tests whether or not this term "naturally" returns a numeric value.- Returns:
 trueif so
 - 
isS
public final boolean isS()Tests whether or not this term returns aString.- Returns:
 trueif so
 - 
toB
public static boolean toB(int value) Converts anintto aboolean.- Parameters:
 value- the value to be converted- Returns:
 - the conversion result, which is 
value != 0. 
 - 
toB
public static boolean toB(double value) Converts adoubleto aboolean.- Parameters:
 value- the value to be converted- Returns:
 - the conversion result, which is 
value != 0.0. 
 - 
toI
public static int toI(boolean value) Converts abooleanto anint.- Parameters:
 value- the value to be converted- Returns:
 - the conversion result, which is 
value ? 1 : 0. 
 - 
toI
public static int toI(double value) Converts adoubleto anint.- Parameters:
 value- the value to be converted- Returns:
 - the conversion result, which is 
(int) value. 
 - 
toD
public static double toD(boolean value) Converts abooleanto andouble.- Parameters:
 value- the value to be converted- Returns:
 - the conversion result, which is 
value ? 1.0 : 0.0. 
 - 
toS
Converts abooleanto aString.- Parameters:
 value- the value to be converted- Returns:
 - the conversion result, which is 
value ? 1.0 : 0.0. 
 - 
toS
Converts aintegerto aString.- Parameters:
 value- the value to be converted- Returns:
 - the conversion result, which is 
value ? 1.0 : 0.0. 
 - 
toS
Converts adoubleto aString.- Parameters:
 value- the value to be converted- Returns:
 - the conversion result, which is 
value ? 1.0 : 0.0. 
 - 
isConst
public abstract boolean isConst()- Returns:
 true, if this term evaluates to the same constant value regardless of anyEvalEnv, evennull.
 - 
compare
 - 
pre
public abstract int pre() 
 -