4 * Copyright(c) 2008 olyutorskii
\r
7 package jp.sourceforge.jindolf.archiver;
\r
9 import java.io.IOException;
\r
10 import java.io.Writer;
\r
11 import java.util.Collections;
\r
12 import java.util.LinkedList;
\r
13 import java.util.List;
\r
18 public class MultiPlexer extends Writer{
\r
20 private final List<Writer> childs = new LinkedList<Writer>();
\r
25 public MultiPlexer(){
\r
32 * @param writer 初期Writer
\r
34 public MultiPlexer(Writer writer){
\r
38 this.childs.add(writer);
\r
46 * @param writer 追加するWriter。nullなら無視。
\r
48 public void addWriter(Writer writer){
\r
49 if(writer == null) return;
\r
50 this.childs.add(writer);
\r
58 public List<Writer> getWriterList(){
\r
59 return Collections.unmodifiableList(this.childs);
\r
64 * @throws IOException {@inheritDoc}
\r
67 public void close() throws IOException{
\r
68 for(Writer writer : this.childs){
\r
76 * @throws IOException {@inheritDoc}
\r
79 public void flush() throws IOException{
\r
80 for(Writer writer : this.childs){
\r
88 * @param cbuf {@inheritDoc}
\r
89 * @param off {@inheritDoc}
\r
90 * @param len {@inheritDoc}
\r
91 * @throws IOException {@inheritDoc}
\r
94 public void write(char[] cbuf, int off, int len) throws IOException{
\r
95 for(Writer writer : this.childs){
\r
96 writer.write(cbuf, off, len);
\r
103 * @param csq {@inheritDoc}
\r
104 * @return {@inheritDoc}
\r
105 * @throws IOException {@inheritDoc}
\r
108 public Writer append(CharSequence csq) throws IOException{
\r
109 for(Writer writer : this.childs){
\r
110 writer.append(csq);
\r
117 * @param csq {@inheritDoc}
\r
118 * @param start {@inheritDoc}
\r
119 * @param end {@inheritDoc}
\r
120 * @return {@inheritDoc}
\r
121 * @throws IOException {@inheritDoc}
\r
124 public Writer append(CharSequence csq, int start, int end)
\r
125 throws IOException{
\r
126 for(Writer writer : this.childs){
\r
127 writer.append(csq, start, end);
\r
134 * @param c {@inheritDoc}
\r
135 * @return {@inheritDoc}
\r
136 * @throws IOException {@inheritDoc}
\r
139 public Writer append(char c) throws IOException{
\r
140 for(Writer writer : this.childs){
\r
148 * @param c {@inheritDoc}
\r
149 * @throws IOException {@inheritDoc}
\r
152 public void write(int c) throws IOException{
\r
153 for(Writer writer : this.childs){
\r
161 * @param cbuf {@inheritDoc}
\r
162 * @throws IOException {@inheritDoc}
\r
165 public void write(char[] cbuf) throws IOException{
\r
166 for(Writer writer : this.childs){
\r
167 writer.write(cbuf);
\r
174 * @param str {@inheritDoc}
\r
175 * @throws IOException {@inheritDoc}
\r
178 public void write(String str) throws IOException{
\r
179 for(Writer writer : this.childs){
\r
187 * @param str {@inheritDoc}
\r
188 * @param off {@inheritDoc}
\r
189 * @param len {@inheritDoc}
\r
190 * @throws IOException {@inheritDoc}
\r
193 public void write(String str, int off, int len) throws IOException{
\r
194 for(Writer writer : this.childs){
\r
195 writer.write(str, off, len);
\r