From: <th...@us...> - 2004-01-07 10:59:31
|
Update of /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme In directory sc8-pr-cvs1:/tmp/cvs-serv18038/src/runtime/de/ispsoft/jaxme Modified Files: JMManagerImpl.java JMManager.java Log Message: extended cursoring and bugfixes Index: JMManagerImpl.java =================================================================== RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/JMManagerImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- JMManagerImpl.java 11 Jul 2002 22:20:07 -0000 1.8 +++ JMManagerImpl.java 7 Jan 2004 10:59:28 -0000 1.9 @@ -1,5 +1,12 @@ package de.ispsoft.jaxme; +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.w3c.dom.Node; import org.w3c.dom.Element; @@ -10,6 +17,7 @@ * @author <a href="mailto:jo...@is...">Jochen Wiedmann</a> */ public class JMManagerImpl implements JMManager { + /** <p>The local name of the ElementClass element.</p> */ public static final String ELEMENT_CLASS_NAME = "ElementClass"; @@ -26,14 +34,14 @@ private static final String propertyBase = JMManager.class.getName(); private String propTree; private String localPropTree; - private java.util.List prefixList; + private List prefixList; protected class MyObserver implements Observer { private int maxResultSize = -1; private int resultSize = 0; - public java.util.List resultList = new java.util.ArrayList(); + public List resultList = new ArrayList(); public MyObserver() {} - public void notify(Object o) throws org.xml.sax.SAXException { + public void notify(Object o) throws SAXException { if (maxResultSize != -1) { if (++resultSize > maxResultSize) { throw new SAXException("Maximum result size of " + maxResultSize + @@ -83,7 +91,7 @@ throw new NullPointerException("Namespace element must have a prefix attribute"); } if (prefixList == null) { - prefixList = new java.util.ArrayList(); + prefixList = new ArrayList(); } prefixList.add(uriNode.getNodeValue()); prefixList.add(prefixNode.getNodeValue()); @@ -193,7 +201,6 @@ select(pObserver, pQuery, null, 0 , 0); } - /** <p>Reads documents matching the given query. For any document * matching, the Observer's notify method is executed with the * matching document as an argument.</p> @@ -245,7 +252,7 @@ * @param pMax Return at most the given number of documents. A value * of zero will return all documents. */ - public java.util.Iterator select(String pQuery, int pStart, int pMax) + public Iterator select(String pQuery, int pStart, int pMax) throws SAXException { return select(pQuery, null, pStart, pMax); } @@ -271,9 +278,8 @@ * @param pMax Return at most the given number of documents. A value * of zero will return all documents. */ - public java.util.Iterator select(String pQuery, - Object[] pPlaceHolderArgs, - int pStart, int pMax) throws SAXException { + public Iterator select(String pQuery, Object[] pPlaceHolderArgs, + int pStart, int pMax) throws SAXException { MyObserver o = new MyObserver(); select(o, pQuery, pPlaceHolderArgs, pStart, pMax); return o.resultList.iterator(); @@ -283,7 +289,7 @@ * * @param pQuery The query to perform. */ - public java.util.Iterator select(String pQuery) throws SAXException { + public Iterator select(String pQuery) throws SAXException { return select(pQuery, null, 0, 0); } @@ -304,9 +310,8 @@ * @param pPlaceHolderArgs An array of objects or null, if the * query doesn't contain any placeholders. */ - public java.util.Iterator select(String pQuery, - Object[] pPlaceHolderArgs) - throws SAXException { + public Iterator select(String pQuery, Object[] pPlaceHolderArgs) + throws SAXException { return select(pQuery, pPlaceHolderArgs, 0, 0); } @@ -328,18 +333,16 @@ /** <p>Serializes an element to a SAX ContentHandler using the configured * prefix settings.</p> */ - public void toSAX(JMAnyElement pElement, - org.xml.sax.ContentHandler pContentHandler) - throws SAXException { + public void toSAX(JMAnyElement pElement, ContentHandler pContentHandler) + throws SAXException { pElement.toSAX(pContentHandler, getNamespaceSupport()); } /** <p>Serializes an element to a SAX ContentHandler using the configured * prefix settings.</p> */ - public void toWriter(JMAnyElement pElement, - java.io.Writer pWriter) - throws SAXException, java.io.IOException { + public void toWriter(JMAnyElement pElement, Writer pWriter) + throws SAXException, IOException { pElement.toWriter(pWriter, getNamespaceSupport()); } @@ -351,7 +354,7 @@ } public void select(Observer pObserver, String pQuery, Object[] pPlaceHolders, - int pStart, int pMax) throws SAXException { + int pStart, int pMax) throws SAXException { throw new SAXException("Not implemented"); } @@ -366,4 +369,21 @@ public void insert(JMAnyElement pElement) throws SAXException { throw new SAXException("Not implemented"); } + + /* (non-Javadoc) + * @see de.ispsoft.jaxme.JMManager#select(de.ispsoft.jaxme.Observer, java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo) + */ + public void select(Observer pObserver, String pQuery, Object[] pPlaceHolderArgs, + int pStart, int pMax, ResultInfo pResultInfo) throws SAXException { + throw new SAXException("Not implemented"); + } + + /* (non-Javadoc) + * @see de.ispsoft.jaxme.JMManager#select(java.lang.String, java.lang.Object[], int, int, de.ispsoft.jaxme.ResultInfo) + */ + public Iterator select(String pQuery, Object[] pPlaceHolderArgs, int pStart, + int pMax, ResultInfo pResultInfo) throws SAXException { + throw new SAXException("Not implemented"); + } + } Index: JMManager.java =================================================================== RCS file: /cvsroot/jaxme/JaxMe/src/runtime/de/ispsoft/jaxme/JMManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- JMManager.java 25 Apr 2003 19:57:46 -0000 1.4 +++ JMManager.java 7 Jan 2004 10:59:28 -0000 1.5 @@ -1,5 +1,7 @@ package de.ispsoft.jaxme; +import java.util.Iterator; + import org.xml.sax.SAXException; @@ -147,6 +149,38 @@ Object[] pPlaceHolderArgs, int pStart, int pMax) throws SAXException; + /** + * <p>Reads documents matching the given query. For any document + * matching, the Observer's notify method is executed with the + * matching document as an argument.</p> + * <p>The query may contain placeholders. If it does, you have + * to supply an object array with two elements per placeholder: + * An Integer with a java.sql.Types type and the actual placeholder + * value. Example: + * <pre> + * manager.select("Name = ? and Id = ?", + * new Object[]{JMManager.VARCHAR, + * "Someone", + * JMManager.INTEGER, + * 4}, 0, 0); + * </pre></p> + * + * @param pObserver This Observer is notified for any matching document. + * The document is added as an argument. + * @param pQuery The query to perform. May contain placeholders. + * @param pPlaceHolderArgs An array of objects or null, if the + * query doesn't contain any placeholders. + * @param pStart Ignore the given number of result documents at the + * beginning. A value of zero will return all documents. + * @param pMax Return at most the given number of documents. A value + * of zero will return all documents. + * @param pResultInfo A container to place the information from query resultset, e.g. the resultset count + * @throws SAXException + */ + public void select(Observer pObserver, String pQuery, + Object[] pPlaceHolderArgs, + int pStart, int pMax, ResultInfo pResultInfo) throws SAXException; + /** <p>Returns an iterator to all documents matching the given query.</p> * * @param pQuery The query to perform. @@ -155,8 +189,7 @@ * @param pMax Return at most the given number of documents. A value * of zero will return all documents. */ - public java.util.Iterator select(String pQuery, int pStart, int pMax) - throws SAXException; + public Iterator select(String pQuery, int pStart, int pMax) throws SAXException; /** <p>Returns an iterator to all documents matching the given query. @@ -180,15 +213,39 @@ * @param pMax Return at most the given number of documents. A value * of zero will return all documents. */ - public java.util.Iterator select(String pQuery, - Object[] pPlaceHolderArgs, + public java.util.Iterator select(String pQuery, Object[] pPlaceHolderArgs, int pStart, int pMax) throws SAXException; + /** <p>Returns an iterator to all documents matching the given query. + * The query may contain placeholders. If it does, you have + * to supply an object array with two elements per placeholder: + * An Integer with a java.sql.Types type and the actual placeholder + * value. Example: + * <pre> + * manager.select("Name = ? and Id = ?", + * new Object[]{JMManager.VARCHAR, + * "Someone", + * JMManager.INTEGER, + * 4}, 0, 0); + * </pre></p> + * + * @param pQuery The query to perform. May contain placeholders. + * @param pPlaceHolderArgs An array of objects or null, if the + * query doesn't contain any placeholders. + * @param pStart Ignore the given number of result documents at the + * beginning. A value of zero will return all documents. + * @param pMax Return at most the given number of documents. A value + * of zero will return all documents. + * @param pResultInfo A container to place the information from query resultset, e.g. the resultset count + */ + public Iterator select(String pQuery, Object[] pPlaceHolderArgs, int pStart, + int pMax, ResultInfo pResultInfo) throws SAXException; + /** <p>Returns an iterator to all documents matching the given query.</p> * * @param pQuery The query to perform. */ - public java.util.Iterator select(String pQuery) throws SAXException; + public Iterator select(String pQuery) throws SAXException; /** <p>Returns an iterator to all documents matching the given query. * The query may contain placeholders. If it does, you have @@ -207,9 +264,7 @@ * @param pPlaceHolderArgs An array of objects or null, if the * query doesn't contain any placeholders. */ - public java.util.Iterator select(String pQuery, - Object[] pPlaceHolderArgs) - throws SAXException; + public Iterator select(String pQuery, Object[] pPlaceHolderArgs) throws SAXException; /** <p>Inserts the given document into the database.</p> */ |