cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r439344 - in /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax: XMLInputStreamInterpreter.java XMLOutputStreamCompiler.java
Date Fri, 01 Sep 2006 15:00:48 GMT
Author: giacomo
Date: Fri Sep  1 08:00:47 2006
New Revision: 439344

URL: http://svn.apache.org/viewvc?rev=439344&view=rev
Log:
added XMLCompiler which uses Streams

Added:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLInputStreamInterpreter.java
  (with props)
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLOutputStreamCompiler.java
  (with props)

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLInputStreamInterpreter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLInputStreamInterpreter.java?rev=439344&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLInputStreamInterpreter.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLInputStreamInterpreter.java
Fri Sep  1 08:00:47 2006
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.sax;
+
+import org.apache.cocoon.components.sax.AbstractXMLByteStreamInterpreter;
+
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+
+/**
+ * This class interpreter compiled SAX event from an InputStream.
+ * If you want to reuse this interpreter make sure to call first {@link #recycle()}
+ * and then set the new consumer for the sax events before restarting with the {@link #deserialize(InputStream)}
method.
+ *
+ * @version $Id: XMLInputStreamInterpreter.java 366211 2006-01-05 16:02:33Z cziegeler $
+ */
+public final class XMLInputStreamInterpreter
+    extends AbstractXMLByteStreamInterpreter {
+
+    private InputStream is;
+
+    public void deserialize(final InputStream inputStream)
+        throws SAXException {
+        this.is = inputStream;
+        super.parse();
+    }
+
+    public void recycle() {
+        this.is = null;
+        super.recycle();
+    }
+
+    protected int read()
+        throws SAXException {
+        try {
+            return is.read();
+        } catch(final IOException e) {
+            throw new SAXException(e);
+        }
+    }
+
+    protected int read(final byte[] b)
+        throws SAXException {
+        try {
+            return is.read(b);
+        } catch(final IOException e) {
+            throw new SAXException(e);
+        }
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLInputStreamInterpreter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLOutputStreamCompiler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLOutputStreamCompiler.java?rev=439344&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLOutputStreamCompiler.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLOutputStreamCompiler.java
Fri Sep  1 08:00:47 2006
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.sax;
+
+import org.apache.cocoon.components.sax.AbstractXMLByteStreamCompiler;
+
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+
+/**
+ * This class compiles SAX events to an OutputStream.
+ * If you want to reuse this instance, make sure to call {@link #recycle(OutputStream)} to
set a new OutputStream
+ * and reset the class inbetween two compilation tasks.
+ *
+ * @version $Id: XMLOutputStreamCompiler.java 366211 2006-01-05 16:02:33Z cziegeler $
+ */
+public final class XMLOutputStreamCompiler
+    extends AbstractXMLByteStreamCompiler {
+
+    /** The buffer for the compile xml byte stream. */
+    private OutputStream os;
+
+    public XMLOutputStreamCompiler(final OutputStream out)
+        throws IOException {
+        super();
+        this.recycle(out);
+    }
+
+    public void recycle(final OutputStream out) {
+        this.os = out;
+        super.recycle();
+    }
+
+    public void recycle() {
+        this.recycle(this.os);
+    }
+
+    protected void write(final int b)
+        throws SAXException {
+        try {
+            this.os.write((byte)b);
+        } catch(final IOException e) {
+            throw new SAXException(e);
+        }
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/sax/XMLOutputStreamCompiler.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message