4 * Copyright(c) 2008 olyutorskii
\r
5 * $Id: MultiPlexer.java 877 2009-10-25 15:16:13Z olyutorskii $
\r
8 package jp.sourceforge.jindolf.archiver;
\r
10 import java.io.IOException;
\r
11 import java.io.Writer;
\r
12 import java.util.Collections;
\r
13 import java.util.LinkedList;
\r
14 import java.util.List;
\r
19 public class MultiPlexer extends Writer{
\r
21 private final List<Writer> childs = new LinkedList<Writer>();
\r
26 public MultiPlexer(){
\r
33 * @param writer 初期Writer
\r
35 public MultiPlexer(Writer writer){
\r
39 this.childs.add(writer);
\r
47 * @param writer 追加するWriter。nullなら無視。
\r
49 public void addWriter(Writer writer){
\r
50 if(writer == null) return;
\r
51 this.childs.add(writer);
\r
59 public List<Writer> getWriterList(){
\r
60 return Collections.unmodifiableList(this.childs);
\r
65 * @throws IOException {@inheritDoc}
\r
68 public void close() throws IOException{
\r
69 for(Writer writer : this.childs){
\r
77 * @throws IOException {@inheritDoc}
\r
80 public void flush() throws IOException{
\r
81 for(Writer writer : this.childs){
\r
89 * @param cbuf {@inheritDoc}
\r
90 * @param off {@inheritDoc}
\r
91 * @param len {@inheritDoc}
\r
92 * @throws IOException {@inheritDoc}
\r
95 public void write(char[] cbuf, int off, int len) throws IOException{
\r
96 for(Writer writer : this.childs){
\r
97 writer.write(cbuf, off, len);
\r
104 * @param csq {@inheritDoc}
\r
105 * @return {@inheritDoc}
\r
106 * @throws IOException {@inheritDoc}
\r
109 public Writer append(CharSequence csq) throws IOException{
\r
110 for(Writer writer : this.childs){
\r
111 writer.append(csq);
\r
118 * @param csq {@inheritDoc}
\r
119 * @param start {@inheritDoc}
\r
120 * @param end {@inheritDoc}
\r
121 * @return {@inheritDoc}
\r
122 * @throws IOException {@inheritDoc}
\r
125 public Writer append(CharSequence csq, int start, int end)
\r
126 throws IOException{
\r
127 for(Writer writer : this.childs){
\r
128 writer.append(csq, start, end);
\r
135 * @param c {@inheritDoc}
\r
136 * @return {@inheritDoc}
\r
137 * @throws IOException {@inheritDoc}
\r
140 public Writer append(char c) throws IOException{
\r
141 for(Writer writer : this.childs){
\r
149 * @param c {@inheritDoc}
\r
150 * @throws IOException {@inheritDoc}
\r
153 public void write(int c) throws IOException{
\r
154 for(Writer writer : this.childs){
\r
162 * @param cbuf {@inheritDoc}
\r
163 * @throws IOException {@inheritDoc}
\r
166 public void write(char[] cbuf) throws IOException{
\r
167 for(Writer writer : this.childs){
\r
168 writer.write(cbuf);
\r
175 * @param str {@inheritDoc}
\r
176 * @throws IOException {@inheritDoc}
\r
179 public void write(String str) throws IOException{
\r
180 for(Writer writer : this.childs){
\r
188 * @param str {@inheritDoc}
\r
189 * @param off {@inheritDoc}
\r
190 * @param len {@inheritDoc}
\r
191 * @throws IOException {@inheritDoc}
\r
194 public void write(String str, int off, int len) throws IOException{
\r
195 for(Writer writer : this.childs){
\r
196 writer.write(str, off, len);
\r