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 classOptionData.TypeAn enum describing the different available types of options
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConstraint(Constraint constraint)Add a constraint for this optionjava.util.List<Constraint>getConstraints()Get the constraints defined for this optionjava.lang.StringgetDetailText()Return the text to be used for the <detail> argument of a detail optionjava.lang.StringgetHelpText()Return the text describing the purpose of the optionintgetResultCount()Get the number of results found for this option, which is number of times the key matchedjava.lang.StringgetResultDetail(int index)Get the detail with the given index.java.util.List<java.lang.String>getResultDetails()Return a list of all option detailsjava.lang.StringgetResultValue(int index)Get the value with the given index.java.util.List<java.lang.String>getResultValues()Return a list of all result valuesjava.lang.StringgetSyntax()Get the command line syntax for this option.java.lang.StringgetValueText()Return the text to be used for the <value> argument of a value optionbooleanisSet()Check whether this option has been found on the command lineOptionDatasetDetailText(java.lang.String text)Set the text to be used for the <detail> argument of a value option.OptionDatasetHelpText(java.lang.String text)Set the text describing the purpose of the option.OptionDatasetValueText(java.lang.String text)Set the text to be used for the <value> argument of a value option.java.lang.StringtoString()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-nullvalue 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-nulldetail 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 theHelpPrinteroutput.- 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 theHelpPrinteroutput.- 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 theHelpPrinteroutput.- 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:
addConstraintin interfaceConstrainable- Parameters:
constraint- TheConstraintto add
-
getConstraints
public java.util.List<Constraint> getConstraints()
Get the constraints defined for this option- Specified by:
getConstraintsin interfaceConstrainable- Returns:
- The defined constraints for this option (or
nullif 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:
toStringin classjava.lang.Object- Returns:
- A string representing the instance
-
-