public VariableDefinition getDefinition(String variableId) {
VariableState state = (VariableState) (idMap.get(variableId));
// make sure this is an identifier we handle
if (state == null)
throw new ProcessingException("variable is unsupported: " + variableId);
// if we've resolved the definition before, then we're done
if (state.definition != null)
return state.definition;
// we don't have the definition, so get the DOM node
Node node = state.rootNode;
// we can't keep going unless we have a node to work with
if (node != null) {
// if we've already started parsing this node before, then
// don't start again
if (state.handled)
throw new ProcessingException("processing in progress");
// keep track of the fact that we're parsing this node, and
// also get the type (if it's an Apply node)
state.handled = true;
discoverApplyType(node, state);
try {
// now actually try parsing the definition...remember that
// if its expression has a reference, we could end up
// calling this manager method again
state.definition = VariableDefinition.getInstance(state.rootNode, metaData, this);
return state.definition;
} catch (ParsingException pe) {
// we failed to parse the definition for some reason
throw new ProcessingException("failed to parse the definition", pe);
}
}
// we couldn't figure out how to resolve the definition
throw new ProcessingException("couldn't retrieve definition: " + variableId);
}