Class NameDeduper

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

public class NameDeduper extends Object
Helper for allocating unique string names.

"Reserved names" are names that will be used by later calls to the de-duper.

"Used names" are names that are already allocated and are in use.

Reserved names only prevent re-use of a name when a name is being generated because of a collision with a "used name".

  • Constructor Details

    • NameDeduper

      public NameDeduper()
      Create a new name de-duper.
  • Method Details

    • addUsedNames

      public void addUsedNames(Collection<String> alreadyUsedNames)
      Add names to the the de-duper that have already been used.
      Parameters:
      alreadyUsedNames - names already used
    • addReservedNames

      public void addReservedNames(Collection<String> additionalReservedNames)
      Add names to the de-duper that will be used in a future call. These names do not block calls to confirm that a name is unique, but instead prevent the name from being used when an auto-generated name is created.
      Parameters:
      additionalReservedNames - names to reserve
    • isUniqueName

      public boolean isUniqueName(String name)
      Returns true if the specified name hasn't been allocated yet.
      Parameters:
      name - string name to check
      Returns:
      boolean true if the specified name hasn't been allocated yet
    • getUniqueName

      public String getUniqueName(String name)
      Confirms that the specified name is unique, or returns a generated name that is unique.
      Parameters:
      name - name to test
      Returns:
      null if specified name is already unique (and marks the specified name as used), or returns a new, unique generated name