Clover icon

Coverage Report

  1. Project Clover database Fri Nov 1 2024 11:46:37 GMT
  2. Package com.stevesoft.pat

File Group.java

 

Coverage histogram

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

Code metrics

14
21
5
1
77
59
16
0.76
4.2
5
3.2

Classes

Class Line # Actions
Group 16 21 16
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    * This class implements the (?@<>) syntax that matches a balanced parenthesis.
14    * Not in perl 5.
15    */
 
16    class Group extends Pattern
17    {
18    char op, cl;
19   
 
20  0 toggle Group(char opi, char cli)
21    {
22  0 op = opi;
23  0 cl = cli;
24    }
25   
 
26  0 toggle public int matchInternal(int pos, Pthings pt)
27    {
28  0 int i, count = 1;
29  0 if (pos < pt.src.length())
30    {
31  0 if (!Masked(pos, pt) && pt.src.charAt(pos) != op)
32    {
33  0 return -1;
34    }
35    }
36  0 for (i = pos + 1; i < pt.src.length(); i++)
37    {
38  0 char c = pt.src.charAt(i);
39  0 boolean b = !Masked(i, pt);
40  0 if (b && c == ESC)
41    {
42  0 i++;
43    }
44    else
45    {
46  0 if (b && c == cl)
47    {
48  0 count--;
49    }
50  0 if (count == 0)
51    {
52  0 return nextMatch(i + 1, pt);
53    }
54  0 if (b && c == op)
55    {
56  0 count++;
57    }
58    }
59    }
60  0 return -1;
61    }
62   
 
63  0 toggle public String toString()
64    {
65  0 return "(?@" + op + cl + ")" + nextString();
66    }
67   
 
68  0 toggle public patInt minChars()
69    {
70  0 return new patInt(2);
71    }
72   
 
73  0 toggle Pattern clone1(Hashtable h)
74    {
75  0 return new Group(op, cl);
76    }
77    };