19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file 49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information 59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file 69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License. 89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at 99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software 139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and 169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License. 179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: WriterChain.java 468654 2006-10-28 07:09:23Z minchau $ 209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xml.serializer; 229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.io.IOException; 249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/** 269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * It is unfortunate that java.io.Writer is a class rather than an interface. 279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The serializer has a number of classes that extend java.io.Writer 289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and which send their ouput to a yet another wrapped Writer or OutputStream. 299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The purpose of this interface is to force such classes to over-ride all of 319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the important methods defined on the java.io.Writer class, namely these: 329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code> 339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * write(int val) 349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * write(char[] chars) 359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * write(char[] chars, int start, int count) 369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * write(String chars) 379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * write(String chars, int start, int count) 389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * flush() 399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * close() 409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * </code> 419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * In this manner nothing will accidentally go directly to 429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the base class rather than to the wrapped Writer or OutputStream. 439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The purpose of this class is to have a uniform way of chaining the output of one writer to 459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the next writer in the chain. In addition there are methods to obtain the Writer or 469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * OutputStream that this object sends its output to. 479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This interface is only for internal use withing the serializer. 499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @xsl.usage internal 509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsoninterface WriterChain 529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{ 539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** This method forces us to over-ride the method defined in java.io.Writer */ 549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void write(int val) throws IOException; 559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** This method forces us to over-ride the method defined in java.io.Writer */ 569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void write(char[] chars) throws IOException; 579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** This method forces us to over-ride the method defined in java.io.Writer */ 589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void write(char[] chars, int start, int count) throws IOException; 599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** This method forces us to over-ride the method defined in java.io.Writer */ 609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void write(String chars) throws IOException; 619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** This method forces us to over-ride the method defined in java.io.Writer */ 629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void write(String chars, int start, int count) throws IOException; 639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** This method forces us to over-ride the method defined in java.io.Writer */ 649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void flush() throws IOException; 659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** This method forces us to over-ride the method defined in java.io.Writer */ 669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void close() throws IOException; 679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If this method returns null, getOutputStream() must return non-null. 709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the writer that this writer sends its output to. 719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * It is possible that the Writer returned by this method does not 739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * implement the WriterChain interface. 749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public java.io.Writer getWriter(); 769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If this method returns null, getWriter() must return non-null. 799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the OutputStream that this writer sends its output to. 809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public java.io.OutputStream getOutputStream(); 829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} 83