Package com.cleancoder.args
Class Args
java.lang.Object
com.cleancoder.args.Args
public class Args extends Object
This is the root class. All other methods
are invoked either directly or indirectly from this class.
- See Also:
Args
,ArgsData
,ArgsException
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description boolean
getBoolean(char arg)
double
getDouble(char arg)
int
getInt(char arg)
Map<String,String>
getMap(char arg)
String
getString(char arg)
String[]
getStringArray(char arg)
boolean
has(char arg)
int
nextArgument()
private void
parseArgumentCharacter(char argChar)
Checks if the ValidateselementId
character given in command line argument to check if there exists a matching schema.private void
parseArgumentCharacters(String argChars)
private void
parseArgumentStrings(List<String> argsList)
Parses outelementId
(s) from theargs
string.private ArgumentMarshaler
setArgumentCharacter(char argChar)
-
Field Details
-
Constructor Details
-
Args
Processesargs
string array according to schema defined inschema
string.- Parameters:
schema
- Set of schema definitions(elementId + elementTail) separated by commas.- Example:
"p#, ch*, d##"
where elementId is p and elementTail is #. Similarly for ch and * are elementId and elementTail respectively.- Example:
args
- String array which may contain command line input.- Example:
"-p 34 -ch abcd -d 3.2"
- Example:
- Throws:
ArgsException
-ArgsException
- See Also:
ArgsData
-
-
Method Details
-
parseArgumentStrings
Parses outelementId
(s) from theargs
string. Passes them further to validate and identify the marshaler corresponding to them.- Parameters:
argsList
- List of substrings ofargs
string.- Throws:
ArgsException
-ArgsException
- See Also:
method.
-
parseArgumentCharacters
- Parameters:
argChars
- List ofelementId
s extracted fromargs
string.- Throws:
ArgsException
-ArgsException
-
parseArgumentCharacter
Checks if the ValidateselementId
character given in command line argument to check if there exists a matching schema.- Parameters:
argChar
- schema given in command line input- Throws:
ArgsException
-UNEXPECTED_ARGUMENT
if flag don't match with schema.- See Also:
method.
-
setArgumentCharacter
Checks if theelementId
given inargs
string exists inmap
map. IfTrue
thenmarshaler
corresponding to thatelementId
is executed.- Parameters:
argChar
- element from list ofelementId
(s) extracted fromargs
string.- Returns:
- m Marshaler method if specified in the map for given
argChar
else returns null. - Throws:
ArgsException
-ArgsException
- See Also:
ArgsData
-
has
public boolean has(char arg) -
nextArgument
public int nextArgument() -
getBoolean
public boolean getBoolean(char arg) -
getString
-
getInt
public int getInt(char arg) -
getDouble
public double getDouble(char arg) -
getStringArray
-
getMap
-