public class ValueConstraint extends java.lang.Object implements XMLConstraint
Modifier and Type | Class and Description |
---|---|
static class |
ValueConstraint.Type
An enum with the supported subtypes for this constraint type
|
Constructor and Description |
---|
ValueConstraint()
The public no-org constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
add(OptionData optionData,
int[] values)
Add a constraint of
ValueConstraint.Type INT_ARRAY for the given option |
static void |
add(OptionData optionData,
int imin,
int imax)
Add a constraint of
ValueConstraint.Type INT_RANGE for the given option |
static void |
add(OptionData optionData,
java.lang.String[] values,
boolean caseSensitive)
Add a constraint of
ValueConstraint.Type STRING_ARRAY for the given option |
static void |
add(OptionData optionData,
ValueConstraint.Type type,
java.lang.String spec)
Add a constraint of the given
ValueConstraint.Type with the specified details |
void |
init(Constrainable constrainable,
java.util.List<org.jdom.Element> list)
This method is used to initialize this constraint based on data read from an XML configuration
file.
|
boolean |
isSatisfied()
The actual check routine
|
boolean |
supports(Constrainable constrainable)
Indicates whether a constraint supports a given type of
Constrainable |
java.lang.String |
toString()
This is the overloaded
Object.toString() method |
public ValueConstraint()
public void init(Constrainable constrainable, java.util.List<org.jdom.Element> list)
Constrainable
to which the constraint applies and a list of JDOM elements,
which contain the details about the constraint itself.
This method initializes the constraint and attaches it to the list of constraints
of the Constrainable
instance.
The parameters expected in the XML <param>
tags for this constraint
are
Name | Value | Status |
type | Same as the type parameter in add(OptionData, Type, String) | Required |
spec | Same as the spec parameter in add(OptionData, Type, String) | Required |
init
in interface XMLConstraint
constrainable
- The Constrainable
instance to which this constraint applieslist
- A list of JDOM elements to be used to initialize the constraint. Specifically,
these are tags of the form
<param name="..." value="..." />
containing key/value pairs with information.
public static void add(OptionData optionData, java.lang.String[] values, boolean caseSensitive)
ValueConstraint.Type
STRING_ARRAY
for the given option
optionData
- values
- A string array with the acceptable values for the optioncaseSensitive
- Whether the string comparisons are to be made case sensitive or notpublic static void add(OptionData optionData, int[] values)
ValueConstraint.Type
INT_ARRAY
for the given option
optionData
- values
- An integer array with the acceptable values for the optionpublic static void add(OptionData optionData, int imin, int imax)
ValueConstraint.Type
INT_RANGE
for the given option
optionData
- imin
- The minimum acceptable integer valueimax
- The maximum acceptable integer value (must be greater than or equal to imin
)public static void add(OptionData optionData, ValueConstraint.Type type, java.lang.String spec)
ValueConstraint.Type
with the specified details
optionData
- type
- The type for this constraintspec
- A string specifying the details for this constraint:
Type | Format for specification |
STRING_ARRAY | All values separated by vertical bar (e. g. Foo|Bah|Yeah). If the first string is preceded by '+', the checks are run case insensitive (default is to run them case sensitive) |
INT_ARRAY | All values separated by vertical bar (e. g. 1|2|7) |
INT_RANGE | MIN:MAX (e. g. 7:12) |
public boolean isSatisfied()
isSatisfied
in interface Constraint
public boolean supports(Constrainable constrainable)
Constrainable
supports
in interface Constraint
constrainable
- Constrainable
is supported. This constraint only
supports OptionData
constrainablespublic java.lang.String toString()
Object.toString()
method
toString
in class java.lang.Object