Examples of CommandSyntaxException


Examples of org.jnode.shell.syntax.CommandSyntaxException

    @Override
    protected String doAccept(Token value, int flags) throws CommandSyntaxException {
        int index = value.text.indexOf(':');
        if (index == -1) {
            throw new CommandSyntaxException("missing ':'");
        } else if (index == 0) {
            throw new CommandSyntaxException("no hostname before ':'");
        } else if (index == value.text.length() - 1) {
            throw new CommandSyntaxException("no directory after ':'");
        } else {
            return value.text;
        }
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

            String[] parts = str.split("\\+");
            int modifiers = 0;
            for (int i = 0; i < parts.length - 1; i++) {
                Integer m = MODIFIER_NAME_MAP.get(constCase(parts[i]));
                if (m == null) {
                    throw new CommandSyntaxException(String.format(ex_unknown_mod, parts[i]));
                }
                modifiers |= m;
            }
            Integer vk = VK_NAME_MAP.get(constCase(parts[parts.length - 1]));
            if (vk == null) {
                throw new CommandSyntaxException(String.format(ex_unknown_vkey, parts[parts.length - 1]));
            }
            return new VirtualKey(vk, modifiers);
        }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

            }
            if (str.startsWith("0x") || str.startsWith("0X")) {
                int ch = Integer.parseInt(str.substring(2), 16);
                return (char) ch;
            }
            throw new CommandSyntaxException(ex_inv_char);
        }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    private NumberRange parseRange(String text) throws CommandSyntaxException {
        int delimPos = text.indexOf(rangeDelim);
        int start;
        int end;
        if (text.equals(rangeDelim)) {
            throw new CommandSyntaxException("Invalid number range");
        }
        if (delimPos == -1) {
            // this is ok, as we allow a single integer to represent the range n-n
            start = end = parseInt(text);
        } else if (delimPos == 0) {
            start = min;
            end = parseInt(text.substring(rangeDelim.length(), text.length()));
        } else if (delimPos == (text.length() - rangeDelim.length())) {
            start = parseInt(text.substring(0, delimPos));
            end = max;
        } else {
            start = parseInt(text.substring(0, delimPos));
            end   = parseInt(text.substring(delimPos + rangeDelim.length(), text.length()));
        }
        try {
            return new NumberRange(start, end, min - 1, max + 1);
        } catch (IllegalArgumentException ex) {
            throw new CommandSyntaxException("Invalid number range");
        }
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    private int parseInt(String text) throws CommandSyntaxException {
        int n;
        try {
            n = Integer.parseInt(text);
        } catch (NumberFormatException ex) {
            throw new CommandSyntaxException("Invalid number range");
        }
        if (n < min || n > max) {
            throw new CommandSyntaxException("Number out of range");
        }
        return n;
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

            DeviceUtils.getDevicesByAPI(KeyboardAPI.class);

        if (argAdd.isSet()) {
            String layoutID = getLayoutID(mgr);
            if (!argClass.isSet()) {
                throw new CommandSyntaxException(ex_syntax_class);
            }
            String className = argClass.getValue();
            mgr.add(layoutID, className);
            out.format(fmt_add, layoutID);
        } else if (argRemove.isSet()) {
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    private String getLayoutID(KeyboardLayoutManager mgr) throws CommandSyntaxException {
        if (!argTriple.isSet()) {
            if (argLayout.isSet()) {
                return argLayout.getValue();
            } else {
                throw new CommandSyntaxException(ex_syntax_layout);
            }
        } else {
            if (!argCountry.isSet()) {
                throw new CommandSyntaxException(ex_syntax_country);
            }
            String country = argCountry.getValue();
            String language = argLanguage.isSet() ? argLanguage.getValue() : "";
            String variant = argVariant.isSet() ? argVariant.getValue() : "";
            if (language.trim().length() == 0) {
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

        String commandName = commandLine.getCommandName();
        bracketted = (commandName != null && commandName.equals("["));
        args = commandLine.getArguments();
        try {
            if (bracketted && args.length == 0) {
                throw new CommandSyntaxException("missing ']'");
            } else if (bracketted && !args[args.length - 1].equals("]")) {
                processAsOptions(args);
                res = true;
            } else {
                lastArg = bracketted ? args.length - 2 : args.length - 1;
                if (lastArg == -1) {
                    res = false;
                } else {
                    Object obj = evaluate();
                    if (pos <= lastArg) {
                        if (args[pos].equals(")")) {
                            throw new CommandSyntaxException("unmatched ')'");
                        } else {
                            throw new AssertionError("I'm confused!  pos = " + pos +
                                    ", lastArg = " + lastArg + ", next arg is " + args[pos]);
                        }
                    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

        evaluatePrimary(nested);
        while (pos <= lastArg) {
            String tok = next();
            Operator op = OPERATOR_MAP.get(tok);
            if (op == null) {
                throw new CommandSyntaxException("expected an operator");
            }
            switch(op.kind) {
                case OP_UNARY:
                    throw new CommandSyntaxException("misplaced unary operator");
                case OP_BINARY:
                    evaluatePrimary(nested);
                    reduceAndPush(op, popOperand());
                    break;
                case OP_SPECIAL:
                    if (op.opNo == OP_LPAREN) {
                        throw new CommandSyntaxException("misplaced '('");
                    } else if (op.opNo == OP_RPAREN) {
                        if (!nested) {
                            throw new CommandSyntaxException("misplaced ')'");
                        }
                        back();
                        return;
                    }
            }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

                case OP_UNARY:
                    operatorStack.push(op);
                    operandStack.push(next());
                    break;
                case OP_BINARY:
                    throw new CommandSyntaxException("misplaced binary operator");
                case OP_SPECIAL:
                    if (op.opNo == OP_LPAREN) {
                        operatorStack.push(op); // ... as a marker.
                        evaluateExpression(true);
                        if (!next().equals(")")) {
                            throw new CommandSyntaxException("missing ')'");
                        }
                        while (operatorStack.peek() != op) {
                            reduce();
                        }
                        if (operatorStack.pop() != op) {
                            throw new AssertionError("cannot find my marker!");
                        }
                    } else {
                        throw new CommandSyntaxException("unmatched ')'");
                    }
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.