code: private static void escapeXml(final char[] text, final int offset, final int len, final Writer writer,
                                   final XmlEscapeSymbols symbols, final XmlEscapeType type, final XmlEscapeLevel level)
                                   throws IOException {
  
          if (writer == null) {
              throw new IllegalArgumentException("Argument 'writer' cannot be null");
          }
  
          if (type == null) {
              throw new IllegalArgumentException("The 'type' argument cannot be null");
          }
  
          if (level == null) {
              throw new IllegalArgumentException("The 'level' argument cannot be null");
          }
  
          final int textLen = (text == null? 0 : text.length);
  
          if (offset < 0 || offset > textLen) {
              throw new IllegalArgumentException(
                      "Invalid (offset, len). offset=" + offset + ", len=" + len + ", text.length=" + textLen);
          }
  
          if (len < 0 || (offset + len) > textLen) {
              throw new IllegalArgumentException(
                      "Invalid (offset, len). offset=" + offset + ", len=" + len + ", text.length=" + textLen);
          }
  
          XmlEscapeUtil.escape(text, offset, len, writer, symbols, type, level);
  
      }
docs: /*
  Private escape method called from XML 1.0 and XML 1.1 public methods, once the correct
  symbol set has been selected.