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 ParserParserImpl
- Version:
- $Revision$ $Date$
- 
Nested Class SummaryNested 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 aSymbolstatic 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 SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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_Bpublic static final int TYPE_BThe ID for thebooleantype.- See Also:
 
- 
TYPE_Ipublic static final int TYPE_IThe ID for theinttype.- See Also:
 
- 
TYPE_Dpublic static final int TYPE_DThe ID for thedoubletype.- See Also:
 
- 
TYPE_Spublic static final int TYPE_SThe ID for thestringtype.- See Also:
 
 
- 
- 
Constructor Details- 
Termpublic Term()
 
- 
- 
Method Details- 
getRetTypepublic 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.
 
- 
evalBEvaluates this term to abooleanvalue.- Parameters:
- context- the application dependant environment.
- Returns:
- a booleanvalue
- Throws:
- EvalException- if the evaluation fails
 
- 
evalIEvaluates this term to anintvalue.- Parameters:
- env- the application dependant environment.
- Returns:
- an intvalue
- Throws:
- EvalException- if the evaluation fails
 
- 
evalDEvaluates this term to adoublevalue.- Parameters:
- env- the application dependant environment.
- Returns:
- a doublevalue
- Throws:
- EvalException- if the evaluation fails
 
- 
acceptVisitor support.- Parameters:
- visitor- A visitor.
 
- 
evalSEvaluates 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
 
- 
getChildrenReturns an array of terms which are children of this term.- Returns:
- an array of terms, never nullbut can be empty
 
- 
toStringReturns a string representation of this term which can be used for debugging.
- 
isBpublic final boolean isB()Tests whether or not this term "naturally" returns aboolean.- Returns:
- trueif so
 
- 
isIpublic final boolean isI()Tests whether or not this term "naturally" returns anint.- Returns:
- trueif so
 
- 
isDpublic final boolean isD()Tests whether or not this term "naturally" returns adouble.- Returns:
- trueif so
 
- 
isNpublic final boolean isN()Tests whether or not this term "naturally" returns a numeric value.- Returns:
- trueif so
 
- 
isSpublic final boolean isS()Tests whether or not this term returns aString.- Returns:
- trueif so
 
- 
toBpublic static boolean toB(int value) Converts anintto aboolean.- Parameters:
- value- the value to be converted
- Returns:
- the conversion result, which is value != 0.
 
- 
toBpublic static boolean toB(double value) Converts adoubleto aboolean.- Parameters:
- value- the value to be converted
- Returns:
- the conversion result, which is value != 0.0.
 
- 
toIpublic static int toI(boolean value) Converts abooleanto anint.- Parameters:
- value- the value to be converted
- Returns:
- the conversion result, which is value ? 1 : 0.
 
- 
toIpublic static int toI(double value) Converts adoubleto anint.- Parameters:
- value- the value to be converted
- Returns:
- the conversion result, which is (int) value.
 
- 
toDpublic 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.
 
- 
toSConverts abooleanto aString.- Parameters:
- value- the value to be converted
- Returns:
- the conversion result, which is value ? 1.0 : 0.0.
 
- 
toSConverts aintegerto aString.- Parameters:
- value- the value to be converted
- Returns:
- the conversion result, which is value ? 1.0 : 0.0.
 
- 
toSConverts adoubleto aString.- Parameters:
- value- the value to be converted
- Returns:
- the conversion result, which is value ? 1.0 : 0.0.
 
- 
isConstpublic abstract boolean isConst()- Returns:
- true, if this term evaluates to the same constant value regardless of any- EvalEnv, even- null.
 
- 
compare
- 
prepublic abstract int pre()
 
-