@Test public void testIsMatchGlobPattern() throws Exception { assertTrue(ParseUtils.isMatchGlobPattern(null, null)); assertFalse(ParseUtils.isMatchGlobPattern("abc", null)); assertFalse(ParseUtils.isMatchGlobPattern(null, "xxx")); assertTrue(ParseUtils.isMatchGlobPattern("", "")); assertFalse(ParseUtils.isMatchGlobPattern("", "xxx")); assertFalse(ParseUtils.isMatchGlobPattern("abc", "")); assertFalse(ParseUtils.isMatchGlobPattern("a*bc", "")); assertFalse(ParseUtils.isMatchGlobPattern("*abc", "")); assertFalse(ParseUtils.isMatchGlobPattern("abc*", "")); assertTrue(ParseUtils.isMatchGlobPattern("*", "")); assertTrue(ParseUtils.isMatchGlobPattern("*", "xxx")); assertTrue(ParseUtils.isMatchGlobPattern("abc*123", "abc123")); assertTrue(ParseUtils.isMatchGlobPattern("abc*123", "abcXXX123")); assertFalse(ParseUtils.isMatchGlobPattern("abc*123", "abcXXX333")); assertTrue(ParseUtils.isMatchGlobPattern("*abc123", "abc123")); assertTrue(ParseUtils.isMatchGlobPattern("*abc123", "XXXabc123")); assertTrue(ParseUtils.isMatchGlobPattern("*abc123", "abc123abc123")); assertFalse(ParseUtils.isMatchGlobPattern("*abc123", "abc123abc333")); assertTrue(ParseUtils.isMatchGlobPattern("abc123*", "abc123")); assertTrue(ParseUtils.isMatchGlobPattern("abc123*", "abc123YYY")); assertTrue(ParseUtils.isMatchGlobPattern("abc123*", "abc123abc123")); assertFalse(ParseUtils.isMatchGlobPattern("abc123*", "abc333abc123")); assertFalse(ParseUtils.isMatchGlobPattern("*abc123*", "abc123abc123")); assertTrue(ParseUtils.isMatchGlobPattern("*abc123*", "*abc123abc123")); assertTrue(ParseUtils.isMatchGlobPattern("*abc123*", "*abc123XXX")); }
public static boolean isMatchGlobPattern(String pattern, String value) { if ("*".equals(pattern)) return true; if((pattern == null || pattern.length() == 0) && (value == null || value.length() == 0)) return true; if((pattern == null || pattern.length() == 0) || (value == null || value.length() == 0)) return false; int i = pattern.lastIndexOf('*'); if(i == -1) { return value.equals(pattern); } else if (i == pattern.length() - 1) { return value.startsWith(pattern.substring(0, i)); } else if (i == 0) { return value.endsWith(pattern.substring(i + 1)); } else { String prefix = pattern.substring(0, i); String suffix = pattern.substring(i + 1); return value.startsWith(prefix) && value.endsWith(suffix); } }
ParseUtils { public static boolean isMatchGlobPattern(String pattern, String value) { if ("*".equals(pattern)) return true; if((pattern == null || pattern.length() == 0) && (value == null || value.length() == 0)) return true; if((pattern == null || pattern.length() == 0) || (value == null || value.length() == 0)) return false; int i = pattern.lastIndexOf('*'); if(i == -1) { return value.equals(pattern); } else if (i == pattern.length() - 1) { return value.startsWith(pattern.substring(0, i)); } else if (i == 0) { return value.endsWith(pattern.substring(i + 1)); } else { String prefix = pattern.substring(0, i); String suffix = pattern.substring(i + 1); return value.startsWith(prefix) && value.endsWith(suffix); } } }
ParseUtils { public static boolean isMatchGlobPattern(String pattern, String value) { if ("*".equals(pattern)) return true; if((pattern == null || pattern.length() == 0) && (value == null || value.length() == 0)) return true; if((pattern == null || pattern.length() == 0) || (value == null || value.length() == 0)) return false; int i = pattern.lastIndexOf('*'); if(i == -1) { return value.equals(pattern); } else if (i == pattern.length() - 1) { return value.startsWith(pattern.substring(0, i)); } else if (i == 0) { return value.endsWith(pattern.substring(i + 1)); } else { String prefix = pattern.substring(0, i); String suffix = pattern.substring(i + 1); return value.startsWith(prefix) && value.endsWith(suffix); } } private  ParseUtils(); }
ParseUtils { public static boolean isMatchGlobPattern(String pattern, String value) { if ("*".equals(pattern)) return true; if((pattern == null || pattern.length() == 0) && (value == null || value.length() == 0)) return true; if((pattern == null || pattern.length() == 0) || (value == null || value.length() == 0)) return false; int i = pattern.lastIndexOf('*'); if(i == -1) { return value.equals(pattern); } else if (i == pattern.length() - 1) { return value.startsWith(pattern.substring(0, i)); } else if (i == 0) { return value.endsWith(pattern.substring(i + 1)); } else { String prefix = pattern.substring(0, i); String suffix = pattern.substring(i + 1); return value.startsWith(prefix) && value.endsWith(suffix); } } private  ParseUtils(); static String interpolate(String expression, Map<String, String> params); static List<String> interpolate(List<String> expressions, Map<String, String> params); static boolean isMatchGlobPattern(String pattern, String value); static boolean isMatchGlobPatternsNeedInterpolate(
            Collection<String> patternsNeedInterpolate,
            Map<String, String> interpolateParams, String value); static Set<String> filterByGlobPattern(String pattern, Collection<String> values); static Set<String> filterByGlobPattern(Collection<String> patterns, Collection<String> values); static boolean hasIntersection(String glob1, String glob2); static Map<String, String> parseQuery(String keyPrefix, String query); static Map<String, String> parseQuery(String query); static String replaceParameter(String query, String key, String value); static String appendParamToUri(String uri, String name, String value); static String appendParamsToUri(String uri, Map<String, String> params); static boolean matchEndStarPattern(String value, String pattern); }
ParseUtils { public static boolean isMatchGlobPattern(String pattern, String value) { if ("*".equals(pattern)) return true; if((pattern == null || pattern.length() == 0) && (value == null || value.length() == 0)) return true; if((pattern == null || pattern.length() == 0) || (value == null || value.length() == 0)) return false; int i = pattern.lastIndexOf('*'); if(i == -1) { return value.equals(pattern); } else if (i == pattern.length() - 1) { return value.startsWith(pattern.substring(0, i)); } else if (i == 0) { return value.endsWith(pattern.substring(i + 1)); } else { String prefix = pattern.substring(0, i); String suffix = pattern.substring(i + 1); return value.startsWith(prefix) && value.endsWith(suffix); } } private  ParseUtils(); static String interpolate(String expression, Map<String, String> params); static List<String> interpolate(List<String> expressions, Map<String, String> params); static boolean isMatchGlobPattern(String pattern, String value); static boolean isMatchGlobPatternsNeedInterpolate(
            Collection<String> patternsNeedInterpolate,
            Map<String, String> interpolateParams, String value); static Set<String> filterByGlobPattern(String pattern, Collection<String> values); static Set<String> filterByGlobPattern(Collection<String> patterns, Collection<String> values); static boolean hasIntersection(String glob1, String glob2); static Map<String, String> parseQuery(String keyPrefix, String query); static Map<String, String> parseQuery(String query); static String replaceParameter(String query, String key, String value); static String appendParamToUri(String uri, String name, String value); static String appendParamsToUri(String uri, Map<String, String> params); static boolean matchEndStarPattern(String value, String pattern); static String METHOD_SPLIT; }