public final class Option extends Object
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 and Description |
|---|
Option(Option src)
Copy constructor
|
Option(String name,
String validValues)
Constructor for Option.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object object)
Compare this option object to another for equality.
|
int |
getArgType()
Return the option type
|
boolean |
getBool()
Return the boolean value held by this option
|
double |
getDouble()
Return the double value held by this option
|
int |
getInteger()
Return the integer held by this option
|
int |
getMatchingIndex()
Return the integer held by this option
|
String |
getName()
Return the name of this option
|
String |
getString()
Return the string value held by this option
|
int |
hashCode() |
boolean |
isSet()
Return whether this option has been set via setValue
|
void |
reset()
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).
|
public Option(Option src)
src - the Option to copypublic static int setOptionByArray(String packageName, Option[] options, String optionName, String optionValue, boolean bCritical)
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.OptionWrongPackageExceptionInvalidOptionExceptionpublic boolean equals(Object object)
public int getArgType()
public boolean getBool()
OptionMisuseExceptionpublic double getDouble()
OptionMisuseExceptionpublic int getInteger()
OptionMisuseExceptionpublic int getMatchingIndex()
public String getName()
public String getString()
OptionMisuseExceptionpublic boolean isSet()
public void reset()
public void setValue(String value, boolean bCritical)
getInteger(), getString(), getMatchingIndex() etc.value - the value to take onbCritical - disallow further modification of this option.OptionLockedExceptionCopyright © 2010 - 2020 Adobe. All Rights Reserved