Package org.jboss.jandex
Class IndexWriterV2
java.lang.Object
org.jboss.jandex.IndexWriterImpl
org.jboss.jandex.IndexWriterV2
Writes a Jandex index file to a stream. The write process is somewhat more
expensive to allow for fast reads and a compact size. For more information on
the index content, see the documentation on
Indexer
.
The IndexWriter operates on standard output streams, and also provides suitable buffering.
Thread-Safety
IndexWriter is not thread-safe and can not be shared between concurrent threads.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final byte
private static final byte
private static final byte
private static final byte
private static final int
private static final int
private static final int
(package private) static final int
private static final byte
private static final byte
private static final byte
(package private) static final int
private NameTable
private static final int
private static final int
private static final byte
private final OutputStream
private static final byte
private static final byte
private static final byte
private static final byte
private IndexWriterV2.ReferenceTable
<Type[]> private IndexWriterV2.ReferenceTable
<Type> private final int
-
Constructor Summary
ConstructorsConstructorDescriptionIndexWriterV2
(OutputStream out, int version) Constructs an IndexWriter using the specified stream -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addAnnotation
(AnnotationInstance instance) private void
addAnnotationTarget
(AnnotationTarget target) private void
private void
addClassName
(DotName name) private void
addClassNames
(List<DotName> names) private void
addEnclosingMethod
(ClassInfo.EnclosingMethodInfo enclosingMethod) private void
addFieldList
(FieldInternal[] fields) private void
addMethodList
(MethodInternal[] methods) private void
addModule
(ModuleInfo module) private String
addNullableString
(String name) private void
addRecordComponentList
(RecordComponentInternal[] recordComponents) private String
private void
private void
addTypeList
(Type[] types) private void
private void
buildTables
(Index index) private void
deepIntern
(FieldInternal field) private void
deepIntern
(MethodInternal method) private void
deepIntern
(RecordComponentInternal recordComponent) private boolean
markWritten
(AnnotationInstance annotation) private boolean
markWritten
(Type[] types) private int
positionOf
(byte[] bytes) private int
positionOf
(String string) private int
positionOf
(AnnotationInstance instance) private int
positionOf
(DotName className) private int
positionOf
(FieldInternal field) private int
positionOf
(MethodInternal method) private int
positionOf
(RecordComponentInternal recordComponent) private int
positionOf
(Type type) private int
positionOf
(Type[] types) (package private) int
Writes the specified index to the associated output stream.private void
writeAnnotation
(PackedDataOutputStream stream, AnnotationInstance instance) private void
writeAnnotations
(PackedDataOutputStream stream, Collection<AnnotationInstance> annotations) private void
writeAnnotations
(PackedDataOutputStream stream, AnnotationInstance[] annotations) private void
writeAnnotationTarget
(PackedDataOutputStream stream, AnnotationTarget target) private void
writeAnnotationValue
(PackedDataOutputStream stream, AnnotationValue value) private void
writeAnnotationValues
(PackedDataOutputStream stream, Collection<AnnotationValue> values) private void
writeByteTable
(PackedDataOutputStream stream) private void
writeClassEntry
(PackedDataOutputStream stream, ClassInfo clazz) private void
writeClasses
(PackedDataOutputStream stream, Index index) private void
writeDotNames
(PackedDataOutputStream stream, List<DotName> names) private void
writeFieldEntry
(PackedDataOutputStream stream, FieldInternal field) private void
private void
writeMethodEntry
(PackedDataOutputStream stream, MethodInternal method) private void
private void
writeModuleEntry
(PackedDataOutputStream stream, ModuleInfo module) private void
writeModules
(PackedDataOutputStream stream, Index index) private void
writeNameTable
(PackedDataOutputStream stream) private void
writeRecordComponentEntry
(PackedDataOutputStream stream, RecordComponentInternal recordComponent) private void
private void
writeReference
(PackedDataOutputStream stream, Type type, boolean nullable) private void
writeReferenceOrFull
(PackedDataOutputStream stream, AnnotationInstance annotation) private void
writeReferenceOrFull
(PackedDataOutputStream stream, Type[] types) private void
private void
writeTypeEntry
(PackedDataOutputStream stream, Type type) private void
writeTypeListEntry
(PackedDataOutputStream stream, Type[] types) private void
private void
writeTypeTable
(PackedDataOutputStream stream) private void
writeTypeTarget
(PackedDataOutputStream stream, TypeTarget typeTarget) private void
writeTypeTargetFields
(PackedDataOutputStream stream, byte tag, TypeTarget target) private void
writeUsersSet
(PackedDataOutputStream stream, DotName user, ClassInfo[] uses) private void
writeUsersTable
(PackedDataOutputStream stream, Map<DotName, ClassInfo[]> users)
-
Field Details
-
MIN_VERSION
static final int MIN_VERSION- See Also:
-
MAX_VERSION
static final int MAX_VERSION- See Also:
-
MAGIC
private static final int MAGIC- See Also:
-
NULL_TARGET_TAG
private static final byte NULL_TARGET_TAG- See Also:
-
FIELD_TAG
private static final byte FIELD_TAG- See Also:
-
METHOD_TAG
private static final byte METHOD_TAG- See Also:
-
METHOD_PARAMETER_TAG
private static final byte METHOD_PARAMETER_TAG- See Also:
-
CLASS_TAG
private static final byte CLASS_TAG- See Also:
-
EMPTY_TYPE_TAG
private static final byte EMPTY_TYPE_TAG- See Also:
-
CLASS_EXTENDS_TYPE_TAG
private static final byte CLASS_EXTENDS_TYPE_TAG- See Also:
-
TYPE_PARAMETER_TAG
private static final byte TYPE_PARAMETER_TAG- See Also:
-
TYPE_PARAMETER_BOUND_TAG
private static final byte TYPE_PARAMETER_BOUND_TAG- See Also:
-
METHOD_PARAMETER_TYPE_TAG
private static final byte METHOD_PARAMETER_TYPE_TAG- See Also:
-
THROWS_TYPE_TAG
private static final byte THROWS_TYPE_TAG- See Also:
-
RECORD_COMPONENT_TAG
private static final byte RECORD_COMPONENT_TAG- See Also:
-
AVALUE_BYTE
private static final int AVALUE_BYTE- See Also:
-
AVALUE_SHORT
private static final int AVALUE_SHORT- See Also:
-
AVALUE_INT
private static final int AVALUE_INT- See Also:
-
AVALUE_CHAR
private static final int AVALUE_CHAR- See Also:
-
AVALUE_FLOAT
private static final int AVALUE_FLOAT- See Also:
-
AVALUE_DOUBLE
private static final int AVALUE_DOUBLE- See Also:
-
AVALUE_LONG
private static final int AVALUE_LONG- See Also:
-
AVALUE_BOOLEAN
private static final int AVALUE_BOOLEAN- See Also:
-
AVALUE_STRING
private static final int AVALUE_STRING- See Also:
-
AVALUE_CLASS
private static final int AVALUE_CLASS- See Also:
-
AVALUE_ENUM
private static final int AVALUE_ENUM- See Also:
-
AVALUE_ARRAY
private static final int AVALUE_ARRAY- See Also:
-
AVALUE_NESTED
private static final int AVALUE_NESTED- See Also:
-
HAS_ENCLOSING_METHOD
private static final int HAS_ENCLOSING_METHOD- See Also:
-
NO_ENCLOSING_METHOD
private static final int NO_ENCLOSING_METHOD- See Also:
-
NO_NESTING
private static final int NO_NESTING- See Also:
-
HAS_NESTING
private static final int HAS_NESTING- See Also:
-
out
-
version
private final int version -
names
-
nameTable
-
sortedNameTable
-
annotationTable
-
typeTable
-
typeListTable
-
-
Constructor Details
-
IndexWriterV2
IndexWriterV2(OutputStream out, int version) Constructs an IndexWriter using the specified stream- Parameters:
out
- a stream to write an index to
-
-
Method Details
-
write
Writes the specified index to the associated output stream. This may be called multiple times in order to write multiple indexes.- Specified by:
write
in classIndexWriterImpl
- Parameters:
index
- the index to write to the streamversion
- the index file version- Returns:
- the number of bytes written to the stream
- Throws:
IOException
- if any i/o error occurs
-
writeUsersTable
private void writeUsersTable(PackedDataOutputStream stream, Map<DotName, ClassInfo[]> users) throws IOException- Throws:
IOException
-
writeUsersSet
private void writeUsersSet(PackedDataOutputStream stream, DotName user, ClassInfo[] uses) throws IOException - Throws:
IOException
-
writeStringTable
- Throws:
IOException
-
writeByteTable
- Throws:
IOException
-
writeTypeTable
- Throws:
IOException
-
writeTypeListTable
- Throws:
IOException
-
writeTypeListEntry
- Throws:
IOException
-
writeMethodTable
- Throws:
IOException
-
writeFieldTable
- Throws:
IOException
-
writeRecordComponentTable
- Throws:
IOException
-
writeFieldEntry
- Throws:
IOException
-
writeRecordComponentEntry
private void writeRecordComponentEntry(PackedDataOutputStream stream, RecordComponentInternal recordComponent) throws IOException - Throws:
IOException
-
writeMethodEntry
private void writeMethodEntry(PackedDataOutputStream stream, MethodInternal method) throws IOException - Throws:
IOException
-
writeAnnotation
private void writeAnnotation(PackedDataOutputStream stream, AnnotationInstance instance) throws IOException - Throws:
IOException
-
writeAnnotationTarget
private void writeAnnotationTarget(PackedDataOutputStream stream, AnnotationTarget target) throws IOException - Throws:
IOException
-
writeTypeTarget
private void writeTypeTarget(PackedDataOutputStream stream, TypeTarget typeTarget) throws IOException - Throws:
IOException
-
writeTypeTargetFields
private void writeTypeTargetFields(PackedDataOutputStream stream, byte tag, TypeTarget target) throws IOException - Throws:
IOException
-
writeNameTable
- Throws:
IOException
-
positionOf
-
positionOf
private int positionOf(byte[] bytes) -
positionOf
-
positionOf
-
positionOf
-
positionOf
-
positionOf
-
positionOf
-
positionOf
-
markWritten
-
markWritten
-
writeClasses
- Throws:
IOException
-
writeModules
- Throws:
IOException
-
writeClassEntry
- Throws:
IOException
-
writeModuleEntry
- Throws:
IOException
-
writeDotNames
- Throws:
IOException
-
writeAnnotationValues
private void writeAnnotationValues(PackedDataOutputStream stream, Collection<AnnotationValue> values) throws IOException - Throws:
IOException
-
writeAnnotationValue
private void writeAnnotationValue(PackedDataOutputStream stream, AnnotationValue value) throws IOException - Throws:
IOException
-
writeReference
private void writeReference(PackedDataOutputStream stream, Type type, boolean nullable) throws IOException - Throws:
IOException
-
writeAnnotations
private void writeAnnotations(PackedDataOutputStream stream, AnnotationInstance[] annotations) throws IOException - Throws:
IOException
-
writeAnnotations
private void writeAnnotations(PackedDataOutputStream stream, Collection<AnnotationInstance> annotations) throws IOException - Throws:
IOException
-
writeReferenceOrFull
private void writeReferenceOrFull(PackedDataOutputStream stream, AnnotationInstance annotation) throws IOException - Throws:
IOException
-
writeReferenceOrFull
- Throws:
IOException
-
writeTypeEntry
- Throws:
IOException
-
buildTables
-
addClass
-
addModule
-
addAnnotation
-
addAnnotationTarget
-
addFieldList
-
deepIntern
-
addMethodList
-
deepIntern
-
addRecordComponentList
-
deepIntern
-
addEnclosingMethod
-
addTypeList
-
addType
-
buildAValueEntries
-
addNullableString
-
addString
-
addClassNames
-
addClassName
-