Class SymbolPath

java.lang.Object
ghidra.app.util.SymbolPath
All Implemented Interfaces:
Comparable<SymbolPath>

public class SymbolPath extends Object implements Comparable<SymbolPath>
A convenience object for parsing a namespace path to a symbol.

For example, if a SymbolPath is constructed with "foo::bar::baz", then "baz" is the name of a symbol in the "bar" namespace, which is in the "foo" namespace.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SymbolPath(SymbolPath parent, String name)
    Creates a Symbol from a parent SymbolPath and a symbol name.
    Constructs a new SymbolPath for the given symbol.
    SymbolPath(Symbol symbol, boolean excludeLibrary)
    Constructs a new SymbolPath for the given symbol with the option to exclude a beginning library name.
    SymbolPath(String symbolPathString)
    Construct a SymbolPath from a string containing NAMESPACE_DELIMITER ("::") sequences to separate the namespace names.
    SymbolPath(String[] symbolPath)
    Construct a SymbolPath from an array of strings where each string is the name of a namespace in the symbol path.
    SymbolPath(List<String> symbolList)
    Construct a SymbolPath from a list of strings where each string is the name of a namespace in the symbol path.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new SymbolPath composed of the list of names in this path followed by the list of names in the given path.
    Returns an array of names of the symbols in the symbol path, starting with the name just below the global namespace.
    Returns a list of names of the symbols in the symbol path, starting with the name just below the global namespace.
    int
     
    boolean
    Returns true if this path contains any path entry matching the given text
    boolean
     
    Returns the name of the symbol;
    Returns the SymbolPath for the parent namespace or null if the parent is the global space.
    Returns null if the parent is null or global; otherwise returns the path as a string of the parent namespace path.
    Returns the full symbol path as a string.
    int
     
    boolean
    A convenience method to check if the given symbol's symbol path matches this path
    Returns a new SymbolPath in which invalid characters are replaced with underscores.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SymbolPath

      public SymbolPath(String symbolPathString)
      Construct a SymbolPath from a string containing NAMESPACE_DELIMITER ("::") sequences to separate the namespace names. This is the only constructor that employs special string-based namespace parsing.
      Parameters:
      symbolPathString - the string to parse as a sequence of namespace names separated by "::".
    • SymbolPath

      public SymbolPath(String[] symbolPath)
      Construct a SymbolPath from an array of strings where each string is the name of a namespace in the symbol path.
      Parameters:
      symbolPath - the array of names of namespaces.
    • SymbolPath

      public SymbolPath(List<String> symbolList)
      Construct a SymbolPath from a list of strings where each string is the name of a namespace in the symbol path.
      Parameters:
      symbolList - the array of names of namespaces.
      Throws:
      IllegalArgumentException - if the given list is null or empty.
    • SymbolPath

      public SymbolPath(Symbol symbol)
      Constructs a new SymbolPath for the given symbol.
      Parameters:
      symbol - the symbol to get a SymbolPath for.
    • SymbolPath

      public SymbolPath(Symbol symbol, boolean excludeLibrary)
      Constructs a new SymbolPath for the given symbol with the option to exclude a beginning library name.
      Parameters:
      symbol - the symbol to get a SymbolPath for.
      excludeLibrary - if true, any library name at the front of the path will be removed.
    • SymbolPath

      public SymbolPath(SymbolPath parent, String name)
      Creates a Symbol from a parent SymbolPath and a symbol name.
      Parameters:
      parent - the parent SymbolPath. Can be null if the name is in the global space.
      name - the name of the symbol. This can't be null;
  • Method Details

    • replaceInvalidChars

      public SymbolPath replaceInvalidChars()
      Returns a new SymbolPath in which invalid characters are replaced with underscores.
      Returns:
      the new SymbolPath with replaced characters.
    • getName

      public String getName()
      Returns the name of the symbol;
      Returns:
      the symbol name as string without any path information.
    • getParent

      public SymbolPath getParent()
      Returns the SymbolPath for the parent namespace or null if the parent is the global space.
      Returns:
      the SymbolPath for the parent namespace or null if the parent is the global space.
    • getParentPath

      public String getParentPath()
      Returns null if the parent is null or global; otherwise returns the path as a string of the parent namespace path.
      Returns:
      the path of the parent namespace as string. Returns null if the parent is null or global.
    • getPath

      public String getPath()
      Returns the full symbol path as a string.
      Returns:
      the SymbolPath for the complete name as string, including namespace.
    • append

      public SymbolPath append(SymbolPath path)
      Creates a new SymbolPath composed of the list of names in this path followed by the list of names in the given path.
      Parameters:
      path - the path of names to append to this path.
      Returns:
      a new SymbolPath that appends the given path to this path.
    • containsPathEntry

      public boolean containsPathEntry(String text)
      Returns true if this path contains any path entry matching the given text
      Parameters:
      text - the text for which to search
      Returns:
      true if any path entry matches the given text
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • matchesPathOf

      public boolean matchesPathOf(Symbol s)
      A convenience method to check if the given symbol's symbol path matches this path
      Parameters:
      s - the symbol to check
      Returns:
      true if the symbol paths match
    • asList

      public List<String> asList()
      Returns a list of names of the symbols in the symbol path, starting with the name just below the global namespace.
      Returns:
      a list of names of the symbols in the symbol path.
    • asArray

      public String[] asArray()
      Returns an array of names of the symbols in the symbol path, starting with the name just below the global namespace.
      Returns:
      an array of names of the symbols in the symbol path.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(SymbolPath o)
      Specified by:
      compareTo in interface Comparable<SymbolPath>