Class CategoryPath

java.lang.Object
ghidra.program.model.data.CategoryPath
All Implemented Interfaces:
Comparable<CategoryPath>

public class CategoryPath extends Object implements Comparable<CategoryPath>
A category path is the full path to a particular data type
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
     
    static final String
     
    static final String
     
    static final CategoryPath
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CategoryPath(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.
    Creates a category path given a forward-slash-delimited string (e.g., "/aa/bb").
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a hierarchical array of names of the categories in the category path, starting with the name just below the ROOT category.
    Returns a hierarchical list of names of the categories in the category path, starting with the name just below the ROOT category.
    int
     
    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.
    extend(String... subPathElements)
    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.
    extend(List<String> subPathElements)
    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.
    Return the terminating name of this category path.
    Return the parent category path.
    Return the String representation of this category path including the category name, where components are delimited with a forward slash.
    getPath(String childName)
    Return the String representation of the specified childName within this category path where all path components are delimited with a forward slash.
    Returns array of names in category path.
    int
     
    boolean
    isAncestorOrSelf(CategoryPath candidateAncestorPath)
    Tests if the specified categoryPath is the same as, or an ancestor of, this category path.
    boolean
    Determine if this category path corresponds to the root category
     
    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.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • CategoryPath

      public CategoryPath(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.
      Parameters:
      parent - the parent CategoryPath. Choose ROOT 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

      public 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.
      Parameters:
      parent - the parent CategoryPath. Choose ROOT 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

      public CategoryPath(String path)
      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 the escapeString(String) utility method. The unescapeString(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

      public 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. 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

      public 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.
      Parameters:
      escapedString - String that might need unescaping for characters used for delimiting
      Returns:
      non-escaped String
      See Also:
    • extend

      public CategoryPath extend(String... subPathElements)
      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

      public CategoryPath extend(List<String> subPathElements)
      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

      public CategoryPath getParent()
      Return the parent category path.
      Returns:
      the parent
    • getName

      public String getName()
      Return the terminating name of this category path.
      Returns:
      the name
    • getPath

      public String getPath()
      Return the String 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

      public String getPath(String childName)
      Return the String representation of the specified childName 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 the childName, will be escaped (e.g., "\/").
      Parameters:
      childName - child name
      Returns:
      full path for a child within this category
    • equals

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

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

      public boolean isAncestorOrSelf(CategoryPath candidateAncestorPath)
      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

      public String[] getPathElements()
      Returns array of names in category path.
      Returns:
      array of names
    • compareTo

      public int compareTo(CategoryPath other)
      Specified by:
      compareTo in interface Comparable<CategoryPath>
    • toString

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

      public List<String> asList()
      Returns a hierarchical list of names of the categories in the category path, starting with the name just below the ROOT category.
      Returns:
      a hierarchical list of names of the category in the category path.
    • asArray

      public String[] asArray()
      Returns a hierarchical array of names of the categories in the category path, starting with the name just below the ROOT category.
      Returns:
      a hierarchical array of names of the categories in the category path.