Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 71690 invoked from network); 6 May 2004 17:21:28 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 6 May 2004 17:21:28 -0000 Received: (qmail 38803 invoked by uid 500); 6 May 2004 17:21:00 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 38751 invoked by uid 500); 6 May 2004 17:21:00 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 38711 invoked by uid 500); 6 May 2004 17:21:00 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 38689 invoked from network); 6 May 2004 17:21:00 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 6 May 2004 17:21:00 -0000 Received: (qmail 95708 invoked by uid 1638); 6 May 2004 10:09:04 -0000 Date: 6 May 2004 10:09:04 -0000 Message-ID: <20040506100904.95707.qmail@minotaur.apache.org> From: bruno@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/src/java/org/apache/cocoon/xml ParamSaxBuffer.java SaxBuffer.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N bruno 2004/05/06 03:09:04 Modified: src/java/org/apache/cocoon/xml ParamSaxBuffer.java SaxBuffer.java Log: Added possibility to dump a human-readable representation of the content of the SaxBuffer Revision Changes Path 1.6 +7 -1 cocoon-2.1/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java Index: ParamSaxBuffer.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ParamSaxBuffer.java 18 Mar 2004 23:59:12 -0000 1.5 +++ ParamSaxBuffer.java 6 May 2004 10:09:03 -0000 1.6 @@ -17,6 +17,8 @@ import java.util.Iterator; import java.util.Map; +import java.io.Writer; +import java.io.IOException; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; @@ -118,6 +120,10 @@ if (value != null) { value.toSAX(contentHandler); } + } + + public void dump(Writer writer) throws IOException { + writer.write("[ParamSaxBuffer.Parameter] name=" + name); } } } 1.13 +84 -1 cocoon-2.1/src/java/org/apache/cocoon/xml/SaxBuffer.java Index: SaxBuffer.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/xml/SaxBuffer.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- SaxBuffer.java 4 May 2004 18:21:50 -0000 1.12 +++ SaxBuffer.java 6 May 2004 10:09:03 -0000 1.13 @@ -24,6 +24,8 @@ import org.apache.avalon.excalibur.pool.Recyclable; import java.io.Serializable; +import java.io.Writer; +import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -188,11 +190,21 @@ saxbits.clear(); } + public void dump(Writer writer) throws IOException { + Iterator saxbitIt = saxbits.iterator(); + while (saxbitIt.hasNext()) { + SaxBit saxbit = (SaxBit)saxbitIt.next(); + saxbit.dump(writer); + } + writer.flush(); + } + /** * SaxBit is a representation of the SAX event. Every SaxBit is immutable object. */ interface SaxBit { public void send(ContentHandler contentHandler) throws SAXException; + public void dump(Writer writer) throws IOException; } public final static class StartDocument implements SaxBit, Serializable { @@ -200,6 +212,10 @@ public void send(ContentHandler contentHandler) throws SAXException { contentHandler.startDocument(); } + + public void dump(Writer writer) throws IOException { + writer.write("[StartDocument]\n"); + } } public final static class EndDocument implements SaxBit, Serializable { @@ -207,6 +223,10 @@ public void send(ContentHandler contentHandler) throws SAXException { contentHandler.endDocument(); } + + public void dump(Writer writer) throws IOException { + writer.write("[EndDocument]\n"); + } } public final static class PI implements SaxBit, Serializable { @@ -221,6 +241,10 @@ public void send(ContentHandler contentHandler) throws SAXException { contentHandler.processingInstruction(target, data); } + + public void dump(Writer writer) throws IOException { + writer.write("[ProcessingInstruction] target=" + target + ",data=" + data + "\n"); + } } public final static class StartDTD implements SaxBit, Serializable { @@ -238,6 +262,10 @@ if (contentHandler instanceof LexicalHandler) ((LexicalHandler)contentHandler).startDTD(name, publicId, systemId); } + + public void dump(Writer writer) throws IOException { + writer.write("[StartDTD] name=" + name + ",publicId=" + publicId + ",systemId=" + systemId + "\n"); + } } public final static class EndDTD implements SaxBit, Serializable { @@ -246,6 +274,10 @@ if (contentHandler instanceof LexicalHandler) ((LexicalHandler)contentHandler).endDTD(); } + + public void dump(Writer writer) throws IOException { + writer.write("[EndDTD]\n"); + } } public final static class StartEntity implements SaxBit, Serializable { @@ -259,6 +291,10 @@ if (contentHandler instanceof LexicalHandler) ((LexicalHandler)contentHandler).startEntity(name); } + + public void dump(Writer writer) throws IOException { + writer.write("[StartEntity] name=" + name + "\n"); + } } public final static class EndEntity implements SaxBit, Serializable { @@ -272,6 +308,10 @@ if (contentHandler instanceof LexicalHandler) ((LexicalHandler)contentHandler).endEntity(name); } + + public void dump(Writer writer) throws IOException { + writer.write("[EndEntity] name=" + name + "\n"); + } } public final static class SkippedEntity implements SaxBit, Serializable { @@ -284,6 +324,10 @@ public void send(ContentHandler contentHandler) throws SAXException { contentHandler.skippedEntity(name); } + + public void dump(Writer writer) throws IOException { + writer.write("[SkippedEntity] name=" + name + "\n"); + } } public final static class StartPrefixMapping implements SaxBit, Serializable { @@ -298,6 +342,10 @@ public void send(ContentHandler contentHandler) throws SAXException { contentHandler.startPrefixMapping(prefix, uri); } + + public void dump(Writer writer) throws IOException { + writer.write("[StartPrefixMapping] prefix=" + prefix + ",uri=" + uri + "\n"); + } } public final static class EndPrefixMapping implements SaxBit, Serializable { @@ -310,6 +358,10 @@ public void send(ContentHandler contentHandler) throws SAXException { contentHandler.endPrefixMapping(prefix); } + + public void dump(Writer writer) throws IOException { + writer.write("[EndPrefixMapping] prefix=" + prefix + "\n"); + } } public final static class StartElement implements SaxBit, Serializable { @@ -328,6 +380,13 @@ public void send(ContentHandler contentHandler) throws SAXException { contentHandler.startElement(namespaceURI, localName, qName, attrs); } + + public void dump(Writer writer) throws IOException { + writer.write("[StartElement] namespaceURI=" + namespaceURI + ",localName=" + localName + ",qName=" + qName + "\n"); + for (int i = 0; i < attrs.getLength(); i++) { + writer.write(" [Attribute] namespaceURI=" + attrs.getURI(i) + ",localName=" + attrs.getLocalName(i) + ",qName=" + attrs.getQName(i) + ",type=" + attrs.getType(i) + ",value=" + attrs.getValue(i) + "\n"); + } + } } public final static class EndElement implements SaxBit, Serializable { @@ -344,6 +403,10 @@ public void send(ContentHandler contentHandler) throws SAXException { contentHandler.endElement(namespaceURI, localName, qName); } + + public void dump(Writer writer) throws IOException { + writer.write("[EndElement] namespaceURI=" + namespaceURI + ",localName=" + localName + ",qName=" + qName + "\n"); + } } public final static class Characters implements SaxBit, Serializable { @@ -362,6 +425,10 @@ public void toString(StringBuffer value) { value.append(ch); } + + public void dump(Writer writer) throws IOException { + writer.write("[Characters] ch=" + new String(ch) + "\n"); + } } public final static class Comment implements SaxBit, Serializable { @@ -377,6 +444,10 @@ if (contentHandler instanceof LexicalHandler) ((LexicalHandler)contentHandler).comment(ch, 0, ch.length); } + + public void dump(Writer writer) throws IOException { + writer.write("[Comment] ch=" + new String(ch) + "\n"); + } } public final static class StartCDATA implements SaxBit, Serializable { @@ -385,6 +456,10 @@ if (contentHandler instanceof LexicalHandler) ((LexicalHandler)contentHandler).startCDATA(); } + + public void dump(Writer writer) throws IOException { + writer.write("[StartCDATA]\n"); + } } public final static class EndCDATA implements SaxBit, Serializable { @@ -393,6 +468,10 @@ if (contentHandler instanceof LexicalHandler) ((LexicalHandler)contentHandler).endCDATA(); } + + public void dump(Writer writer) throws IOException { + writer.write("[EndCDATA]\n"); + } } public final static class IgnorableWhitespace implements SaxBit, Serializable { @@ -406,6 +485,10 @@ public void send(ContentHandler contentHandler) throws SAXException { contentHandler.ignorableWhitespace(ch, 0, ch.length); + } + + public void dump(Writer writer) throws IOException { + writer.write("IgnorableWhitespace] ch=" + new String(ch) + "\n"); } } }