1 package com.daffodilwoods.daffodildb.server.sql99.dql.execution; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.server.sql99.common.*; 6 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*; 7 import com.daffodilwoods.daffodildb.server.sql99.dql.tableexpression.groupbyclause.*; 8 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 9 import com.daffodilwoods.daffodildb.utils.comparator.*; 10 import com.daffodilwoods.database.resource.*; 11 import com.daffodilwoods.database.utility.*; 12 13 23 24 public class GroupByCondition { 25 26 29 30 private groupbyclause _grouppByClause; 31 32 35 36 private Object previous; 37 38 41 42 private _VariableValues variableValues; 43 44 48 49 private SuperComparator comparator; 50 51 59 60 public GroupByCondition(groupbyclause _grouppByClause0, _Iterator iterator, TableDetails[] tableDetails) throws DException { 61 _grouppByClause = _grouppByClause0; 62 _Reference[] ref = _grouppByClause.getReferences(tableDetails); 63 variableValues = new VariableValues(ref, null); 64 variableValues.setIterator(iterator); 65 ColumnDetails[] columns = _grouppByClause0.getColumnDetails(); 66 boolean[] order = new boolean[columns.length]; 67 Arrays.fill(order, true); 68 comparator = GeneralPurposeStaticClass.getOrderComparator(columns, order); 69 } 70 71 77 78 public void setIterator(_Iterator iterator) throws DException { 79 variableValues.setIterator(iterator); 80 } 81 82 89 90 public boolean compare() throws DException { 91 Object object = _grouppByClause.run(variableValues); 92 if (previous == null) { 93 previous = object; 94 return true; 95 } 96 boolean bool = false; 97 try { 98 bool = comparator.compare(previous, object) == 0; 99 } catch (NullPointerException ex) { 100 throw ex; 101 } 102 previous = object; 103 return bool; 104 } 105 106 111 112 public void setPreviousState() throws DException { 113 previous = null; 114 } 115 116 121 122 public ColumnDetails[] getColumnDetails() throws DException { 123 return _grouppByClause.getColumnDetails(); 124 } 125 126 public String toString() { 127 return "" + _grouppByClause; 128 } 129 130 134 135 public groupbyclause get_grouppByClause() { 136 return _grouppByClause; 137 } 138 139 146 147 public void setConditionVariableValue(_Reference[] references, Object [] values, int priority) throws DException { 148 variableValues.setConditionVariableValue(references, values, priority); 149 } 150 151 } 152 | Popular Tags |