src/main/java/org/ucmtwine/proxy/ScriptProxy.java
public boolean evaluateValue(ScriptInfo info, boolean[] returnBool, String[] returnString, ExecutionContext context,
      boolean isConditional) throws ServiceException {
    /**
     * This code, like the beginning block of code in evaluateFunction, is
     * required for preparing the data for evaluation. It should not be altered.
     * Only customize the switch statement below.
     */
    int config[] = (int[]) info.m_entry;
    String key = info.m_key;

    if ((context instanceof Service) == false) {
      // Some variables will evaluate trivially instead of throwing an
      // exception.
      if (config[1] == RETURN_BOOLEAN) {
        returnBool[0] = false;
        returnString[0] = "";
        return true;
      }

      throw new ServiceException("Script variable " + key + " must have be evaluated in "
          + "context of a Service object.");
    }

    UserData userData = (UserData) context.getCachedObject("UserData");

    if (userData == null) {
      throw new ServiceException("Script variable " + key + " must have user data context.");
    }

    int variableIndex = config[0];
    String variableRequested = m_variableTable[variableIndex];

    if (variableIndex > m_variableTable.length) {
      return false; // unknown variable
    }

    Object result = null;

    try {
      result = runVariableMethod(variableIndex, context);

    } catch (Exception e) {
      String msg = "Unable to handle variable " + variableRequested + ": " + e.getMessage();
      SystemUtils.err(e, msg);
      SystemUtils.trace("twine", msg);
      throw new ServiceException(msg);
    }

    if (isConditional) {
      returnBool[0] = ObjectConverter.convert(result, boolean.class);
    } else {
      returnString[0] = ObjectConverter.convert(result, String.class);
    }

    return true;
  }
public boolean evaluateValue(ScriptInfo info, boolean[] returnBool, String[] returnString, ExecutionContext context,
      boolean isConditional) throws ServiceException {
    /**
     * This code, like the beginning block of code in evaluateFunction, is
     * required for preparing the data for evaluation. It should not be altered.
     * Only customize the switch statement below.
     */
    int config[] = (int[]) info.m_entry;
    String key = info.m_key;

    if ((context instanceof Service) == false) {
      // Some variables will evaluate trivially instead of throwing an
      // exception.
      if (config[1] == RETURN_BOOLEAN) {
        returnBool[0] = false;
        returnString[0] = "";
        return true;
      }

      throw new ServiceException("Script variable " + key + " must have be evaluated in "
          + "context of a Service object.");
    }

    UserData userData = (UserData) context.getCachedObject("UserData");

    if (userData == null) {
      throw new ServiceException("Script variable " + key + " must have user data context.");
    }

    int variableIndex = config[0];
    String variableRequested = m_variableTable[variableIndex];

    if (variableIndex > m_variableTable.length) {
      return false; // unknown variable
    }

    Object result = null;

    try {
      result = runVariableMethod(variableIndex, context);

    } catch (Exception e) {
      String msg = "Unable to handle variable " + variableRequested + ": " + e.getMessage();
      SystemUtils.err(e, msg);
      SystemUtils.trace("twine", msg);
      throw new ServiceException(msg);
    }

    if (isConditional) {
      returnBool[0] = ObjectConverter.convert(result, boolean.class);
    } else {
      returnString[0] = ObjectConverter.convert(result, String.class);
    }

    return true;
  }
This is where the custom IdocScript variable is evaluated.