Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package com.stevesoft.pat

File Multi.java

 

Coverage histogram

../../../img/srcFileCovDistChart5.png
43% of files have more coverage

Code metrics

0
20
6
1
90
55
8
0.4
3.33
6
1.33

Classes

Class Line # Actions
Multi 19 20 8
0.550%
 

Contributing tests

This file is covered by 2 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    /**
13    * Matches any number of instances of sub Pattern this was the hardest method to
14    * write. It implements '+', '*', '?', "{0,10}", "{5,}", "{5}", etc.
15    *
16    * @see pat.Multi_stage2
17    * @see pat.MultiMin
18    */
 
19    class Multi extends PatternSub
20    {
21    patInt a, b;
22   
 
23  0 toggle public patInt minChars()
24    {
25  0 return a.mul(p.countMinChars());
26    }
27   
 
28  0 toggle public patInt maxChars()
29    {
30  0 return b.mul(p.countMaxChars());
31    }
32   
33    Pattern p;
34   
35    Multi_stage2 st2;
36   
37    public boolean matchFewest = false;
38   
39    /**
40    * @param a
41    * The fewest number of times the sub pattern can match.
42    * @param b
43    * The maximum number of times the sub pattern can match.
44    * @param p
45    * The sub pattern.
46    * @see Multi_stage2
47    * @see MultiMin
48    */
 
49  8 toggle public Multi(patInt a, patInt b, Pattern p) throws RegSyntax
50    {
51  8 this.a = a;
52  8 this.b = b;
53  8 this.p = p;
54  8 st2 = new Multi_stage2(a, b, p);
55  8 st2.parent = this;
56  8 sub = st2.sub;
57    }
58   
 
59  0 toggle public String toString()
60    {
61  0 st2.matchFewest = matchFewest;
62  0 return st2.toString();
63    }
64   
 
65  8 toggle public int matchInternal(int pos, Pthings pt)
66    {
67  8 try
68    {
69  8 st2 = new Multi_stage2(a, b, p);
70    } catch (RegSyntax r__)
71    {
72    }
73  8 st2.matchFewest = matchFewest;
74  8 st2.parent = this;
75  8 return st2.matchInternal(pos, pt);
76    }
77   
 
78  0 toggle public Pattern clone1(Hashtable h)
79    {
80  0 try
81    {
82  0 Multi m = new Multi(a, b, ((Pattern) p).clone(h));
83  0 m.matchFewest = matchFewest;
84  0 return m;
85    } catch (RegSyntax rs)
86    {
87  0 return null;
88    }
89    }
90    };