parseLine
// The line is expected to be in <customerID> <name> format
String[] tokens = line.split( "\\|" );
if ( tokens.length < 2 )
{
throw new ParseLineDeviation( ERROR_CUSTOMER_TOKEN_COUNT +
tokens.length );
}
String customerIDString = tokens[0];
String customerNameString = tokens[1];
try
{
CustomerID aCustomerID = CustomerID.parseString( customerIDString );
if ( customerNameString.length() < 1 )
{
throw new ParseLineDeviation( ERROR_NO_NAME + line );
}
Name aName = Name.parseString( customerNameString );
return new Customer( aName, aCustomerID );
}
catch ( CustomerIDFormatDeviation e )
{
throw new ParseLineDeviation( e.getMessage() +
customerIDString );
}
catch ( NameFormatDeviation e )
{
throw new ParseLineDeviation( e.getMessage() +
customerNameString );
}