Class ArrayOperand<T>
- Type Parameters:
T- the generic type
- All Implemented Interfaces:
Cloneable, Comparable<Operand<?>>, MatchCountAccessor, Operand<T[]>, ParsedArgsAccessor, Synopsisable, Term, ExceptionAccessor<ArgsSyntaxException>, VisibleAccessor, VisibleAccessor.VisibleBuilder<Term>, VisibleAccessor.VisibleMutator, VisibleAccessor.VisibleProperty, AliasAccessor, Clonable, DescriptionAccessor, Resetable, TypeAccessor<T[]>, ValueAccessor<T[]>, Diagnosable, Schemable<DiagnosticOptions>
- Direct Known Subclasses:
ArrayDirective, ArrayOption
-
Nested Class Summary
Nested classes/interfaces inherited from interface AliasAccessor
AliasAccessor.AliasBuilder<B>, AliasAccessor.AliasMutator, AliasAccessor.AliasPropertyNested classes/interfaces inherited from interface DescriptionAccessor
DescriptionAccessor.DescriptionBuilder<B>, DescriptionAccessor.DescriptionMutator, DescriptionAccessor.DescriptionPropertyNested classes/interfaces inherited from interface ExceptionAccessor
ExceptionAccessor.ExceptionBuilder<EXC,B>, ExceptionAccessor.ExceptionMutator<EXC>, ExceptionAccessor.ExceptionProperty<EXC> Nested classes/interfaces inherited from interface MatchCountAccessor
MatchCountAccessor.MatchCountBuilder<B>, MatchCountAccessor.MatchCountMutator, MatchCountAccessor.MatchCountPropertyNested classes/interfaces inherited from interface ParsedArgsAccessor
ParsedArgsAccessor.ParsedArgsMutator, ParsedArgsAccessor.ParsedArgsPropertyNested classes/interfaces inherited from interface TypeAccessor
TypeAccessor.TypeBuilder<T,B>, TypeAccessor.TypeMutator<T>, TypeAccessor.TypeProperty<T> Nested classes/interfaces inherited from interface ValueAccessor
ValueAccessor.ValueBuilder<V,B>, ValueAccessor.ValueMutator<V>, ValueAccessor.ValueProperty<V> Nested classes/interfaces inherited from interface VisibleAccessor
VisibleAccessor.VisibleBuilder<B>, VisibleAccessor.VisibleMutator, VisibleAccessor.VisibleProperty -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected ArgsSyntaxExceptionprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionArrayOperand(Operand<T> aOperand) Constructs theArrayOperandby encapsulating the givenOperandand providing its definition as array definition to the CLI.ArrayOperand(Operand<T> aOperand, int aLength) Constructs theArrayOperandby encapsulating the givenOperandand providing its definition as array definition to the CLI.ArrayOperand(Operand<T> aOperand, int aMinLength, int aMaxLength) Constructs theArrayOperandby encapsulating the givenOperandand providing its definition as array definition to the CLI. -
Method Summary
Modifier and TypeMethodDescriptionclone()intgetAlias()Retrieves theArgsSyntaxExceptionexception in case invokingTerm.parseArgs(String[], CliContext)failed.intDetermines the number of args being matched by theTerm.parseArgs(String[], CliContext)(and similar) method(s) of the according syntax.intRetrieves the maximum number of array elements to be present, e.g. maximum number of options provided in the command line arguments.intRetrieves the minimum number of array elements to be present, e.g. minimum number of options provided in the command line arguments.Hook for accessing the encapsulatedOperand.String[]Retrieves the (command line) args which represent thisOperandafter being "parsed" (provided with command line args).getType()T[]getValue()booleanOperand<?>[]parseArgs(String[] aArgs, String[] aOperands, CliContext aCliCtx) Parses the given command line arguments using the provided keyword set and CLI context.voidreset()voidsetVisible(boolean isVisible) protected static String[]toArgsDiff(String[] aArgs, String[] aArgsSubset) Creates the difference between the provided set and the provided subset.protected static String[]toArgsDiff(String[] aArgs, List<? extends Operand<?>> aArgsSubset) Creates the difference between the provided set and the providedLists therein found argument arrays subset (as ofOperand.getParsedArgs()).protected static String[]toArgsDiff(String[] aArgs, Operand<?>[] aArgsSubset) Creates the difference between the provided set and the providedLists therein found argument arrays subset (as ofOperand.getParsedArgs()).String[]toKeywords(CliContext aCliCtx) Produces the keywords (short and/or long options, operations, commands, whatever) with the according prefix (if any) to be considered when overall parsing the command line arguments.protected static String[]toParsedArgs(Operand<?>[]... aOperands) Takes allOperandinstances found in the providedLists and adds all therein found argument arrays (as ofOperand.getParsedArgs()) to the result.toSchema()toSpec(CliContext aCliCtx) Creates a specification including its arguments.toSyntax(CliContext aCliCtx) Creates a syntax including its arguments.toUsage(CliContext aCliCtx) Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.withVisible(boolean isVisible) Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Synopsisable
toSynopsis, toSynopsis, toSynopsis, toSynopsisMethods inherited from interface Term
argsParser, getException, isVisible, parseArgs, setVisible, toSynopsis, toSyntax, toSyntax, toSyntax, toSyntaxMethods inherited from interface ValueAccessor
getValueOrMethods inherited from interface VisibleAccessor
isHiddenMethods inherited from interface VisibleAccessor.VisibleBuilder
withHide, withShowMethods inherited from interface VisibleAccessor.VisibleMutator
hide, showMethods inherited from interface VisibleAccessor.VisibleProperty
letVisible
-
Field Details
-
_description
-
_exception
-
_isVisible
protected boolean _isVisible
-
-
Constructor Details
-
ArrayOperand
Constructs theArrayOperandby encapsulating the givenOperandand providing its definition as array definition to the CLI.- Parameters:
aOperand- TheOperandwhich's array counterpart is to be defined.
-
ArrayOperand
Constructs theArrayOperandby encapsulating the givenOperandand providing its definition as array definition to the CLI.- Parameters:
aOperand- TheOperandwhich's array counterpart is to be defined.aLength- The number of array elements, or -1 if there is no limit.
-
ArrayOperand
Constructs theArrayOperandby encapsulating the givenOperandand providing its definition as array definition to the CLI.- Parameters:
aOperand- TheOperandwhich's array counterpart is to be defined.aMinLength- The minimum number of array elements, or -1 if there is no limit.aMaxLength- The maximum number of array elements, or -1 if there is no limit.
-
-
Method Details
-
getMatchCount
public int getMatchCount()Determines the number of args being matched by theTerm.parseArgs(String[], CliContext)(and similar) method(s) of the according syntax. This way we can determine which part of the syntax (tree) had most matches.- Specified by:
getMatchCountin interfaceMatchCountAccessor- Specified by:
getMatchCountin interfaceTerm- Returns:
- The number of args matching the according syntax (tree).
-
clone
- Specified by:
clonein interfaceClonable- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-
getAlias
Retrieves the name (alias) of the parameter value which can be the name of the operand (Operand) or the option argument (Option), depending on the sub-type inheriting from this interface. The parameter name is merely used for constructing the command line arguments syntaxStringviaOperand.toSyntax(CliContext)and the command line arguments detail description when creating a command line tool's help output. Attention: The alias can also be used as a key when putting anOperand's key/value-pair into a dictionary such as is done by theApplicationPropertiestype provided by therefcodes-properties-ext-runimeartifact!- Specified by:
getAliasin interfaceAliasAccessor- Specified by:
getAliasin interfaceOperand<T>- Returns:
- The name of the parameter, e.g the name of the operand or the name of the option argument.
-
getDescription
- Specified by:
getDescriptionin interfaceDescriptionAccessor
-
getMaxLength
public int getMaxLength()Retrieves the maximum number of array elements to be present, e.g. maximum number of options provided in the command line arguments.- Returns:
- The maximum number of array elements, or -1 if there is no limit.
-
getMinLength
public int getMinLength()Retrieves the minimum number of array elements to be present, e.g. minimum number of options provided in the command line arguments.- Returns:
- The minimum number of array elements, or -1 if there is no limit.
-
getType
- Specified by:
getTypein interfaceTypeAccessor<T>
-
getValue
-
parseArgs
public Operand<?>[] parseArgs(String[] aArgs, String[] aOperands, CliContext aCliCtx) throws ArgsSyntaxException Parses the given command line arguments using the provided keyword set and CLI context.This method represents the core parsing operation. It evaluates this
Termor, if this term is an inner node, delegates parsing to its child terms.The
aKeywordsparameter defines reserved tokens such as option names that must not be interpreted as operand values.This method does not validate whether all arguments have been consumed. Superfluous arguments must be handled by the caller.
- Specified by:
parseArgsin interfaceTerm- Parameters:
aArgs- The command line arguments to parseaOperands- Reserved option and keyword tokensaCliCtx- TheCliContextcontrolling parsing and rendering- Returns:
- The evaluated operands
- Throws:
ArgsSyntaxException- If the arguments do not match the syntax
-
reset
-
getParsedArgs
Retrieves the (command line) args which represent thisOperandafter being "parsed" (provided with command line args).- Specified by:
getParsedArgsin interfaceOperand<T>- Specified by:
getParsedArgsin interfaceParsedArgsAccessor- Returns:
- The according args from the command line args.
-
withVisible
Visibility in this context means displaying or hiding this
Term's existence to the user (defaults totrue).- Specified by:
withVisiblein interfaceVisibleAccessor.VisibleBuilder<T>
-
toSyntax
Creates a syntax including its arguments.A specification differs from a syntax in that the specification provides the full definition not omitting any choices whereas the syntax only provides a syntactically correct variant. For example, having an option with a short option and a long option, the specification will show the short option and the long option whereas the syntax will only show either the short option or, if no short option is set, the long option.
-
toUsage
Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.- Specified by:
toUsagein interfaceOperand<T>- Parameters:
aCliCtx- TheCliContextto use when creating a beautiful usage text.- Returns:
- The according usage text.
-
toSpec
Creates a specification including its arguments.A specification differs from a syntax in that the specification provides the full definition not omitting any choices whereas the syntax only provides a syntactically correct variant. For example, having an option with a short option and a long option, the specification will show the short option and the long option whereas the syntax will only show either the short option or, if no short option is set, the long option.
- Specified by:
toSpecin interfaceOperand<T>- Parameters:
aCliCtx- TheCliContextto use when creating a beautiful specification text.- Returns:
- The according specification text.
-
toKeywords
Produces the keywords (short and/or long options, operations, commands, whatever) with the according prefix (if any) to be considered when overall parsing the command line arguments.- Specified by:
toKeywordsin interfaceOperand<T>- Parameters:
aCliCtx- TheCliContextto use when assembling the keywords.- Returns:
- The keywords with the according prefix.
-
toSchema
-
getOperand
-
getException
Retrieves theArgsSyntaxExceptionexception in case invokingTerm.parseArgs(String[], CliContext)failed. The exception (and the according suppressed ones alongside the causes) does not necessarily have been thrown by theTerm.parseArgs(String[], CliContext)method depending on the semantics of theTermhanding the exception (theAnyConditionprovides any exceptions it caught even though it did not throw them as of its semantics).- Specified by:
getExceptionin interfaceExceptionAccessor<ArgsSyntaxException>- Specified by:
getExceptionin interfaceTerm- Returns:
- The
ArgsSyntaxExceptionexception occurring while parsing the arguments.
-
setVisible
public void setVisible(boolean isVisible) Visibility in this context means displaying or hiding this
Term's existence to the user (defaults totrue).- Specified by:
setVisiblein interfaceTerm- Specified by:
setVisiblein interfaceVisibleAccessor.VisibleMutator
-
isVisible
public boolean isVisible()Visibility in this context means displaying or hiding this
Term's existence to the user (defaults totrue).- Specified by:
isVisiblein interfaceTerm- Specified by:
isVisiblein interfaceVisibleAccessor
-
toArgsDiff
Creates the difference between the provided set and the providedLists therein found argument arrays subset (as ofOperand.getParsedArgs()).- Parameters:
aArgs- The set to be used for the diff operation.aArgsSubset- The subset to be used for the diff operation being the lists containing theOperandinstances whose command line arguments are to be diffed.- Returns:
- The difference between the set and the subset.
-
toArgsDiff
Creates the difference between the provided set and the providedLists therein found argument arrays subset (as ofOperand.getParsedArgs()).- Parameters:
aArgs- The set to be used for the diff operation.aArgsSubset- The subset to be used for the diff operation being the lists containing theOperandinstances whose command line arguments are to be diffed.- Returns:
- The difference between the set and the subset.
-
toArgsDiff
Creates the difference between the provided set and the provided subset.- Parameters:
aArgs- The set to be used for the diff operation.aArgsSubset- The subset to be used for the diff operation.- Returns:
- The difference between the set and the subset.
-
toParsedArgs
Takes allOperandinstances found in the providedLists and adds all therein found argument arrays (as ofOperand.getParsedArgs()) to the result.
-