]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_8_1_1/main/tests/framework/src/com/ibm/icu/dev/test/TestLogWriter.java
Added flags.
[Dictionary.git] / jars / icu4j-4_8_1_1 / main / tests / framework / src / com / ibm / icu / dev / test / TestLogWriter.java
1 /**
2  *******************************************************************************
3  * Copyright (C) 2005-2008, International Business Machines Corporation and    *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  */
7 package com.ibm.icu.dev.test;
8
9 import java.io.IOException;
10 import java.io.Writer;
11
12 public final class TestLogWriter extends Writer {
13     private TestLog log;
14     private int level;
15     private boolean closed;
16
17     public TestLogWriter(TestLog log, int level) {
18     this.log = log;
19     this.level = level;
20     }
21
22     public void write(char cbuf[], int off, int len) throws IOException {
23         write(new String(cbuf, off, len));
24     }
25
26     public void write(String str) throws IOException {
27         if (closed) {
28             throw new IOException("stream closed");
29         }
30         if ("\r\n".indexOf(str) != -1) {
31             log.msg("", level, level == TestLog.ERR, true);
32         } else {
33             log.msg(str, level, level == TestLog.ERR, false);
34         }
35     }
36
37     public void flush() throws IOException {
38     }
39
40     public void close() throws IOException {
41         closed = true;
42     }
43 }