public URI getVariableType(String variableId) {
VariableState state = (VariableState)(idMap.get(variableId));
// make sure the variable is supported
if (state == null)
throw new ProcessingException("variable not supported: " +
variableId);
// if we've previously figured out the type, then return that
if (state.type != null)
return state.type;
// we haven't figured out the type already, so see if we have or
// can resolve the definition
VariableDefinition definition = state.definition;
if (definition == null)
definition = getDefinition(variableId);
// if we could get the definition, then ask it for the type
if (definition != null)
return definition.getExpression().getType();
// we exhausted all our ways to get the right answer
throw new ProcessingException("we couldn't establish the type: " +
variableId);
}