public static @Nullable StringBuilder appendEscapedSymbol(@NotNull String str, StringBuilder buffer, int i, String entity, char ch) {
    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 StringBuilder(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);
    }
    return buffer;
  }
public static @Nullable StringBuilder appendEscapedSymbol(@NotNull String str, StringBuilder buffer, int i, String entity, char ch)