[prev in list] [next in list] [prev in thread] [next in thread]
List: xalan-cvs
Subject: cvs commit: xml-xalan/java/src/org/apache/xml/serializer WriterChain.java WriterToASCI.java WriterTo
From: minchau () apache ! org
Date: 2004-09-01 17:36:30
Message-ID: 20040901173630.29611.qmail () minotaur ! apache ! org
[Download RAW message or body]
minchau 2004/09/01 10:36:30
Modified: java/src/org/apache/xml/serializer WriterToASCI.java
WriterToUTF8Buffered.java ToStream.java
SerializerTraceWriter.java
Added: java/src/org/apache/xml/serializer WriterChain.java
Log:
Submitted by: Brian Minchau
Code clean up, to have an explicit interface, WriterChain,
for writers that wrap other Writers or OutputStreams,
e.g. WriterToUTF8Buffered.
Revision Changes Path
1.3 +13 -2 xml-xalan/java/src/org/apache/xml/serializer/WriterToASCI.java
Index: WriterToASCI.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/WriterToASCI.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WriterToASCI.java 17 Feb 2004 04:18:18 -0000 1.2
+++ WriterToASCI.java 1 Sep 2004 17:36:30 -0000 1.3
@@ -29,8 +29,12 @@
* moment it does not do buffering, though I reserve the right to do some
* buffering down the line if I can prove that it will be faster even if the
* output stream is buffered.
+ *
+ * This class is only used internally within Xalan.
+ *
+ * @xsl.usage internal
*/
-public class WriterToASCI extends Writer
+public class WriterToASCI extends Writer implements WriterChain
{
/** The byte stream to write to. */
@@ -139,4 +143,11 @@
return m_os;
}
+ /**
+ * Get the writer that this writer directly chains to.
+ */
+ public Writer getWriter()
+ {
+ return null;
+ }
}
1.8 +9 -2 xml-xalan/java/src/org/apache/xml/serializer/WriterToUTF8Buffered.java
Index: WriterToUTF8Buffered.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/WriterToUTF8Buffered.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- WriterToUTF8Buffered.java 31 Aug 2004 05:25:57 -0000 1.7
+++ WriterToUTF8Buffered.java 1 Sep 2004 17:36:30 -0000 1.8
@@ -34,7 +34,7 @@
*
* @xsl.usage internal
*/
-final class WriterToUTF8Buffered extends Writer
+final class WriterToUTF8Buffered extends Writer implements WriterChain
{
/** number of bytes that the byte buffer can hold.
@@ -430,5 +430,12 @@
public OutputStream getOutputStream()
{
return m_os;
+ }
+
+ public Writer getWriter()
+ {
+ // Only one of getWriter() or getOutputStream() can return null
+ // This type of writer wraps an OutputStream, not a Writer.
+ return null;
}
}
1.34 +3 -3 xml-xalan/java/src/org/apache/xml/serializer/ToStream.java
Index: ToStream.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToStream.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- ToStream.java 27 Aug 2004 21:37:13 -0000 1.33
+++ ToStream.java 1 Sep 2004 17:36:30 -0000 1.34
@@ -46,8 +46,8 @@
/**
* This abstract class is a base class for other stream
* serializers (xml, html, text ...) that write output to a stream.
- * @author Santiago Pericas-Geertsen
- * @author G. Todd Miller
+ *
+ * @xsl.usage internal
*/
abstract public class ToStream extends SerializerBase
{
1.3 +22 -2 xml-xalan/java/src/org/apache/xml/serializer/SerializerTraceWriter.java
Index: SerializerTraceWriter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/SerializerTraceWriter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SerializerTraceWriter.java 17 Feb 2004 04:18:18 -0000 1.2
+++ SerializerTraceWriter.java 1 Sep 2004 17:36:30 -0000 1.3
@@ -19,6 +19,7 @@
package org.apache.xml.serializer;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.Writer;
/**
@@ -38,7 +39,7 @@
* resonable facsimile of the true output.
*
*/
-public class SerializerTraceWriter extends Writer
+public class SerializerTraceWriter extends Writer implements WriterChain
{
/** The real writer to immediately write to.
@@ -315,4 +316,23 @@
}
}
+ /**
+ * Get the writer that this one directly wraps.
+ */
+ public Writer getWriter()
+ {
+ return m_writer;
+ }
+
+ /**
+ * Get the OutputStream that is the at the end of the
+ * chain of writers.
+ */
+ public OutputStream getOutputStream()
+ {
+ OutputStream retval = null;
+ if (m_writer instanceof WriterChain)
+ retval = ((WriterChain) m_writer).getOutputStream();
+ return retval;
+ }
}
1.1 xml-xalan/java/src/org/apache/xml/serializer/WriterChain.java
Index: WriterChain.java
===================================================================
/*
* Copyright 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.
*/
/*
* $Id: WriterChain.java,v 1.1 2004/09/01 17:36:30 minchau Exp $
*/
package org.apache.xml.serializer;
import java.io.IOException;
/**
* It is unfortunate that java.io.Writer is a class rather than an interface.
* The serializer has a number of classes that extend java.io.Writer
* and which send their ouput to a yet another wrapped Writer or OutputStream.
*
* The purpose of this interface is to force such classes to over-ride all of
* the important methods defined on the java.io.Writer class, namely these:
* <code>
* write(int val)
* write(char[] chars)
* write(char[] chars, int start, int count)
* write(String chars)
* write(String chars, int start, int count)
* flush()
* close()
* </code>
* In this manner nothing will accidentally go directly to
* the base class rather than to the wrapped Writer or OutputStream.
*
* The purpose of this class is to have a uniform way of chaining the output of one writer to
* the next writer in the chain. In addition there are methods to obtain the Writer or
* OutputStream that this object sends its output to.
*
* This interface is only for internal use withing the serializer.
* @xsl.usage internal
*/
interface WriterChain
{
/** This method forces us to over-ride the method defined in java.io.Writer */
public void write(int val) throws IOException;
/** This method forces us to over-ride the method defined in java.io.Writer */
public void write(char[] chars) throws IOException;
/** This method forces us to over-ride the method defined in java.io.Writer */
public void write(char[] chars, int start, int count) throws IOException;
/** This method forces us to over-ride the method defined in java.io.Writer */
public void write(String chars) throws IOException;
/** This method forces us to over-ride the method defined in java.io.Writer */
public void write(String chars, int start, int count) throws IOException;
/** This method forces us to over-ride the method defined in java.io.Writer */
public void flush() throws IOException;
/** This method forces us to over-ride the method defined in java.io.Writer */
public void close() throws IOException;
/**
* If this method returns null, getOutputStream() must return non-null.
* Get the writer that this writer sends its output to.
*
* It is possible that the Writer returned by this method does not
* implement the WriterChain interface.
*/
public java.io.Writer getWriter();
/**
* If this method returns null, getWriter() must return non-null.
* Get the OutputStream that this writer sends its output to.
*/
public java.io.OutputStream getOutputStream();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic