--- /dev/null
+//\r
+// This software is now distributed according to\r
+// the Lesser Gnu Public License. Please see\r
+// http://www.gnu.org/copyleft/lesser.txt for\r
+// the details.\r
+// -- Happy Computing!\r
+//\r
+package com.stevesoft.pat.wrap;\r
+\r
+import com.stevesoft.pat.*;\r
+import java.io.*;\r
+\r
+/** Allows the outcome of a replaceAll() or replaceFirst()\r
+ to be directed to a Writer rather than a String.\r
+ <p>\r
+ The method toStringLike() cannot work, however.\r
+ This means that the return value of replaceAll() will\r
+ be null if this Object is used as the StringBufferLike.*/\r
+public class WriterWrap\r
+ implements BasicStringBufferLike\r
+ {\r
+ Writer w;\r
+ public WriterWrap(Writer w) {\r
+ this.w = w;\r
+ }\r
+ public void append(char c) {\r
+ try {\r
+ w.write((int)c);\r
+ } catch(IOException ioe) {}\r
+ }\r
+ public void append(String s) {\r
+ try {\r
+ w.write(s);\r
+ } catch(IOException ioe) {}\r
+ }\r
+\r
+ /** This operation can't really be done. */\r
+ public StringLike toStringLike() {\r
+ return null;\r
+ }\r
+\r
+ public Object unwrap() {\r
+ return w;\r
+ }\r
+}\r