Clover icon

Coverage Report

  1. Project Clover database Wed Nov 6 2024 14:47:21 GMT
  2. Package com.stevesoft.pat

File Boundary.java

 

Coverage histogram

../../../img/srcFileCovDistChart6.png
36% of files have more coverage

Code metrics

20
27
7
1
89
73
23
0.85
3.86
7
3.29

Classes

Class Line # Actions
Boundary 13 27 23
0.518518551.9%
 

Contributing tests

This file is covered by 11 tests. .

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;
9   
10    import java.util.Hashtable;
11   
12    /** This class implements the word boundary pattern element: \b. */
 
13    class Boundary extends Pattern
14    {
 
15  0 toggle public String toString()
16    {
17  0 return "\\b" + nextString();
18    }
19   
 
20  168 toggle boolean isAChar(char c)
21    {
22  168 if (c >= 'a' && c <= 'z')
23    {
24  0 return true;
25    }
26  168 if (c >= 'A' && c <= 'Z')
27    {
28  0 return true;
29    }
30  168 if (c >= '0' && c <= '9')
31    {
32  0 return true;
33    }
34  168 if (c == '_')
35    {
36  0 return true;
37    }
38  168 return false;
39    }
40   
 
41  388 toggle boolean matchLeft(int pos, Pthings pt)
42    {
43  388 if (pos <= 0)
44    {
45  388 return true;
46    }
47  0 if (isAChar(pt.src.charAt(pos)) && isAChar(pt.src.charAt(pos - 1)))
48    {
49  0 return false;
50    }
51  0 return true;
52    }
53   
 
54  556 toggle boolean matchRight(int pos, Pthings pt)
55    {
56  556 if (pos < 0)
57    {
58  388 return false;
59    }
60  168 if (pos + 1 >= pt.src.length())
61    {
62  0 return true;
63    }
64  168 if (isAChar(pt.src.charAt(pos)) && isAChar(pt.src.charAt(pos + 1)))
65    {
66  0 return false;
67    }
68  168 return true;
69    }
70   
 
71  556 toggle public int matchInternal(int pos, Pthings pt)
72    {
73  556 if (matchRight(pos - 1, pt) || matchLeft(pos, pt))
74    {
75  556 return nextMatch(pos, pt);
76    }
77  0 return -1;
78    }
79   
 
80  0 toggle public patInt maxChars()
81    {
82  0 return new patInt(0);
83    }
84   
 
85  0 toggle public Pattern clone1(Hashtable h)
86    {
87  0 return new Boundary();
88    }
89    };