use of org.apache.metron.profiler.client.window.generated.WindowParser in project metron by apache.
the class WindowProcessor method process.
/**
* Create a reusable Window object (parameterized by time) from a statement specifying the window intervals
* conforming to the Window grammar.
*
* @param statement
* @return Window returns a Window object (parameterized by time) from a statement specifying the window
* intervals conforming to the Window grammar.
* @throws ParseException
*/
public static Window process(String statement) throws ParseException {
TokenStream tokens = createTokenStream(statement);
if (tokens == null) {
return null;
}
WindowProcessor treeBuilder = new WindowProcessor();
WindowParser parser = createParser(tokens, Optional.of(treeBuilder));
parser.window();
if (treeBuilder.throwable != null) {
throw new ParseException(treeBuilder.throwable.getMessage(), treeBuilder.throwable);
}
return treeBuilder.getWindow();
}
use of org.apache.metron.profiler.client.window.generated.WindowParser in project metron by apache.
the class WindowProcessor method syntaxTree.
/**
* Create a textual representation of the syntax tree. This is useful for those intrepid souls
* who wish to extend the window selector language. God speed.
* @param statement
* @return A string representation of the syntax tree.
*/
public static String syntaxTree(String statement) {
TokenStream tokens = createTokenStream(statement);
if (tokens == null) {
return null;
}
WindowParser parser = createParser(tokens, Optional.empty());
ParseTree tree = parser.window();
return GrammarUtils.toSyntaxTree(tree);
}
use of org.apache.metron.profiler.client.window.generated.WindowParser in project metron by apache.
the class WindowProcessor method createParser.
private static WindowParser createParser(TokenStream tokens, Optional<WindowProcessor> windowProcessor) {
WindowParser parser = new WindowParser(tokens);
if (windowProcessor.isPresent()) {
parser.addParseListener(windowProcessor.get());
}
parser.removeErrorListeners();
parser.addErrorListener(new ErrorListener());
return parser;
}
Aggregations