Class TemplateSimplifier

java.lang.Object
ghidra.app.util.template.TemplateSimplifier
All Implemented Interfaces:
NameTransformer

public class TemplateSimplifier extends Object implements NameTransformer
Class for simplify names with template data. This class can be used with tool options or as a stand alone configurable simplifier.
  • Field Details

  • Constructor Details

    • TemplateSimplifier

      public TemplateSimplifier()
      Constructor to use for a TemplateSimplifier that doesn't use values from ToolOptions
    • TemplateSimplifier

      public TemplateSimplifier(ToolOptions fieldOptions)
      Constructor to use for a TemplateSimplifier that operates using the current values in the tool options
      Parameters:
      fieldOptions - the "Listing Field" options
  • Method Details

    • setNestingDepth

      public void setNestingDepth(int depth)
      Sets the template nesting depth to be simplified. A depth of 0 simplifies the entire template portion of the name (everything in between <>). A depth of 1 leaves one level of template information
      Parameters:
      depth - the nesting depth
    • getNestingDepth

      public int getNestingDepth()
      Returns the nesting depth for simplification
      Returns:
      the nesting depth for simplification
    • setMaxTemplateLength

      public void setMaxTemplateLength(int maxLength)
      Sets the maximum length do display the template portion. If, after any nesting, simplification, the resulting template string is longer that the max length, the middle portion will be replaced with "..." to reduce the template string to the given max length.
      Parameters:
      maxLength - the max length of a template to display
    • getMaxTemplateLength

      public int getMaxTemplateLength()
      Gets the maximum length that a template will display.
      Returns:
      the maximum length that a template will display
    • setEnabled

      public void setEnabled(boolean doSimplify)
      Sets if this TemplateSimplifier is enabled. If disabled, the simplify(String) method will return the input string.
      Parameters:
      doSimplify - true to do simplification, false to do nothing
    • isEnabled

      public boolean isEnabled()
      Returns if this TemplateSimplifier is enabled.
      Returns:
      if this TemplateSimplifier is enabled
    • setMinimumTemplateLength

      public void setMinimumTemplateLength(int minLength)
      Sets the minimum length for a template string to be simplified. In other words, template strings less than this length will not be changed.
      Parameters:
      minLength - the minimum length to simplify
    • getMinimumTemplateLength

      public int getMinimumTemplateLength()
      Returns the minimum length of a template string that will be simplified.
      Returns:
      the minimum length of a template string that will be simplified.
    • simplify

      public String simplify(String input)
      Simplifies any template string in the given input base on the current simplification settings.
      Specified by:
      simplify in interface NameTransformer
      Parameters:
      input - the input string to be simplified
      Returns:
      a simplified string
    • reloadFromOptions

      public void reloadFromOptions(ToolOptions fieldOptions)
      Reloads the current simplification settings from the given field options
      Parameters:
      fieldOptions - the options to retrieve the simplification settings.
    • fieldOptionsChanged

      public boolean fieldOptionsChanged(Options options, String optionName, Object oldValue, Object newValue)
      Notification that options have changed
      Parameters:
      options - the options object that has changed values
      optionName - the name of the options that changed
      oldValue - the old value for the option that changed
      newValue - the new value for the option that changed
      Returns:
      true if the option that changed was a template simplification option