Hi @bcazabonne and @luc ,
About the missing “EOF
”, is that OK if we just check the number of epochs?
That is, if “pi.nbEpochs == pi.file.getNumberOfEpochs()
” means the file is OK, regardless of EOF
exists or not.
// initialize internal data structures
final ParseInfo pi = new ParseInfo();
int lineNumber = 0;
Stream<LineParser> candidateParsers = Stream.of(LineParser.HEADER_VERSION);
for (String line = br.readLine(); line != null; line = br.readLine()) {
++lineNumber;
final String l = line;
final Optional<LineParser> selected = candidateParsers.filter(p -> p.canHandle(l)).findFirst();
if (selected.isPresent()) {
try {
selected.get().parse(line, pi);
} catch (StringIndexOutOfBoundsException | NumberFormatException e) {
throw new OrekitException(e,
OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE,
lineNumber, source.getName(), line);
}
candidateParsers = selected.get().allowedNext();
} else {
throw new OrekitException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE,
lineNumber, source.getName(), line);
}
if (pi.done) {
if (pi.nbEpochs != pi.file.getNumberOfEpochs()) {
throw new OrekitException(OrekitMessages.SP3_NUMBER_OF_EPOCH_MISMATCH,
pi.nbEpochs, source.getName(), pi.file.getNumberOfEpochs());
}
return pi.file;
}
}
// we never reached the EOF marker
throw new OrekitException(OrekitMessages.SP3_UNEXPECTED_END_OF_FILE, lineNumber);