package Ext_Tools; import java.util.Iterator; import java.util.Vector; /** * * Task of this class:
* it provides a list of where-elements which are connected by the logical operator OR */ public class WhereClause { private Vector WLists; private boolean Empty = false; public WhereClause(WhereList newElem) { WLists = new Vector(); WLists.add(newElem); } /** * * Task of this constructor
* if no WhereList is passed the queryclause has no where-section * @param Nothing */ public WhereClause(String Nothing) { this.Empty = true; } public WhereClause addElement(WhereList newElem) { WLists.add(newElem); return this; } /** * * Task of this method
* checks whether any of the Where-Elements of the where-Lists contains a sub * it is needed for Search-Condition in Bool-Primaries because they are not supported * if the Search-Condition contains a sub. * @return */ public boolean containsSubs() { boolean result = false; if (!this.Empty) { Iterator it; it = this.WLists.iterator(); while (it.hasNext() && !result) result |= it.next().containsSubs(); } return result; } /** * * Task of this method
* in case any of the WhereElements of the WhereLists uses Subqueries the upper query is * set here * @param UQ */ public void SetUpperQuery(QueryClause UQ) { if (!this.Empty) { Iterator it; it = this.WLists.iterator(); while (it.hasNext()) it.next().SetUpperQuery(UQ); } } /** * * Task of this method
* all WhereElements of all WhereLists are looked through and ql is filled up * with all Qualifiers needed. * @param ql * @return */ public boolean NeedQualifier(QualifierList ql) { boolean result = false; if (!this.Empty) { Iterator it; it = this.WLists.iterator(); while (it.hasNext()) result |= it.next().getQualifierNeeded(ql); } return result; } /** * * Task of this method
* Outputs the WhereClause as a string * it throws an exception in case the QueryExpression of the Where-Element has a groupby-conflict * @return */ public String getWhereClause() throws Exception{ String result=""; if (!this.Empty) { Iterator it; it = this.WLists.iterator(); if (it.hasNext()) result = "(" + it.next().getWhereList() + ")"; while (it.hasNext()) result += " or (" + it.next().getWhereList() + ")"; if (result != "") result = " where " + result; } return result; } }