01: /**
02: *******************************************************************************
03: * Copyright (C) 2005, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: *******************************************************************************
06: */package com.ibm.icu.dev.test;
07:
08: import java.io.IOException;
09: import java.io.Writer;
10:
11: public final class TestLogWriter extends Writer {
12: private TestLog log;
13: private int level;
14: private boolean closed;
15:
16: public TestLogWriter(TestLog log, int level) {
17: this .log = log;
18: this .level = level;
19: }
20:
21: public void write(char cbuf[], int off, int len) throws IOException {
22: write(new String(cbuf, off, len));
23: }
24:
25: public void write(String str) throws IOException {
26: if (closed) {
27: throw new IOException("stream closed");
28: }
29: if ("\r\n".indexOf(str) != -1) {
30: log.msg("", level, level == TestLog.ERR, true);
31: } else {
32: log.msg(str, level, level == TestLog.ERR, false);
33: }
34: }
35:
36: public void flush() throws IOException {
37: }
38:
39: public void close() throws IOException {
40: closed = true;
41: }
42: }
|