Package org.restlet.ext.jaxrs.internal.exceptions

Examples of org.restlet.ext.jaxrs.internal.exceptions.IllegalPathException


                i = processTemplVarname(pathTemplate, i, stb, pathForExcMess);
            } else if (c == '%') {
                try {
                    EncodeOrCheck.processPercent(i, true, pathTemplate, stb);
                } catch (IllegalArgumentException e) {
                    throw new IllegalPathException(pathForExcMess, e);
                }
            } else if (c == '}') {
                throw new IllegalPathException(pathForExcMess,
                        "'}' is only allowed as "
                                + "end of a variable name in \"" + pathTemplate
                                + "\"");
            } else if (c == ';') {
                throw new IllegalPathException(pathForExcMess,
                        "A semicolon is not allowed in a path");
            } else if (c == '/') {
                stb.append(c);
            } else {
                EncodeOrCheck.encode(c, stb);
View Full Code Here


        stb.append('{');
        int state = NAME_READ_START;
        for (int i = braceIndex + 1; i < l; i++) {
            final char c = pathTemplate.charAt(i);
            if (c == '{') {
                throw new IllegalPathException(pathForExcMess,
                        "A variable must not " + "contain an extra '{' in \""
                                + pathTemplate + "\"");
            } else if (c == ' ' || c == '\t') {
                if (state == NAME_READ)
                    state = NAME_READ_READY;
                continue;
            } else if (c == ':') {
                if (state == NAME_READ_START) {
                    throw new IllegalPathException(pathForExcMess,
                            "The variable name at position must not be null at "
                                    + braceIndex + " of \"" + pathTemplate
                                    + "\"");
                }
                if (state == NAME_READ || state == NAME_READ_READY) {
                    for (int j = i; j < l; j++) {
                        if (pathTemplate.charAt(j) == '}') {
                            stb.append('}');
                            return j;
                        }
                    }
                    throw new IllegalPathException(pathForExcMess,
                            "No '}' found after '{' at position " + braceIndex
                                    + " of \"" + pathTemplate + "\"");
                }
            } else if (c == '}') {
                if (state == NAME_READ_START) {
                    throw new IllegalPathException(pathForExcMess,
                            "The template variable name '{}' is not allowed in "
                                    + "\"" + pathTemplate + "\"");
                }
                stb.append('}');
                return i;
            }

            if (state == NAME_READ_START) {
                state = NAME_READ;
                stb.append(c);
            } else if (state == NAME_READ) {
                stb.append(c);
            } else {
                throw new IllegalPathException(pathForExcMess,
                        "Invalid character found at position " + i + " of \""
                                + pathTemplate + "\"");
            }
        }
        throw new IllegalPathException(pathForExcMess,
                "No '}' found after '{' " + "at position " + braceIndex
                        + " of \"" + pathTemplate + "\"");
    }
View Full Code Here

            } else if (c == '%') {
                try {
                    EncodeOrCheck.processPercent(i, true, pathTemplate,
                            pathPattern);
                } catch (IllegalArgumentException e) {
                    throw new IllegalPathException(pathForExcMess, e);
                }
            } else if (c == '}') {
                throw new IllegalPathException(pathForExcMess,
                        "'}' is only allowed as "
                                + "end of a variable name in \"" + pathTemplate
                                + "\"");
            } else if (c == ';') {
                throw new IllegalPathException(pathForExcMess,
                        "matrix parameters are not allowed in a @Path");
            } else if (!false && (c == '/')) {
                pathPattern.append(c);
                noLitChars++;
            } else {
View Full Code Here

        final StringBuilder regExp = new StringBuilder();
        int state = NAME_READ_START;
        for (int i = braceIndex + 1; i < l; i++) {
            final char c = pathTemplate.charAt(i);
            if (c == '{') {
                throw new IllegalPathException(pathForExcMess,
                        "A variable must not " + "contain an extra '{' in \""
                                + pathTemplate + "\"");
            } else if (c == ' ' || c == '\t') {
                if (state == NAME_READ)
                    state = NAME_READ_READY;
                else if (state == REGEXP_READ)
                    state = REGEXP_READ_READY;
                continue;
            } else if (c == ':') {
                if (state == NAME_READ_START) {
                    throw new IllegalPathException(pathForExcMess,
                            "The variable name at position must not be null at "
                                    + braceIndex + " of \"" + pathTemplate
                                    + "\"");
                }
                if (state == NAME_READ || state == NAME_READ_READY) {
                    state = REGEXP_READ_START;
                }
                continue;
            } else if (c == '}') {
                if (state == NAME_READ_START) {
                    throw new IllegalPathException(pathForExcMess,
                            "The template variable name '{}' is not allowed in "
                                    + "\"" + pathTemplate + "\"");
                } else if ((state == REGEXP_READ)
                        || (state == REGEXP_READ_READY)) {
                    pathPattern.append(regExp);
                    if (!regExp.equals(DEFAULT_REG_EXP)) {
                        this.noNonDefaultRegExp++;
                    }
                } else {
                    pathPattern.append(DEFAULT_REG_EXP);
                }
                pathPattern.append(')');
                this.varNames.add(varName.toString());
                return i;
            }

            if (state == NAME_READ_START) {
                state = NAME_READ;
                varName.append(c);
            } else if (state == NAME_READ) {
                varName.append(c);
            } else if (state == REGEXP_READ_START) {
                state = REGEXP_READ;
                regExp.append(c);
            } else if (state == REGEXP_READ) {
                regExp.append(c);
            } else {
                throw new IllegalPathException(pathForExcMess,
                        "Invalid character found at position " + i + " of \""
                                + pathTemplate + "\"");
            }
        }
        throw new IllegalPathException(pathForExcMess,
                "No '}' found after '{' " + "at position " + braceIndex
                        + " of \"" + pathTemplate + "\"");
    }
View Full Code Here

TOP

Related Classes of org.restlet.ext.jaxrs.internal.exceptions.IllegalPathException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.