Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:56:54 GMT
  2. Package com.stevesoft.pat

File Bracket.java

 

Coverage histogram

../../../img/srcFileCovDistChart8.png
21% of files have more coverage

Code metrics

8
23
9
1
89
68
16
0.7
2.56
9
1.78

Classes

Class Line # Actions
Bracket 16 23 16
0.7575%
 

Contributing tests

This file is covered by 84 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    import java.util.Vector;
12   
13    /**
14    * The Bracket is a form of the Or class, implements the pattern element [ ].
15    */
 
16    class Bracket extends Or
17    {
18    boolean neg;
19   
 
20  5797 toggle Bracket(boolean n)
21    {
22  5797 neg = n;
23    }
24   
 
25  0 toggle String leftForm()
26    {
27  0 if (neg)
28    {
29  0 return "[^";
30    }
31    else
32    {
33  0 return "[";
34    }
35    }
36   
 
37  0 toggle String rightForm()
38    {
39  0 return "]";
40    }
41   
 
42  0 toggle String sepForm()
43    {
44  0 return "";
45    }
46   
 
47  55871 toggle public int matchInternal(int pos, Pthings pt)
48    {
49  55871 if (pos >= pt.src.length())
50    {
51  4948 return -1;
52    }
53  50923 int r = super.matchInternal(pos, pt);
54  50923 if ((neg && r < 0) || (!neg && r >= 0))
55    {
56  25704 return nextMatch(pos + 1, pt);
57    }
58  25219 return -1;
59    }
60   
 
61  4689 toggle public patInt minChars()
62    {
63  4689 return new patInt(1);
64    }
65   
 
66  348 toggle public patInt maxChars()
67    {
68  348 return new patInt(1);
69    }
70   
 
71  13256 toggle public Or addOr(Pattern p)
72    {
73  13256 pv = null;
74  13256 v.addElement(p);
75  13256 p.setParent(null);
76  13256 return this;
77    }
78   
 
79  1414 toggle public Pattern clone1(Hashtable h)
80    {
81  1414 Bracket b = new Bracket(neg);
82  1414 b.v = new Vector();
83  5252 for (int i = 0; i < v.size(); i++)
84    {
85  3838 b.v.addElement(((Pattern) v.elementAt(i)).clone1(h));
86    }
87  1414 return b;
88    }
89    };