Package org.jboss.jandex
Class IndexReader
java.lang.Object
org.jboss.jandex.IndexReader
Reads a Jandex index file and returns the saved index. See
Indexer
for a thorough description of how the Index data is produced.
An IndexReader loads the stream passed to it's constructor and applies the appropriate buffering. The Jandex index format is designed for efficient reading and low final memory storage.
Thread-Safety
IndexReader is not thread-safe and can not be shared between concurrent threads. The resulting index, however, is.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PackedDataInputStream
private static final int
The latest index version supported by this version of Jandex.private IndexReaderImpl
private int
-
Constructor Summary
ConstructorsConstructorDescriptionIndexReader
(InputStream input) Constructs a new IndedReader using the passed stream. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the version of the data contract stored in the index that was read.int
Returns the index file version.private void
initReader
(int version) read()
Read the index at the associated stream of this reader.private void
-
Field Details
-
MAGIC
private static final int MAGICThe latest index version supported by this version of Jandex.- See Also:
-
input
-
version
private int version -
reader
-
-
Constructor Details
-
IndexReader
Constructs a new IndedReader using the passed stream. The stream is not read from until the read method is called.- Parameters:
input
- a stream which points to a jandex index file
-
-
Method Details
-
read
Read the index at the associated stream of this reader. This method can be called multiple times if the stream contains multiple index files.- Returns:
- the Index contained in the stream
- Throws:
IOException
- if an I/O error occursIllegalArgumentException
- if the stream does not point to Jandex index dataUnsupportedVersion
- if the index data is tagged with a version not known to this reader
-
initReader
- Throws:
IOException
-
getDataVersion
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.
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.- Returns:
- The data contract version of the index that was read
- Throws:
IOException
- If the index could not be read
-
getIndexVersion
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,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.- Returns:
- the internal index file version
- Throws:
IOException
- If the index could not be read
-
readVersion
- Throws:
IOException
-