public class LengthRestriction extends AbstractStringRestriction implements HelpHint
| Constructor and Description |
|---|
LengthRestriction(int length,
boolean maximum)
Creates a length restriction with either a minimum or maximum
|
LengthRestriction(int min,
int max)
Creates a length restriction with a minimum and maximum i.e.
|
| Modifier and Type | Method and Description |
|---|---|
String[] |
getContentBlock(int blockNumber)
Gets the content block with the given number
|
HelpFormat |
getFormat()
Gets the format of the provided help information
|
String |
getPreamble()
Gets the preamble text that should be included
|
protected boolean |
isValid(String value)
Method that derived classes must implement to check whether a value is
valid
|
int |
numContentBlocks()
Gets the number of content blocks provided
|
protected <T> ParseRestrictionViolatedException |
violated(ParseState<T> state,
ArgumentsMetadata arguments,
String value)
Method that derived classes must implement to provide an exception for
the case of an invalid argument value, this will be called if
AbstractStringRestriction.isValid(String) returns false |
protected <T> ParseRestrictionViolatedException |
violated(ParseState<T> state,
OptionMetadata option,
String value)
Method that derived classes must implement to provide an exception for
the case of an invalid option value, this will be called if
AbstractStringRestriction.isValid(String) returns false |
preValidate, preValidatefinalValidate, finalValidate, getArgumentTitle, getArgumentTitle, getOptionTitle, postValidate, postValidatepublic LengthRestriction(int length,
boolean maximum)
length - Lengthmaximum - True if the length is a maximum, false if it is a minimumpublic LengthRestriction(int min,
int max)
min - Minimum lengthmax - Maximum lengthprotected boolean isValid(String value)
AbstractStringRestrictionisValid in class AbstractStringRestrictionvalue - Valueprotected <T> ParseRestrictionViolatedException violated(ParseState<T> state, OptionMetadata option, String value)
AbstractStringRestrictionAbstractStringRestriction.isValid(String) returns falseviolated in class AbstractStringRestrictionstate - Parser stateoption - Option metadata for the option whose value is being checkedvalue - Value which has been deemed invalidprotected <T> ParseRestrictionViolatedException violated(ParseState<T> state, ArgumentsMetadata arguments, String value)
AbstractStringRestrictionAbstractStringRestriction.isValid(String) returns falseviolated in class AbstractStringRestrictionstate - Parser statearguments - Arguments metadatavalue - Value which has been deemed invalidpublic String getPreamble()
HelpHintgetPreamble in interface HelpHintpublic HelpFormat getFormat()
HelpHintpublic int numContentBlocks()
HelpHint
Help generators should consult the HelpHint.getFormat() return value to
determine how to format the content blocks but they are not required to
do so
numContentBlocks in interface HelpHintpublic String[] getContentBlock(int blockNumber)
HelpHintgetContentBlock in interface HelpHintblockNumber - Block numberCopyright © 2012–2022. All rights reserved.