Package ghidra.app.util.bin.format.dwarf4.next

# Class DWARFNameInfo

java.lang.Object
ghidra.app.util.bin.format.dwarf4.next.DWARFNameInfo

public class DWARFNameInfo 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).
  `DWARFNameInfo`
  `createChild(String childOriginalName, String childName, SymbolType childType)`
  Creates a `DWARFNameInfo` instance, which has a name that is contained with this instance's namespace, using the specified name and symbol type.
  `static DWARFNameInfo`
  `createRoot(CategoryPath rootCategory)`
  Create a root name entry that will serve as the parent for all children.
  `boolean`
  `equals(Object obj)`
  `static DWARFNameInfo`
  `fromDataType(DataType dataType)`
  Create a `DWARFNameInfo` instance using the specified `DataType`'s name.
  `static DWARFNameInfo`
  `fromList(DWARFNameInfo parent, List<String> names)`
  Create a child `DWARFNameInfo` 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.
  `DWARFNameInfo`
  `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.
  `DWARFNameInfo`
  `replaceName(String newName, String newOriginalName)`
  Creates a new DWARFNameInfo instance, using this instance as the template, replacing the name with a new name.
  `DWARFNameInfo`
  `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 DWARFNameInfo 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 `DWARFNameInfo` instance

  - ### fromDataType

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

  - ### fromList

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

    Example:

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

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

  - ### getParent

    public DWARFNameInfo 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 DWARFNameInfo 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 DWARFNameInfo 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 DWARFNameInfo createChild(String childOriginalName, String childName, SymbolType childType)
    Creates a `DWARFNameInfo` 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`