protected void verifyFormat(String bodyFile, String plainText, String delimiter) {
        final String meta = Srl.substringFirstFront(plainText, delimiter);
        if (!meta.endsWith(LF)) { // also CRLF checked
            throwBodyMetaNoIndependentDelimiterException(bodyFile, plainText);
        }
        final int rearIndex = plainText.indexOf(delimiter) + delimiter.length();
        if (plainText.length() > rearIndex) { // just in case (empty mail possible?)
            final String rearFirstStr = plainText.substring(rearIndex, rearIndex + 1);
            if (!Srl.equalsPlain(rearFirstStr, LF, CR)) { // e.g. >>> Hello, ...
                throwBodyMetaNoIndependentDelimiterException(bodyFile, plainText);
            }
        }
        if (!meta.startsWith(COMMENT_BEGIN)) { // also leading spaces not allowed
            throwBodyMetaNotStartWithHeaderCommentException(bodyFile, plainText, meta);
        }
        if (!meta.contains(COMMENT_END)) {
            throwBodyMetaHeaderCommentEndMarkNotFoundException(bodyFile, plainText, meta);
        }
        final String headerComment = Srl.extractScopeFirst(plainText, COMMENT_BEGIN, COMMENT_END).getContent();
        final ScopeInfo titleScope = Srl.extractScopeFirst(headerComment, TITLE_BEGIN, TITLE_END);
        if (titleScope == null) {
            throwBodyMetaTitleCommentNotFoundException(bodyFile, plainText);
        }
        final String desc = Srl.substringFirstRear(headerComment, TITLE_END);
        if (desc.isEmpty()) {
            throwBodyMetaDescriptionCommentNotFoundException(bodyFile, plainText);
        }
        final String rearMeta = Srl.substringFirstRear(meta, COMMENT_END);
        // no way because of already checked
        //if (!rearMeta.contains(LF)) {
        //}
        final List<String> splitList = Srl.splitList(rearMeta, LF);
        if (!splitList.get(0).trim().isEmpty()) { // after '*/'
            throwBodyMetaHeaderCommentEndMarkNoIndependentException(bodyFile, plainText);
        }
        if (!splitList.get(1).startsWith(SUBJECT_LABEL)) { // also leading spaces not allowed
            throwBodyMetaSubjectNotFoundException(bodyFile, plainText);
        }
        final int nextIndex = 2;
        if (splitList.size() > nextIndex) { // after subject
            final List<String> nextList = splitList.subList(nextIndex, splitList.size());
            final int nextSize = nextList.size();
            int index = 0;
            for (String line : nextList) {
                if (index == nextSize - 1) { // last loop
                    if (line.isEmpty()) { // empty line only allowed in last loop
                        break;
                    }
                }
                if (!allowedPrefixList.stream().anyMatch(prefix -> line.startsWith(prefix))) {
                    throwBodyMetaUnknownLineException(bodyFile, plainText, line);
                }
                if (line.startsWith(OPTION_LABEL)) {
                    final String options = Srl.substringFirstRear(line, OPTION_LABEL);
                    final List<String> optionList = Srl.splitListTrimmed(options, ".");
                    for (String option : optionList) {
                        if (!optionSet.contains(option)) {
                            throwBodyMetaUnknownOptionException(bodyFile, plainText, option);
                        }
                    }
                }
                ++index;
            }
        }
    }
protected void verifyFormat ( String bodyFile , String plainText , String delimiter ) { final String meta = Srl . substringFirstFront ( plainText , delimiter ) ; if ( ! meta . endsWith ( LF ) ) { throwBodyMetaNoIndependentDelimiterException ( bodyFile , plainText ) ; } final int rearIndex = plainText . indexOf ( delimiter ) + delimiter . length ( ) ; if ( plainText . length ( ) > rearIndex ) { final String rearFirstStr = plainText . substring ( rearIndex , rearIndex + 1 ) ; if ( ! Srl . equalsPlain ( rearFirstStr , LF , CR ) ) { throwBodyMetaNoIndependentDelimiterException ( bodyFile , plainText ) ; } } if ( ! meta . startsWith ( COMMENT_BEGIN ) ) { throwBodyMetaNotStartWithHeaderCommentException ( bodyFile , plainText , meta ) ; } if ( ! meta . contains ( COMMENT_END ) ) { throwBodyMetaHeaderCommentEndMarkNotFoundException ( bodyFile , plainText , meta ) ; } final String headerComment = Srl . extractScopeFirst ( plainText , COMMENT_BEGIN , COMMENT_END ) . getContent ( ) ; final ScopeInfo titleScope = Srl . extractScopeFirst ( headerComment , TITLE_BEGIN , TITLE_END ) ; if ( titleScope == null ) { throwBodyMetaTitleCommentNotFoundException ( bodyFile , plainText ) ; } final String desc = Srl . substringFirstRear ( headerComment , TITLE_END ) ; if ( desc . isEmpty ( ) ) { throwBodyMetaDescriptionCommentNotFoundException ( bodyFile , plainText ) ; } final String rearMeta = Srl . substringFirstRear ( meta , COMMENT_END ) ; final List < String > splitList = Srl . splitList ( rearMeta , LF ) ; if ( ! splitList . get ( 0 ) . trim ( ) . isEmpty ( ) ) { throwBodyMetaHeaderCommentEndMarkNoIndependentException ( bodyFile , plainText ) ; } if ( ! splitList . get ( 1 ) . startsWith ( SUBJECT_LABEL ) ) { throwBodyMetaSubjectNotFoundException ( bodyFile , plainText ) ; } final int nextIndex = 2 ; if ( splitList . size ( ) > nextIndex ) { final List < String > nextList = splitList . subList ( nextIndex , splitList . size ( ) ) ; final int nextSize = nextList . size ( ) ; int index = 0 ; for ( String line : nextList ) { if ( index == nextSize - 1 ) { if ( line . isEmpty ( ) ) { break ; } } if ( ! allowedPrefixList . stream ( ) . anyMatch ( prefix -> line . startsWith ( prefix ) ) ) { throwBodyMetaUnknownLineException ( bodyFile , plainText , line ) ; } if ( line . startsWith ( OPTION_LABEL ) ) { final String options = Srl . substringFirstRear ( line , OPTION_LABEL ) ; final List < String > optionList = Srl . splitListTrimmed ( options , "." ) ; for ( String option : optionList ) { if ( ! optionSet . contains ( option ) ) { throwBodyMetaUnknownOptionException ( bodyFile , plainText , option ) ; } } } ++ index ; } } }
=============