X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2Fwrap%2FWriterWrap.java;h=189b0f2fa4ba46c2a1bf234bc7d97282c712a9c1;hb=4b2be7cd8c14e67cc347609199e25c7f09fda988;hp=a1be479835f58171662519d4910cbe977ad958dc;hpb=c40cf903f740a72ab63dd1abc10fa33450ce660d;p=jalview.git diff --git a/src/com/stevesoft/pat/wrap/WriterWrap.java b/src/com/stevesoft/pat/wrap/WriterWrap.java index a1be479..189b0f2 100755 --- a/src/com/stevesoft/pat/wrap/WriterWrap.java +++ b/src/com/stevesoft/pat/wrap/WriterWrap.java @@ -1,45 +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 com.stevesoft.pat.*; -import java.io.*; - -/** 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; + } +}