Package org.jboss.jandex
Class IndexWriterV2
- java.lang.Object
-
- org.jboss.jandex.IndexWriterImpl
-
- org.jboss.jandex.IndexWriterV2
-
final class IndexWriterV2 extends IndexWriterImpl
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 onIndexer
.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
IndexWriterV2.ReferenceEntry
(package private) static class
IndexWriterV2.ReferenceTable<T>
-
Field Summary
Fields Modifier and Type Field Description private IndexWriterV2.ReferenceTable<AnnotationInstance>
annotationTable
private static int
AVALUE_ARRAY
private static int
AVALUE_BOOLEAN
private static int
AVALUE_BYTE
private static int
AVALUE_CHAR
private static int
AVALUE_CLASS
private static int
AVALUE_DOUBLE
private static int
AVALUE_ENUM
private static int
AVALUE_FLOAT
private static int
AVALUE_INT
private static int
AVALUE_LONG
private static int
AVALUE_NESTED
private static int
AVALUE_SHORT
private static int
AVALUE_STRING
private static byte
CLASS_EXTENDS_TYPE_TAG
private static byte
CLASS_TAG
private static byte
EMPTY_TYPE_TAG
private static byte
FIELD_TAG
private static int
HAS_ENCLOSING_METHOD
private static int
HAS_NESTING
private static int
MAGIC
(package private) static int
MAX_VERSION
private static byte
METHOD_PARAMETER_TAG
private static byte
METHOD_PARAMETER_TYPE_TAG
private static byte
METHOD_TAG
(package private) static int
MIN_VERSION
private NameTable
names
private java.util.HashMap<DotName,java.lang.Integer>
nameTable
private static int
NO_ENCLOSING_METHOD
private static int
NO_NESTING
private static byte
NULL_TARGET_TAG
private java.io.OutputStream
out
private static byte
RECORD_COMPONENT_TAG
private java.util.TreeMap<java.lang.String,DotName>
sortedNameTable
private static byte
THROWS_TYPE_TAG
private static byte
TYPE_PARAMETER_BOUND_TAG
private static byte
TYPE_PARAMETER_TAG
private IndexWriterV2.ReferenceTable<Type[]>
typeListTable
private IndexWriterV2.ReferenceTable<Type>
typeTable
-
Constructor Summary
Constructors Constructor Description IndexWriterV2(java.io.OutputStream out)
Constructs an IndexWriter using the specified stream
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addAnnotation(AnnotationInstance instance)
private void
addAnnotationTarget(AnnotationTarget target)
private void
addClass(ClassInfo clazz)
private void
addClassName(DotName name)
private void
addClassNames(java.util.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 java.lang.String
addNullableString(java.lang.String name)
private void
addRecordComponentList(RecordComponentInternal[] recordComponents)
private java.lang.String
addString(java.lang.String name)
private void
addType(Type type)
private void
addTypeList(Type[] types)
private void
buildAValueEntries(AnnotationValue value)
private void
buildTables(Index index, int version)
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(java.lang.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
write(Index index, int version)
Writes the specified index to the associated output stream.private void
writeAnnotation(PackedDataOutputStream stream, AnnotationInstance instance)
private void
writeAnnotationTarget(PackedDataOutputStream stream, AnnotationTarget target)
private void
writeAnnotationValue(PackedDataOutputStream stream, AnnotationValue value)
private void
writeAnnotationValues(PackedDataOutputStream stream, java.util.Collection<AnnotationValue> values)
private void
writeByteTable(PackedDataOutputStream stream)
private void
writeClassEntry(PackedDataOutputStream stream, ClassInfo clazz, int version)
private void
writeClasses(PackedDataOutputStream stream, Index index, int version)
private void
writeDotNames(PackedDataOutputStream stream, java.util.List<DotName> names)
private void
writeFieldEntry(PackedDataOutputStream stream, FieldInternal field)
private void
writeFieldTable(PackedDataOutputStream stream)
private void
writeMethodEntry(PackedDataOutputStream stream, int version, MethodInternal method)
private void
writeMethodTable(PackedDataOutputStream stream, int version)
private void
writeModuleEntry(PackedDataOutputStream stream, ModuleInfo module, int version)
private void
writeModules(PackedDataOutputStream stream, Index index, int version)
private void
writeNameTable(PackedDataOutputStream stream)
private void
writeRecordComponentEntry(PackedDataOutputStream stream, RecordComponentInternal recordComponent)
private void
writeRecordComponentTable(PackedDataOutputStream stream)
private void
writeReference(PackedDataOutputStream stream, AnnotationInstance annotation)
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
writeStringTable(PackedDataOutputStream stream)
private void
writeTypeEntry(PackedDataOutputStream stream, Type type)
private void
writeTypeListEntry(PackedDataOutputStream stream, Type[] types)
private void
writeTypeListTable(PackedDataOutputStream stream)
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, java.util.List<ClassInfo> uses)
private void
writeUsersTable(PackedDataOutputStream stream, java.util.Map<DotName,java.util.List<ClassInfo>> users)
-
-
-
Field Detail
-
MIN_VERSION
static final int MIN_VERSION
- See Also:
- Constant Field Values
-
MAX_VERSION
static final int MAX_VERSION
- See Also:
- Constant Field Values
-
MAGIC
private static final int MAGIC
- See Also:
- Constant Field Values
-
NULL_TARGET_TAG
private static final byte NULL_TARGET_TAG
- See Also:
- Constant Field Values
-
FIELD_TAG
private static final byte FIELD_TAG
- See Also:
- Constant Field Values
-
METHOD_TAG
private static final byte METHOD_TAG
- See Also:
- Constant Field Values
-
METHOD_PARAMETER_TAG
private static final byte METHOD_PARAMETER_TAG
- See Also:
- Constant Field Values
-
CLASS_TAG
private static final byte CLASS_TAG
- See Also:
- Constant Field Values
-
EMPTY_TYPE_TAG
private static final byte EMPTY_TYPE_TAG
- See Also:
- Constant Field Values
-
CLASS_EXTENDS_TYPE_TAG
private static final byte CLASS_EXTENDS_TYPE_TAG
- See Also:
- Constant Field Values
-
TYPE_PARAMETER_TAG
private static final byte TYPE_PARAMETER_TAG
- See Also:
- Constant Field Values
-
TYPE_PARAMETER_BOUND_TAG
private static final byte TYPE_PARAMETER_BOUND_TAG
- See Also:
- Constant Field Values
-
METHOD_PARAMETER_TYPE_TAG
private static final byte METHOD_PARAMETER_TYPE_TAG
- See Also:
- Constant Field Values
-
THROWS_TYPE_TAG
private static final byte THROWS_TYPE_TAG
- See Also:
- Constant Field Values
-
RECORD_COMPONENT_TAG
private static final byte RECORD_COMPONENT_TAG
- See Also:
- Constant Field Values
-
AVALUE_BYTE
private static final int AVALUE_BYTE
- See Also:
- Constant Field Values
-
AVALUE_SHORT
private static final int AVALUE_SHORT
- See Also:
- Constant Field Values
-
AVALUE_INT
private static final int AVALUE_INT
- See Also:
- Constant Field Values
-
AVALUE_CHAR
private static final int AVALUE_CHAR
- See Also:
- Constant Field Values
-
AVALUE_FLOAT
private static final int AVALUE_FLOAT
- See Also:
- Constant Field Values
-
AVALUE_DOUBLE
private static final int AVALUE_DOUBLE
- See Also:
- Constant Field Values
-
AVALUE_LONG
private static final int AVALUE_LONG
- See Also:
- Constant Field Values
-
AVALUE_BOOLEAN
private static final int AVALUE_BOOLEAN
- See Also:
- Constant Field Values
-
AVALUE_STRING
private static final int AVALUE_STRING
- See Also:
- Constant Field Values
-
AVALUE_CLASS
private static final int AVALUE_CLASS
- See Also:
- Constant Field Values
-
AVALUE_ENUM
private static final int AVALUE_ENUM
- See Also:
- Constant Field Values
-
AVALUE_ARRAY
private static final int AVALUE_ARRAY
- See Also:
- Constant Field Values
-
AVALUE_NESTED
private static final int AVALUE_NESTED
- See Also:
- Constant Field Values
-
HAS_ENCLOSING_METHOD
private static final int HAS_ENCLOSING_METHOD
- See Also:
- Constant Field Values
-
NO_ENCLOSING_METHOD
private static final int NO_ENCLOSING_METHOD
- See Also:
- Constant Field Values
-
NO_NESTING
private static final int NO_NESTING
- See Also:
- Constant Field Values
-
HAS_NESTING
private static final int HAS_NESTING
- See Also:
- Constant Field Values
-
out
private final java.io.OutputStream out
-
names
private NameTable names
-
nameTable
private java.util.HashMap<DotName,java.lang.Integer> nameTable
-
sortedNameTable
private java.util.TreeMap<java.lang.String,DotName> sortedNameTable
-
annotationTable
private IndexWriterV2.ReferenceTable<AnnotationInstance> annotationTable
-
typeTable
private IndexWriterV2.ReferenceTable<Type> typeTable
-
typeListTable
private IndexWriterV2.ReferenceTable<Type[]> typeListTable
-
-
Method Detail
-
write
int write(Index index, int version) throws java.io.IOException
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:
java.io.IOException
- if any i/o error occurs
-
writeUsersTable
private void writeUsersTable(PackedDataOutputStream stream, java.util.Map<DotName,java.util.List<ClassInfo>> users) throws java.io.IOException
- Throws:
java.io.IOException
-
writeUsersSet
private void writeUsersSet(PackedDataOutputStream stream, DotName user, java.util.List<ClassInfo> uses) throws java.io.IOException
- Throws:
java.io.IOException
-
writeStringTable
private void writeStringTable(PackedDataOutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeByteTable
private void writeByteTable(PackedDataOutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTypeTable
private void writeTypeTable(PackedDataOutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTypeListTable
private void writeTypeListTable(PackedDataOutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTypeListEntry
private void writeTypeListEntry(PackedDataOutputStream stream, Type[] types) throws java.io.IOException
- Throws:
java.io.IOException
-
writeMethodTable
private void writeMethodTable(PackedDataOutputStream stream, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFieldTable
private void writeFieldTable(PackedDataOutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeRecordComponentTable
private void writeRecordComponentTable(PackedDataOutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFieldEntry
private void writeFieldEntry(PackedDataOutputStream stream, FieldInternal field) throws java.io.IOException
- Throws:
java.io.IOException
-
writeRecordComponentEntry
private void writeRecordComponentEntry(PackedDataOutputStream stream, RecordComponentInternal recordComponent) throws java.io.IOException
- Throws:
java.io.IOException
-
writeMethodEntry
private void writeMethodEntry(PackedDataOutputStream stream, int version, MethodInternal method) throws java.io.IOException
- Throws:
java.io.IOException
-
writeAnnotation
private void writeAnnotation(PackedDataOutputStream stream, AnnotationInstance instance) throws java.io.IOException
- Throws:
java.io.IOException
-
writeAnnotationTarget
private void writeAnnotationTarget(PackedDataOutputStream stream, AnnotationTarget target) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTypeTarget
private void writeTypeTarget(PackedDataOutputStream stream, TypeTarget typeTarget) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTypeTargetFields
private void writeTypeTargetFields(PackedDataOutputStream stream, byte tag, TypeTarget target) throws java.io.IOException
- Throws:
java.io.IOException
-
writeNameTable
private void writeNameTable(PackedDataOutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
positionOf
private int positionOf(java.lang.String string)
-
positionOf
private int positionOf(byte[] bytes)
-
positionOf
private int positionOf(MethodInternal method)
-
positionOf
private int positionOf(FieldInternal field)
-
positionOf
private int positionOf(RecordComponentInternal recordComponent)
-
positionOf
private int positionOf(DotName className)
-
positionOf
private int positionOf(Type type)
-
positionOf
private int positionOf(Type[] types)
-
positionOf
private int positionOf(AnnotationInstance instance)
-
markWritten
private boolean markWritten(Type[] types)
-
markWritten
private boolean markWritten(AnnotationInstance annotation)
-
writeClasses
private void writeClasses(PackedDataOutputStream stream, Index index, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
writeModules
private void writeModules(PackedDataOutputStream stream, Index index, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
writeClassEntry
private void writeClassEntry(PackedDataOutputStream stream, ClassInfo clazz, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
writeModuleEntry
private void writeModuleEntry(PackedDataOutputStream stream, ModuleInfo module, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
writeDotNames
private void writeDotNames(PackedDataOutputStream stream, java.util.List<DotName> names) throws java.io.IOException
- Throws:
java.io.IOException
-
writeAnnotationValues
private void writeAnnotationValues(PackedDataOutputStream stream, java.util.Collection<AnnotationValue> values) throws java.io.IOException
- Throws:
java.io.IOException
-
writeAnnotationValue
private void writeAnnotationValue(PackedDataOutputStream stream, AnnotationValue value) throws java.io.IOException
- Throws:
java.io.IOException
-
writeReference
private void writeReference(PackedDataOutputStream stream, Type type, boolean nullable) throws java.io.IOException
- Throws:
java.io.IOException
-
writeReferenceOrFull
private void writeReferenceOrFull(PackedDataOutputStream stream, AnnotationInstance annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
writeReference
private void writeReference(PackedDataOutputStream stream, AnnotationInstance annotation) throws java.io.IOException
- Throws:
java.io.IOException
-
writeReferenceOrFull
private void writeReferenceOrFull(PackedDataOutputStream stream, Type[] types) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTypeEntry
private void writeTypeEntry(PackedDataOutputStream stream, Type type) throws java.io.IOException
- Throws:
java.io.IOException
-
buildTables
private void buildTables(Index index, int version)
-
addClass
private void addClass(ClassInfo clazz)
-
addModule
private void addModule(ModuleInfo module)
-
addAnnotation
private void addAnnotation(AnnotationInstance instance)
-
addAnnotationTarget
private void addAnnotationTarget(AnnotationTarget target)
-
addFieldList
private void addFieldList(FieldInternal[] fields)
-
deepIntern
private void deepIntern(FieldInternal field)
-
addMethodList
private void addMethodList(MethodInternal[] methods)
-
deepIntern
private void deepIntern(MethodInternal method)
-
addRecordComponentList
private void addRecordComponentList(RecordComponentInternal[] recordComponents)
-
deepIntern
private void deepIntern(RecordComponentInternal recordComponent)
-
addEnclosingMethod
private void addEnclosingMethod(ClassInfo.EnclosingMethodInfo enclosingMethod)
-
addTypeList
private void addTypeList(Type[] types)
-
addType
private void addType(Type type)
-
buildAValueEntries
private void buildAValueEntries(AnnotationValue value)
-
addNullableString
private java.lang.String addNullableString(java.lang.String name)
-
addString
private java.lang.String addString(java.lang.String name)
-
addClassNames
private void addClassNames(java.util.List<DotName> names)
-
addClassName
private void addClassName(DotName name)
-
-