Class Option

java.lang.Object
ghidra.app.util.Option
Direct Known Subclasses:
AbstractOption

public class Option extends Object
Container class to hold an option
  • Constructor Details

    • Option

      @Deprecated(since="12.2", forRemoval=true) public Option(String name, Object value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use AbstractOptionBuilder subclasses instead
      Constructs a new Option
      Parameters:
      name - the name of the option
      value - the value of the option
      Throws:
      IllegalArgumentException - if value is null
    • Option

      @Deprecated(since="12.2", forRemoval=true) public Option(String group, String name, Object value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use AbstractOptionBuilder subclasses instead
      Constructs a new Option
      Parameters:
      group - the name for group of options
      name - the name of the option
      value - the value of the option
      Throws:
      IllegalArgumentException - if value is null
    • Option

      @Deprecated(since="12.2", forRemoval=true) public Option(String name, Class<?> valueClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use AbstractOptionBuilder subclasses instead
      Constructs a new Option
      Parameters:
      name - the name of the option
      valueClass - valueClass the type of the option value
    • Option

      @Deprecated(since="12.2", forRemoval=true) public Option(String name, Object value, Class<?> valueClass, String arg)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use AbstractOptionBuilder subclasses instead
      Constructs a new Option
      Parameters:
      name - the name of the option
      value - the value of the option (could be null)
      valueClass - valueClass the type of the option value, which should match <T>
      arg - the option's command line argument (could be null)
    • Option

      @Deprecated(since="12.2", forRemoval=true) public Option(String name, Class<?> valueClass, Object value, String arg, String group)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use AbstractOptionBuilder subclasses instead
      Constructs a new Option
      Parameters:
      name - the name of the option
      valueClass - valueClass the type of the option value, which should match <T>
      value - the value of the option (could be null)
      arg - the option's command line argument (could be null)
      group - the name for group of options (could be null)
    • Option

      @Deprecated(since="12.2", forRemoval=true) public Option(String name, Class<?> valueClass, Object value, String arg, String group, String stateKey, boolean hidden)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use AbstractOptionBuilder subclasses instead
      Constructs a new Option
      Parameters:
      name - the name of the option
      valueClass - valueClass the type of the option value, which should match <T>
      value - the value of the option (could be null)
      arg - the option's command line argument (could be null)
      group - the name for group of options (could be null)
      stateKey - the state key name (could be null)
      hidden - true if this option should be hidden from the user; otherwise, false
    • Option

      protected Option(String name, Class<?> valueClass, Object value, String arg, String group, String stateKey, boolean hidden, String description)
      Constructs a new Option.
      Parameters:
      name - the name of the option
      valueClass - valueClass the type of the option value, which should match <T>
      value - the value of the option (could be null)
      arg - the option's command line argument (could be null)
      group - the name for group of options (could be null)
      stateKey - the state key name (could be null)
      hidden - true if this option should be hidden from the user; otherwise, false
      description - a description of the option (could be null)
  • Method Details

    • newBoolean

      public static BooleanOption.Builder newBoolean(String name)
      Returns a new BooleanOption.Builder.
      Parameters:
      name - The name of the option
      Returns:
      a new BooleanOption.Builder
    • newString

      public static StringOption.Builder newString(String name)
      Returns a new StringOption.Builder.
      Parameters:
      name - The name of the option
      Returns:
      a new StringOption.Builder
    • newInteger

      public static IntegerOption.Builder newInteger(String name)
      Returns a new IntegerOption.Builder.
      Parameters:
      name - The name of the option
      Returns:
      a new IntegerOption.Builder
    • newHexLong

      public static HexLongOption.Builder newHexLong(String name)
      Returns a new HexLongOption.Builder.
      Parameters:
      name - The name of the option
      Returns:
      a new HexLongOption.Builder
    • newAddress

      public static AddressOption.Builder newAddress(String name)
      Returns a new AddressOption.Builder.
      Parameters:
      name - The name of the option
      Returns:
      a new AddressOption.Builder
    • newAddressSpace

      public static AddressSpaceOption.Builder newAddressSpace(String name)
      Parameters:
      name - The name of the option
      Returns:
      a new AddressSpaceOption.Builder
    • newDomainFile

      public static DomainFileOption.Builder newDomainFile(String name)
      Parameters:
      name - The name of the option
      Returns:
      a new DomainFileOption.Builder
    • newDomainFolder

      public static DomainFolderOption.Builder newDomainFolder(String name)
      Parameters:
      name - The name of the option
      Returns:
      a new DomainFolderOption.Builder
    • setOptionListener

      public void setOptionListener(OptionListener listener)
      Sets this option's listener
      Parameters:
      listener - The OptionListener to set
    • getCustomEditorComponent

      public Component getCustomEditorComponent(AddressFactoryService addressFactoryService)
      Override if you want to provide a custom widget for selecting your options.

      Important! If you override this you MUST also override the copy() method so it returns a new instance of your custom editor.

      Parameters:
      addressFactoryService - The AddressFactoryService
      Returns:
      the custom editor Component, or null if there isn't one
    • getValueClass

      public Class<?> getValueClass()
      Returns the class of the value for this option.
      Returns:
      the class of the value for this option
    • getGroup

      public String getGroup()
      Returns the group name for this option; may be null if group was not specified.
      Returns:
      the group name for this option; may be null if group was not specified
    • getName

      public String getName()
      Returns the name of this option.
      Returns:
      the name of this option
    • getValue

      public Object getValue()
      Returns the value of this option.
      Returns:
      the value of this option
    • setValue

      public void setValue(Object object) throws IllegalArgumentException
      Set the value for this option
      Parameters:
      object - value of this option
      Throws:
      IllegalArgumentException - if the type of the object doesn't not match this option's value class
    • parseAndSetValueByType

      public boolean parseAndSetValueByType(String str, AddressFactory addressFactory)
      Set the value for this option by parsing the given string and converting it to the option's type. Fails if this option doesn't have a type associated with it, or if an unsupported type is needed to be parsed.
      Parameters:
      str - The value to set, in string form.
      addressFactory - An address factory to use for when the option trying to be set is an Address. If null, an exception will be thrown for Address type options.
      Returns:
      True if the value was successfully parsed and set; otherwise, false.
    • getArg

      public String getArg()
      Returns the command line argument for this option (could be null).
      Returns:
      the command line argument for this option (could be null)
    • getStateKey

      public String getStateKey()
      Returns the state key name (could be null).
      Returns:
      the state key name (could be null)
    • getState

      public SaveState getState()
      Returns the current project state associated with this option (could be null).
      Returns:
      the current project state associated with this option (could be null)
    • isHidden

      public boolean isHidden()
      Returns whether or not this option is hidden.
      Returns:
      whether or not this option is hidden
    • getDescription

      public String getDescription()
      Returns the option's description (could be null).
      Returns:
      the option's description (could be null)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • copy

      public Option copy()
      Returns a copy of this Option object.

      NOTE: Option subclasses should always overwrite this method so they can return their exact type, instead of the more generic Option type.

      NOTE: When the deprecated constructors of this class get removed, this method should become abstract.

      Returns:
      a copy of this Option object