cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: rev 53967 - cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml
Date Thu, 07 Oct 2004 13:27:24 GMT
Author: vgritsenko
Date: Thu Oct  7 06:27:23 2004
New Revision: 53967

Modified:
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/SaxBuffer.java
Log:
Add new "SAX event": xmlizable.


Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/ParamSaxBuffer.java	Thu Oct
 7 06:27:23 2004
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,7 @@
  * Any <code>{name}</code> expression inside of the character events can be
  * replaced by the content of another SaxBuffer if it is present in the map
  * passed to the {@link #toSAX(ContentHandler, Map)} method.
- * 
+ *
  * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
  * @version CVS $Id$
  */
@@ -62,7 +62,7 @@
                 if (i > start) {
                     addBit(new Characters(ch, start, i - start));
                 }
-                
+
                 // Find closing brace, and construct parameter name
                 StringBuffer name = new StringBuffer();
                 int j = i + 1;
@@ -76,14 +76,14 @@
                     throw new SAXException("Unclosed '}'");
                 }
                 addBit(new Parameter(name.toString()));
-                
+
                 // Continue processing
                 i = j;
                 start = j + 1;
                 continue;
             }
         }
-        
+
         // Send any tailing characters
         if (start < end) {
             addBit(new Characters(ch, start, end - start));
@@ -123,7 +123,7 @@
         }
 
         public void dump(Writer writer) throws IOException {
-            writer.write("[ParamSaxBuffer.Parameter] name=" + name);
+            writer.write("[Parameter] name=" + name);
         }
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/SaxBuffer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/SaxBuffer.java	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/SaxBuffer.java	Thu Oct  7
06:27:23 2004
@@ -161,6 +161,13 @@
     //
 
     /**
+     * Add a bit containing XMLizable object
+     */
+    public void xmlizable(XMLizable xml) {
+        saxbits.add(new XMLizableBit(xml));
+    }
+
+    /**
      * @return true if buffer is empty
      */
     public boolean isEmpty() {
@@ -534,6 +541,28 @@
 
         public void dump(Writer writer) throws IOException {
             writer.write("[IgnorableWhitespace] ch=" + new String(ch) + "\n");
+        }
+    }
+
+    public final static class XMLizableBit implements SaxBit, Serializable {
+        public final XMLizable xml;
+
+        public XMLizableBit(XMLizable xml) {
+            this.xml = xml;
+        }
+
+        public void send(ContentHandler contentHandler) throws SAXException {
+            this.xml.toSAX(new EmbeddedXMLPipe(contentHandler));
+        }
+
+        public void dump(Writer writer) throws IOException {
+            if (xml instanceof SaxBuffer) {
+                writer.write("[XMLizable] Begin nested SaxBuffer\n");
+                ((SaxBuffer)xml).dump(writer);
+                writer.write("[XMLizable] End nested SaxBuffer\n");
+            } else {
+                writer.write("[XMLizable] xml=" + xml + "\n");
+            }
         }
     }
 }

Mime
View raw message