use of net.sourceforge.processdash.util.glob.node.Start in project processdash by dtuma.
the class GlobEngine method test.
public static boolean test(String expression, Object value) {
if (expression == null || expression.trim().length() == 0 || value == null)
return false;
Collection words = asCollection(value);
if (words == null || words.isEmpty())
return false;
Start s = compile(expression);
if (s == null)
return false;
GlobTestEvaluator eval = new GlobTestEvaluator(words);
eval.caseStart(s);
return eval.getResult();
}
use of net.sourceforge.processdash.util.glob.node.Start in project processdash by dtuma.
the class GlobEngine method compile.
private static Start compile(String expression) {
Start result = (Start) COMPILED_EXPRESSIONS.get(expression);
if (result == null) {
try {
Parser p = new Parser(new Lexer(new PushbackReader(new StringReader(expression), 1024)));
// Parse the input
result = p.parse();
} catch (Exception e) {
logger.warning("Invalid glob expression: " + expression);
e.printStackTrace();
}
}
return result;
}
use of net.sourceforge.processdash.util.glob.node.Start in project processdash by dtuma.
the class GlobEngine method search.
public static Set search(String expression, Map taggedData, TaggedDataMapSource deferredDataSource) {
if (expression == null || expression.trim().length() == 0)
return Collections.EMPTY_SET;
Start s = compile(expression);
if (s == null)
return Collections.EMPTY_SET;
GlobSearchEvaluator eval = new GlobSearchEvaluator(taggedData, deferredDataSource);
eval.caseStart(s);
Set matches = eval.getResult();
if (matches == null || matches.isEmpty())
return Collections.EMPTY_SET;
else
return matches;
}
Aggregations