public int read()

in enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/checksum/NormalizeLineSeparatorReader.java [108:146]


    public int read() throws IOException {
        // spool buffered characters, if any
        if (bufferedCharacter != null) {
            char localBuffer = bufferedCharacter;
            bufferedCharacter = null;
            return localBuffer;
        }
        int readResult = super.read();
        if (readResult == EOL) {
            return readResult;
        }
        char currentCharacter = (char) readResult;
        if (lineSeparator == LineSeparator.UNIX) {
            switch (LineSeparator.WINDOWS.matches(currentCharacter, previousCharacter)) {
                case MATCH:
                    return lineSeparator.separatorChars[0];
                case POTENTIAL_MATCH:
                    previousCharacter = currentCharacter;
                    return read();
                default:
                    // fall-through
            }
        } else { // WINDOWS
            // if current is unix, convert
            switch (LineSeparator.UNIX.matches(currentCharacter, previousCharacter)) {
                case MATCH:
                    bufferedCharacter = lineSeparator.separatorChars[1];
                    // set buffered character and return current
                    return lineSeparator.separatorChars[0];
                case POTENTIAL_MATCH:
                    // invalid option
                    throw new IllegalStateException("No potential matches expected for Unix line separator");
                default:
                    // fall-through
            }
        }
        previousCharacter = currentCharacter;
        return currentCharacter;
    }