Package com.adobe.xfa

Class Option

java.lang.Object
com.adobe.xfa.Option

public final class Option extends Object
Represents an option such as those passed to XFAModelFactory::setOption(). This class shouldn't be part of the published XFA DOM API.
 
  
   Usage: an Option is generally stored as a member of the object 
          to which the option pertains.  An Option is created with
          two strings: the name of the option, and a string 
          representing all of the possible values to which the option
          can be set.  The format of the validation string is as 
          follows:
  
          "option1|option2|...|optionN"
  
          Each section of the string represents one possible value.
          It can be one of the following:
  
          "literal"  - a literal string that must match exactly 
                       (i.e. a keyword)
          "%d"       - an integer
          "%lf"      - a double (%lf is long-float scanf notation)
          "%b"       - a boolean (i.e. a "1" or a "0")
          "%s"       - a string
  
          Example: "default|%d|%s" represents that an option can be 
          either the word "default", or an integer, or a string.  
          Note that the order is important.  Possible matches are 
          considered from left to right.
  
          The caller passes the option into setValue(), which matches
          the option against the validation string.  In the example 
          above, if setValue were called with "default", then 
          getMatchingIndex() would return 0.  If instead setValue() 
          were called with "5", then getMatchingIndex() would return 
          1, and the caller could retrieve the value 5 from 
          getInteger().  Finally if a string other than "default" 
          were passed in, then getMatchingIndex() would return 2, and
          the string could be retrieved via getString().
  
          An exception is thrown if setValue is called with an 
          invalid option.
  
          If the option has never been set (ie. setValue() has not 
          been called) then getMatchingIndex() returns -1.
  
  
 
  • Constructor Summary

    Constructors
    Constructor
    Description
    Copy constructor
    Option(String name, String validValues)
    Constructor for Option.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object object)
    Compare this option object to another for equality.
    int
    Return the option type
    boolean
    Return the boolean value held by this option
    double
    Return the double value held by this option
    int
    Return the integer held by this option
    int
    Return the integer held by this option
    Return the name of this option
    Return the string value held by this option
    int
     
    boolean
    Return whether this option has been set via setValue
    void
    Reset an option.
    static int
    setOptionByArray(String packageName, Option[] options, String optionName, String optionValue, boolean bCritical)
    Static routine: given a null-terminated list of pointers to Option, this routine will look up the option called optionName in the list, and call setValue on that option (passing optionValue and bCritical).
    void
    setValue(String value, boolean bCritical)
    Set the value of this option (value is validated against validValues specified in ructor).

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Option

      public Option(Option src)
      Copy constructor
      Parameters:
      src - the Option to copy
    • Option

      public Option(String name, String validValues)
      Constructor for Option.
      Parameters:
      name - the name of the new option
      validValues - the value of the new option.
  • Method Details

    • setOptionByArray

      public static int setOptionByArray(String packageName, Option[] options, String optionName, String optionValue, boolean bCritical)
      Static routine: given a null-terminated list of pointers to Option, this routine will look up the option called optionName in the list, and call setValue on that option (passing optionValue and bCritical). If the option name contains a package name (such as "data_flatten"), this routine will verify that it matches packageName. If it doesn't match, an exception will be thrown. If the optionName is an empty string, then all the options are reset. In this case, -1 is returned. All other parameters except for the option list are ignored when resetting options.
      Parameters:
      packageName - the name of the package that the options belong to (eg. "data").
      options - the list of pointers to options.
      optionName - the name of the option.
      optionValue - the value of the option.
      bCritical - disallow further modification of this option.
      Returns:
      the index into the array of the option that was set, or -1 if optionName is an empty string.
    • equals

      public boolean equals(Object object)
      Compare this option object to another for equality.
      Overrides:
      equals in class Object
      Parameters:
      object - the other option
      Returns:
      true if the two options are equal in value, false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getArgType

      public int getArgType()
      Return the option type
      Returns:
      our option type. This is EMPTY if this option has not been set. If this option has been set, the return type of getArgType will be one of types represented by the validation string in the constructor.
    • getBool

      public boolean getBool()
      Return the boolean value held by this option
      Returns:
      our boolean value
    • getDouble

      public double getDouble()
      Return the double value held by this option
      Returns:
      our double value
    • getInteger

      public int getInteger()
      Return the integer held by this option
      Returns:
      our integer value.
    • getMatchingIndex

      public int getMatchingIndex()
      Return the integer held by this option
      Returns:
      the 0-based index (into validValues specified in the ructor) that this option has been set to via setValue. Returns -1 if option has not been set.
    • getName

      public String getName()
      Return the name of this option
      Returns:
      our name (set in the ructor)
    • getString

      public String getString()
      Return the string value held by this option
      Returns:
      our string value
    • isSet

      public boolean isSet()
      Return whether this option has been set via setValue
      Returns:
      true if the option has been set, false if it has not. (isSet() is equivalent to getMatchingIndex != -1).
    • reset

      public void reset()
      Reset an option. This empties it and clears the locked flag.
    • setValue

      public void setValue(String value, boolean bCritical)
      Set the value of this option (value is validated against validValues specified in ructor).

      After setting the value, the parsed value may be read via getInteger(), getString(), getMatchingIndex() etc.
      Parameters:
      value - the value to take on
      bCritical - disallow further modification of this option.