You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2001/12/04 18:11:08 UTC
cvs commit: jakarta-commons/digester/src/java/org/apache/commons/digester Digester.java
jstrachan 01/12/04 09:11:08
Modified: digester/src/java/org/apache/commons/digester Digester.java
Log:
Added helper method parse(Reader) to Digester for completeness. So any Reader or InputStream can now be used as input of the XML source without the user having to explicitly use a SAX InputSource. This makes it a little easier to work with internal String buffers, e.g. using a StringReader() as the source of a piece of XML.
Revision Changes Path
1.29 +23 -4 jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java
Index: Digester.java
===================================================================
RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Digester.java 2001/11/18 21:53:24 1.28
+++ Digester.java 2001/12/04 17:11:08 1.29
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v 1.28 2001/11/18 21:53:24 craigmcc Exp $
- * $Revision: 1.28 $
- * $Date: 2001/11/18 21:53:24 $
+ * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v 1.29 2001/12/04 17:11:08 jstrachan Exp $
+ * $Revision: 1.29 $
+ * $Date: 2001/12/04 17:11:08 $
*
* ====================================================================
*
@@ -68,6 +68,7 @@
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
@@ -108,7 +109,7 @@
*
* @author Craig McClanahan
* @author Scott Sanders
- * @version $Revision: 1.28 $ $Date: 2001/11/18 21:53:24 $
+ * @version $Revision: 1.29 $ $Date: 2001/12/04 17:11:08 $
*/
public class Digester extends DefaultHandler {
@@ -1231,6 +1232,24 @@
configure();
getReader().parse(new InputSource(input));
+ return (root);
+
+ }
+
+
+ /**
+ * Parse the content of the specified reader using this Digester.
+ * Returns the root element from the object stack (if any).
+ *
+ * @param reader Reader containing the XML data to be parsed
+ *
+ * @exception IOException if an input/output error occurs
+ * @exception SAXException if a parsing exception occurs
+ */
+ public Object parse(Reader reader) throws IOException, SAXException {
+
+ configure();
+ getReader().parse(new InputSource(reader));
return (root);
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>