/** * Returns the index file version. Note that the index file version may increment even though the underlying * data contract remains the same. In most cases, {@link #getDataVersion()} should be used instead of this method, * since applications are typically interested in the underlying contract of the data stored, and not the internal * implementation details of a Jandex index. * * @return the internal index file version * @throws IOException If the index could not be read */ public int getIndexVersion() throws IOException { if (version == -1) { readVersion(); } return version; }
/** * Read the index at the associated stream of this reader. This method can be called multiple * times if the stream contains multiple index files. * * @return the Index contained in the stream * @throws IOException if an I/O error occurs * @throws IllegalArgumentException if the stream does not point to Jandex index data * @throws UnsupportedVersion if the index data is tagged with a version not known to this reader */ public Index read() throws IOException { if (version == -1) { readVersion(); } return reader.read(version); }
/** * Returns the version of the data contract stored in the index that was read. This version is incremented when * the contract adds new information. Generally this is used to determine if the underlying index contains * necessary information for analysis. As an example, generics are recorded in version 4; therefore, a tool that * requires generic data would need to reject/ignore version 3 data. * <br> * The data contract version should not be confused with the index file version, which represents the internal * storage format of the file. The index file version moves independently of the data contract. * * @return The data contract version of the index that was read * @throws IOException If the index could not be read */ public int getDataVersion() throws IOException { if (version == -1) { readVersion(); } return reader.toDataVersion(version); }