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>argsFoundListIterator<String>currentArgumentMap<Character,ArgumentMarshaler>marshalers -
Constructor Summary
Constructors Constructor Description ArgsData() -
Method Summary
Modifier and Type Method Description voidparseSchema(String schema)Splits theschemastring by commas.private voidparseSchemaElement(String element)Creates mapping betweenelementTailand relevant marshalers by comparingelementTailwith predefined tail strings.private voidvalidateSchemaElementId(char elementId)Checks if the first character of each substring inschemais a letter or not.
-
Field Details
-
Constructor Details
-
ArgsData
public ArgsData()
-
-
Method Details
-
parseSchema
Splits theschemastring 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 betweenelementTailand relevant marshalers by comparingelementTailwith predefined tail strings.- Tail strings:
Also, calls"*", "#", "##", "[*], "&".validateSchemaElementIdmethod to validate schema element id.- Parameters:
element- schema string as defined in main program.- Throws:
ArgsException- Throws exceptionINVALID_ARGUMENT_FORMATif 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 inschemais 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_NAMEif the first character is not a letter.
-