code: private void escape(StringBuilder sb, String text) {
          if (text == null) {
              text = "<null>";
          }
          for (int i = 0; i < text.length(); i++) {
              char ch = text.charAt(i);
              if (ch == '<') {
                  sb.append("&lt;");
              } else if (ch == '>') {
                  sb.append("&gt;");
              } else if (ch == '&') {
                  sb.append("&amp;");
              } else {
                  sb.append(ch);
              }
          }
      }
docs: For a null string we append "<null>"