Package ghidra.app.util.template
Class TemplateSimplifier
java.lang.Object
ghidra.app.util.template.TemplateSimplifier
- All Implemented Interfaces:
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
-
Constructor Summary
ConstructorDescriptionConstructor to use for a TemplateSimplifier that doesn't use values from ToolOptionsTemplateSimplifier
(ToolOptions fieldOptions) Constructor to use for a TemplateSimplifier that operates using the current values in the tool options -
Method Summary
Modifier and TypeMethodDescriptionboolean
fieldOptionsChanged
(Options options, String optionName, Object oldValue, Object newValue) Notification that options have changedint
Gets the maximum length that a template will display.int
Returns the minimum length of a template string that will be simplified.int
Returns the nesting depth for simplificationboolean
Returns if this TemplateSimplifier is enabled.void
reloadFromOptions
(ToolOptions fieldOptions) Reloads the current simplification settings from the given field optionsvoid
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.Simplifies any template string in the given input base on the current simplification settings.
-
Field Details
-
SUB_OPTION_NAME
- See Also:
-
SIMPLIFY_TEMPLATES_OPTION
- See Also:
-
TEMPLATE_NESTING_DEPTH_OPTION
- See Also:
-
MAX_TEMPLATE_LENGTH_OPTION
- See Also:
-
MIN_TEMPLATE_LENGTH_OPTION
- See Also:
-
SIMPLY_TEMPLATES_DESCRIPTION
- See Also:
-
TEMPLATE_NESTING_DEPTH_DESCRIPTION
- See Also:
-
MAX_TEMPLATE_LENGTH_DESCRIPTION
- See Also:
-
MIN_TEMPLATE_LENGTH_DESCRIPTION
- See Also:
-
-
Constructor Details
-
TemplateSimplifier
public TemplateSimplifier()Constructor to use for a TemplateSimplifier that doesn't use values from ToolOptions -
TemplateSimplifier
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, thesimplify(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
Simplifies any template string in the given input base on the current simplification settings.- Specified by:
simplify
in interfaceNameTransformer
- Parameters:
input
- the input string to be simplified- Returns:
- a simplified string
-
reloadFromOptions
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 valuesoptionName
- the name of the options that changedoldValue
- the old value for the option that changednewValue
- the new value for the option that changed- Returns:
- true if the option that changed was a template simplification option
-