Examples of CommandSyntaxException


Examples of mireka.pop.CommandSyntaxException

        if (session.getSessionState() != SessionState.TRANSACTION)
            throw new IllegalSessionStateException();

        List<String> args = commandParser.parseArguments();
        if (args.size() != 2)
            throw new CommandSyntaxException(
                    "Two numeric arguments are expected");
        int messageNumber;
        int lines;
        try {
            messageNumber = Integer.valueOf(args.get(0));
            lines = Integer.valueOf(args.get(1));
        } catch (NumberFormatException e) {
            throw new CommandSyntaxException(
                    "Two numeric arguments are expected");
        }
        if (lines < 0)
            throw new CommandSyntaxException(
                    "Two numeric arguments are expected");

        InputStream mailAsStream =
                session.getMaildrop().getMailAsStream(messageNumber);
        try {
View Full Code Here

Examples of mireka.pop.CommandSyntaxException

        if (session.getSessionState() != AUTHORIZATION)
            throw new IllegalSessionStateException();

        List<String> args = commandParser.parseArguments();
        if (args.size() != 2)
            throw new CommandSyntaxException("Two arguments are expected");
        String user = args.get(0);
        String digest = args.get(1);
        byte[] digestBytes = valueOfHex(digest);
        LoginResult result =
                loginSpecification.evaluateApop(user, timestamp, digestBytes);
View Full Code Here

Examples of mireka.pop.CommandSyntaxException

        }
    }

    private static byte[] valueOfHex(String s) throws CommandSyntaxException {
        if (s.length() != 32)
            throw new CommandSyntaxException(
                    "Second argument must be a 16 bytes hexadecimal number");
        byte[] result = new byte[16];
        for (int i = 0; i < 16; i++) {
            String byteString = s.substring(i * 2, i * 2 + 2);
            try {
                result[i] = (byte) Integer.parseInt(byteString, 16);
            } catch (NumberFormatException e) {
                throw new CommandSyntaxException(
                        "Second argument must be a 16 bytes hexadecimal number");
            }
        }
        return result;
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    @Override
    protected String doAccept(Token value, int flags) throws CommandSyntaxException {
        String tok = value.text;
        if (!BjorneToken.isName(tok)) {
            throw new CommandSyntaxException("invalid name ('" + tok + "')");
        }
        return tok;
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    protected String doAccept(Token value, int flags) throws CommandSyntaxException {
        String tok = value.text;
        int pos = tok.indexOf('=');
        String name = (pos == -1) ? tok : tok.substring(0, pos);
        if (!BjorneToken.isName(name)) {
            throw new CommandSyntaxException("invalid alias name ('" + name + "')");
        }
        return tok;
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    @Override
    protected String doAccept(Token value, int flags) throws CommandSyntaxException {
        String name = value.text;
        if (!BjorneToken.isName(name)) {
            throw new CommandSyntaxException("invalid name ('" + name + "')");
        }
        return name;
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    protected String doAccept(Token value, int flags) throws CommandSyntaxException {
        String tok = value.text;
        int pos = tok.indexOf('=');
        String name = (pos == -1) ? tok : tok.substring(0, pos);
        if (!BjorneToken.isName(name)) {
            throw new CommandSyntaxException("invalid name ('" + name + "')");
        }
        return tok;
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    @Override
    protected Boolean doAccept(Token value, int flags) throws CommandSyntaxException {
        String tok = value.text;
        if (tok.length() != 2 || tok.charAt(1) != flagCh ||
                (tok.charAt(0) != '-' && tok.charAt(0) != '+')) {
            throw new CommandSyntaxException("this does not match the '-'" + flagCh + " flag");
        }
        return Boolean.valueOf(tok.charAt(0) == '+');
    }
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

        protected String doAccept(String category) throws CommandSyntaxException {
            Set<String> availCategories = TestManager.getInstance().getCategories();
            if (availCategories.contains(category)) {
                return category;
            } else {
                throw new CommandSyntaxException("not a recognized JUnit test category");
            }
        }   
View Full Code Here

Examples of org.jnode.shell.syntax.CommandSyntaxException

    protected IBMPartitionTypes doAccept(Token value, int flags) throws CommandSyntaxException {
        try {
            int code = Integer.parseInt(value.text, 16);
            return IBMPartitionTypes.valueOf(code);
        } catch (NumberFormatException ex) {
            throw new CommandSyntaxException("not a valid hexadecimal number");
        } catch (IllegalArgumentException ex) {
            throw new CommandSyntaxException(ex.getMessage());
        }
    }
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.