cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r439334 - in /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax: AbstractXMLByteStreamCompiler.java AbstractXMLByteStreamInterpreter.java
Date Fri, 01 Sep 2006 14:36:02 GMT
Author: giacomo
Date: Fri Sep  1 07:36:01 2006
New Revision: 439334

URL: http://svn.apache.org/viewvc?rev=439334&view=rev
Log:
fixed bugs introduced during refactoring

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java?rev=439334&r1=439333&r2=439334&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java
Fri Sep  1 07:36:01 2006
@@ -102,6 +102,8 @@
     }
 
     public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
{
+        if(!hasProlog)
+            writeProlog();
         this.writeEvent(IGNORABLE_WHITESPACE);
         this.writeChars(ch, start, length);
     }
@@ -114,6 +116,8 @@
 
     public void setDocumentLocator(Locator locator) {
         try {
+            if(!hasProlog)
+                writeProlog();
             this.writeEvent(LOCATOR);
             String publicId = locator.getPublicId();
             String systemId = locator.getSystemId();
@@ -191,7 +195,7 @@
         }
     }
 
-    public final void writeEvent( final int event) {
+    public final void writeEvent( final int event) throws SAXException {
         this.write(event);
     }
 
@@ -218,7 +222,7 @@
         }
     }
 
-    public final void writeChars( final char[] ch, final int start, final int length) {
+    public final void writeChars( final char[] ch, final int start, final int length) throws
SAXException {
         int utflen = 0;
         int c;
 
@@ -323,9 +327,9 @@
     }
 */
 
-    abstract protected void write( final int b );
+    abstract protected void write( final int b ) throws SAXException;
 
-    private void writeProlog()
+    private void writeProlog() throws SAXException
     {
         write((byte)'C');
         write((byte)'X');

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java?rev=439334&r1=439333&r2=439334&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java
Fri Sep  1 07:36:01 2006
@@ -95,7 +95,7 @@
         int lastEvent = -1;
         while ( ( event = readEvent() ) != -1 ) {
             lastEvent = event;
-            switch (this.readEvent()) {
+            switch (event) {
                 case START_DOCUMENT:
                     contentHandler.startDocument();
                     break;
@@ -304,12 +304,18 @@
 
     private void checkProlog() throws SAXException {
         int valid = 0;
-        if (this.read() == 'C') valid++;
-        if (this.read() == 'X') valid++;
-        if (this.read() == 'M') valid++;
-        if (this.read() == 'L') valid++;
-        if (this.read() == 1) valid++;
-        if (this.read() == 0) valid++;
-        if (valid != 6) throw new SAXException("Unrecognized file format.");
+        int ch = 0;
+        if ((ch = this.read()) == 'C') valid++;
+        else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
+        if ((ch = this.read()) == 'X') valid++;
+        else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
+        if ((ch = this.read()) == 'M') valid++;
+        else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
+        if ((ch = this.read()) == 'L') valid++;
+        else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
+        if ((ch = this.read()) == 1) valid++;
+        else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
+        if ((ch = this.read()) == 0) valid++;
+        else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
     }
 }



Mime
View raw message