JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / src / com / stevesoft / pat / wrap / StringBufferWrap.java
1 //
2 // This software is now distributed according to
3 // the Lesser Gnu Public License.  Please see
4 // http://www.gnu.org/copyleft/lesser.txt for
5 // the details.
6 //    -- Happy Computing!
7 //
8 package com.stevesoft.pat.wrap;
9
10 import com.stevesoft.pat.*;
11
12 /**
13  * This provides a wrapper for StringBuffer to capture the output of a
14  * replacement.
15  */
16 public class StringBufferWrap implements BasicStringBufferLike
17 {
18   StringBuffer sb = new StringBuffer();
19
20   public void appendC(char c)
21   {
22     sb.append(c);
23   }
24
25   public void append(String s)
26   {
27     sb.append(s);
28   }
29
30   public int length()
31   {
32     return sb.length();
33   }
34
35   public String toString()
36   {
37     return sb.toString();
38   }
39
40   public StringLike toStringLike()
41   {
42     return new StringWrap(sb.toString());
43   }
44
45   public Object unwrap()
46   {
47     return sb;
48   }
49 }