1 19 20 21 package org.apache.cayenne.access.util; 22 23 import java.io.IOException ; 24 import java.io.PrintWriter ; 25 import java.io.StringWriter ; 26 import java.util.List ; 27 28 import org.apache.cayenne.CayenneException; 29 import org.apache.cayenne.CayenneRuntimeException; 30 import org.apache.cayenne.access.ResultIterator; 31 import org.apache.cayenne.query.Query; 32 33 39 public class IteratedSelectObserver extends DefaultOperationObserver { 40 protected ResultIterator resultIterator; 41 42 public boolean isIteratedResult() { 43 return true; 44 } 45 46 public void nextDataRows(Query query, List dataRows) { 47 throw new CayenneRuntimeException("Results unexpectedly returned as list."); 48 } 49 50 public void nextDataRows(Query q, ResultIterator it) { 51 resultIterator = it; 53 } 54 55 public ResultIterator getResultIterator() throws CayenneException { 56 if (super.hasExceptions()) { 57 StringWriter str = new StringWriter (); 58 PrintWriter out = new PrintWriter (str); 59 super.printExceptions(out); 60 61 try { 62 out.close(); 63 str.close(); 64 } catch (IOException ioex) { 65 } 67 68 throw new CayenneException( 69 "Error getting ResultIterator: " + str.getBuffer()); 70 } 71 72 return resultIterator; 73 } 74 75 } 76 | Popular Tags |