package Ext_Tools; import java.util.Iterator; import java.util.Vector; /** * * Task of this class
* A ValueList represents a Term which can contain several Factors * Each Factor needs to be connected via an operator (Asterisk or Solidus) to another Factor * The operator is stored inside the Factor class (called SimpleValue) * This class basically consists of a vector of SimpleValue elements. * */ public class ValueList { private Vector SV; private boolean hasSubQuery; private boolean hasSetFunction; private String Operator; /** * Task of the constructor
* It automatically stores a term * @param newElem */ public ValueList(SimpleValue newElem) { SV = new Vector(); SV.add(newElem); this.hasSubQuery = newElem.containsSub(); this.hasSetFunction = newElem.containsSetFunc(); this.Operator = ""; } /** * Task of this method
* It stores a new element and the operator the new element is connected with * it is eather a Asterisk or a Solidus * @param newElem * @param op * @return */ public ValueList addElement(SimpleValue newElem, String op) { newElem.addOperator(op); SV.add(newElem); return this; } public boolean containsSub() { return this.hasSubQuery; } public boolean containsSetFunc() { return this.hasSetFunction; } /** * Task of this method
* ValueLists might add up to a Numeric Value Expression. Therefore they need to be able to contain an operator like + or - * The operator is set by the NumericValueExpression-Class (called ValueExpr) if needed. * * @param op Either Plus or Minus */ public void addOperator(String op) { this.Operator = op; } /** * * Task of this method
* returns the content of this ValueList in form of a string * @return */ public String getStrValueList() { String result = ""; Iterator it; it = this.SV.iterator(); while (it.hasNext()) result += it.next().getString(); if (this.Operator != "") result = this.Operator + " " + result; return result; } /** * * Task of this method
* returns the subquery in case the ValueList contains a subquery * @return */ public QueryClause getSubValueList() { Iterator it = this.SV.iterator(); return it.next().getQuery(); } }