1 19 24 25 package org.netbeans.core.output2; 26 27 import java.util.logging.Logger ; 28 import org.openide.windows.OutputListener; 29 import org.openide.windows.OutputWriter; 30 31 import java.io.IOException ; 32 33 39 class ErrWriter extends OutputWriter { 40 private OutWriter wrapped; 41 private NbWriter parent; 42 43 ErrWriter(OutWriter wrapped, NbWriter parent) { 44 super (new OutWriter.DummyWriter()); 45 this.wrapped = wrapped; 46 this.parent = parent; 47 } 48 49 synchronized void setWrapped (OutWriter wrapped) { 50 this.wrapped = wrapped; 51 closed = true; 52 } 53 54 public void println(String s, OutputListener l) throws java.io.IOException { 55 println(s, l, false); 56 } 57 58 public void println(String s, OutputListener l, boolean important) throws java.io.IOException { 59 closed = false; 60 synchronized (wrapped) { 61 wrapped.println (s, l, important); 62 ((AbstractLines) wrapped.getLines()).markErr(); 63 } 64 } 65 66 public void reset() throws IOException { 67 Logger.getAnonymousLogger().warning("Do not call reset() on the error io," + 68 " only on the output IO. Reset on the error io does nothing."); 69 closed = false; 70 } 71 72 public void close() { 73 if (!closed) { 74 closed = true; 75 parent.notifyErrClosed(); 76 } 77 } 78 79 boolean closed = true; 80 boolean isClosed() { 81 return closed; 82 } 83 84 public void flush() { 85 wrapped.flush(); 86 } 87 88 public boolean checkError() { 89 return wrapped.checkError(); 90 } 91 92 public void write(int c) { 93 closed = false; 94 synchronized (wrapped) { 95 wrapped.write(c); 96 ((AbstractLines) wrapped.getLines()).markErr(); 97 } 98 } 99 100 public void write(char buf[], int off, int len) { 101 closed = false; 102 synchronized (wrapped) { 103 wrapped.write(buf, off, len); 104 ((AbstractLines) wrapped.getLines()).markErr(); 105 } 106 } 107 108 public void write(String s, int off, int len) { 109 closed = false; 110 synchronized (wrapped) { 111 wrapped.write(s, off, len); 112 ((AbstractLines) wrapped.getLines()).markErr(); 113 } 114 } 115 116 public void println(boolean x) { 117 closed = false; 118 synchronized (wrapped) { 119 wrapped.println (x); 120 ((AbstractLines) wrapped.getLines()).markErr(); 121 } 122 } 123 124 public void println(int x) { 125 closed = false; 126 synchronized (wrapped) { 127 wrapped.println(x); 128 ((AbstractLines) wrapped.getLines()).markErr(); 129 } 130 } 131 132 public void println(char x) { 133 closed = false; 134 synchronized (wrapped) { 135 wrapped.println(x); 136 ((AbstractLines) wrapped.getLines()).markErr(); 137 } 138 } 139 140 public void println(long x) { 141 closed = false; 142 synchronized (wrapped) { 143 wrapped.println(x); 144 ((AbstractLines) wrapped.getLines()).markErr(); 145 } 146 } 147 148 public void println(float x) { 149 closed = false; 150 synchronized (wrapped) { 151 wrapped.println(x); 152 ((AbstractLines) wrapped.getLines()).markErr(); 153 } 154 } 155 156 public void println(double x) { 157 closed = false; 158 synchronized (wrapped) { 159 wrapped.println(x); 160 ((AbstractLines) wrapped.getLines()).markErr(); 161 } 162 } 163 164 public void println(char x[]) { 165 closed = false; 166 synchronized (wrapped) { 167 wrapped.println(x); 168 ((AbstractLines) wrapped.getLines()).markErr(); 169 } 170 } 171 172 public void println(String x) { 173 closed = false; 174 synchronized (wrapped) { 175 wrapped.println(x); 176 ((AbstractLines) wrapped.getLines()).markErr(); 177 } 178 } 179 180 public void println(Object x) { 181 closed = false; 182 synchronized (wrapped) { 183 wrapped.println(x); 184 ((AbstractLines) wrapped.getLines()).markErr(); 185 } 186 } 187 188 public void print(char[] s) { 189 closed = false; 190 synchronized (wrapped) { 191 wrapped.print(s); 192 ((AbstractLines) wrapped.getLines()).markErr(); 193 } 194 } 195 196 public void print(Object obj) { 197 closed = false; 198 synchronized (wrapped) { 199 wrapped.print(obj); 200 ((AbstractLines) wrapped.getLines()).markErr(); 201 } 202 } 203 204 public void print(char c) { 205 closed = false; 206 synchronized (wrapped) { 207 wrapped.print(c); 208 ((AbstractLines) wrapped.getLines()).markErr(); 209 } 210 } 211 212 public void print(int i) { 213 closed = false; 214 synchronized (wrapped) { 215 wrapped.print(i); 216 ((AbstractLines) wrapped.getLines()).markErr(); 217 } 218 } 219 220 public void print(String s) { 221 closed = false; 222 synchronized (wrapped) { 223 wrapped.print(s); 224 ((AbstractLines) wrapped.getLines()).markErr(); 225 } 226 } 227 228 public void print(boolean b) { 229 closed = false; 230 synchronized (wrapped) { 231 wrapped.print(b); 232 ((AbstractLines) wrapped.getLines()).markErr(); 233 } 234 } 235 236 public void println() { 237 closed = false; 238 synchronized (wrapped) { 239 wrapped.println(); 240 ((AbstractLines) wrapped.getLines()).markErr(); 241 } 242 } 243 244 245 } 246 | Popular Tags |