Package ghidra.util

Class NamingUtilities


  • public final class NamingUtilities
    extends java.lang.Object
    Utility class with static methods for validating names and converting strings to numbers, etc.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_NAME_LENGTH
      Max length for a name.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String demangle​(java.lang.String name)
      Performs the inverse of the mangle method.
      static char findInvalidChar​(java.lang.String name)
      Find the invalid character in the given name.
      static boolean isValidMangledName​(java.lang.String name)
      Performs a validity check on a mangled name
      static boolean isValidName​(java.lang.String name)
      tests whether the given string is a valid name.
      static java.lang.String mangle​(java.lang.String name)
      Returns a string such that all uppercase characters in the given string are replaced by the MANGLE_CHAR followed by the lowercase version of the character.
      • Methods inherited from class java.lang.Object

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

      • MAX_NAME_LENGTH

        public static final int MAX_NAME_LENGTH
        Max length for a name.
        See Also:
        Constant Field Values
    • Method Detail

      • isValidName

        public static boolean isValidName​(java.lang.String name)
        tests whether the given string is a valid name.
        Parameters:
        name - name to validate
      • findInvalidChar

        public static char findInvalidChar​(java.lang.String name)
        Find the invalid character in the given name.

        This method should only be used with isValidName(String)} and not {@link #isValidFileName(String);

        Parameters:
        name - the name with an invalid character
        Returns:
        the invalid character or 0 if no invalid character can be found
        See Also:
        isValidName(String)
      • mangle

        public static java.lang.String mangle​(java.lang.String name)
        Returns a string such that all uppercase characters in the given string are replaced by the MANGLE_CHAR followed by the lowercase version of the character. MANGLE_CHARs are replaced by 2 MANGLE_CHARs. This method is to get around the STUPID windows problem where filenames are not case sensitive. Under Windows, Foo.exe and foo.exe represent the same filename. To fix this we mangle names first such that Foo.exe becomes _foo.exe.
      • demangle

        public static java.lang.String demangle​(java.lang.String name)
        Performs the inverse of the mangle method. A string is returned such that all characters following a MANGLE_CHAR are converted to uppercase. Two MANGLE chars in a row are replace by a single MANGLE_CHAR.
      • isValidMangledName

        public static boolean isValidMangledName​(java.lang.String name)
        Performs a validity check on a mangled name
        Parameters:
        name - mangled name
        Returns:
        true if name can be demangled else false