01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: /*
17: * $Id: WriterChain.java,v 1.1 2004/09/01 17:36:30 minchau Exp $
18: */
19: package org.apache.xml.serializer;
20:
21: import java.io.IOException;
22:
23: /**
24: * It is unfortunate that java.io.Writer is a class rather than an interface.
25: * The serializer has a number of classes that extend java.io.Writer
26: * and which send their ouput to a yet another wrapped Writer or OutputStream.
27: *
28: * The purpose of this interface is to force such classes to over-ride all of
29: * the important methods defined on the java.io.Writer class, namely these:
30: * <code>
31: * write(int val)
32: * write(char[] chars)
33: * write(char[] chars, int start, int count)
34: * write(String chars)
35: * write(String chars, int start, int count)
36: * flush()
37: * close()
38: * </code>
39: * In this manner nothing will accidentally go directly to
40: * the base class rather than to the wrapped Writer or OutputStream.
41: *
42: * The purpose of this class is to have a uniform way of chaining the output of one writer to
43: * the next writer in the chain. In addition there are methods to obtain the Writer or
44: * OutputStream that this object sends its output to.
45: *
46: * This interface is only for internal use withing the serializer.
47: * @xsl.usage internal
48: */
49: interface WriterChain {
50: /** This method forces us to over-ride the method defined in java.io.Writer */
51: public void write(int val) throws IOException;
52:
53: /** This method forces us to over-ride the method defined in java.io.Writer */
54: public void write(char[] chars) throws IOException;
55:
56: /** This method forces us to over-ride the method defined in java.io.Writer */
57: public void write(char[] chars, int start, int count)
58: throws IOException;
59:
60: /** This method forces us to over-ride the method defined in java.io.Writer */
61: public void write(String chars) throws IOException;
62:
63: /** This method forces us to over-ride the method defined in java.io.Writer */
64: public void write(String chars, int start, int count)
65: throws IOException;
66:
67: /** This method forces us to over-ride the method defined in java.io.Writer */
68: public void flush() throws IOException;
69:
70: /** This method forces us to over-ride the method defined in java.io.Writer */
71: public void close() throws IOException;
72:
73: /**
74: * If this method returns null, getOutputStream() must return non-null.
75: * Get the writer that this writer sends its output to.
76: *
77: * It is possible that the Writer returned by this method does not
78: * implement the WriterChain interface.
79: */
80: public java.io.Writer getWriter();
81:
82: /**
83: * If this method returns null, getWriter() must return non-null.
84: * Get the OutputStream that this writer sends its output to.
85: */
86: public java.io.OutputStream getOutputStream();
87: }
|