// Trim the attribute name and leading spaces
attrVal.delete(0,attrName.length());
if (attrVal.length() == 0){
// We have a missing token value
ResultException ex = new ResultException();
ex.addError("No value for attribute: " + attrName);
ex.setLocationInfo(fileName, in.getLineNumber());
throw(ex);
}
while(attrVal.charAt(0) == ' '){
attrVal.delete(0,1);
}
}
}
}
else{
if (uco != null){
// We have a blank line which means we've reached the end of an object - pass off
// the current object for processing
inObject = false;
// Tack on the last attribute
if (attrName != null){
val = attrVal.toString().trim();
if (preserveNL.get(attrName) != null)
val = val.replaceAll("\n", "\\\\n");
uco.addValue(attrName,new String(val));
}
try{
handler.handleObject(uco,fn, in.getLineNumber());
}
catch(ResultException ex){
// DebugInfo.debug(ex.toString());
// If this is the first exception, just hang on to it - we may
// wind up adding to it later. Otherwise, just append the results
// to our existing exception.
if (exG == null)
exG = ex;
else
exG.result.addResults(ex.result);
if (exG.result.worst() == Result.FATAL){
uco = null;
break;
}
if (allowedErrorsV == -1){
// Couldn't care less about errors! Just go merrily on our way.
}
else if ((allowedErrorsV == 0) && (exG.result.errors() > 0)){
// Couldn't allow errors - let's bail
uco = null;
break;
}
else if (exG.result.errors() >= allowedErrorsV){
// We've reached the limits of our patience
uco = null;
break;
}
}
// Reset our object and go on for the next one
uco = null;
}
}
}
lastLine = in.getLineNumber();
}
in.close();
}
catch (IOException e) {
if (exG == null)
exG = new ResultException();
exG.result.addResult(Result.FATAL,e.toString());
exG.result.lastResult().moreMessages("Occurred while reading file: " + fileName);
uco = null;
}