Class | Line # | Actions | |||
---|---|---|---|---|---|
Skip2 | 17 | 15 | 9 |
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 | /** | |
11 | * This is the same as Skip, except it needs a minimum of two characters in the | |
12 | * initializing String. | |
13 | * | |
14 | * @see com.stevesoft.pat.Skip | |
15 | * @see com.stevesoft.pat.SkipBMH | |
16 | */ | |
17 | public class Skip2 extends Skip | |
18 | { | |
19 | int c1, mask1; | |
20 | ||
21 | 0 | public Skip2(String s, boolean ign, int offset) |
22 | { | |
23 | 0 | super(s, ign, offset); |
24 | 0 | c1 = s.charAt(1); |
25 | 0 | m1 = 2 == s.length(); |
26 | 0 | if (ign) |
27 | { | |
28 | 0 | mask1 = mkmask(c1); |
29 | } | |
30 | else | |
31 | { | |
32 | 0 | mask1 = 0; |
33 | } | |
34 | } | |
35 | ||
36 | 0 | public int find(StringLike s, int start, int end) |
37 | { | |
38 | 0 | if (start > end) |
39 | { | |
40 | 0 | return -1; |
41 | } | |
42 | 0 | start += offset; |
43 | 0 | int vend = min(s.length() - 2, end + offset); |
44 | 0 | for (int i = start; i <= vend; i++) |
45 | { | |
46 | 0 | if (0 == (s.charAt(i) & mask) && 0 == (s.charAt(i + 1) & mask1)) |
47 | { | |
48 | // if(m1||s.regionMatches(ign,i,src,0,src.length()) ) | |
49 | 0 | if (m1 || CaseMgr.regionMatches(s, ign, i, src, 0, src.length())) |
50 | { | |
51 | 0 | return i - offset; |
52 | } | |
53 | } | |
54 | } | |
55 | 0 | return -1; |
56 | } | |
57 | } |