Class NamespacePath

  • All Implemented Interfaces:

    public class NamespacePath
    extends java.lang.Object
    implements java.lang.Comparable<NamespacePath>
    Represents a hierarchical path of containers that hold names of objects.

    Each container of names (lets call them a namespace for short) can have a type that distinguishes it from other containers: classes, functions, c++ namespaces, etc.

    A NamespacePath does not correlate directly to a Ghidra Namespace, as a Ghidra Namespace is tied to a Program and has rules about what can be placed inside of it.

    NamespacePath instances can be created without referring to a Ghidra Program and without concern as to what will be valid or have collisions.

    Use a NamespacePath to represent and hold forward-engineering namespace nesting information (ie. namespace info recovered from debug info), and when a Ghidra Namespace is needed, convert to or lookup the live/'real' Ghidra Namespace.

    • Method Detail

      • isRoot

        public boolean isRoot()
        Returns true if this namespace path points to the root of the namespace space.
        boolean true if ROOT
      • getName

        public java.lang.String getName()
        Returns the name of this namespace element, ie. the last thing on the path.
        string name.
      • getParent

        public NamespacePath getParent()
        Returns a reference to the parent NamespacePath.
        parent NamespacePath
      • getType

        public SymbolType getType()
        Returns the SymbolType of this namespace element (ie. the symbol type of the last thing on the path).
      • getNamespace

        public Namespace getNamespace​(Program program)
        Converts this NamespacePath into a Ghidra Namespace in the specified Program, creating missing elements on the path as necessary.
        program - Ghidra Program where the namespace should be retrieved from or created in.
        Namespace or fallback to the progam's Global root namespace if problem.
      • asCategoryPathString

        public java.lang.String asCategoryPathString()
        Converts this namespace path into a CategoryPath style string.
        string path "/namespace1/namespace2"
      • asNamespaceString

        public java.lang.String asNamespaceString()
        Converts this namespace path into a Namespace style string.
        string path "ROOT::namespace1::namespace2"
      • asFormattedString

        public java.lang.String asFormattedString()
        Converts this namespace path into a Namespace style string without the ROOT namespace included.
        string path "namespace1::namespace2"
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(NamespacePath otherPath)
        Specified by:
        compareTo in interface java.lang.Comparable<NamespacePath>