Package ghidra.app.util
Class SymbolPath
java.lang.Object
ghidra.app.util.SymbolPath
- All Implemented Interfaces:
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.
getName()
will return "baz".getParentPath()
will return "foo:bar".getPath()
will return "foo::bar::baz".
-
Constructor Summary
ConstructorDescriptionSymbolPath
(SymbolPath parent, String name) Creates a Symbol from a parent SymbolPath and a symbol name.SymbolPath
(Symbol symbol) 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 TypeMethodDescriptionappend
(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.String[]
asArray()
Returns an array of names of the symbols in the symbol path, starting with the name just below the global namespace.asList()
Returns a list of names of the symbols in the symbol path, starting with the name just below the global namespace.int
boolean
containsPathEntry
(String text) Returns true if this path contains any path entry matching the given textboolean
getName()
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.getPath()
Returns the full symbol path as a string.int
hashCode()
boolean
A convenience method to check if the given symbol's symbol path matches this pathReturns a new SymbolPath in which invalid characters are replaced with underscores.toString()
-
Constructor Details
-
SymbolPath
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
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
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
Constructs a new SymbolPath for the given symbol.- Parameters:
symbol
- the symbol to get a SymbolPath for.
-
SymbolPath
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
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
Returns a new SymbolPath in which invalid characters are replaced with underscores.- Returns:
- the new SymbolPath with replaced characters.
-
getName
Returns the name of the symbol;- Returns:
- the symbol name as string without any path information.
-
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
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
Returns the full symbol path as a string.- Returns:
- the SymbolPath for the complete name as string, including namespace.
-
append
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
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() -
equals
-
matchesPathOf
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
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
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
-
compareTo
- Specified by:
compareTo
in interfaceComparable<SymbolPath>
-