001    /**
002     * Copyright (c) 2000-2013 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            @Override
030            public void close() throws IOException {
031                    _writer.close();
032            }
033    
034            @Override
035            public void flush() {
036            }
037    
038            public void write(char cbuf) throws IOException {
039                    _writer.write(cbuf);
040            }
041    
042            @Override
043            public void write(char[] cbuf, int off, int len) throws IOException {
044                    StringBuilder sb = new StringBuilder(len);
045    
046                    sb.append(cbuf, off, len);
047    
048                    _writer.write(sb.toString());
049            }
050    
051            @Override
052            public void write(int c) throws IOException {
053                    _writer.write(c);
054            }
055    
056            @Override
057            public void write(String str) throws IOException {
058                    _writer.write(str);
059            }
060    
061            @Override
062            public void write(String str, int off, int len) throws IOException {
063                    _writer.write(str, off, len);
064            }
065    
066            private Writer _writer;
067    
068    }