System.out.println("Line " + line + " doesn't match " + m.pattern().pattern());
return null;
}
String[] lineParts = line.split(delimiter);
CDR cdr = new CDR();
for (int i=0; i<attributeList.size(); i++) {
AttributeBase attr = null;
try
{
attr = (AttributeBase)attributeList.get(i);
AttributeType type = AttributeType.lookup(attr.getType());
if (type == AttributeType.EXTENSION_ID)
cdr.setExtensionID(attr.getValueString(lineParts));
else if (type == AttributeType.DATE_ANSWERED)
cdr.setDateTimeAnswered(((DateAttribute)attr).getDate(lineParts));
else if (type == AttributeType.TIME_ANSWERED)
cdr.setDateTimeAnswered(((TimeAttribute)attr).getDate(cdr.getDateTimeAnswered(), lineParts));
else if (type == AttributeType.CALL_TYPE)
cdr.setCallType(CallType.lookup(
((CallTypeAttribute)attr).getTypeString(lineParts)
));
else if (type == AttributeType.DESTINATION_CLI)
cdr.setDestinationOrCallID(attr.getValueString(lineParts));
else if (type == AttributeType.DURATION_ANSWERED)
cdr.setDurationAnswered(((DurationAttribute)attr).getDurationSeconds(lineParts));
}
catch(StringIndexOutOfBoundsException e) {
System.out.println("Failed to parser attr " + attr + "for line " + line);
}