JAL-1807 still testing
[jalviewjs.git] / unused / com / stevesoft / pat / wrap / WriterWrap.java
1 //\r
2 // This software is now distributed according to\r
3 // the Lesser Gnu Public License.  Please see\r
4 // http://www.gnu.org/copyleft/lesser.txt for\r
5 // the details.\r
6 //    -- Happy Computing!\r
7 //\r
8 package com.stevesoft.pat.wrap;\r
9 \r
10 import java.io.*;\r
11 \r
12 import com.stevesoft.pat.*;\r
13 \r
14 /**\r
15  * Allows the outcome of a replaceAll() or replaceFirst() to be directed to a\r
16  * Writer rather than a String.\r
17  * <p>\r
18  * The method toStringLike() cannot work, however. This means that the return\r
19  * value of replaceAll() will be null if this Object is used as the\r
20  * StringBufferLike.\r
21  */\r
22 public class WriterWrap implements BasicStringBufferLike\r
23 {\r
24   Writer w;\r
25 \r
26   public WriterWrap(Writer w)\r
27   {\r
28     this.w = w;\r
29   }\r
30 \r
31   public void appendChar(char c)\r
32   {\r
33     try\r
34     {\r
35       w.write((int) c);\r
36     } catch (IOException ioe)\r
37     {\r
38     }\r
39   }\r
40 \r
41   public void appendStr(String s)\r
42   {\r
43     try\r
44     {\r
45       w.write(s);\r
46     } catch (IOException ioe)\r
47     {\r
48     }\r
49   }\r
50 \r
51   /** This operation can't really be done. */\r
52   public StringLike toStringLike()\r
53   {\r
54     return null;\r
55   }\r
56 \r
57   public Object unwrap()\r
58   {\r
59     return w;\r
60   }\r
61 }\r