001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 /* 019 * $Id: WriterChain.java 468654 2006-10-28 07:09:23Z minchau $ 020 */ 021 package org.apache.xml.serializer; 022 023 import java.io.IOException; 024 025 /** 026 * It is unfortunate that java.io.Writer is a class rather than an interface. 027 * The serializer has a number of classes that extend java.io.Writer 028 * and which send their ouput to a yet another wrapped Writer or OutputStream. 029 * 030 * The purpose of this interface is to force such classes to over-ride all of 031 * the important methods defined on the java.io.Writer class, namely these: 032 * <code> 033 * write(int val) 034 * write(char[] chars) 035 * write(char[] chars, int start, int count) 036 * write(String chars) 037 * write(String chars, int start, int count) 038 * flush() 039 * close() 040 * </code> 041 * In this manner nothing will accidentally go directly to 042 * the base class rather than to the wrapped Writer or OutputStream. 043 * 044 * The purpose of this class is to have a uniform way of chaining the output of one writer to 045 * the next writer in the chain. In addition there are methods to obtain the Writer or 046 * OutputStream that this object sends its output to. 047 * 048 * This interface is only for internal use withing the serializer. 049 * @xsl.usage internal 050 */ 051 interface WriterChain 052 { 053 /** This method forces us to over-ride the method defined in java.io.Writer */ 054 public void write(int val) throws IOException; 055 /** This method forces us to over-ride the method defined in java.io.Writer */ 056 public void write(char[] chars) throws IOException; 057 /** This method forces us to over-ride the method defined in java.io.Writer */ 058 public void write(char[] chars, int start, int count) throws IOException; 059 /** This method forces us to over-ride the method defined in java.io.Writer */ 060 public void write(String chars) throws IOException; 061 /** This method forces us to over-ride the method defined in java.io.Writer */ 062 public void write(String chars, int start, int count) throws IOException; 063 /** This method forces us to over-ride the method defined in java.io.Writer */ 064 public void flush() throws IOException; 065 /** This method forces us to over-ride the method defined in java.io.Writer */ 066 public void close() throws IOException; 067 068 /** 069 * If this method returns null, getOutputStream() must return non-null. 070 * Get the writer that this writer sends its output to. 071 * 072 * It is possible that the Writer returned by this method does not 073 * implement the WriterChain interface. 074 */ 075 public java.io.Writer getWriter(); 076 077 /** 078 * If this method returns null, getWriter() must return non-null. 079 * Get the OutputStream that this writer sends its output to. 080 */ 081 public java.io.OutputStream getOutputStream(); 082 }