Class ClassTranslator


  • public class ClassTranslator
    extends java.lang.Object
    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

      Constructors 
      Constructor Description
      ClassTranslator()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean contains​(java.lang.String oldClassPath)
      Returns true if this ClassTranslator has a mapping for the indicated old class path name.
      static java.lang.String get​(java.lang.String oldClassPath)
      Returns the current class path name that is mapped for the indicated old class path name.
      static void put​(java.lang.String oldClassPath, java.lang.String currentClassPath)
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClassTranslator

        public ClassTranslator()
    • Method Detail

      • contains

        public static boolean contains​(java.lang.String oldClassPath)
        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

        public static java.lang.String get​(java.lang.String oldClassPath)
        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

        public static void put​(java.lang.String oldClassPath,
                               java.lang.String currentClassPath)
        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 implement ExtensionPoint.