Examples of CommandSyntaxException


Examples of org.jnode.shell.syntax.CommandSyntaxException

            if (option.equals("--help")) {
                err.println("Don't panic!");
            } else if (option.equals("--version")) {
                err.println("JNode test 0.0");
            } else {
                throw new CommandSyntaxException("unknown option '" + option + '\'');
            }
        }
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

        operandStack.push(value);
    }

    private Object popOperand() throws CommandSyntaxException {
        if (operandStack.isEmpty()) {
            throw new CommandSyntaxException("missing LHS for operator");
        }
        return operandStack.pop();
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

            return (Long) obj;
        } else if (obj instanceof String) {
            try {
                return Long.parseLong((String) obj);
            } catch (NumberFormatException ex) {
                throw new CommandSyntaxException(
                        "operand is not a number: '" + obj.toString() + '\'');
            }
        } else {
            throw new CommandSyntaxException("subexpression is not an INTEGER");
        }
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

        if (obj instanceof Boolean) {
            return obj == Boolean.TRUE;
        } else if (obj instanceof String) {
            return ((String) obj).length() > 0;
        } else {
            throw new CommandSyntaxException("operand is an INTEGER");
        }
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    private String toString(Object obj) throws CommandSyntaxException {
        if (obj instanceof String) {
            return (String) obj;
        } else {
            throw new CommandSyntaxException("operand is not a STRING");
        }
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    private File toFile(Object obj) throws CommandSyntaxException {
        if (obj instanceof String) {
            return new File((String) obj);
        } else {
            throw new CommandSyntaxException("operand is not a FILENAME");
        }
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    @Override
    protected IPv4Address doAccept(Token value, int flags) throws CommandSyntaxException {
        try {
            return new IPv4Address(value.text);
        } catch (IllegalArgumentException ex) {
            throw new CommandSyntaxException("invalid hostname or IPv4 address");
        }
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

        if (value.text.equals("default")) {
            return new IPv4Address(new byte[]{0, 0, 0, 0}, 0);
        }
        final StringTokenizer tok = new StringTokenizer(value.text, ".");
        if (tok.countTokens() != 4) {
            throw new CommandSyntaxException("wrong number of components for an IPv4 address");
        }
        try {
            final byte b1 = parseUnsignedByte(tok.nextToken());
            final byte b2 = parseUnsignedByte(tok.nextToken());
            final byte b3 = parseUnsignedByte(tok.nextToken());
            final byte b4 = parseUnsignedByte(tok.nextToken());
            return new IPv4Address(new byte[]{b1, b2, b3, b4}, 0);
        } catch (NumberFormatException ex) {
            throw new CommandSyntaxException("invalid component in IPv4 address");
        }
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

                    case '8':
                    case '9':
                    case '0':
                        break LOOP;
                    default:
                        throw new CommandSyntaxException("Invalid field: " + text);
                }
                i--;
            }
            text = text.substring(0, i + 1);
            i = text.indexOf('.');
            if (i == 0) {
                throw new CommandSyntaxException("Field offset cannot be empty");
            }
            if (i == (text.length() - 1)) {
                throw new CommandSyntaxException("Character offset cannot be empty if '.' is given");
            }
            try {
                if (i == -1) {
                    field.field = Integer.parseInt(text) - 1;
                    field.offset = end ? -1 : 0;
                } else {
                    field.field = Integer.parseInt(text.substring(0, i)) - 1;
                    field.offset = Integer.parseInt(text.substring(i + 1)) - 1;
                }
            } catch (NumberFormatException e) {
                throw new CommandSyntaxException("Invalid number: " + text);
            }
            if (field.field < 0) {
                throw new CommandSyntaxException("Field offset cannot be less than one: " + field.field);
            }
            if (field.offset < 0 && !end) {
                throw new CommandSyntaxException("Start character offset cannot be less than one: " + field.offset);
            }
            if (field.offset < -1 && end) {
                throw new CommandSyntaxException("End character offset cannot be less than zero");
            }
            return field;
        }
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.