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 classIndexWriterV2.ReferenceEntry(package private) static classIndexWriterV2.ReferenceTable<T>
-
Field Summary
Fields Modifier and Type Field Description private IndexWriterV2.ReferenceTable<AnnotationInstance>annotationTableprivate static intAVALUE_ARRAYprivate static intAVALUE_BOOLEANprivate static intAVALUE_BYTEprivate static intAVALUE_CHARprivate static intAVALUE_CLASSprivate static intAVALUE_DOUBLEprivate static intAVALUE_ENUMprivate static intAVALUE_FLOATprivate static intAVALUE_INTprivate static intAVALUE_LONGprivate static intAVALUE_NESTEDprivate static intAVALUE_SHORTprivate static intAVALUE_STRINGprivate static byteCLASS_EXTENDS_TYPE_TAGprivate static byteCLASS_TAGprivate static byteEMPTY_TYPE_TAGprivate static byteFIELD_TAGprivate static intHAS_ENCLOSING_METHODprivate static intHAS_NESTINGprivate static intMAGIC(package private) static intMAX_VERSIONprivate static byteMETHOD_PARAMETER_TAGprivate static byteMETHOD_PARAMETER_TYPE_TAGprivate static byteMETHOD_TAG(package private) static intMIN_VERSIONprivate NameTablenamesprivate java.util.HashMap<DotName,java.lang.Integer>nameTableprivate static intNO_ENCLOSING_METHODprivate static intNO_NESTINGprivate static byteNULL_TARGET_TAGprivate java.io.OutputStreamoutprivate static byteRECORD_COMPONENT_TAGprivate java.util.TreeMap<java.lang.String,DotName>sortedNameTableprivate static byteTHROWS_TYPE_TAGprivate static byteTYPE_PARAMETER_BOUND_TAGprivate static byteTYPE_PARAMETER_TAGprivate IndexWriterV2.ReferenceTable<Type[]>typeListTableprivate 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 voidaddAnnotation(AnnotationInstance instance)private voidaddAnnotationTarget(AnnotationTarget target)private voidaddClass(ClassInfo clazz)private voidaddClassName(DotName name)private voidaddClassNames(java.util.List<DotName> names)private voidaddEnclosingMethod(ClassInfo.EnclosingMethodInfo enclosingMethod)private voidaddFieldList(FieldInternal[] fields)private voidaddMethodList(MethodInternal[] methods)private voidaddModule(ModuleInfo module)private java.lang.StringaddNullableString(java.lang.String name)private voidaddRecordComponentList(RecordComponentInternal[] recordComponents)private java.lang.StringaddString(java.lang.String name)private voidaddType(Type type)private voidaddTypeList(Type[] types)private voidbuildAValueEntries(AnnotationValue value)private voidbuildTables(Index index, int version)private voiddeepIntern(FieldInternal field)private voiddeepIntern(MethodInternal method)private voiddeepIntern(RecordComponentInternal recordComponent)private booleanmarkWritten(AnnotationInstance annotation)private booleanmarkWritten(Type[] types)private intpositionOf(byte[] bytes)private intpositionOf(java.lang.String string)private intpositionOf(AnnotationInstance instance)private intpositionOf(DotName className)private intpositionOf(FieldInternal field)private intpositionOf(MethodInternal method)private intpositionOf(RecordComponentInternal recordComponent)private intpositionOf(Type type)private intpositionOf(Type[] types)(package private) intwrite(Index index, int version)Writes the specified index to the associated output stream.private voidwriteAnnotation(PackedDataOutputStream stream, AnnotationInstance instance)private voidwriteAnnotationTarget(PackedDataOutputStream stream, AnnotationTarget target)private voidwriteAnnotationValue(PackedDataOutputStream stream, AnnotationValue value)private voidwriteAnnotationValues(PackedDataOutputStream stream, java.util.Collection<AnnotationValue> values)private voidwriteByteTable(PackedDataOutputStream stream)private voidwriteClassEntry(PackedDataOutputStream stream, ClassInfo clazz, int version)private voidwriteClasses(PackedDataOutputStream stream, Index index, int version)private voidwriteDotNames(PackedDataOutputStream stream, java.util.List<DotName> names)private voidwriteFieldEntry(PackedDataOutputStream stream, FieldInternal field)private voidwriteFieldTable(PackedDataOutputStream stream)private voidwriteMethodEntry(PackedDataOutputStream stream, int version, MethodInternal method)private voidwriteMethodTable(PackedDataOutputStream stream, int version)private voidwriteModuleEntry(PackedDataOutputStream stream, ModuleInfo module, int version)private voidwriteModules(PackedDataOutputStream stream, Index index, int version)private voidwriteNameTable(PackedDataOutputStream stream)private voidwriteRecordComponentEntry(PackedDataOutputStream stream, RecordComponentInternal recordComponent)private voidwriteRecordComponentTable(PackedDataOutputStream stream)private voidwriteReference(PackedDataOutputStream stream, AnnotationInstance annotation)private voidwriteReference(PackedDataOutputStream stream, Type type, boolean nullable)private voidwriteReferenceOrFull(PackedDataOutputStream stream, AnnotationInstance annotation)private voidwriteReferenceOrFull(PackedDataOutputStream stream, Type[] types)private voidwriteStringTable(PackedDataOutputStream stream)private voidwriteTypeEntry(PackedDataOutputStream stream, Type type)private voidwriteTypeListEntry(PackedDataOutputStream stream, Type[] types)private voidwriteTypeListTable(PackedDataOutputStream stream)private voidwriteTypeTable(PackedDataOutputStream stream)private voidwriteTypeTarget(PackedDataOutputStream stream, TypeTarget typeTarget)private voidwriteTypeTargetFields(PackedDataOutputStream stream, byte tag, TypeTarget target)private voidwriteUsersSet(PackedDataOutputStream stream, DotName user, java.util.List<ClassInfo> uses)private voidwriteUsersTable(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:
writein 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)
-
-