Package com.adobe.xfa
Class Option
java.lang.Object
com.adobe.xfa.Option
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompare this option object to another for equality.intReturn the option typebooleangetBool()Return the boolean value held by this optiondoubleReturn the double value held by this optionintReturn the integer held by this optionintReturn the integer held by this optiongetName()Return the name of this optionReturn the string value held by this optioninthashCode()booleanisSet()Return whether this option has been set via setValuevoidreset()Reset an option.static intsetOptionByArray(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).voidSet the value of this option (value is validated against validValues specified in ructor).
-
Constructor Details
-
Option
Copy constructor- Parameters:
src- the Option to copy
-
Option
Constructor for Option.- Parameters:
name- the name of the new optionvalidValues- 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
Compare this option object to another for equality. -
hashCode
public int hashCode() -
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
Return the name of this option- Returns:
- our name (set in the ructor)
-
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
Set the value of this option (value is validated against validValues specified in ructor).
After setting the value, the parsed value may be read viagetInteger(), getString(), getMatchingIndex()etc.- Parameters:
value- the value to take onbCritical- disallow further modification of this option.
-