protected Object doBody(String segmentsFile) throws CorruptIndexException,
IOException {
FormatDetails res = new FormatDetails();
res.capabilities = "unknown";
res.genericName = "unknown";
IndexInput in = dir.openInput(segmentsFile, IOContext.READ);
try {
int indexFormat = in.readInt();
if (indexFormat == CodecUtil.CODEC_MAGIC) {
res.genericName = "Lucene 4.x";
res.capabilities = "flexible, codec-specific";
int actualVersion = SegmentInfos.VERSION_40;
try {
actualVersion = CodecUtil.checkHeaderNoMagic(in, "segments", SegmentInfos.VERSION_40, Integer.MAX_VALUE);
if (actualVersion > SegmentInfos.VERSION_49) {
res.capabilities += " (WARNING: newer version of Lucene than this tool)";
}
} catch (Exception e) {
e.printStackTrace();
res.capabilities += " (error reading: " + e.getMessage() + ")";
}
res.genericName = "Lucene 4.x, segment ver.:" + actualVersion;
res.version = "4." + actualVersion;
} else {
res.genericName = "Lucene 3.x or prior";
detectOldFormats(res, indexFormat);
if (res.version.compareTo("3") < 0) {
res.capabilities = res.capabilities + " (UNSUPPORTED)";
}
}
} finally {
in.close();
}
return res;
}
};
return (FormatDetails)fsf.run();