Clover icon

Coverage Report

  1. Project Clover database Fri Nov 15 2024 13:56:46 GMT
  2. Package com.stevesoft.pat.wrap

File WriterWrap.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
59% of files have more coverage

Code metrics

0
7
5
1
63
39
7
1
1.4
5
1.4

Classes

Class Line # Actions
WriterWrap 24 7 7
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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 java.io.IOException;
11    import java.io.Writer;
12   
13    import com.stevesoft.pat.BasicStringBufferLike;
14    import com.stevesoft.pat.StringLike;
15   
16    /**
17    * Allows the outcome of a replaceAll() or replaceFirst() to be directed to a
18    * Writer rather than a String.
19    * <p>
20    * The method toStringLike() cannot work, however. This means that the return
21    * value of replaceAll() will be null if this Object is used as the
22    * StringBufferLike.
23    */
 
24    public class WriterWrap implements BasicStringBufferLike
25    {
26    Writer w;
27   
 
28  0 toggle public WriterWrap(Writer w)
29    {
30  0 this.w = w;
31    }
32   
 
33  0 toggle public void append(char c)
34    {
35  0 try
36    {
37  0 w.write((int) c);
38    } catch (IOException ioe)
39    {
40    }
41    }
42   
 
43  0 toggle public void append(String s)
44    {
45  0 try
46    {
47  0 w.write(s);
48    } catch (IOException ioe)
49    {
50    }
51    }
52   
53    /** This operation can't really be done. */
 
54  0 toggle public StringLike toStringLike()
55    {
56  0 return null;
57    }
58   
 
59  0 toggle public Object unwrap()
60    {
61  0 return w;
62    }
63    }