Class ClassTranslator
ClassTranslator
provides a way to map an old Ghidra class to
a current Ghidra class. It can be used whenever a class is moved or renamed
and Ghidra needs to know.
Important: Any class that is indicated by the currentClassPath
passed to the put
method should implement ExtensionPoint
.
Whenever a class whose name gets stored in the data base is moved to
another package or renamed, the map of the old class path name to the
new one should get put into the ClassTranslator.
Example: The class ghidra.app.plugin.core.MyPlugin.MyInfo
is in Ghidra version 1.
In Ghidra version 2, it is moved and renamed to ghidra.app.plugin.core.RenamedPlugin.SubPackage.SaveInfo
.
Put the following static initializer in the version 2 SaveInfo class.
static {
ClassTranslator.put("ghidra.app.plugin.core.MyPlugin.MyInfo", SaveInfo.class.getName());
}
Warning: If the class gets moved or renamed again in a subsequent version
of Ghidra, a new translation (put call) should get added to the static initializer block
and any old translations should have their current path name changed to the new
class path.
Example: The class ghidra.app.plugin.core.MyPlugin.MyInfo
is in Ghidra version 1.
In Ghidra version 2, it is moved and renamed to ghidra.app.plugin.core.RenamedPlugin.SubPackage.SaveInfo
.
In Ghidra version 3, it is renamed to ghidra.app.plugin.core.RenamedPlugin.SubPackage.SaveInfo
.
Put the following static initializer in the version 3 SaveInfo class.
static {
ClassTranslator.put("ghidra.app.plugin.core.MyPlugin.MyInfo", SaveInfo.class.getName());
ClassTranslator.put("ghidra.app.plugin.core.RenamedPlugin.SubPackage.SaveInfo", SaveInfo.class.getName());
}
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Returns true if this ClassTranslator has a mapping for the indicated old class path name.static String
Returns the current class path name that is mapped for the indicated old class path name.static void
Defines a mapping indicating the class path name of the current Ghidra class that is the same class as the indicated old class path name from a previous Ghidra version.
-
Constructor Details
-
ClassTranslator
public ClassTranslator()
-
-
Method Details
-
contains
Returns true if this ClassTranslator has a mapping for the indicated old class path name.- Parameters:
oldClassPath
- the old class path name of the class.- Returns:
- true if the old class path is mapped to a new class path name in the current Ghidra version.
-
get
Returns the current class path name that is mapped for the indicated old class path name.- Parameters:
oldClassPath
- the old class path name of the class.- Returns:
- the class path name of the current Ghidra version's class file. Otherwise, null if the old class path name isn't mapped.
-
put
Defines a mapping indicating the class path name of the current Ghidra class that is the same class as the indicated old class path name from a previous Ghidra version.- Parameters:
oldClassPath
- the old class path name of the class.currentClassPath
- the current class path name of the class.Important: Any class that is indicated by the currentClassPath passed to the
put
method should implementExtensionPoint
.
-