Package com.cleancoder.args
Class ArgsData
java.lang.Object
com.cleancoder.args.ArgsData
public class ArgsData extends Object
This class is responsible for processing the
schema
argument
in Args
constructor and creating mappings between
schemas and marshalers.- See Also:
Args
-
Field Summary
Fields Modifier and Type Field Description Set<Character>
argsFound
ListIterator<String>
currentArgument
Map<Character,ArgumentMarshaler>
marshalers
-
Constructor Summary
Constructors Constructor Description ArgsData()
-
Method Summary
Modifier and Type Method Description void
parseSchema(String schema)
Splits theschema
string by commas.private void
parseSchemaElement(String element)
Creates mapping betweenelementTail
and relevant marshalers by comparingelementTail
with predefined tail strings.private void
validateSchemaElementId(char elementId)
Checks if the first character of each substring inschema
is a letter or not.
-
Field Details
-
Constructor Details
-
ArgsData
public ArgsData()
-
-
Method Details
-
parseSchema
Splits theschema
string by commas.- Parameters:
schema
- It is defined in the main file.- Example schema string
"f,s*,n#,a##,p[*]"
.- Example schema string
- Throws:
ArgsException
- ArgsExceptionArgsException
-
parseSchemaElement
Creates mapping betweenelementTail
and relevant marshalers by comparingelementTail
with predefined tail strings.- Tail strings:
Also, calls"*", "#", "##", "[*], "&"
.validateSchemaElementId
method to validate schema element id.- Parameters:
element
- schema string as defined in main program.- Throws:
ArgsException
- Throws exceptionINVALID_ARGUMENT_FORMAT
if matching tail string is not found.- See Also:
ArgumentMarshaler
,BooleanArgumentMarshaler
,StringArgumentMarshaler
,IntegerArgumentMarshaler
,DoubleArgumentMarshaler
,StringArrayArgumentMarshaler
,MapArgumentMarshaler
- Tail strings:
-
validateSchemaElementId
Checks if the first character of each substring inschema
is a letter or not.- Parameters:
elementId
- first character of the schema substring.- Example: in schema string
"f,s*,3#"
, substrings are f, s*, 3# ..., f and s* are acceptable but 3# is not acceptable.- Example: in schema string
- Throws:
ArgsException
-INVALID_ARGUMENT_NAME
if the first character is not a letter.
-