Package ghidra.app.util.template

# 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 Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `MAX_TEMPLATE_LENGTH_DESCRIPTION`
  `static final String`
  `MAX_TEMPLATE_LENGTH_OPTION`
  `static final String`
  `MIN_TEMPLATE_LENGTH_DESCRIPTION`
  `static final String`
  `MIN_TEMPLATE_LENGTH_OPTION`
  `static final String`
  `SIMPLIFY_TEMPLATES_OPTION`
  `static final String`
  `SIMPLY_TEMPLATES_DESCRIPTION`
  `static final String`
  `SUB_OPTION_NAME`
  `static final String`
  `TEMPLATE_NESTING_DEPTH_DESCRIPTION`
  `static final String`
  `TEMPLATE_NESTING_DEPTH_OPTION`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TemplateSimplifier()`
  Constructor to use for a TemplateSimplifier that doesn't use values from ToolOptions
  `TemplateSimplifier(ToolOptions fieldOptions)`
  Constructor to use for a TemplateSimplifier that operates using the current values in the tool options

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `fieldOptionsChanged(Options options, String optionName, Object oldValue, Object newValue)`
  Notification that options have changed
  `int`
  `getMaxTemplateLength()`
  Gets the maximum length that a template will display.
  `int`
  `getMinimumTemplateLength()`
  Returns the minimum length of a template string that will be simplified.
  `int`
  `getNestingDepth()`
  Returns the nesting depth for simplification
  `boolean`
  `isEnabled()`
  Returns if this TemplateSimplifier is enabled.
  `void`
  `reloadFromOptions(ToolOptions fieldOptions)`
  Reloads the current simplification settings from the given field options
  `void`
  `setEnabled(boolean doSimplify)`
  Sets if this TemplateSimplifier is enabled.
  `void`
  `setMaxTemplateLength(int maxLength)`
  Sets the maximum length do display the template portion.
  `void`
  `setMinimumTemplateLength(int minLength)`
  Sets the minimum length for a template string to be simplified.
  `void`
  `setNestingDepth(int depth)`
  Sets the template nesting depth to be simplified.
  `String`
  `simplify(String input)`
  Simplifies any template string in the given input base on the current simplification settings.

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### SUB_OPTION_NAME

    public static final String SUB_OPTION_NAME
    See Also:
      - Constant Field Values

  - ### SIMPLIFY_TEMPLATES_OPTION

    public static final String SIMPLIFY_TEMPLATES_OPTION
    See Also:
      - Constant Field Values

  - ### TEMPLATE_NESTING_DEPTH_OPTION

    public static final String TEMPLATE_NESTING_DEPTH_OPTION
    See Also:
      - Constant Field Values

  - ### MAX_TEMPLATE_LENGTH_OPTION

    public static final String MAX_TEMPLATE_LENGTH_OPTION
    See Also:
      - Constant Field Values

  - ### MIN_TEMPLATE_LENGTH_OPTION

    public static final String MIN_TEMPLATE_LENGTH_OPTION
    See Also:
      - Constant Field Values

  - ### SIMPLY_TEMPLATES_DESCRIPTION

    public static final String SIMPLY_TEMPLATES_DESCRIPTION
    See Also:
      - Constant Field Values

  - ### TEMPLATE_NESTING_DEPTH_DESCRIPTION

    public static final String TEMPLATE_NESTING_DEPTH_DESCRIPTION
    See Also:
      - Constant Field Values

  - ### MAX_TEMPLATE_LENGTH_DESCRIPTION

    public static final String MAX_TEMPLATE_LENGTH_DESCRIPTION
    See Also:
      - Constant Field Values

  - ### MIN_TEMPLATE_LENGTH_DESCRIPTION

    public static final String MIN_TEMPLATE_LENGTH_DESCRIPTION
    See Also:
      - Constant Field Values

- ## 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