X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2Fwrap%2FWriterWrap.java;h=189b0f2fa4ba46c2a1bf234bc7d97282c712a9c1;hb=refs%2Fheads%2Freleases%2FRelease_2_11_Branch;hp=1b7f6c25adf8ce0e8df35fec2d2d6825283143ba;hpb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;p=jalview.git diff --git a/src/com/stevesoft/pat/wrap/WriterWrap.java b/src/com/stevesoft/pat/wrap/WriterWrap.java index 1b7f6c2..189b0f2 100755 --- a/src/com/stevesoft/pat/wrap/WriterWrap.java +++ b/src/com/stevesoft/pat/wrap/WriterWrap.java @@ -1,59 +1,63 @@ -// -// This software is now distributed according to -// the Lesser Gnu Public License. Please see -// http://www.gnu.org/copyleft/lesser.txt for -// the details. -// -- Happy Computing! -// -package com.stevesoft.pat.wrap; - -import java.io.*; - -import com.stevesoft.pat.*; - -/** Allows the outcome of a replaceAll() or replaceFirst() - to be directed to a Writer rather than a String. -

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

+ * The method toStringLike() cannot work, however. This means that the return + * value of replaceAll() will be null if this Object is used as the + * StringBufferLike. + */ +public class WriterWrap implements BasicStringBufferLike +{ + Writer w; + + public WriterWrap(Writer w) + { + this.w = w; + } + + public void append(char c) + { + try + { + w.write((int) c); + } catch (IOException ioe) + { + } + } + + public void append(String s) + { + try + { + w.write(s); + } catch (IOException ioe) + { + } + } + + /** This operation can't really be done. */ + public StringLike toStringLike() + { + return null; + } + + public Object unwrap() + { + return w; + } +}