class SCCSHistoryParser {

    static final String SCCS_DIR_NAME = "SCCS";

    boolean pass;
    boolean passRecord;
    boolean active;
    int field;
    boolean sep;
    StringBuilder sccsRecord = new StringBuilder(128);
    Reader in;

    // Record fields
    private String revision;
    private Date rdate;
    private String author;
    private String comment;
    private final SCCSRepository repository;

    SCCSHistoryParser(SCCSRepository repository) {
        this.repository = repository;
    }

    History parse(File file) throws HistoryException {
        try {
            return parseFile(file);
        } catch (IOException e) {
            throw new HistoryException(String.format("Failed to get history for '%s'", file.getAbsolutePath()), e);
        } catch (ParseException e) {
            throw new HistoryException(String.format("Failed to parse history for '%s'", file.getAbsolutePath()), e);
        }
    }

    @Nullable
    private History parseFile(File file) throws IOException, ParseException {
        File f = getSCCSFile(file);
        if (f == null) {
            return null;
        }

        in = new BufferedReader(new FileReader(f));
        pass = sep = false;
        passRecord = true;
        active = true;
        field = 0;

        ArrayList<HistoryEntry> entries = new ArrayList<>();
        while (next()) {
            HistoryEntry entry = new HistoryEntry();
            entry.setRevision(getRevision());
            entry.setDate(getDate());
            entry.setAuthor(getAuthor());
            entry.setMessage(getComment());
            entry.setActive(isActive());
            entries.add(entry);
        }

        IOUtils.close(in);

        History history = new History();
        history.setHistoryEntries(entries);
        return history;
    }

    /**
     * Read a single line of delta record into the {@link #sccsRecord} member.
     *
     * @return boolean indicating whether there is another record.
     * @throws IOException on I/O error
     */
    private boolean next() throws IOException {
        sep = true;
        sccsRecord.setLength(0);
        int c;
        while ((c = read()) > 1) {
            sccsRecord.append((char) c);
        }
        // to flag that revision needs to be re populated if you really need it
        revision = null;
        return (sccsRecord.length() > 2);
    }

    /**
     * Split record into fields.
     *
     * @throws ParseException if the date in the record cannot be parsed
     */
    private void initFields() throws ParseException {
        if (revision == null) {
            String[] f = sccsRecord.toString().split(" ", 6);
            if (f.length > 5) {
                revision = f[1];
                try {
                    rdate = repository.parse(f[2] + " " + f[3]);
                } catch (ParseException e) {
                    rdate = null;
                    //
                    // Throw new exception up so that it can be paired with filename
                    // on which the problem occurred.
                    //
                    throw e;
                }
                author = f[4];
                comment = f[5];
            } else {
                rdate = null;
                author = null;
                comment = null;
            }
        }
    }

    /**
     * @return  get the revision string of current log record
     */
    private String getRevision() throws ParseException {
        initFields();
        return revision;
    }

    /**
     * @return  get the date associated with current log record
     */
    private Date getDate() throws ParseException {
        initFields();
        return rdate;
    }

    /**
     * @return  get the author of current log record
     */
    private String getAuthor() throws ParseException {
        initFields();
        return author;
    }
    /**
     * @return  get the comments of current log record
     */
    private String getComment() throws ParseException {
        initFields();
        return comment;
    }

    private boolean isActive() {
        return active;
    }

    private int read() throws IOException {<FILL_FUNCTION_BODY>}

    private static File getSCCSFile(File file) {
        return getSCCSFile(file.getParent(), file.getName());
    }

    @Nullable
    static File getSCCSFile(String parent, String name) {
        File f = Paths.get(parent, SCCS_DIR_NAME, "s." + name).toFile();
        if (!f.exists()) {
            return null;
        }
        return f;
    }
}

        int c, d, dt;
        while ((c = in.read()) != -1) {
            switch (c) { //NOPMD
                case 1:
                    d = in.read();
                    switch (d) {
                        case 'c':
                        case 't':
                        case 'u':
                            d = in.read();
                            if (d != ' ') {
                                return (d);
                            }
                            pass = true;
                            break;
                        case 'd':
                            d = in.read();
                            if (d == ' ') {
                                dt = in.read();
                                active = dt != 'R';
                                passRecord = true;
                                field = 1;
                            } else {
                                return (d);
                            }
                            break;
                        case -1:
                        case 'I':   //the file contents start
                        case 'D':
                        case 'E':
                        case 'T':
                            return -1;
                        case 'e':
                            pass = false;
                            if (sep && passRecord) {
                                return 1;
                            }
                            passRecord = true;
                            break;
                        default:
                            pass = false;
                    }
                    break;
                case ' ':
                    if (passRecord) {
                        if (field > 0) {
                            field++;
                            pass = true;
                        }
                        if (field > 5) {
                            field = 0;
                            pass = false;
                            return c;
                        }
                    }
                default:
                    if (pass && passRecord) {
                        return c;
                    }
            }
        }
        return -1;
    
<no_super_class>