Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 56670 invoked from network); 1 Sep 2006 11:50:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Sep 2006 11:50:06 -0000 Received: (qmail 27415 invoked by uid 500); 1 Sep 2006 11:50:05 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 27361 invoked by uid 500); 1 Sep 2006 11:50:05 -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: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 27349 invoked by uid 99); 1 Sep 2006 11:50:05 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Sep 2006 04:50:05 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Sep 2006 04:50:04 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 8C4561A981A; Fri, 1 Sep 2006 04:49:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r439278 - in /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax: AbstractXMLByteStreamCompiler.java AbstractXMLByteStreamInterpreter.java XMLByteStreamCompiler.java Date: Fri, 01 Sep 2006 11:49:43 -0000 To: cvs@cocoon.apache.org From: giacomo@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060901114944.8C4561A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: giacomo Date: Fri Sep 1 04:49:43 2006 New Revision: 439278 URL: http://svn.apache.org/viewvc?rev=439278&view=rev Log: stream prolog is abstraction affair 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 cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamCompiler.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=439278&r1=439277&r2=439278&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 04:49:43 2006 @@ -33,15 +33,17 @@ private HashMap map; private int mapCount; + private boolean hasProlog = false; protected AbstractXMLByteStreamCompiler() { this.map = new HashMap(); this.initOutput(); } - protected void initOutput() { + private void initOutput() { this.mapCount = 0; this.map.clear(); + this.hasProlog = false; } public void recycle() { @@ -49,6 +51,8 @@ } public void startDocument() throws SAXException { + if(!hasProlog) + writeProlog(); this.writeEvent(START_DOCUMENT); } @@ -57,6 +61,8 @@ } public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws SAXException { + if(!hasProlog) + writeProlog(); this.writeEvent(START_PREFIX_MAPPING); this.writeString(prefix); this.writeString(uri); @@ -318,5 +324,16 @@ */ abstract protected void write( final int b ); + + private void writeProlog() + { + write((byte)'C'); + write((byte)'X'); + write((byte)'M'); + write((byte)'L'); + write((byte)1); + write((byte)0); + hasProlog = true; + } } 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=439278&r1=439277&r2=439278&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 04:49:43 2006 @@ -187,17 +187,6 @@ } } - 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."); - } - protected int readEvent() throws SAXException { return this.read(); } @@ -311,5 +300,16 @@ int ch3 = this.read(); int ch4 = this.read(); return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); + } + + 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."); } } Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamCompiler.java URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamCompiler.java?rev=439278&r1=439277&r2=439278&view=diff ============================================================================== --- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamCompiler.java (original) +++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamCompiler.java Fri Sep 1 04:49:43 2006 @@ -40,26 +40,19 @@ this.initOutput(); } - protected void initOutput() { - super.initOutput(); + private void initOutput() { this.buf = new byte[bufCountAverage]; - this.buf[0] = (byte)'C'; - this.buf[1] = (byte)'X'; - this.buf[2] = (byte)'M'; - this.buf[3] = (byte)'L'; - this.buf[4] = (byte)1; - this.buf[5] = (byte)0; - this.bufCount = 6; } public void recycle() { bufCountAverage = (bufCountAverage + bufCount) / 2; + initOutput(); super.recycle(); } public Object getSAXFragment() { - if (this.bufCount == 6) { // no event arrived yet + if (this.bufCount == 0) { // no event arrived yet return null; } byte newbuf[] = new byte[this.bufCount];