package Ext_Tools; import java.util.Iterator; import java.util.Vector; /** * * Task of this class
* A ValueExpr represents a Numeric Value Expression or a Value Expression which can contain several Terms * Each Term needs to be connected via an operator (Plus or Minus) to another Term * The operator is stored inside the Term class (called ValueList) * This class basically consists of a vector of ValueList elements. */ public class ValueExpr { private Vector VList; private boolean hasSubQuery; private boolean hasSetFunction; public ValueExpr(ValueList newElem) { VList = new Vector(); VList.add(newElem); this.hasSubQuery = newElem.containsSub(); this.hasSetFunction = newElem.containsSetFunc(); } /** * * Task of this method
* Adds a new ValueList and returns the resulting ValueExpr. * @param newElem * @param op * @return */ public ValueExpr addElement(ValueList newElem, String op) { newElem.addOperator(op); VList.add(newElem); return this; } public boolean containsSub() { return this.hasSubQuery; } public boolean containsSetFunc() { return this.hasSetFunction; } /** * * Task of this method
* returns the content of this ValueExpr in form of a string * @return */ public String getStrValueExpr() { String result = ""; Iterator it; it = this.VList.iterator(); while (it.hasNext()) result += it.next().getStrValueList(); return result; } /** * * Task of this method
* returns the subquery in case this ValueExpr contains a subquery * @return */ public QueryClause getSubValueExpr() { Iterator it = this.VList.iterator(); return it.next().getSubValueList(); } }