Class |
Line # |
Actions |
|||
---|---|---|---|---|---|
End | 18 | 14 | 12 |
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 | End(boolean b) |
23 | { | |
24 | 31 | retIsEnd = b; |
25 | } | |
26 | ||
27 | 1962 | public int matchInternal(int pos, Pthings pt) |
28 | { | |
29 | 1962 | 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 | 1962 | if (pt.src.length() == pos) |
37 | { | |
38 | 54 | return nextMatch(pos, pt); |
39 | } | |
40 | 1908 | else if (pos < pt.src.length()) |
41 | { | |
42 | // Access the next character... | |
43 | // this is crucial to making | |
44 | // RegexReader work. | |
45 | 1908 | pt.src.charAt(pos); |
46 | } | |
47 | 1908 | return -1; |
48 | } | |
49 | ||
50 | 0 | 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 | public patInt maxChars() |
63 | { | |
64 | 0 | return new patInt(1); |
65 | } | |
66 | ||
67 | 0 | public Pattern clone1(Hashtable h) |
68 | { | |
69 | 0 | return new End(retIsEnd); |
70 | } | |
71 | }; |