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.util.bridges.jsf.sun;
016    
017    import java.io.IOException;
018    import java.io.Writer;
019    
020    /**
021     * @author Brian Myunghun Kim
022     */
023    public class WriterWrapper extends Writer {
024    
025            public WriterWrapper(Writer writer) {
026                    _writer = writer;
027            }
028    
029            public void close() throws IOException {
030                    _writer.close();
031            }
032    
033            public void flush() {
034            }
035    
036            public void write(char cbuf) throws IOException {
037                    _writer.write(cbuf);
038            }
039    
040            public void write(char[] cbuf, int off, int len) throws IOException {
041                    StringBuilder sb = new StringBuilder(len);
042    
043                    sb.append(cbuf, off, len);
044    
045                    _writer.write(sb.toString());
046            }
047    
048            public void write(int c) throws IOException {
049                    _writer.write(c);
050            }
051    
052            public void write(String str) throws IOException {
053                    _writer.write(str);
054            }
055    
056            public void write(String str, int off, int len) throws IOException {
057                    _writer.write(str, off, len);
058            }
059    
060            private Writer _writer;
061    
062    }