(String str, String mask, char wildChar, char wildCharSingle)
| 7 | public class StrUtils |
| 8 | { |
| 9 | public static boolean equalsMask(String str, String mask, char wildChar, char wildCharSingle) |
| 10 | { |
| 11 | if (mask != null && str != null) |
| 12 | { |
| 13 | if (mask.indexOf(wildChar) < 0) |
| 14 | { |
| 15 | return mask.indexOf(wildCharSingle) < 0 ? mask.equals(str) : equalsMaskSingle(str, mask, wildCharSingle); |
| 16 | } |
| 17 | else |
| 18 | { |
| 19 | List list = new ArrayList(); |
| 20 | String s = "" + wildChar; |
| 21 | |
| 22 | if (mask.startsWith(s)) |
| 23 | { |
| 24 | list.add(""); |
| 25 | } |
| 26 | |
| 27 | StringTokenizer stringtokenizer = new StringTokenizer(mask, s); |
| 28 | |
| 29 | while (stringtokenizer.hasMoreElements()) |
| 30 | { |
| 31 | list.add(stringtokenizer.nextToken()); |
| 32 | } |
| 33 | |
| 34 | if (mask.endsWith(s)) |
| 35 | { |
| 36 | list.add(""); |
| 37 | } |
| 38 | |
| 39 | String s1 = (String)list.get(0); |
| 40 | |
| 41 | if (!startsWithMaskSingle(str, s1, wildCharSingle)) |
| 42 | { |
| 43 | return false; |
| 44 | } |
| 45 | else |
| 46 | { |
| 47 | String s2 = (String)list.get(list.size() - 1); |
| 48 | |
| 49 | if (!endsWithMaskSingle(str, s2, wildCharSingle)) |
| 50 | { |
| 51 | return false; |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | int i = 0; |
| 56 | |
| 57 | for (int j = 0; j < ((List)list).size(); ++j) |
| 58 | { |
| 59 | String s3 = (String)list.get(j); |
| 60 | |
| 61 | if (s3.length() > 0) |
| 62 | { |
| 63 | int k = indexOfMaskSingle(str, s3, i, wildCharSingle); |
| 64 | |
| 65 | if (k < 0) |
| 66 | { |
no test coverage detected