public class Fragments
extends java.lang.Object
Represents a commandline format as an ordered list of
CommandlineFragment
s that are applied to an array of
arguments.
Constructor and Description |
---|
Fragments(CommandlineFragment[] frags)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
CommandlineFragment[] |
getFragments()
Used after the
matches(String[]) method, this returns the fragments
together with the settings that they have absorbed from the arguments. |
CommandlineFragment[] |
getFragmentsInUserOrder()
For use in formatting commandline help, this method orders the constituent
fragments in a way that would make sense to a user.
|
CommandlineSyntaxException |
getReason()
Used after the
matches(String[]) method, this returns the reason, if
any, that one of the CommandlineFragment s failed to parse the set of
arguments. |
boolean |
matches(java.lang.String[] s)
Apply the
CommandlineFragment s to the supplied arguments (after calling
reset on the components). |
void |
resetFragments()
Reset the constituent fragments to their initial states.
|
public Fragments(CommandlineFragment[] frags)
Create a new instance.
frags
- the CommandlineFragment
s that make up the commandlinepublic void resetFragments()
Reset the constituent fragments to their initial states.
public CommandlineFragment[] getFragments()
Used after the matches(String[])
method, this returns the fragments
together with the settings that they have absorbed from the arguments. The
fragments are returned in order of application, which is not necessarily the
order that the user would see the relevant entries on the commandline.
getFragmentsInUserOrder()
public CommandlineFragment[] getFragmentsInUserOrder()
For use in formatting commandline help, this method orders the constituent
fragments in a way that would make sense to a user. Otherwise, this method is
identical to getFragments()
.
getFragments()
public CommandlineSyntaxException getReason()
Used after the matches(String[])
method, this returns the reason, if
any, that one of the CommandlineFragment
s failed to parse the set of
arguments.
public boolean matches(java.lang.String[] s)
Apply the CommandlineFragment
s to the supplied arguments (after calling
reset on the components).
s
- the arguments, e.g., as passed to a main(...)
true
if the CommandlineFragment
s succeeded in
consuming the arguments.