1 package com.daffodilwoods.daffodildb.server.sql99.dcl.sqlcontrolstatement; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.server.serversystem.*; 6 import com.daffodilwoods.daffodildb.server.sql99.common.*; 7 import com.daffodilwoods.daffodildb.server.sql99.token.*; 8 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 9 import com.daffodilwoods.database.resource.*; 10 11 public class loopstatement implements SQLcontrolstatement { 12 public endinglabel _Optendinglabel0; 13 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439221; 14 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439222; 15 public SQLstatementlist _SQLstatementlist3; 16 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439224; 17 public beginninglabelScolon94842719 _OptbeginninglabelScolon948427195; 18 19 private SQLcontrolstatement outerControlStatement; 20 private String beginningLabel; 21 22 public void setOuterControlStatement(SQLcontrolstatement outerst) { 23 outerControlStatement = outerst; 24 } 25 26 public Object run(Object object) throws DException { 27 _StatementExecutionContext sec = (_StatementExecutionContext) object; 28 _ServerSession serverSession = sec.getServerSession(); 29 checkSyntax(serverSession); 30 _SQLstatementlist3.run(object); 31 return this; 32 } 33 34 private void checkSyntax(_ServerSession serverSession) throws DException { 35 if (checkForLeaveStatement(serverSession)) { 36 throw new DException("DSE8035", null); 37 } 38 checkMatchingBeginningAndEndingLabel(serverSession); 39 if (_OptbeginninglabelScolon948427195 == null) { assignImplicitBeginningLabel(); 41 } else { 42 beginningLabel = "@" + 43 (String ) _OptbeginninglabelScolon948427195.getIdentifier(); 44 } 45 } 46 47 private void checkMatchingBeginningAndEndingLabel(_ServerSession 48 serverSession) throws DException { 49 if (_Optendinglabel0 != null) { 50 if (_OptbeginninglabelScolon948427195 == null) { 51 throw new DException("DSE8036", null); 52 } 53 else if (! ( (String ) _Optendinglabel0.getIdentifier()).equalsIgnoreCase 54 ( (String ) _OptbeginninglabelScolon948427195.getIdentifier())) { 55 throw new DException("DSE8037", null); 56 } 57 } 58 } 59 60 private void scopeManagement(_ServerSession serverSession) throws DException { 61 } 62 63 private void assignImplicitBeginningLabel() throws DException { 64 beginningLabel = "@internalLabel" + this.hashCode(); 65 } 66 67 private Object executeStatements(_VariableValues variableValues) throws DException { 68 ArrayList returningResultList = new ArrayList(); 69 _SQLstatementlist3.setOuterControlStatement(this); 70 while (true) { 71 Object listResult = _SQLstatementlist3.execute(variableValues); 72 if (listResult instanceof SqlStatementListResult) { 73 SqlStatementListResult result = (SqlStatementListResult) listResult; 74 if (result.hasIterateLeaveResult()) { 75 IterateLeaveResult temp = result.getIterateLeaveResult(); 76 if (temp.getLabel().equalsIgnoreCase(beginningLabel)) { 77 returningResultList.add(result.getResult()); 78 if (temp.getType() == IterateLeaveResult.ITERATETYPE) { 79 continue; 80 } else if (temp.getType() == IterateLeaveResult.LEAVETYPE) { 81 break; 82 } 83 } else { 84 SqlStatementListResult returningResult = new SqlStatementListResult(0); 85 returningResult.setResult(returningResultList.toArray()); 86 returningResult.setIterateLeaveResult(temp); 87 if (outerControlStatement == null) { 88 throw new DException("DSE8038", null); 89 } 90 return returningResult; 91 } 92 } else { 93 returningResultList.add(result.getResult()); 94 } 95 } else if (listResult instanceof ReturnResult) { 96 return listResult; 97 } 98 } 99 return returningResultList.toArray(); 100 } 101 102 private boolean checkForLeaveStatement(_ServerSession serverSession) throws 103 DException { 104 return _SQLstatementlist3.constainsLeaveStatement(); 105 } 106 107 public Object [] getParameters(Object object) throws DException { 108 return _SQLstatementlist3.getParameters(object); 109 } 110 111 public _Reference[] checkSemantic(_ServerSession object) throws DException { 112 checkMatchingBeginningAndEndingLabel(object); 113 return _SQLstatementlist3.checkSemantic(object); 114 } 115 116 public Object execute(_VariableValues variableValues) throws DException { 117 Object result = executeStatements(variableValues); 118 return result; 119 } 120 121 public Object execute(Object [] values) throws DException { 122 throw new UnsupportedOperationException (); 123 } 124 125 public Object executeForFresh(Object [] values) throws DException { 126 throw new UnsupportedOperationException (); 127 } 128 129 public ParameterInfo[] getParameterInfo() throws DException { 130 throw new UnsupportedOperationException (); 131 } 132 133 public String toString() { 134 StringBuffer sb = new StringBuffer (); 135 sb.append(" "); 136 if (_OptbeginninglabelScolon948427195 != null) { 137 sb.append(_OptbeginninglabelScolon948427195); 138 } 139 sb.append(" "); 140 sb.append(_SRESERVEDWORD12065439224); 141 sb.append(" "); 142 sb.append(_SQLstatementlist3); 143 sb.append(" "); 144 sb.append(_SRESERVEDWORD12065439222); 145 sb.append(" "); 146 sb.append(_SRESERVEDWORD12065439221); 147 sb.append(" "); 148 if (_Optendinglabel0 != null) { 149 sb.append(_Optendinglabel0); 150 } 151 return sb.toString().trim(); 152 } 153 154 public Object clone() throws CloneNotSupportedException { 155 return this; 156 } 157 158 public ColumnDetails[] getColumnDetails() throws DException { 159 return _SQLstatementlist3.getColumnDetails(); 160 } 161 162 public void getTableIncluded(ArrayList aList) throws DException { 163 } 164 165 public void getColumnsIncluded(ArrayList aList) throws DException { 166 } 167 } 168 | Popular Tags |