private void nextBlock()

in doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptParser.java [1059:1199]


    private void nextBlock(boolean firstBlock) throws AptParseException {
        // Skip open lines.
        int length, indent, i;

        skipLoop:
        for (; ; ) {
            if (line == null) {
                block = null;
                return;
            }

            length = line.length();
            indent = 0;
            for (i = 0; i < length; ++i) {
                switch (line.charAt(i)) {
                    case SPACE:
                        ++indent;
                        break;
                    case TAB:
                        indent += 8;
                        break;
                    default:
                        break skipLoop;
                }
            }

            if (i == length) {
                nextLine();
            }
        }

        blockFileName = source.getName();
        blockLineNumber = source.getLineNumber();
        block = null;
        switch (line.charAt(i)) {
            case STAR:
                if (indent == 0) {
                    if (charAt(line, length, i + 1) == MINUS && charAt(line, length, i + 2) == MINUS) {
                        block = new Table(indent, line);
                    } else if (charAt(line, length, i + 1) == STAR) {
                        if (charAt(line, length, i + 2) == STAR) {
                            if (charAt(line, length, i + 3) == STAR) {
                                block = new Section5(indent, line);
                            } else {
                                block = new Section4(indent, line);
                            }
                        } else {
                            block = new Section3(indent, line);
                        }
                    } else {
                        block = new Section2(indent, line);
                    }
                } else {
                    block = new ListItem(indent, line);
                }
                break;
            case LEFT_SQUARE_BRACKET:
                if (charAt(line, length, i + 1) == RIGHT_SQUARE_BRACKET) {
                    block = new ListBreak(indent, line);
                } else {
                    if (indent == 0) {
                        block = new Figure(indent, line);
                    } else {
                        if (charAt(line, length, i + 1) == LEFT_SQUARE_BRACKET) {
                            int numbering;

                            switch (charAt(line, length, i + 2)) {
                                case NUMBERING_LOWER_ALPHA_CHAR:
                                    numbering = Sink.NUMBERING_LOWER_ALPHA;
                                    break;
                                case NUMBERING_UPPER_ALPHA_CHAR:
                                    numbering = Sink.NUMBERING_UPPER_ALPHA;
                                    break;
                                case NUMBERING_LOWER_ROMAN_CHAR:
                                    numbering = Sink.NUMBERING_LOWER_ROMAN;
                                    break;
                                case NUMBERING_UPPER_ROMAN_CHAR:
                                    numbering = Sink.NUMBERING_UPPER_ROMAN;
                                    break;
                                case NUMBERING:
                                default:
                                    // The first item establishes the numbering
                                    // scheme for the whole list.
                                    numbering = Sink.NUMBERING_DECIMAL;
                            }

                            block = new NumberedListItem(indent, line, numbering);
                        } else {
                            block = new DefinitionListItem(indent, line);
                        }
                    }
                }
                break;
            case MINUS:
                if (charAt(line, length, i + 1) == MINUS && charAt(line, length, i + 2) == MINUS) {
                    if (indent == 0) {
                        block = new Verbatim(indent, line);
                    } else {
                        if (firstBlock) {
                            block = new Title(indent, line);
                        }
                    }
                }
                break;
            case PLUS:
                if (indent == 0 && charAt(line, length, i + 1) == MINUS && charAt(line, length, i + 2) == MINUS) {
                    block = new Verbatim(indent, line);
                }
                break;
            case EQUAL:
                if (indent == 0 && charAt(line, length, i + 1) == EQUAL && charAt(line, length, i + 2) == EQUAL) {
                    block = new HorizontalRule(indent, line);
                }
                break;
            case PAGE_BREAK:
                if (indent == 0) {
                    block = new PageBreak(indent, line);
                }
                break;
            case PERCENT:
                if (indent == 0 && charAt(line, length, i + 1) == LEFT_CURLY_BRACKET) {
                    block = new MacroBlock(indent, line);
                }
                break;
            case COMMENT:
                if (charAt(line, length, i + 1) == COMMENT) {
                    block = new Comment(line.substring(i + 2));
                }
                break;
            default:
                break;
        }

        if (block == null) {
            if (indent == 0) {
                block = new Section1(indent, line);
            } else {
                block = new Paragraph(indent, line);
            }
        }
    }