Package org.jnode.shell

Examples of org.jnode.shell.ShellException


                    case REDIR_GREAT:
                        try {
                            File file = new File(redir.getArg().getText());
                            if (isNoClobber() && file.exists()) {
                                throw new ShellException("File already exists");
                            }
                            out = new CommandOutput(new FileOutputStream(file));
                            stream = new CommandIOHolder(out, true);
                        } catch (IOException ex) {
                            throw new ShellException("Cannot open output file", ex);
                        }
                        break;

                    case REDIR_CLOBBER:
                    case REDIR_DGREAT:
                        try {
                            FileOutputStream tmp = new FileOutputStream(redir.getArg().getText(),
                                    redir.getRedirectionType() == REDIR_DGREAT);
                            stream = new CommandIOHolder(new CommandOutput(tmp), true);
                        } catch (IOException ex) {
                            throw new ShellException("Cannot open output file", ex);
                        }
                        break;

                    case REDIR_LESS:
                        try {
                            File file = new File(redir.getArg().getText());
                            in = new CommandInput(new FileInputStream(file));
                            stream = new CommandIOHolder(in, true);
                        } catch (IOException ex) {
                            throw new ShellException("Cannot open input file", ex);
                        }
                        break;

                    case REDIR_LESSAND:
                        try {
                            int fromFd = Integer.parseInt(redir.getArg().getText());
                            stream = (fromFd >= holders.length) ? null :
                                    new CommandIOHolder(holders[fromFd]);
                        } catch (NumberFormatException ex) {
                            throw new ShellException("Invalid fd after <&");
                        }
                        break;

                    case REDIR_GREATAND:
                        try {
                            int fromFd = Integer.parseInt(redir.getArg().getText());
                            stream = (fromFd >= holders.length) ? null :
                                    new CommandIOHolder(holders[fromFd]);
                        } catch (NumberFormatException ex) {
                            throw new ShellException("Invalid fd after >&");
                        }
                        break;

                    case REDIR_LESSGREAT:
                        throw new UnsupportedOperationException("<>");
View Full Code Here


                res = new Primary(null, Math.round(Math.pow(operand1.getValue(), operand2.getValue())));
                break;
            case SLASH:
                value = operand2.getValue();
                if (value == 0) {
                    throw new ShellException("Divide by zero in expression");
                }
                res = new Primary(null, operand1.getValue() / value);
                break;
            case PERCENT:
                value = operand2.getValue();
                if (value == 0) {
                    throw new ShellException("Remainder by zero in expression");
                }
                res = new Primary(null, operand1.getValue() % value);
                break;
            default:
                throw new ShellFailureException("operator not supported");
View Full Code Here

    }

    public CommandInterpreter createInterpreter(String name) throws ShellException {
        CommandInterpreter.Factory factory = interpreterFactories.get(name);
        if (factory == null) {
            throw new ShellException("Unknown interpreter '" + name + "'");
        }
        return factory.create();
    }
View Full Code Here

    public SimpleCommandInvoker createInvoker(String name, CommandShell shell)
        throws ShellException {
        SimpleCommandInvoker.Factory factory = invokerFactories.get(name);
        if (factory == null) {
            throw new ShellException("Unknown invoker '" + name + "'");
        }
        return factory.create(shell);
    }
View Full Code Here

TOP

Related Classes of org.jnode.shell.ShellException

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.