public String escapeElementEntities(String str) {
    if (escapeOutput == false) return str;

    StringBuffer buffer;
    char ch;
    String entity;
    //EscapeStrategy strategy = currentFormat.escapeStrategy;

    buffer = null;
    for (int i = 0; i < str.length(); i++) {
      ch = str.charAt(i);
      switch (ch) {
        case '<':
          entity = "&lt;";
          break;
        case '>':
          entity = "&gt;";
          break;
        case '&':
          entity = "&amp;";
          break;
        case '\r':
          entity = "&#xD;";
          break;
        case '\n':
          entity = getLineSeparator();
          break;
        default:
          //if (strategy.shouldEscape(ch)) {
          //    entity = "&#x" + Integer.toHexString(ch) + ";";
          //}
          //else {
          entity = null;
          //}
          break;
      }
      if (buffer == null) {
        if (entity != null) {
          // An entity occurred, so we'll have to use StringBuffer
          // (allocate room for it plus a few more entities).
          buffer = new StringBuffer(str.length() + 20);
          // Copy previous skipped characters and fall through
          // to pickup current character
          buffer.append(str, 0, i);
          buffer.append(entity);
        }
      }
      else {
        if (entity == null) {
          buffer.append(ch);
        }
        else {
          buffer.append(entity);
        }
      }
    }

    // If there were any entities, return the escaped characters
    // that we put in the StringBuffer. Otherwise, just return
    // the unmodified input string.
    return (buffer == null) ? str : buffer.toString();
  }
public String escapeElementEntities(String str)