protected boolean work()

in gshell-support/gshell-console/src/main/java/org/apache/geronimo/gshell/console/Console.java [149:196]


    protected boolean work() throws Exception {
        String line = readLine(prompter.prompt());

        log.debug("Read line: {}", line);

        // Log the line as HEX if trace is enabled
        if (log.isTraceEnabled()) {
            StringBuilder idx = new StringBuilder();
            StringBuilder hex = new StringBuilder();

            byte[] bytes = line.getBytes();
            for (byte b : bytes) {
                String h = Integer.toHexString(b);

                hex.append("x").append(h).append(" ");
                idx.append(" ").append((char)b).append("  ");
            }

            log.trace("HEX: {}", hex);
            log.trace("     {}", idx);
        }

        // Stop on null (maybe, else ignore)
        if (line == null) {
            return !breakOnNull;
        }

        // Auto trim the line (maybe)
        if (autoTrim) {
            line = line.trim();
        }

        // Ingore empty lines (maybe)
        if (ignoreEmpty && line.length() == 0) {
            return true;
        }

        // Execute the line
        Executor.Result result = executor.execute(line);

        // Allow executor to request that the loop stop
        if (result == Executor.Result.STOP) {
            log.debug("Executor requested STOP");
            return false;
        }

        return true;
    }