Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 16:21:17 GMT
  2. Package com.stevesoft.pat

File BackMatch.java

 

Coverage histogram

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

Code metrics

8
15
4
1
57
41
10
0.67
3.75
4
2.5

Classes

Class Line # Actions
BackMatch 15 15 10
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;
9   
10    import java.util.Hashtable;
11   
12    /**
13    * Provides the ability to match a backreference from within a Pattern.
14    */
 
15    class BackMatch extends Pattern
16    {
17    int id;
18   
 
19  0 toggle BackMatch(int id)
20    {
21  0 this.id = id;
22    }
23   
 
24  0 toggle public String toString()
25    {
26  0 return "\\" + (id) + nextString();
27    }
28   
 
29  0 toggle public int matchInternal(int pos, Pthings p)
30    {
31  0 int i1 = p.marks[id];
32  0 int i2 = p.marks[id + p.nMarks];
33  0 int imax = i2 - i1;
34  0 if (i1 < 0 || imax < 0 || pos + imax > p.src.length())
35    {
36  0 return -1;
37    }
38  0 int ns = p.src.length() - pos;
39  0 if (imax < ns)
40    {
41  0 ns = imax;
42    }
43  0 for (int i = 0; i < ns; i++)
44    {
45  0 if (p.src.charAt(i + i1) != p.src.charAt(pos + i))
46    {
47  0 return -1;
48    }
49    }
50  0 return nextMatch(pos + imax, p);
51    }
52   
 
53  0 toggle Pattern clone1(Hashtable h)
54    {
55  0 return new BackMatch(id);
56    }
57    }