public void lineEnd()

in mpt/core/src/main/java/org/apache/james/mpt/helper/ScriptBuilder.java [1389:1461]


        public void lineEnd() {
            lineBuffer.flip();
            final String text = lineBuffer.toString();
            String[] lines = text.split("\r\n");
            for (String line : lines) {
                String chompedLine = StringUtils.chomp(line);
                if (!ignoreLine(chompedLine)) {
                    final String[] words = StringUtils.split(chompedLine);
                    if (words.length > 3 && "S:".equalsIgnoreCase(words[0]) && "OK".equalsIgnoreCase(words[2])) {
                        final int commandWordIndex;
                        if (words[3] == null || !words[3].startsWith("\\[")) {
                            commandWordIndex = 3;
                        } else {
                            int wordsCount = 3;
                            while (wordsCount < words.length) {
                                if (words[wordsCount++].endsWith("]")) {
                                    break;
                                }
                            }
                            commandWordIndex = wordsCount;
                        }
                        final String command = words[commandWordIndex];
                        final String commandOkPhrase;
                        if ("CREATE".equalsIgnoreCase(command)) {
                            commandOkPhrase = "OK CREATE completed.";
                        } else if ("FETCH".equalsIgnoreCase(command)) {
                            commandOkPhrase = "OK FETCH completed.";
                        } else if ("APPEND".equalsIgnoreCase(command)) {
                            commandOkPhrase = OK_APPEND_COMPLETED;
                        } else if ("DELETE".equalsIgnoreCase(command)) {
                            commandOkPhrase = "OK DELETE completed.";
                        } else if ("STORE".equalsIgnoreCase(command)) {
                            commandOkPhrase = "OK STORE completed.";
                        } else if ("RENAME".equalsIgnoreCase(command)) {
                            commandOkPhrase = "OK RENAME completed.";
                        } else if ("EXPUNGE".equalsIgnoreCase(command)) {
                            commandOkPhrase = "OK EXPUNGE completed.";
                        } else if ("LIST".equalsIgnoreCase(command)) {
                            commandOkPhrase = "OK LIST completed.";
                        } else if ("SELECT".equalsIgnoreCase(command)) {
                            if (commandWordIndex == 3) {
                                commandOkPhrase = "OK SELECT completed.";
                            } else {
                                commandOkPhrase = "OK " + words[3].toUpperCase(Locale.US) + " SELECT completed.";
                            }
                        } else {
                            commandOkPhrase = null;
                        }
                        if (commandOkPhrase != null) {
                            chompedLine = words[0] + " " + words[1] + " " + commandOkPhrase;
                        }
                    }
                    chompedLine = StringUtils.replace(chompedLine, "\\\\Seen \\\\Draft",
                        "\\\\Draft \\\\Seen");
                    chompedLine = StringUtils.replace(chompedLine, "\\\\Flagged \\\\Deleted",
                        "\\\\Deleted \\\\Flagged");
                    chompedLine = StringUtils.replace(chompedLine, "\\\\Flagged \\\\Draft",
                        "\\\\Draft \\\\Flagged");
                    chompedLine = StringUtils.replace(chompedLine, "\\\\Seen \\\\Recent",
                        "\\\\Recent \\\\Seen");
                    chompedLine = StringUtils.replace(chompedLine, "\\] First unseen\\.",
                        "\\](.)*");
                    if (chompedLine.startsWith("S: \\* OK \\[UIDVALIDITY ")) {
                        chompedLine = "S: \\* OK \\[UIDVALIDITY \\d+\\]";
                    } else if (chompedLine.startsWith("S: \\* OK \\[UIDNEXT")) {
                        chompedLine = "S: \\* OK \\[PERMANENTFLAGS \\(\\\\Answered \\\\Deleted \\\\Draft \\\\Flagged \\\\Seen\\)\\]";
                    }

                    System.out.println(chompedLine);
                }
            }
            lineBuffer.clear();
        }