Package ghidra.util

Class NamingUtilities


  • public final class NamingUtilities
    extends java.lang.Object
    Utility class with static methods for validating project file names.
    • 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 Deprecated Methods 
      Modifier and Type Method Description
      static java.lang.String demangle​(java.lang.String mangledName)
      Performs the inverse of the mangle method.
      static char findInvalidChar​(java.lang.String name)
      Deprecated.
      this method may be removed in a subsequent release due to limited use and applicability (project names and project file names have different naming restrictions).
      static boolean isValidMangledName​(java.lang.String name)
      Performs a validity check on a mangled name
      static boolean isValidName​(java.lang.String name)
      Deprecated.
      method has been deprecated due to improper and widespread use.
      static boolean isValidProjectName​(java.lang.String name)
      Tests whether the given string is a valid project 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

        @Deprecated
        public static boolean isValidName​(java.lang.String name)
        Deprecated.
        method has been deprecated due to improper and widespread use. New methods include isValidProjectName(String) and LocalFileSystem.testValidName(String,boolean).
        Tests whether the given string is a valid. Rules:
        • All characters must be a letter, digit (0..9), period, hyphen, underscore or space
        • May not exceed a length of 60 characters
        Parameters:
        name - name to validate
        Returns:
        true if specified name is valid, else false
      • isValidProjectName

        public static boolean isValidProjectName​(java.lang.String name)
        Tests whether the given string is a valid project name. Rules:
        • Name may not start with period
        • All characters must be a letter, digit (0..9), period, hyphen, underscore or space
        • May not exceed a length of 60 characters
        Parameters:
        name - name to validate
        Returns:
        true if specified name is valid, else false
      • findInvalidChar

        @Deprecated
        public static char findInvalidChar​(java.lang.String name)
        Deprecated.
        this method may be removed in a subsequent release due to limited use and applicability (project names and project file names have different naming restrictions).
        Find the invalid character in the given name.

        This method should only be used with isValidName(String)} and not isValidProjectName(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.
        Parameters:
        name - name string to be mangled
        Returns:
        mangled name
      • demangle

        public static java.lang.String demangle​(java.lang.String mangledName)
        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.
        Parameters:
        mangledName - mangled name string
        Returns:
        demangle name
      • 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