Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 GMT
  2. Package com.stevesoft.pat.wrap

File CharArrayWrap.java

 

Coverage histogram

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

Code metrics

6
15
9
1
76
55
12
0.8
1.67
9
1.33

Classes

Class Line # Actions
CharArrayWrap 16 15 12
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 com.stevesoft.pat.BasicStringBufferLike;
11    import com.stevesoft.pat.StringLike;
12   
13    /**
14    * This provides a wrapper for a char array so that it can be searched by Regex.
15    */
 
16    public class CharArrayWrap implements StringLike
17    {
18    char[] ca;
19   
 
20  0 toggle public char[] getCharArray()
21    {
22  0 return ca;
23    }
24   
 
25  0 toggle public CharArrayWrap(char[] ca)
26    {
27  0 this.ca = ca;
28    }
29   
 
30  0 toggle public String toString()
31    {
32  0 return new String(ca);
33    }
34   
 
35  0 toggle public char charAt(int i)
36    {
37  0 return ca[i];
38    }
39   
 
40  0 toggle public int length()
41    {
42  0 return ca.length;
43    }
44   
 
45  0 toggle public String substring(int i1, int i2)
46    {
47  0 StringBuffer sb = new StringBuffer();
48  0 for (int i = i1; i < i2; i++)
49    {
50  0 sb.append(ca[i]);
51    }
52  0 return sb.toString();
53    }
54   
 
55  0 toggle public Object unwrap()
56    {
57  0 return ca;
58    }
59   
 
60  0 toggle public BasicStringBufferLike newStringBufferLike()
61    {
62  0 return new CharArrayBufferWrap();
63    }
64   
 
65  0 toggle public int indexOf(char c)
66    {
67  0 for (int i = 0; i < ca.length; i++)
68    {
69  0 if (ca[i] == c)
70    {
71  0 return i;
72    }
73    }
74  0 return -1;
75    }
76    }