Class MemoryMappingTree
- All Implemented Interfaces:
MappingVisitor, MappingTree, MappingTreeView, VisitableMappingTree
VisitableMappingTree implementation that stores all data in memory.
Switching the source namespace with an existing destination namespace via
setSrcNamespace(String) or setDstNamespaces(List) is not supported yet.
-
Nested Class Summary
Nested classes/interfaces inherited from interface MappingTree
MappingTree.ClassMapping, MappingTree.ElementMapping, MappingTree.FieldMapping, MappingTree.MemberMapping, MappingTree.MetadataEntry, MappingTree.MethodArgMapping, MappingTree.MethodMapping, MappingTree.MethodVarMappingNested classes/interfaces inherited from interface MappingTreeView
MappingTreeView.ClassMappingView, MappingTreeView.ElementMappingView, MappingTreeView.FieldMappingView, MappingTreeView.MemberMappingView, MappingTreeView.MetadataEntryView, MappingTreeView.MethodArgMappingView, MappingTreeView.MethodMappingView, MappingTreeView.MethodVarMappingView -
Field Summary
Fields inherited from interface MappingTreeView
MIN_NAMESPACE_ID, NULL_NAMESPACE_ID, SRC_NAMESPACE_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(MappingVisitor visitor, VisitOrder order) Merges a class mapping into the tree.void@Nullable MappingTree.ClassMapping@Nullable MappingTree.ClassMappingCollection<? extends MappingTree.ClassMapping> List<? extends MappingTree.MetadataEntry> List<? extends MappingTree.MetadataEntry> getMetadata(String key) @Nullable String@Nullable MappingTree.ClassMappingremoveClass(String srcName) Removes a class mapping from the tree.booleanremoveMetadata(String key) Removes all metadata entries whose key is equal to the passed one.voidreset()Reset the visitor, including any chained visitors, to allow for another independent visit (excluding visitEnd=false).setDstNamespaces(List<String> namespaces) Sets the tree's and all of its contained elements' destination namespace names.voidsetHierarchyInfoProvider(@Nullable HierarchyInfoProvider<?> provider) Experimental feature, may be removed or changed without further notice.voidsetIndexByDstNames(boolean indexByDstNames) Whether to index classes by their destination names, in addition to their source names.@Nullable StringsetSrcNamespace(String namespace) Sets the tree's and all of its contained elements' source namespace name.booleanvisitClass(String srcName) Visit a class.voidvisitComment(MappedElementKind targetKind, String comment) Comment for the specified element (last content-visited or any parent).voidvisitDstName(MappedElementKind targetKind, int namespace, String name) Destination name for the current element.booleanvisitEnd()Finish the visitation pass.booleanvisitField(String srcName, @Nullable String srcDesc) voidvisitMetadata(String key, @Nullable String value) booleanvisitMethod(String srcName, @Nullable String srcDesc) booleanvisitMethodArg(int argPosition, int lvIndex, @Nullable String srcName) Visit a parameter.booleanvisitMethodVar(int lvtRowIndex, int lvIndex, int startOpIdx, int endOpIdx, @Nullable String srcName) Visit a variable.voidvisitNamespaces(String srcNamespace, List<String> dstNamespaces) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MappingTree
getField, getField, getMethod, getMethod, propagateOuterClassNames, propagateOuterClassNamesMethods inherited from interface MappingTreeView
accept, getMaxNamespaceId, getMinNamespaceId, getNamespaceId, getNamespaceName, mapClassName, mapClassName, mapDesc, mapDesc, mapDesc, mapDescMethods inherited from interface MappingVisitor
getFlags, visitContent, visitDstDesc, visitElementContent, visitHeader
-
Constructor Details
-
MemoryMappingTree
public MemoryMappingTree() -
MemoryMappingTree
public MemoryMappingTree(boolean indexByDstNames) -
MemoryMappingTree
-
-
Method Details
-
setIndexByDstNames
public void setIndexByDstNames(boolean indexByDstNames) Whether to index classes by their destination names, in addition to their source names.Trades higher memory consumption for faster lookups by destination name.
-
setHierarchyInfoProvider
@Experimental public void setHierarchyInfoProvider(@Nullable @Nullable HierarchyInfoProvider<?> provider) Experimental feature, may be removed or changed without further notice. -
getSrcNamespace
- Specified by:
getSrcNamespacein interfaceMappingTreeView- Returns:
- The source namespace, or
nullif the tree is uninitialized.
-
setSrcNamespace
Sets the tree's and all of its contained elements' source namespace name.If the passed namespace name equals an existing destination namespace's name, implementors may choose to switch the two namespaces around, analogous to
MappingSourceNsSwitch. This has to be made clear in the implementation's documentation.- Specified by:
setSrcNamespacein interfaceMappingTree- Returns:
- The previous source namespace name, if present.
- Throws:
UnsupportedOperationException- If the passed namespace name is already in use by one of the destination namespaces. This may change in a future release.
-
getDstNamespaces
- Specified by:
getDstNamespacesin interfaceMappingTreeView- Returns:
- A list containing the destination namespaces, in order of their IDs. Can only be empty if the tree is uninitialized.
-
setDstNamespaces
Sets the tree's and all of its contained elements' destination namespace names.Can be used to reorder and/or drop destination namespaces, analogous to
MappingDstNsReorder.Implementors may allow switching with the source namespace as well, analogous to
MappingSourceNsSwitch. This has to be made clear in the implementation's documentation.- Specified by:
setDstNamespacesin interfaceMappingTree- Returns:
- The previous destination namespaces.
- Throws:
IllegalArgumentException- If the passed namespace names contain duplicates.UnsupportedOperationException- If the passed namespace names contain the source namespace's name. This may change in a future release.
-
getMetadata
- Specified by:
getMetadatain interfaceMappingTree- Specified by:
getMetadatain interfaceMappingTreeView- Returns:
- A modifiable list of all metadata entries currently present in the tree. The list's order is equal to the order in which the entries have been originally added.
-
getMetadata
- Specified by:
getMetadatain interfaceMappingTree- Specified by:
getMetadatain interfaceMappingTreeView- Returns:
- An unmodifiable list of all currently present metadata entries whose key is equal to the passed one. The list's order is equal to the order in which the entries have been originally added.
-
addMetadata
- Specified by:
addMetadatain interfaceMappingTree
-
removeMetadata
Description copied from interface:MappingTreeRemoves all metadata entries whose key is equal to the passed one.- Specified by:
removeMetadatain interfaceMappingTree- Returns:
- Whether any entries have been removed.
-
getClasses
- Specified by:
getClassesin interfaceMappingTree- Specified by:
getClassesin interfaceMappingTreeView
-
getClass
- Specified by:
getClassin interfaceMappingTree- Specified by:
getClassin interfaceMappingTreeView
-
getClass
- Specified by:
getClassin interfaceMappingTree- Specified by:
getClassin interfaceMappingTreeView
-
addClass
Description copied from interface:MappingTreeMerges a class mapping into the tree.- Specified by:
addClassin interfaceMappingTree- Returns:
- The
MappingTree.ClassMappinginstance present in the tree after the merge has occurred. May or may not be the passed instance.
-
removeClass
Description copied from interface:MappingTreeRemoves a class mapping from the tree.- Specified by:
removeClassin interfaceMappingTree- Returns:
- The removed class mapping, if any.
-
accept
- Specified by:
acceptin interfaceMappingTreeView- Throws:
IOException
-
reset
public void reset()Description copied from interface:MappingVisitorReset the visitor, including any chained visitors, to allow for another independent visit (excluding visitEnd=false).- Specified by:
resetin interfaceMappingVisitor
-
visitNamespaces
- Specified by:
visitNamespacesin interfaceMappingVisitor
-
visitMetadata
- Specified by:
visitMetadatain interfaceMappingVisitor
-
visitClass
Description copied from interface:MappingVisitorVisit a class.- Specified by:
visitClassin interfaceMappingVisitor- Parameters:
srcName- The fully qualified source name of the class, in internal form (slashes instead of dots, dollar signs for delimiting inner classes).- Returns:
- Whether the class's content should be visited too.
-
visitField
- Specified by:
visitFieldin interfaceMappingVisitor
-
visitMethod
- Specified by:
visitMethodin interfaceMappingVisitor
-
visitMethodArg
Description copied from interface:MappingVisitorVisit a parameter.- Specified by:
visitMethodArgin interfaceMappingVisitor- Parameters:
argPosition- Always starts at 0 and gets incremented by 1 for each additional parameter.lvIndex- The parameter's local variable index in the current method, also known asslot. Starts at 0 for static methods, 1 otherwise. For each additional parameter, it gets incremented by 1, or by 2 if it's a double-wide primitive (longordouble).srcName- The optional source name of the parameter.- Returns:
- Whether the arg's content should be visited too.
-
visitMethodVar
public boolean visitMethodVar(int lvtRowIndex, int lvIndex, int startOpIdx, int endOpIdx, @Nullable @Nullable String srcName) Description copied from interface:MappingVisitorVisit a variable.- Specified by:
visitMethodVarin interfaceMappingVisitor- Parameters:
lvtRowIndex- The variable's index in the method's LVT (local variable table). It is optional, so -1 can be passed instead. This is the case since LVTs themselves are optional debug information, see JVMS 4.7.13.lvIndex- The var's local variable index in the current method, also known asslot. For each additional variable, it gets incremented by 1, or by 2 if it's a double-wide primitive (longordouble). The first variable starts at the last parameter's slot plus wideness.startOpIdx- Required for cases when the lvIndex alone doesn't uniquely identify a local variable. This is the case when variables get re-defined later on, in which case most decompilers opt to not re-define the existing var, but instead generate a new one (with both sharing the same lvIndex).endOpIdx- Counterpart to startOpIdx. Exclusive.srcName- The optional source name of the variable.- Returns:
- Whether the var's content should be visited too.
-
visitEnd
public boolean visitEnd()Description copied from interface:MappingVisitorFinish the visitation pass.Implementors may throw an exception if a second pass is requested without the
NEEDS_MULTIPLE_PASSESflag having been passed beforehand, but only if that behavior is documented.- Specified by:
visitEndin interfaceMappingVisitor- Returns:
trueif the visitation pass is final,falseif it should be started over.
-
visitDstName
Description copied from interface:MappingVisitorDestination name for the current element.- Specified by:
visitDstNamein interfaceMappingVisitor- Parameters:
namespace- Namespace index (index into the dstNamespaces list inMappingVisitor.visitNamespaces(String, List)).name- Destination name.
-
visitComment
Description copied from interface:MappingVisitorComment for the specified element (last content-visited or any parent).- Specified by:
visitCommentin interfaceMappingVisitor- Parameters:
comment- Comment as a potentially multi-line string.
-