Package ghidra.program.model.data
Class CategoryPath
java.lang.Object
ghidra.program.model.data.CategoryPath
- All Implemented Interfaces:
Comparable<CategoryPath>
A category path is the full path to a particular data type
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
static final String
static final String
static final CategoryPath
-
Constructor Summary
ConstructorDescriptionCategoryPath
(CategoryPath parent, String... subPathElements) Construct a CategoryPath from a parent and a hierarchical array of strings where each string is the name of a category in the category path.CategoryPath
(CategoryPath parent, List<String> subPathElements) Construct a CategoryPath from a parent and a hierarchical list of strings where each string is the name of a category in the category path.CategoryPath
(String path) Creates a category path given a forward-slash-delimited string (e.g.,"/aa/bb"
). -
Method Summary
Modifier and TypeMethodDescriptionString[]
asArray()
Returns a hierarchical array of names of the categories in the category path, starting with the name just below theROOT
category.asList()
Returns a hierarchical list of names of the categories in the category path, starting with the name just below theROOT
category.int
compareTo
(CategoryPath other) boolean
static String
escapeString
(String nonEscapedString) Converts a non-escaped String into an escaped string suitable for being passed in as a component of a single category path string to the constructor that takes a single escaped category path string.Returns a CategoryPath that extends the current path using a hierarchical array of strings where each string is the name of a category in the category path extension.Returns a CategoryPath that extends the current path using a hierarchical list of strings where each string is the name of a category in the category path extension.getName()
Return the terminating name of this category path.Return the parent category path.getPath()
Return theString
representation of this category path including the category name, where components are delimited with a forward slash.Return theString
representation of the specifiedchildName
within this category path where all path components are delimited with a forward slash.String[]
Returns array of names in category path.int
hashCode()
boolean
isAncestorOrSelf
(CategoryPath candidateAncestorPath) Tests if the specified categoryPath is the same as, or an ancestor of, this category path.boolean
isRoot()
Determine if this category path corresponds to the root categorytoString()
static String
unescapeString
(String escapedString) Converts an escaped String suitable for being passed in as a component of a single category path string into an non-escaped string.
-
Field Details
-
DELIMITER_CHAR
public static final char DELIMITER_CHAR- See Also:
-
DELIMITER_STRING
- See Also:
-
ESCAPED_DELIMITER_STRING
- See Also:
-
ROOT
-
-
Constructor Details
-
CategoryPath
Construct a CategoryPath from a parent and a hierarchical array of strings where each string is the name of a category in the category path.- Parameters:
parent
- the parent CategoryPath. ChooseROOT
if needed.subPathElements
- the array of names of sub-categories of the parent.- Throws:
IllegalArgumentException
- if the parent is null, the elements list is null or empty, or an individual element is null
-
CategoryPath
Construct a CategoryPath from a parent and a hierarchical list of strings where each string is the name of a category in the category path.- Parameters:
parent
- the parent CategoryPath. ChooseROOT
if needed.subPathElements
- the hierarchical array of sub-categories of the parent.- Throws:
IllegalArgumentException
- if the parent is null, the elements list is null or empty, or an individual element is null
-
CategoryPath
Creates a category path given a forward-slash-delimited string (e.g.,"/aa/bb"
). If an individual path component has one or more '/' characters in it, then it can be escaped using theescapeString(String)
utility method. TheunescapeString(String)
method can be used to unescape an individual component.Refrain from using this constructor in production code, and instead use one of the other constructors that does not require escaping. Situations where using this constructor is OK is in simple cases where a literal is passed in, such as in testing methods or in scripts.
- Parameters:
path
- category path string, delimited with '/' characters where individual components may have '/' characters escaped. Must start with the '/' character.
-
-
Method Details
-
escapeString
Converts a non-escaped String into an escaped string suitable for being passed in as a component of a single category path string to the constructor that takes a single escaped category path string. The user is responsible for constructing the single category path string from the escaped components.- Parameters:
nonEscapedString
- String that might need escaping for characters used for delimiting- Returns:
- escaped String
- See Also:
-
unescapeString
Converts an escaped String suitable for being passed in as a component of a single category path string into an non-escaped string.- Parameters:
escapedString
- String that might need unescaping for characters used for delimiting- Returns:
- non-escaped String
- See Also:
-
extend
Returns a CategoryPath that extends the current path using a hierarchical array of strings where each string is the name of a category in the category path extension.- Parameters:
subPathElements
- the array of names of sub-categories of the parent.- Returns:
- the extended CategoryPath
- Throws:
IllegalArgumentException
- if an element is null
-
extend
Returns a CategoryPath that extends the current path using a hierarchical list of strings where each string is the name of a category in the category path extension.- Parameters:
subPathElements
- the hierarchical array of sub-categories of the parent.- Returns:
- the extended CategoryPath
- Throws:
IllegalArgumentException
- if an element is null
-
isRoot
public boolean isRoot()Determine if this category path corresponds to the root category- Returns:
- true if this is a root category path
-
getParent
Return the parent category path.- Returns:
- the parent
-
getName
Return the terminating name of this category path.- Returns:
- the name
-
getPath
Return theString
representation of this category path including the category name, where components are delimited with a forward slash. Any occurrence of a forward slash within individual path components will be escaped (e.g.,"\/"
).- Returns:
- the full category path
-
getPath
Return theString
representation of the specifiedchildName
within this category path where all path components are delimited with a forward slash. Any occurrence of a forward slash within individual path components, including thechildName
, will be escaped (e.g.,"\/"
).- Parameters:
childName
- child name- Returns:
- full path for a child within this category
-
equals
-
hashCode
public int hashCode() -
isAncestorOrSelf
Tests if the specified categoryPath is the same as, or an ancestor of, this category path.- Parameters:
candidateAncestorPath
- the category path to be checked.- Returns:
- true if the given path is the same as, or an ancestor of, this category path.
-
getPathElements
Returns array of names in category path.- Returns:
- array of names
-
compareTo
- Specified by:
compareTo
in interfaceComparable<CategoryPath>
-
toString
-
asList
Returns a hierarchical list of names of the categories in the category path, starting with the name just below theROOT
category.- Returns:
- a hierarchical list of names of the category in the category path.
-
asArray
Returns a hierarchical array of names of the categories in the category path, starting with the name just below theROOT
category.- Returns:
- a hierarchical array of names of the categories in the category path.
-