HierarchicObject currObj = null;
try {
currObj = (HierarchicObject) factory.createWrapper(uco);
} catch (ClassNotFoundException e) {
ResultException ex = new ResultException("Unknown object class: " + uco.classes.get(0));
ex.result.lastResult().fileName(infile);
ex.result.lastResult().lineNumber(lineNumber);
throw(ex);
}
catch (ResultException ex){
ex.setLocationInfo(infile, lineNumber);
throw(ex);
}
currObj.setLineNumber(lineNumber);
currObj.setFile(infile);
if (currObj.getFQN() == null){
ResultException ex = new ResultException();
ex.addError("Missing FQN for object.");
ex.setLocationInfo(currObj.getFile(), currObj.getLineNumber());
throw(ex);
}
fqn = currObj.getFQN();
if (currObj.getFQN().getParentName() != null)
parentFqn = currObj.getFQN().getParentName();
if (parentFqn == null){
if (root == null){
root = currObj;
root.setParentObject(null);
keyMap.put(fqn,root);
}
else{
// The only time that parent should be null is when we're dealing with the
// root object - otherwise, it's an error
ResultException ex = new ResultException();
ex.addError("Missing parent for object:" + fqn);
ex.setLocationInfo(currObj.getFile(), currObj.getLineNumber());
throw(ex);
}
}
else{
if (keyMap.get(fqn) == null){
parentEntry = keyMap.get(parentFqn);
if (parentEntry == null){
ResultException ex = new ResultException();
ex.addError("Missing parent: " + parentFqn + " for object: " + fqn);
ex.setLocationInfo(currObj.getFile(), currObj.getLineNumber());
throw(ex);
}
else{
newEntry = currObj;
newEntry.setParentObject(parentEntry);
keyMap.put(fqn, newEntry);
}
}
else{
ResultException ex = new ResultException();
ex.addError("Duplicate fqn: " + fqn);
ex.setLocationInfo(currObj.getFile(), currObj.getLineNumber());
throw(ex);
}
System.out.println("HierarchyParser read:\n" + newEntry.getFQN());
}