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

# Class DWARFName

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

public class DWARFName extends Object
A immutable hierarchical path based name implementation that can be viewed as either `namespaces` or `categorypaths`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CategoryPath`
  `asCategoryPath()`
  Converts this object into an equiv `CategoryPath`.
  `DataTypePath`
  `asDataTypePath()`
  Converts this object into an equiv `DataTypePath`.
  `Namespace`
  `asNamespace(Program program)`
  Converts this object into an equiv Ghidra `Namespace`, omitting the organizational category path (which only applies to DataTypes).
  `DWARFName`
  `createChild(String childOriginalName, String childName, SymbolType childType)`
  Creates a `DWARFName` instance, which has a name that is contained with this instance's namespace, using the specified name and symbol type.
  `static DWARFName`
  `createRoot(CategoryPath rootCategory)`
  Create a root name entry that will serve as the parent for all children.
  `boolean`
  `equals(Object obj)`
  `static DWARFName`
  `fromDataType(DataType dataType)`
  Create a `DWARFName` instance using the specified `DataType`'s name.
  `static DWARFName`
  `fromList(DWARFName parent, List<String> names)`
  Create a child `DWARFName` instance of the specified parent.
  `String`
  `getName()`
  Returns the name of this entry.
  `NamespacePath`
  `getNamespacePath()`
  Returns the NamespacePath of this instance.
  `CategoryPath`
  `getOrganizationalCategoryPath()`
  Returns the organizational category path.
  `String`
  `getOriginalName()`
  Returns the original name (unmodified by Ghidra-isms) of this entry.
  `DWARFName`
  `getParent()`
  Returns the parent name
  `CategoryPath`
  `getParentCP()`
  Returns the parent's CategoryPath.
  `Namespace`
  `getParentNamespace(Program program)`
  Returns the Ghidra `Namespace` that represents this entry's parent.
  `SymbolType`
  `getType()`
  Returns the SymbolType of this name.
  `int`
  `hashCode()`
  `boolean`
  `isAnon()`
  Returns true if the original name of this entry was blank.
  `boolean`
  `isNameModified()`
  Returns true if this instance's `name` value is different than its `original` form.
  `boolean`
  `isRoot()`
  Returns true if this instance has no parent and is considered the root.
  `DWARFName`
  `replaceName(String newName, String newOriginalName)`
  Creates a new DWARFNameInfo instance, using this instance as the template, replacing the name with a new name.
  `DWARFName`
  `replaceType(SymbolType newType)`
  Creates a new DWARFNameInfo instance, using this instance as the template, replacing the SymbolType with a new value.
  `String`
  `toString()`

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

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

- ## Method Details

  - ### createRoot

    public static DWARFName createRoot(CategoryPath rootCategory)
    Create a root name entry that will serve as the parent for all children.
    Parameters:
      `rootCategory` - `CategoryPath` in the data type manager that will contain any sub-categories that represent namespaces
    Returns:
      a new `DWARFName` instance

  - ### fromDataType

    public static DWARFName fromDataType(DataType dataType)
    Create a `DWARFName` instance using the specified `DataType`'s name.
    Parameters:
      `dataType` - `DataType`
    Returns:
      new `DWARFName` using the same name / CategoryPath as the data type

  - ### fromList

    public static DWARFName fromList(DWARFName parent, List<String> names)
    Create a child `DWARFName` instance of the specified parent.

    Example:

        fromList(parent, List.of("name1", "name2")) → parent_name/name1/name2

    Parameters:
      `parent` - `DWARFName` parent
      `names` - list of names
    Returns:
      new `DWARFName` instance that is a child of the parent

  - ### getParent

    public DWARFName getParent()
    Returns the parent name
    Returns:
      parent

  - ### isRoot

    public boolean isRoot()
    Returns true if this instance has no parent and is considered the root.
    Returns:
      boolean true if root name, false if not root

  - ### getOrganizationalCategoryPath

    public CategoryPath getOrganizationalCategoryPath()
    Returns the organizational category path.
    Returns:
      organizational category path for dwarf names

  - ### getNamespacePath

    public NamespacePath getNamespacePath()
    Returns the NamespacePath of this instance.
    Returns:
      `NamespacePath` of this instance

  - ### getParentCP

    public CategoryPath getParentCP()
    Returns the parent's CategoryPath.
    Returns:
      parent name's CategoryPath

  - ### getName

    public String getName()
    Returns the name of this entry.
    Returns:
      string name of this entry, safe to use to name a Ghidra object (datatype, namespace, etc)

  - ### replaceName

    public DWARFName replaceName(String newName, String newOriginalName)
    Creates a new DWARFNameInfo instance, using this instance as the template, replacing the name with a new name.
    Parameters:
      `newName` - name for the new instance
      `newOriginalName` - originalName for the new instance
    Returns:
      new instance with new name

  - ### replaceType

    public DWARFName replaceType(SymbolType newType)
    Creates a new DWARFNameInfo instance, using this instance as the template, replacing the SymbolType with a new value.
    Parameters:
      `newType` - new SymbolType value
    Returns:
      new instance with the specified SymbolType

  - ### getType

    public SymbolType getType()
    Returns the SymbolType of this name.
    Returns:
      `SymbolType` of this entry

  - ### asCategoryPath

    public CategoryPath asCategoryPath()
    Converts this object into an equiv `CategoryPath`.
    Returns:
      `CategoryPath`: "/organizational_cat_path/namespace1/namespace2/obj_name"

  - ### asDataTypePath

    public DataTypePath asDataTypePath()
    Converts this object into an equiv `DataTypePath`.
    Returns:
      `DataTypePath`: { "/organizational_cat_path/namespace1/namespace2", "obj_name" }

  - ### getParentNamespace

    public Namespace getParentNamespace(Program program)
    Returns the Ghidra `Namespace` that represents this entry's parent.
    Parameters:
      `program` - the Ghidra program that contains the namespace
    Returns:
      `Namespace` representing this entry's parent

  - ### asNamespace

    public Namespace asNamespace(Program program)
    Converts this object into an equiv Ghidra `Namespace`, omitting the organizational category path (which only applies to DataTypes).
    Parameters:
      `program` - `Program` where the namespace lives.
    Returns:
      `Namespace`: "ROOT::namespace1::namespace2::obj_name"

  - ### toString

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

  - ### isAnon

    public boolean isAnon()
    Returns true if the original name of this entry was blank.
    Returns:
      boolean true if there was no original name

  - ### getOriginalName

    public String getOriginalName()
    Returns the original name (unmodified by Ghidra-isms) of this entry.
    Returns:
      original name

  - ### isNameModified

    public boolean isNameModified()
    Returns true if this instance's `name` value is different than its `original` form.
    Returns:
      boolean true if the original name doesn't match the ghidra-ized name

  - ### createChild

    public DWARFName createChild(String childOriginalName, String childName, SymbolType childType)
    Creates a `DWARFName` instance, which has a name that is contained with this instance's namespace, using the specified name and symbol type.
    Parameters:
      `childOriginalName` - the unmodified name
      `childName` - the ghidra-ized name of the type/symbol/namespace/etc
      `childType` - the type of the object being named
    Returns:
      new DWARFNameInfo instance

  - ### hashCode

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

  - ### equals

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