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