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
 
 public abstract class Term extends Object The abstractTermclass is an in-memory representation of an element within an arbitrary expression tree. The class defines a number of concreteTermimplementations 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 Classes Modifier and Type Class Description static classTerm.AddThe numerical ADD operation: n-term+n-termstatic classTerm.AndBThe logical AND operation: b-term&&b-termstatic classTerm.AndIThe bitwise AND operation: i-term&i-termstatic classTerm.AssignThe assignment operation variable-ref-term=termstatic classTerm.Binarystatic classTerm.BinaryBAn abstract binary (= 2 operands) operation.static classTerm.BinaryIAn abstract binary (= 2 operands) operation with a return type ofint.static classTerm.BinaryNAn abstract binary (= 2 operands) operation with a numeric return type.static classTerm.CallA call of a (or reference to a)Functionstatic classTerm.CondThe conditional operation b-term?term:termstatic classTerm.ConstA boolean constant, e.g.static classTerm.ConstBA boolean constant, e.g.static classTerm.ConstDA floating point constant, e.g.static classTerm.ConstIAn integer constant, e.g.static classTerm.ConstSstatic classTerm.DivThe numerical DIV operation: n-term/n-termstatic classTerm.EqBThe boolean EQ operation: b-term==b-termstatic classTerm.EqDThe double EQ operation: d-term==d-termstatic classTerm.EqIThe integer EQ operation: i-term==i-termstatic classTerm.GeDThe double GE operation: d-term>=d-termstatic classTerm.GeIThe integer GE operation: i-term>=i-termstatic classTerm.GtDThe double GT operation: d-term>d-termstatic classTerm.GtIThe integer GT operation: i-term>i-termstatic classTerm.LeDThe double LE operation: d-term<=d-termstatic classTerm.LeIThe integer LE operation: i-term<=i-termstatic classTerm.LtDThe double LT operation: d-term<d-termstatic classTerm.LtIThe integer LT operation: i-term<i-termstatic classTerm.ModThe numerical MOD (modulo) operation: n-term%n-termstatic classTerm.MulThe numerical MUL operation: n-term*n-termstatic classTerm.NegThe numerical NEG operation:-d-termstatic classTerm.NEqBThe boolean NEQ operation: b-term!=b-termstatic classTerm.NEqDThe double NEQ operation: d-term!=d-termstatic classTerm.NEqIThe integer NEQ operation: i-term!=i-termstatic classTerm.NotBThe logical NOT operation!b-termstatic classTerm.NotIThe bitwise NOT operation:~i-termstatic classTerm.OpAn abstract operation.static classTerm.OrBThe logical OR operation: b-term||b-termstatic classTerm.OrIThe bitwise OR operation: i-term¦i-termstatic classTerm.RefA reference to aSymbolstatic classTerm.SubThe numerical SUB operation: n-term-n-termstatic classTerm.UnaryAn abstract unary (= 1 operand) operation.static classTerm.UnaryBAn abstract unary (= 1 operand) operation with return type ofboolean.static classTerm.UnaryIAn abstract unary (= 1 operand) operation with return type ofint.static classTerm.UnaryNAn abstract unary (= 1 operand) operation with a numeric return type.static classTerm.XOrIThe bitwise XOR operation: i-term^i-term
 - 
Constructor SummaryConstructors Constructor Description Term()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <T> Taccept(TermVisitor<T> visitor)Visitor support.abstract intcompare(Term other)abstract booleanevalB(EvalEnv context)Evaluates this term to abooleanvalue.abstract doubleevalD(EvalEnv env)Evaluates this term to adoublevalue.abstract intevalI(EvalEnv env)Evaluates this term to anintvalue.StringevalS(EvalEnv env)Evaluates this term to aStringvalue.Term[]getChildren()Returns an array of terms which are children of this term.abstract intgetRetType()Gets the term's "natural" return type.booleanisB()Tests whether or not this term "naturally" returns aboolean.abstract booleanisConst()booleanisD()Tests whether or not this term "naturally" returns adouble.booleanisI()Tests whether or not this term "naturally" returns anint.booleanisN()Tests whether or not this term "naturally" returns a numeric value.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 Detail- 
TYPE_Bpublic static final int TYPE_B The ID for thebooleantype.- See Also:
- Constant Field Values
 
 - 
TYPE_Ipublic static final int TYPE_I The ID for theinttype.- See Also:
- Constant Field Values
 
 - 
TYPE_Dpublic static final int TYPE_D The ID for thedoubletype.- See Also:
- Constant Field Values
 
 - 
TYPE_Spublic static final int TYPE_S The ID for thestringtype.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
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.
 
 - 
evalBpublic abstract boolean evalB(EvalEnv context) Evaluates this term to abooleanvalue.- Parameters:
- context- the application dependant environment.
- Returns:
- a booleanvalue
- Throws:
- EvalException- if the evaluation fails
 
 - 
evalIpublic abstract int evalI(EvalEnv env) Evaluates this term to anintvalue.- Parameters:
- env- the application dependant environment.
- Returns:
- an intvalue
- Throws:
- EvalException- if the evaluation fails
 
 - 
evalDpublic abstract double evalD(EvalEnv env) Evaluates this term to adoublevalue.- Parameters:
- env- the application dependant environment.
- Returns:
- a doublevalue
- Throws:
- EvalException- if the evaluation fails
 
 - 
acceptpublic abstract <T> T accept(TermVisitor<T> visitor) Visitor support.- Parameters:
- visitor- A visitor.
 
 - 
evalSpublic String evalS(EvalEnv env) 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
 
 - 
getChildrenpublic Term[] getChildren() Returns an array of terms which are children of this term.- Returns:
- an array of terms, never nullbut can be empty
 
 - 
toStringpublic abstract String toString() Returns 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.
 
 - 
toSpublic static String toS(boolean value) Converts abooleanto aString.- Parameters:
- value- the value to be converted
- Returns:
- the conversion result, which is value ? 1.0 : 0.0.
 
 - 
toSpublic static String toS(int value) Converts aintegerto aString.- Parameters:
- value- the value to be converted
- Returns:
- the conversion result, which is value ? 1.0 : 0.0.
 
 - 
toSpublic static String toS(double value) Converts 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.
 
 - 
comparepublic abstract int compare(Term other) 
 - 
prepublic abstract int pre() 
 
- 
 
-