Class |
Line # |
Actions |
|||
---|---|---|---|---|---|
Backup | 17 | 8 | 8 |
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 | * Implements the (?<number) Pattern, where number is an integer telling us | |
14 | * how far to back up in the Pattern. Not in perl 5. It also allows | |
15 | * (?>number). | |
16 | */ | |
17 | class Backup extends Pattern | |
18 | { | |
19 | int bk; | |
20 | ||
21 | 0 | Backup(int ii) |
22 | { | |
23 | 0 | bk = ii; |
24 | } | |
25 | ||
26 | 0 | public String toString() |
27 | { | |
28 | 0 | return "(?" + (bk < 0 ? ">" + (-bk) : "<" + bk) + ")" + nextString(); |
29 | } | |
30 | ||
31 | 0 | public int matchInternal(int pos, Pthings pt) |
32 | { | |
33 | 0 | if (pos < bk) |
34 | { | |
35 | 0 | return -1; |
36 | } | |
37 | 0 | return nextMatch(pos - bk, pt); |
38 | } | |
39 | ||
40 | 0 | public patInt minChars() |
41 | { | |
42 | 0 | return new patInt(-bk); |
43 | } | |
44 | ||
45 | 0 | public patInt maxChars() |
46 | { | |
47 | 0 | return new patInt(-bk); |
48 | } | |
49 | ||
50 | 0 | public Pattern clone1(Hashtable h) |
51 | { | |
52 | 0 | return new Backup(bk); |
53 | } | |
54 | }; |