1 11 package org.eclipse.ui.actions; 12 13 18 public final class SimpleWildcardTester { 19 26 public static boolean testWildcard(String pattern, String str) { 27 if (pattern.equals("*")) { return true; 29 } else if (pattern.startsWith("*")) { if (pattern.endsWith("*")) { if (pattern.length() == 2) { 32 return true; 33 } 34 return str.indexOf(pattern.substring(1, pattern.length() - 1)) >= 0; 35 } 36 return str.endsWith(pattern.substring(1)); 37 } else if (pattern.endsWith("*")) { return str.startsWith(pattern.substring(0, pattern.length() - 1)); 39 } else { 40 return str.equals(pattern); 41 } 42 } 43 44 52 public static boolean testWildcardIgnoreCase(String pattern, String str) { 53 54 if (str == null) { 56 return false; 57 } 58 pattern = pattern.toLowerCase(); 59 str = str.toLowerCase(); 60 return testWildcard(pattern, str); 61 } 62 } 63 | Popular Tags |