code: private static void writeAttribute(String name,
                                         Object value,
                                         PrintWriter writer) {
          if (value != null) {
              String s;
              if (value instanceof String || value instanceof Boolean) {
                  // for String/Boolean we can just use toString()
                  s = value.toString();
              } else {
                  // otherwise its a String[], so space-delimit the values
                  String[] tokens = (String[]) value;
                  int bufLen = tokens.length - 1;
                  for (String token: tokens) bufLen += token.length();
                  StringBuffer buf = new StringBuffer(bufLen);
                  for (int i = 0; i < tokens.length; i++) {
                      if (i > 0) {
                          buf.append(' ');
                      }
                      buf.append(tokens[i]);
                  }
                  s = buf.toString();
              }
              writer.print(" " + name + "=\"" + s + "\"");
          }
      }
docs: Write (space)name="value" to the given PrintWriter if value is defined.