Clover icon

Coverage Report

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

File End.java

 

Coverage histogram

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

Code metrics

10
14
5
1
71
48
12
0.86
2.8
5
2.4

Classes

Class Line # Actions
End 18 14 12
0.4482758644.8%
 

Contributing tests

This file is covered by 13 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    //class AddToEnd extends RegSyntax {};
13   
14    /**
15    * Compiles the '$' or the '\Z' Pattern. It is an error to have further Pattern
16    * elements after '\Z'. It is the end of the String.
17    */
 
18    class End extends Pattern
19    {
20    boolean retIsEnd;
21   
 
22  31 toggle End(boolean b)
23    {
24  31 retIsEnd = b;
25    }
26   
 
27  2067 toggle public int matchInternal(int pos, Pthings pt)
28    {
29  2067 if (retIsEnd && pt.mFlag && pos < pt.src.length())
30    {
31  0 if (pt.src.charAt(pos) == '\n')
32    {
33  0 return nextMatch(pos, pt);
34    }
35    }
36  2067 if (pt.src.length() == pos)
37    {
38  54 return nextMatch(pos, pt);
39    }
40  2013 else if (pos < pt.src.length())
41    {
42    // Access the next character...
43    // this is crucial to making
44    // RegexReader work.
45  2013 pt.src.charAt(pos);
46    }
47  2013 return -1;
48    }
49   
 
50  0 toggle public String toString()
51    {
52  0 if (retIsEnd)
53    {
54  0 return "$";
55    }
56    else
57    {
58  0 return "\\Z";
59    }
60    }
61   
 
62  0 toggle public patInt maxChars()
63    {
64  0 return new patInt(1);
65    }
66   
 
67  0 toggle public Pattern clone1(Hashtable h)
68    {
69  0 return new End(retIsEnd);
70    }
71    };