286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2001-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A/*
286N/A * $Id: WriterOutputBuffer.java,v 1.2.4.1 2005/09/06 11:43:01 pvedula Exp $
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xalan.internal.xsltc.runtime.output;
286N/A
524N/Aimport com.sun.org.apache.xalan.internal.utils.SecuritySupport;
286N/Aimport java.io.BufferedWriter;
286N/Aimport java.io.IOException;
286N/Aimport java.io.Writer;
286N/A
286N/A/**
286N/A * @author Santiago Pericas-Geertsen
286N/A */
286N/Aclass WriterOutputBuffer implements OutputBuffer {
286N/A private static final int KB = 1024;
286N/A private static int BUFFER_SIZE = 4 * KB;
286N/A
286N/A static {
286N/A // Set a larger buffer size for Solaris
524N/A final String osName = SecuritySupport.getSystemProperty("os.name");
286N/A if (osName.equalsIgnoreCase("solaris")) {
286N/A BUFFER_SIZE = 32 * KB;
286N/A }
286N/A }
286N/A
286N/A private Writer _writer;
286N/A
286N/A /**
286N/A * Initializes a WriterOutputBuffer by creating an instance of a
286N/A * BufferedWriter. The size of the buffer in this writer may have
286N/A * a significant impact on throughput. Solaris prefers a larger
286N/A * buffer, while Linux works better with a smaller one.
286N/A */
286N/A public WriterOutputBuffer(Writer writer) {
286N/A _writer = new BufferedWriter(writer, BUFFER_SIZE);
286N/A }
286N/A
286N/A public String close() {
286N/A try {
286N/A _writer.flush();
286N/A }
286N/A catch (IOException e) {
286N/A throw new RuntimeException(e.toString());
286N/A }
286N/A return "";
286N/A }
286N/A
286N/A public OutputBuffer append(String s) {
286N/A try {
286N/A _writer.write(s);
286N/A }
286N/A catch (IOException e) {
286N/A throw new RuntimeException(e.toString());
286N/A }
286N/A return this;
286N/A }
286N/A
286N/A public OutputBuffer append(char[] s, int from, int to) {
286N/A try {
286N/A _writer.write(s, from, to);
286N/A }
286N/A catch (IOException e) {
286N/A throw new RuntimeException(e.toString());
286N/A }
286N/A return this;
286N/A }
286N/A
286N/A public OutputBuffer append(char ch) {
286N/A try {
286N/A _writer.write(ch);
286N/A }
286N/A catch (IOException e) {
286N/A throw new RuntimeException(e.toString());
286N/A }
286N/A return this;
286N/A }
286N/A}