001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.servlet;
016    
017    import com.liferay.portal.kernel.io.unsync.UnsyncPrintWriter;
018    
019    import java.io.IOException;
020    import java.io.PrintWriter;
021    import java.io.Writer;
022    
023    import javax.servlet.jsp.JspWriter;
024    
025    /**
026     * @author Shuyang Zhou
027     */
028    public class PipingJspWriter extends JspWriter {
029    
030            public PipingJspWriter(PrintWriter printWriter) {
031                    super(NO_BUFFER, false);
032    
033                    _printWriter = printWriter;
034            }
035    
036            public PipingJspWriter(Writer writer) {
037                    super(NO_BUFFER, false);
038    
039                    _printWriter = new UnsyncPrintWriter(writer, true);
040            }
041    
042            public void clear() throws IOException {
043                    throw new IOException();
044            }
045    
046            public void clearBuffer() {
047            }
048    
049            public void close() {
050                    _printWriter.close();
051            }
052    
053            public void flush() {
054                    _printWriter.flush();
055            }
056    
057            public int getRemaining() {
058                    return 0;
059            }
060    
061            public void newLine() {
062                    _printWriter.println();
063            }
064    
065            public void print(boolean b) {
066                    _printWriter.print(b);
067            }
068    
069            public void print(char c) {
070                    _printWriter.print(c);
071            }
072    
073            public void print(char[] charArray) {
074                    _printWriter.print(charArray);
075            }
076    
077            public void print(double d) {
078                    _printWriter.print(d);
079            }
080    
081            public void print(float f) {
082                    _printWriter.print(f);
083            }
084    
085            public void print(int i) {
086                    _printWriter.print(i);
087            }
088    
089            public void print(long l) {
090                    _printWriter.print(l);
091            }
092    
093            public void print(Object object) {
094                    _printWriter.print(object);
095            }
096    
097            public void print(String string) {
098                    _printWriter.print(string);
099            }
100    
101            public void println() {
102                    _printWriter.println();
103            }
104    
105            public void println(boolean b) {
106                    _printWriter.println(b);
107            }
108    
109            public void println(char c) {
110                    _printWriter.println(c);
111            }
112    
113            public void println(char[] charArray) {
114                    _printWriter.println(charArray);
115            }
116    
117            public void println(double d) {
118                    _printWriter.println(d);
119            }
120    
121            public void println(float f) {
122                    _printWriter.println(f);
123            }
124    
125            public void println(int i) {
126                    _printWriter.println(i);
127            }
128    
129            public void println(long l) {
130                    _printWriter.println(l);
131            }
132    
133            public void println(Object object) {
134                    _printWriter.println(object);
135            }
136    
137            public void println(String string) {
138                    _printWriter.println(string);
139            }
140    
141            public void write(char[] charArray) {
142                    _printWriter.write(charArray);
143            }
144    
145            public void write(char[] charArray, int offset, int length) {
146                    _printWriter.write(charArray, offset, length);
147            }
148    
149            public void write(int c) {
150                    _printWriter.write(c);
151            }
152    
153            public void write(String string) {
154                    _printWriter.write(string);
155            }
156    
157            public void write(String string, int offset, int length) {
158                    _printWriter.write(string, offset, length);
159            }
160    
161            private PrintWriter _printWriter;
162    
163    }