Skip to main content
summaryrefslogtreecommitdiffstats
blob: 63ce67f50b8171f5910d6eced5cc379de8dc0490 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package org.eclipse.osee.ote.io.internal;

import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.CopyOnWriteArrayList;

import org.eclipse.osee.ote.io.SystemOutputListener;

public class SpecializedOutputStream extends OutputStream {

   private CopyOnWriteArrayList<SystemOutputListener> listeners;

   public SpecializedOutputStream() {
      this.listeners = new CopyOnWriteArrayList<SystemOutputListener>();
   }

   public void add(SystemOutputListener listener){
      listeners.add(listener);
   }
   
   public void remove(SystemOutputListener listner){
      listeners.remove(listner);
   }
   
   @Override
   public void write(int arg0) throws IOException {
      
   }

   @Override
   public void close() throws IOException {
      for(SystemOutputListener listner:listeners){
         listner.close();
      }
   }

   @Override
   public void flush() throws IOException {
      for(SystemOutputListener listner:listeners){
         listner.flush();
      }
   }

   @Override
   public void write(byte[] b, int off, int len) throws IOException {
      for(SystemOutputListener listner:listeners){
         listner.write(b, off, len);
      }
   }

   @Override
   public void write(byte[] b) throws IOException {
      for(SystemOutputListener listner:listeners){
         listner.write(b);
      }
   }

}

Back to the top