Beispiel #1
0
  void storeXml(ParseIndexContext ctx, Path xml) throws IOException {
    Files.createFile(xml);
    PrintWriter p = new PrintWriter(Files.newBufferedWriter(xml, utf8));
    p.print("<?xml version='1.1' encoding='" + NotesRetriever.utf8.name() + "'?><snotes>");

    ctx.list.sort(Comparator.comparing(o1 -> o1.number));
    for (NoteListItem i : ctx.list) {
      p.print("\n<n");
      p.print(" n='" + i.number + "'");
      if (i.mark != null) p.print(" m='" + i.mark + "'");
      p.print(" a='" + i.apparea + "'");
      p.print(" l='" + i.asklangu + "'");
      p.print(" d='" + DateTimeFormatter.ISO_LOCAL_DATE.format(i.date) + "'");
      p.print(" c='" + i.category + "'");
      p.print(" p='" + i.priority + "'");
      if (i.objid != null) p.print(" o='" + i.objid + "'");
      p.print(">" + StringEscapeUtils.escapeXml11(i.title) + "</n>");
    }
    p.flush();
    for (Pair<String, String> a : ctx.lareas) {
      p.print("\n<area rcode='" + a.getKey() + "' value='" + a.getValue() + "'/>");
    }
    p.flush();
    //		p.print("\n<!-- [Statistics]");
    //		if (dsd==0 && dod==0) {
    //			p.print("\tNotes collected: " + q + ", no duplicates found");
    //		} else {
    //			p.print("\nUnique notes collected: " + q);
    //			p.print("\nDuplicate notes with the same date: " + dsd);
    //			p.print("\nDuplocate notes with the other date: " + dod);
    //		}
    //		p.println("\t-->");
    p.print("\n</snotes>");
    p.close();
  }
Beispiel #2
0
  private void echoText() throws SAXException {
    if (textBuffer == null) return;
    String s = textBuffer.toString();

    if (samplerBuffer != null && classNames != null) {
      Matcher matcher = pattern.matcher(s);
      while (matcher.find()) {
        String group = matcher.group(1);
        String[] split = StringUtils.split(group, '.');
        String simpleClassName = split[split.length - 1];
        if (StringUtils.endsWith(simpleClassName, "Action")) {
          classNames.add(simpleClassName);
        }
      }
    }

    emit(StringEscapeUtils.escapeXml11(s));
    textBuffer = null;
  }
Beispiel #3
0
 // StringUtils.escapeForXML(json)
 @Override
 public String toXML() {
   return String.format(
       "<%s xmlns=\"%s\">%s</%s>",
       GCM_ELEMENT_NAME, GCM_NAMESPACE, StringEscapeUtils.escapeXml11(json), GCM_ELEMENT_NAME);
 }
Beispiel #4
0
 /** Xml 转码. */
 public static String escapeXml(String xml) {
   return StringEscapeUtils.escapeXml11(xml);
 }