public String getSubIndex(Byte sub) {
    StringBuilder subIndex = new StringBuilder();

    subIndex.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
    subIndex.append("<sub_index>\n");
    subIndex.append("	<entries value=\"" + this.wordsByMD5.get(sub).size() + "\"/>\n");
    subIndex.append("	<header>\n");
    subIndex.append(
        "		<title>Index of " + HTMLEncoder.encodeXML(this.flog.getTitle()) + "</title>\n");
    subIndex.append("	</header>\n");
    subIndex.append("	<files>\n");
    for (int i = 0; i < this.pageIDs.size(); ++i) {
      final String pageName = this.pageIDs.elementAt(i);
      subIndex.append(
          "		<file id=\""
              + Integer.toString(i)
              + "\" key=\""
              + this.baseKey
              + pageName
              + "\" title=\""
              + HTMLEncoder.encodeXML(
                  this.flog
                      .getContentByID(pageName.replace("Content-", "").replace(".html", ""))
                      .getTitle())
              + "\"/>\n");
    }
    subIndex.append("	</files>\n");
    subIndex.append("	<keywords>\n");

    for (String w : this.wordsByMD5.get(sub)) {
      subIndex.append("		<word v=\"" + HTMLEncoder.encodeXML(w) + "\">\n");

      for (int i = 0; i < pageIDs.size(); ++i) {
        if (!this.ourWords.get(w).containsKey(i)) {
          continue;
        }
        StringBuilder positions = new StringBuilder();
        boolean first = true;
        for (Long pos : this.ourWords.get(w).get(i)) {
          if (first) {
            first = false;
          } else {
            positions.append(",");
          }
          positions.append(Long.toString(pos));
        }
        subIndex.append(
            "			<file id=\"" + Integer.toString(i) + "\">" + positions.toString() + "</file>\n");
      }

      subIndex.append("		</word>\n");
    }

    subIndex.append("	</keywords>\n");
    subIndex.append("</sub_index>\n");

    return subIndex.toString();
  }
 private static void sendURIParseError(OutputStream os, boolean shouldDisconnect, Throwable e)
     throws IOException {
   StringWriter sw = new StringWriter();
   PrintWriter pw = new PrintWriter(sw);
   e.printStackTrace(pw);
   pw.close();
   String message =
       "<html><head><title>"
           + l10n("uriParseErrorTitle")
           + "</title></head><body><p>"
           + HTMLEncoder.encode(e.getMessage())
           + "</p><pre>\n"
           + sw.toString();
   sendHTMLError(os, 400, "Bad Request", message, shouldDisconnect, null);
 }
  public String getIndexIndex() {
    StringBuilder index =
        new StringBuilder(
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
                + "<main_index>\n"
                + "	<prefix value=\"1\"/>\n"
                + "	<header>\n"
                + "		<title>Index of "
                + HTMLEncoder.encodeXML(this.flog.getTitle())
                + "</title>\n"
                + "		<owner>"
                + this.flog.getAuthorName()
                + "</owner>\n"
                + "	</header>\n"
                + "	<keywords>\n");
    for (byte i : IndexBuilder.subStores) {
      index.append("		<subIndex key=\"" + Integer.toHexString(i).toLowerCase() + "\"/>\n");
    }

    index.append("	</keywords>\n" + "</main_index>\n");

    return index.toString();
  }