Java Code Examples for io.undertow.attribute.ExchangeAttributeParser#parse()

The following examples show how to use io.undertow.attribute.ExchangeAttributeParser#parse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetAttributeHandler.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value) {
    this.next = next;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
    this.preCommit = false;
}
 
Example 2
Source File: SetAttributeHandler.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, final ClassLoader classLoader) {
    this.next = next;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
    this.preCommit = false;
}
 
Example 3
Source File: SetAttributeHandler.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, boolean preCommit) {
    this.next = next;
    this.preCommit = preCommit;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
}
 
Example 4
Source File: SetAttributeHandler.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, final ClassLoader classLoader, boolean preCommit) {
    this.next = next;
    this.preCommit = preCommit;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
}
 
Example 5
Source File: PredicatedHandlersParser.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
private static Object coerceToType(final String string, final Token token, final Class<?> type, final ExchangeAttributeParser attributeParser) {
    if (type.isArray()) {
        Object array = Array.newInstance(type.getComponentType(), 1);
        Array.set(array, 0, coerceToType(string, token, type.getComponentType(), attributeParser));
        return array;
    }

    if (type == String.class) {
        return token.getToken();
    } else if (type.equals(Boolean.class) || type.equals(boolean.class)) {
        return Boolean.valueOf(token.getToken());
    } else if (type.equals(Byte.class) || type.equals(byte.class)) {
        return Byte.valueOf(token.getToken());
    } else if (type.equals(Character.class) || type.equals(char.class)) {
        if (token.getToken().length() != 1) {
            throw error(string, token.getPosition(), "Cannot coerce " + token.getToken() + " to a Character");
        }
        return Character.valueOf(token.getToken().charAt(0));
    } else if (type.equals(Short.class) || type.equals(short.class)) {
        return Short.valueOf(token.getToken());
    } else if (type.equals(Integer.class) || type.equals(int.class)) {
        return Integer.valueOf(token.getToken());
    } else if (type.equals(Long.class) || type.equals(long.class)) {
        return Long.valueOf(token.getToken());
    } else if (type.equals(Float.class) || type.equals(float.class)) {
        return Float.valueOf(token.getToken());
    } else if (type.equals(Double.class) || type.equals(double.class)) {
        return Double.valueOf(token.getToken());
    } else if (type.equals(ExchangeAttribute.class)) {
        return attributeParser.parse(token.getToken());
    }

    return token.getToken();
}
 
Example 6
Source File: SetAttributeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value) {
    this.next = next;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
    this.preCommit = false;
}
 
Example 7
Source File: SetAttributeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, final ClassLoader classLoader) {
    this.next = next;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
    this.preCommit = false;
}
 
Example 8
Source File: SetAttributeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, boolean preCommit) {
    this.next = next;
    this.preCommit = preCommit;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
}
 
Example 9
Source File: SetAttributeHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SetAttributeHandler(HttpHandler next, final String attribute, final String value, final ClassLoader classLoader, boolean preCommit) {
    this.next = next;
    this.preCommit = preCommit;
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    this.attribute = parser.parseSingleToken(attribute);
    this.value = parser.parse(value);
}
 
Example 10
Source File: PredicatedHandlersParser.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static Object coerceToType(final String string, final Token token, final Class<?> type, final ExchangeAttributeParser attributeParser) {
    if (type.isArray()) {
        Object array = Array.newInstance(type.getComponentType(), 1);
        Array.set(array, 0, coerceToType(string, token, type.getComponentType(), attributeParser));
        return array;
    }

    if (type == String.class) {
        return token.getToken();
    } else if (type.equals(Boolean.class) || type.equals(boolean.class)) {
        return Boolean.valueOf(token.getToken());
    } else if (type.equals(Byte.class) || type.equals(byte.class)) {
        return Byte.valueOf(token.getToken());
    } else if (type.equals(Character.class) || type.equals(char.class)) {
        if (token.getToken().length() != 1) {
            throw error(string, token.getPosition(), "Cannot coerce " + token.getToken() + " to a Character");
        }
        return Character.valueOf(token.getToken().charAt(0));
    } else if (type.equals(Short.class) || type.equals(short.class)) {
        return Short.valueOf(token.getToken());
    } else if (type.equals(Integer.class) || type.equals(int.class)) {
        return Integer.valueOf(token.getToken());
    } else if (type.equals(Long.class) || type.equals(long.class)) {
        return Long.valueOf(token.getToken());
    } else if (type.equals(Float.class) || type.equals(float.class)) {
        return Float.valueOf(token.getToken());
    } else if (type.equals(Double.class) || type.equals(double.class)) {
        return Double.valueOf(token.getToken());
    } else if (type.equals(ExchangeAttribute.class)) {
        return attributeParser.parse(token.getToken());
    }

    return token.getToken();
}
 
Example 11
Source File: RedirectHandler.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
public RedirectHandler(final String location) {
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    attribute = parser.parse(location);
}
 
Example 12
Source File: RedirectHandler.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
public RedirectHandler(final String location, final ClassLoader classLoader) {
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    attribute = parser.parse(location);
}
 
Example 13
Source File: RedirectHandler.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public RedirectHandler(final String location) {
    ExchangeAttributeParser parser = ExchangeAttributes.parser(getClass().getClassLoader());
    attribute = parser.parse(location);
}
 
Example 14
Source File: RedirectHandler.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public RedirectHandler(final String location, final ClassLoader classLoader) {
    ExchangeAttributeParser parser = ExchangeAttributes.parser(classLoader);
    attribute = parser.parse(location);
}