1 56 57 package org.objectstyle.cayenne.access.util; 58 59 import java.io.IOException ; 60 import java.io.PrintWriter ; 61 import java.io.StringWriter ; 62 import java.util.List ; 63 64 import org.objectstyle.cayenne.CayenneException; 65 import org.objectstyle.cayenne.CayenneRuntimeException; 66 import org.objectstyle.cayenne.access.ResultIterator; 67 import org.objectstyle.cayenne.query.Query; 68 69 75 public class IteratedSelectObserver extends DefaultOperationObserver { 76 protected ResultIterator resultIterator; 77 78 public boolean isIteratedResult() { 79 return true; 80 } 81 82 public void nextDataRows(Query query, List dataRows) { 83 throw new CayenneRuntimeException("Results unexpectedly returned as list."); 84 } 85 86 public void nextDataRows(Query q, ResultIterator it) { 87 resultIterator = it; 89 } 90 91 public ResultIterator getResultIterator() throws CayenneException { 92 if (super.hasExceptions()) { 93 StringWriter str = new StringWriter (); 94 PrintWriter out = new PrintWriter (str); 95 super.printExceptions(out); 96 97 try { 98 out.close(); 99 str.close(); 100 } catch (IOException ioex) { 101 } 103 104 throw new CayenneException( 105 "Error getting ResultIterator: " + str.getBuffer()); 106 } 107 108 return resultIterator; 109 } 110 111 } 112 | Popular Tags |