Package ghidra.app.util
Class SymbolPath
- java.lang.Object
-
- ghidra.app.util.SymbolPath
-
- All Implemented Interfaces:
java.lang.Comparable<SymbolPath>
public class SymbolPath extends java.lang.Object implements java.lang.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
Constructors Constructor Description SymbolPath(SymbolPath parent, java.lang.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(java.lang.String symbolPathString)Construct a SymbolPath from a string containing NAMESPACE_DELIMITER ("::") sequences to separate the namespace names.SymbolPath(java.lang.String[] symbolPath)Construct a SymbolPath from an array of strings where each string is the name of a namespace in the symbol path.SymbolPath(java.util.List<java.lang.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SymbolPathappend(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.java.lang.String[]asArray()Returns an array of names of the symbols in the symbol path, starting with the name just below the global namespace.java.util.List<java.lang.String>asList()Returns a list of names of the symbols in the symbol path, starting with the name just below the global namespace.intcompareTo(SymbolPath o)booleanequals(java.lang.Object obj)java.lang.StringgetName()Returns the name of the symbol;SymbolPathgetParent()Returns the SymbolPath for the parent namespace or null if the parent is the global space.java.lang.StringgetParentPath()Returns null if the parent is null or global; otherwise returns the path as a string of the parent namespace path.java.lang.StringgetPath()Returns the full symbol path as a string.inthashCode()SymbolPathreplaceInvalidChars()Returns a new SymbolPath in which invalid characters are replaced with underscores.java.lang.StringtoString()
-
-
-
Constructor Detail
-
SymbolPath
public SymbolPath(java.lang.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(java.lang.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(java.util.List<java.lang.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:
java.lang.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, java.lang.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 Detail
-
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 java.lang.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 java.lang.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 java.lang.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.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
asList
public java.util.List<java.lang.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 java.lang.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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(SymbolPath o)
- Specified by:
compareToin interfacejava.lang.Comparable<SymbolPath>
-
-