Package ml.options
Class OptionData
- java.lang.Object
-
- ml.options.OptionData
-
- All Implemented Interfaces:
Constrainable
public class OptionData extends java.lang.Object implements 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 theOptions.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 Classes Modifier and Type Class Description static class
OptionData.Type
An enum describing the different available types of options
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConstraint(Constraint constraint)
Add a constraint for this optionjava.util.List<Constraint>
getConstraints()
Get the constraints defined for this optionjava.lang.String
getDetailText()
Return the text to be used for the <detail> argument of a detail optionjava.lang.String
getHelpText()
Return the text describing the purpose of the optionint
getResultCount()
Get the number of results found for this option, which is number of times the key matchedjava.lang.String
getResultDetail(int index)
Get the detail with the given index.java.util.List<java.lang.String>
getResultDetails()
Return a list of all option detailsjava.lang.String
getResultValue(int index)
Get the value with the given index.java.util.List<java.lang.String>
getResultValues()
Return a list of all result valuesjava.lang.String
getSyntax()
Get the command line syntax for this option.java.lang.String
getValueText()
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 lineOptionData
setDetailText(java.lang.String text)
Set the text to be used for the <detail> argument of a value option.OptionData
setHelpText(java.lang.String text)
Set the text describing the purpose of the option.OptionData
setValueText(java.lang.String text)
Set the text to be used for the <value> argument of a value option.java.lang.String
toString()
This is the overloadedObject.toString()
method.
-
-
-
Method Detail
-
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
public java.lang.String getResultValue(int index)
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
public java.util.List<java.lang.String> getResultValues()
Return a list of all result values- Returns:
- A list with all result values
-
getResultDetail
public java.lang.String getResultDetail(int index)
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
public java.util.List<java.lang.String> getResultDetails()
Return a list of all option details- Returns:
- A list with all option details
-
setValueText
public OptionData setValueText(java.lang.String text)
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
public OptionData setDetailText(java.lang.String text)
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
public OptionData setHelpText(java.lang.String text)
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
public java.lang.String 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
public java.lang.String 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
public java.lang.String 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
public void addConstraint(Constraint constraint)
Add a constraint for this option- Specified by:
addConstraint
in interfaceConstrainable
- Parameters:
constraint
- TheConstraint
to add
-
getConstraints
public java.util.List<Constraint> 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
public java.lang.String 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
public java.lang.String toString()
This is the overloadedObject.toString()
method.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representing the instance
-
-