Package ghidra.app.util.bin.format.dwarf

# Class NamespacePath

java.lang.Object
ghidra.app.util.bin.format.dwarf.NamespacePath

All Implemented Interfaces:
  `Comparable<NamespacePath>`

public class NamespacePath extends Object implements 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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final NamespacePath`
  `ROOT`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `asFormattedString()`
  Converts this namespace path into a `Namespace` style string without the ROOT namespace included.
  `String`
  `asNamespaceString()`
  Converts this namespace path into a `Namespace` style string.
  `int`
  `compareTo(NamespacePath otherPath)`
  `static NamespacePath`
  `create(NamespacePath parent, String name, SymbolType type)`
  Creates a new `NamespacePath` instance.
  `boolean`
  `equals(Object obj)`
  `String`
  `getName()`
  Returns the name of this namespace element, ie.
  `Namespace`
  `getNamespace(Program program)`
  Converts this NamespacePath into a Ghidra `Namespace` in the specified `Program`, creating missing elements on the path as necessary.
  `NamespacePath`
  `getParent()`
  Returns a reference to the parent NamespacePath.
  `List<String>`
  `getParts()`
  Returns the individual parts of the path as elements in a list.
  `SymbolType`
  `getType()`
  Returns the `SymbolType` of this namespace element (ie.
  `int`
  `hashCode()`
  `boolean`
  `isRoot()`
  Returns true if this namespace path points to the root of the namespace space.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### ROOT

    public static final NamespacePath ROOT

- ## Method Details

  - ### create

    public static NamespacePath create(NamespacePath parent, String name, SymbolType type)
    Creates a new `NamespacePath` instance.
    Parameters:
      `parent` - optional - parent `NamespacePath` instance, default to `ROOT` if null.
      `name` - string name of the new namespace.
      `type` - `SymbolType` of the named space - ie. a "namespace", a class,
    Returns:
      new `NamespacePath`

  - ### isRoot

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

  - ### getName

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

  - ### getParent

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

  - ### getType

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

  - ### 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.
    Parameters:
      `program` - Ghidra `Program` where the namespace should be retrieved from or created in.
    Returns:
      `Namespace` or fallback to the progam's Global root namespace if problem.

  - ### asNamespaceString

    public String asNamespaceString()
    Converts this namespace path into a `Namespace` style string.
    Returns:
      string path "ROOT::namespace1::namespace2"

  - ### asFormattedString

    public String asFormattedString()
    Converts this namespace path into a `Namespace` style string without the ROOT namespace included.
    Returns:
      string path "namespace1::namespace2"

  - ### getParts

    public List<String> getParts()
    Returns the individual parts of the path as elements in a list.
    Returns:
      list of strings containing individual parts of the path

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### compareTo

    public int compareTo(NamespacePath otherPath)
    Specified by:
      `compareTo` in interface `Comparable<NamespacePath>`