/**
   * Wrapper for addJavascript/Stylesheet
   *
   * @param type
   * @param contentId
   * @param group
   * @param order
   * @throws DataException
   */
  private void addScript(DataBinder binder, int type, String contentId, String group, long order) {
    DataResultSet rsItems = (DataResultSet) binder.getResultSet(BINDER_RESULT_SET);

    if (rsItems == null) {
      rsItems = createScriptsResultSet(binder);
    }

    Vector<String> values = new Vector<String>();

    values.add(Integer.toString(type));
    values.add(contentId);
    values.add(group);
    values.add(Long.toString(order));

    rsItems.addRow(values);

    binder.addResultSet(BINDER_RESULT_SET, rsItems);
  }
  /**
   * Wrapper for renderJavascripts/stylesheets
   *
   * @param type
   * @param group
   * @return
   * @throws ServiceException
   * @throws DataException
   * @throws IllegalArgumentException
   */
  private static String renderScripts(DataBinder binder, int type, String group)
      throws IllegalArgumentException, DataException, ServiceException {
    boolean compress = SharedObjects.getEnvValueAsBoolean(ENV_COMPRESS_SCRIPTS, false);

    DataResultSet rsItems = (DataResultSet) binder.getResultSet(BINDER_RESULT_SET);

    if (rsItems == null || rsItems.isEmpty()) {
      SystemUtils.trace("system", "Resultset was empty.");
      return "";
    }

    List<String> scripts = new ArrayList<String>();

    rsItems.first();

    do {
      @SuppressWarnings("unchecked")
      Vector<String> scriptRow = rsItems.getCurrentRowValues();

      if (scriptRow.get(SCRIPT_ROW_TYPE).equals(Integer.toString(type))
          && scriptRow.get(SCRIPT_ROW_GROUP).equalsIgnoreCase(group)) {
        scripts.add(scriptRow.get(SCRIPT_ROW_PATH));
      }
    } while (rsItems.next());

    if (scripts.size() > 0) {
      // return single script with combined content
      if (SharedObjects.getEnvValueAsBoolean(ENV_COMBINE_SCRIPTS, false)) {
        return combineScripts(binder, type, scripts, group, compress);
      }

      // return individual script tags
      return writeScriptTags(type, scripts);
    }

    return "";
  }