code: public Object tryEscape(Object contents) {
          if (contents instanceof CharSequence) {
              return escapeXml(contents.toString());
          }
          return contents;
      }
docs: Escapes the string representation of the supplied object if it derives from {@link java.lang.CharSequence},
  otherwise returns the object itself.
  @param contents an object to be escaped for XML
  @return  an escaped string, or the object itself