if (colonPosition != -1) {
String scriptType = functionName.substring(0, colonPosition);
functionName = functionName.substring(colonPosition+1);
ScriptEnv env = envs.get(scriptType);
if (env == null)
throw new ApiException("UnsupportedScriptLanguage","Unsupported script language: \""+scriptType+"\" for this function: \""+functionName+"\"");
return env.getFunction(functionName, numParameters);
} else { // not prefixed; try to find in each env:
String lang = null;
ScriptFunction fn = null;
for(Map.Entry<String, ScriptEnv> entry: envs.entrySet()) {
ScriptFunction curFn = entry.getValue().getFunction(functionName, numParameters);
if (curFn != null) {
String curLang = entry.getKey();
if (fn != null) { // multiply defined
throw new ApiException("MultiplyDefinedObject", "This object (\""+functionName+"\" is defined under multiple scripting languages ("+lang+" and "+curLang+")");
}
fn = curFn;
lang = curLang;
}
}