Package ml.options
Class OptionData
java.lang.Object
ml.options.OptionData
- All Implemented Interfaces:
Constrainable
This class holds all the data for an option. This includes the prefix, the key, the separators
(for value and detail options), the multiplicity, and all the other settings describing the option. The class
is designed to be only a data container from a user perspective, i. e. the user has access to
any data determined by the
Options.check()
methods, but not access to any of the other methods
which are used internally for the operation of the actual check.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enum describing the different available types of options -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConstraint
(Constraint constraint) Add a constraint for this optionGet the constraints defined for this optionReturn the text to be used for the <detail> argument of a detail optionReturn the text describing the purpose of the optionint
Get the number of results found for this option, which is number of times the key matchedgetResultDetail
(int index) Get the detail with the given index.Return a list of all option detailsgetResultValue
(int index) Get the value with the given index.Return a list of all result valuesGet the command line syntax for this option.Return the text to be used for the <value> argument of a value optionboolean
isSet()
Check whether this option has been found on the command linesetDetailText
(String text) Set the text to be used for the <detail> argument of a value option.setHelpText
(String text) Set the text describing the purpose of the option.setValueText
(String text) Set the text to be used for the <value> argument of a value option.toString()
This is the overloadedObject.toString()
method.
-
Method Details
-
isSet
public boolean isSet()Check whether this option has been found on the command line- Returns:
- A boolean indicating whether this option has been found on the command line
-
getResultCount
public int getResultCount()Get the number of results found for this option, which is number of times the key matched- Returns:
- The number of results
-
getResultValue
Get the value with the given index. The index can range between 0 andgetResultCount()
- 1
. However, only for value options, a non-null
value will be returned. Non-value options always returnnull
.- Parameters:
index
- The index for the desired value- Returns:
- The option value with the given index
-
getResultValues
Return a list of all result values- Returns:
- A list with all result values
-
getResultDetail
Get the detail with the given index. The index can range between 0 andgetResultCount()
- 1
. However, only for value options which take details, a non-null
detail will be returned. Non-value options and value options which do not take details always returnnull
.- Parameters:
index
- The index for the desired value- Returns:
- The option detail with the given index
-
getResultDetails
Return a list of all option details- Returns:
- A list with all option details
-
setValueText
Set the text to be used for the <value> argument of a value option. This is used in theHelpPrinter
output.- Parameters:
text
- The text used for the <value> argument of a value option- Returns:
- The option instance itself to allow incovation chaining
-
setDetailText
Set the text to be used for the <detail> argument of a value option. This is used in theHelpPrinter
output.- Parameters:
text
- The text used for the <detail> argument of a value option- Returns:
- The option instance itself to allow incovation chaining
-
setHelpText
Set the text describing the purpose of the option. This is used in theHelpPrinter
output.- Parameters:
text
- The text describing the purpose of the option- Returns:
- The option instance itself to allow incovation chaining
-
getHelpText
Return the text describing the purpose of the option- Returns:
- The text describing the purpose of the option (or an empty string, if that text has not been set)
-
getValueText
Return the text to be used for the <value> argument of a value option- Returns:
- The text to be used for the <value> argument of a value option (or a default value if this text has not been set, or if this is not a value option at all)
-
getDetailText
Return the text to be used for the <detail> argument of a detail option- Returns:
- The text to be used for the <detail> argument of a detail option (or a default value if this text has not been set, or if this is not a detail option at all)
-
addConstraint
Add a constraint for this option- Specified by:
addConstraint
in interfaceConstrainable
- Parameters:
constraint
- TheConstraint
to add
-
getConstraints
Get the constraints defined for this option- Specified by:
getConstraints
in interfaceConstrainable
- Returns:
- The defined constraints for this option (or
null
if no constraints have been defined)
-
getSyntax
Get the command line syntax for this option. This method accounts for all characteristics of the option such as separators, multiplicity, alternate keys and the like.- Returns:
- A string with the command line syntax
-
toString
This is the overloadedObject.toString()
method.
-