Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.undertow.server.handlers.builder;
Parser for the undertow-handlers.conf file.

This file has a line by line syntax, specifying predicate -> handler. If no predicate is specified then the line is assumed to just contain a handler.

Stuart Douglas
public class PredicatedHandlersParser {
    public static List<PredicatedHandlerparse(final File filefinal ClassLoader classLoader) {
        return parse(FileUtils.readFile(file), classLoader);
    public static List<PredicatedHandlerparse(final InputStream inputStreamfinal ClassLoader classLoader) {
        return parse(FileUtils.readFile(inputStream), classLoader);
    public static List<PredicatedHandlerparse(final String contentsfinal ClassLoader classLoader) {
        String[] lines = contents.split("\\n");
        final List<PredicatedHandlerwrappers = new ArrayList<PredicatedHandler>();
        for (String line : lines) {
            if (line.trim().length() > 0) {
                Predicate predicate;
                HandlerWrapper handler;
                String[] parts = line.split("->");
                if (parts.length == 2) {
                    predicate = PredicateParser.parse(parts[0], classLoader);
                    handler = HandlerParser.parse(parts[1], classLoader);
                } else if (parts.length == 1) {
                    predicate = Predicates.truePredicate();
                    handler = HandlerParser.parse(parts[0], classLoader);
                } else {
                    throw ..invalidSyntax(line);
                wrappers.add(new PredicatedHandler(predicatehandler));
        return wrappers;
New to GrepCode? Check out our FAQ X