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 booleangetBoolean(char arg)doublegetDouble(char arg)intgetInt(char arg)Map<String,String>getMap(char arg)StringgetString(char arg)String[]getStringArray(char arg)booleanhas(char arg)intnextArgument()private voidparseArgumentCharacter(char argChar)Checks if the ValidateselementIdcharacter given in command line argument to check if there exists a matching schema.private voidparseArgumentCharacters(String argChars)private voidparseArgumentStrings(List<String> argsList)Parses outelementId(s) from theargsstring.private ArgumentMarshalersetArgumentCharacter(char argChar)
-
Field Details
-
Constructor Details
-
Args
Processesargsstring array according to schema defined inschemastring.- 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 theargsstring. Passes them further to validate and identify the marshaler corresponding to them.- Parameters:
argsList- List of substrings ofargsstring.- Throws:
ArgsException-ArgsException- See Also:
method.
-
parseArgumentCharacters
- Parameters:
argChars- List ofelementIds extracted fromargsstring.- Throws:
ArgsException-ArgsException
-
parseArgumentCharacter
Checks if the ValidateselementIdcharacter given in command line argument to check if there exists a matching schema.- Parameters:
argChar- schema given in command line input- Throws:
ArgsException-UNEXPECTED_ARGUMENTif flag don't match with schema.- See Also:
method.
-
setArgumentCharacter
Checks if theelementIdgiven inargsstring exists inmapmap. IfTruethenmarshalercorresponding to thatelementIdis executed.- Parameters:
argChar- element from list ofelementId(s) extracted fromargsstring.- Returns:
- m Marshaler method if specified in the map for given
argCharelse 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
-