public Object evaluate(Object target, Class targetClass, Object[] args, Class[] argClasses, Object candidate, StoreContext ctx) { if (target == null || args[0] == null) return Boolean.FALSE; // create a regexp for the wildcard expression by subbing '.' for '?' // and '.*' for '*' String wild = args[0].toString().replace('?', '.'); for (int st = 0, i; (i = wild.indexOf("*", st)) != -1; st = i + 3) wild = wild.substring(0, i) + "." + wild.substring(i); SimpleRegex re = new SimpleRegex(wild, false); return (re.matches(target.toString())) ? Boolean.TRUE : Boolean.FALSE; }
public Object evaluate(Object target, Class targetClass, Object[] args, Class[] argClasses, Object candidate, StoreContext ctx) { if (target == null || args[0] == null) return Boolean.FALSE; // create a regexp for the wildcard expression by subbing '.' for '?' // and '.*' for '*' String wild = args[0].toString().replace('?', '.'); for (int st = 0, i; (i = wild.indexOf("*", st)) != -1; st = i + 3) wild = wild.substring(0, i) + "." + wild.substring(i); SimpleRegex re = new SimpleRegex(wild, false); return (re.matches(target.toString())) ? Boolean.TRUE : Boolean.FALSE; }
public Object evaluate(Object target, Class targetClass, Object[] args, Class[] argClasses, Object candidate, StoreContext ctx) { if (target == null || args[0] == null) return Boolean.FALSE; // create a regexp for the wildcard expression by subbing '.' for '?' // and '.*' for '*' String wild = args[0].toString().replace('?', '.'); for (int st = 0, i; (i = wild.indexOf("*", st)) != -1; st = i + 3) wild = wild.substring(0, i) + "." + wild.substring(i); SimpleRegex re = new SimpleRegex(wild, false); return (re.matches(target.toString())) ? Boolean.TRUE : Boolean.FALSE; }
public Object evaluate(Object target, Class targetClass, Object[] args, Class[] argClasses, Object candidate, StoreContext ctx) { if (target == null || args[0] == null) return Boolean.FALSE; // create a regexp for the wildcard expression by subbing '.' for '?' // and '.*' for '*' String wild = args[0].toString().replace('?', '.'); for (int st = 0, i; (i = wild.indexOf("*", st)) != -1; st = i + 3) wild = wild.substring(0, i) + "." + wild.substring(i); SimpleRegex re = new SimpleRegex(wild, false); return (re.matches(target.toString())) ? Boolean.TRUE : Boolean.FALSE; }
public Object evaluate(Object target, Class targetClass, Object[] args, Class[] argClasses, Object candidate, StoreContext ctx) { if (target == null || args[0] == null) return Boolean.FALSE; // create a regexp for the wildcard expression by subbing '.' for '?' // and '.*' for '*' String wild = args[0].toString().replace('?', '.'); for (int st = 0, i; (i = wild.indexOf("*", st)) != -1; st = i + 3) wild = wild.substring(0, i) + "." + wild.substring(i); SimpleRegex re = new SimpleRegex(wild, false); return (re.matches(target.toString())) ? Boolean.TRUE : Boolean.FALSE; }
protected boolean compare(Object o1, Object o2) { if (o1 == null || o2 == null) return false; // case insensitive? String str = o2.toString(); int idx = str.indexOf("(?i)"); boolean uncase = false; if (idx != -1) { uncase = true; if (idx + 4 < str.length()) str = str.substring(0, idx) + str.substring(idx + 4); else str = str.substring(0, idx); } // now translate from the single and multi character escape // sequences into an escape that conforms to the regexp syntax str = Strings.replace(str, _multi, ".*"); str = Strings.replace(str, _single, "."); SimpleRegex re = new SimpleRegex(str, uncase); boolean matches = re.matches(o1.toString()); return _affirmation ? matches : !matches; } }
protected boolean compare(Object o1, Object o2) { if (o1 == null || o2 == null) return false; // case insensitive? String str = o2.toString(); int idx = str.indexOf("(?i)"); boolean uncase = false; if (idx != -1) { uncase = true; if (idx + 4 < str.length()) str = str.substring(0, idx) + str.substring(idx + 4); else str = str.substring(0, idx); } // now translate from the single and multi character escape // sequences into an escape that conforms to the regexp syntax str = StringUtil.replace(str, _multi, ".*"); str = StringUtil.replace(str, _single, "."); SimpleRegex re = new SimpleRegex(str, uncase); boolean matches = re.matches(o1.toString()); return _affirmation ? matches : !matches; } }
protected boolean compare(Object o1, Object o2) { if (o1 == null || o2 == null) return false; // case insensitive? String str = o2.toString(); int idx = str.indexOf("(?i)"); boolean uncase = false; if (idx != -1) { uncase = true; if (idx + 4 < str.length()) str = str.substring(0, idx) + str.substring(idx + 4); else str = str.substring(0, idx); } // now translate from the single and multi character escape // sequences into an escape that conforms to the regexp syntax str = StringUtil.replace(str, _multi, ".*"); str = StringUtil.replace(str, _single, "."); SimpleRegex re = new SimpleRegex(str, uncase); boolean matches = re.matches(o1.toString()); return _affirmation ? matches : !matches; } }
protected boolean compare(Object o1, Object o2) { if (o1 == null || o2 == null) return false; // case insensitive? String str = o2.toString(); int idx = str.indexOf("(?i)"); boolean uncase = false; if (idx != -1) { uncase = true; if (idx + 4 < str.length()) str = str.substring(0, idx) + str.substring(idx + 4); else str = str.substring(0, idx); } // now translate from the single and multi character escape // sequences into an escape that conforms to the regexp syntax str = Strings.replace(str, _multi, ".*"); str = Strings.replace(str, _single, "."); SimpleRegex re = new SimpleRegex(str, uncase); boolean matches = re.matches(o1.toString()); return _affirmation ? matches : !matches; } }
protected boolean compare(Object o1, Object o2) { if (o1 == null || o2 == null) return false; // case insensitive? String str = o2.toString(); int idx = str.indexOf("(?i)"); boolean uncase = false; if (idx != -1) { uncase = true; if (idx + 4 < str.length()) str = str.substring(0, idx) + str.substring(idx + 4); else str = str.substring(0, idx); } // now translate from the single and multi character escape // sequences into an escape that conforms to the regexp syntax str = Strings.replace(str, _multi, ".*"); str = Strings.replace(str, _single, "."); SimpleRegex re = new SimpleRegex(str, uncase); boolean matches = re.matches(o1.toString()); return _affirmation ? matches : !matches; } }