Package com.google.gdata.util.common.xml

Examples of com.google.gdata.util.common.xml.XmlWriter


  }

  /** Pretty-print an entry. */
  private static void pp(GoogleService service, BaseEntry entry, Writer w)
      throws IOException {
    XmlWriter xw = new XmlWriter(w, XML_PP, null);
    ExtensionProfile extProfile = service.getExtensionProfile();
    entry.generateAtom(xw, extProfile);
    xw.flush();
    w.write("\n");
    w.flush();
  }
View Full Code Here


      this.xmlBlob = xmlBlob;
      this.mixedContent = mixedContent;
      this.innerXmlStringWriter = new StringWriter();
      try {
        this.innerXml = new XmlWriter(innerXmlStringWriter);

        // The XmlWriter constructor doesn't actually throw an IOException, so
        // once that constructor is fixed we can remove this catch block.
      } catch (IOException impossible) {
        throw new AssertionError(impossible);
View Full Code Here

            throw new IllegalArgumentException("txtConent==null");
        }
        if( txtConent.getContent().isEmpty() )return "";
       
        StringWriter strw = new StringWriter();
        XmlWriter xmlWriter = new XmlWriter(strw);
        txtConent.getContent().generateRss(xmlWriter, "body", RssFormat.FULL_HTML);
        xmlWriter.flush();
        String xml = strw.toString();
       
        Document xdoc = XMLUtil.parseXML(xml);
        Element e = xdoc.getDocumentElement();
        return e.getTextContent();
View Full Code Here

      this.xmlBlob = xmlBlob;
      this.mixedContent = mixedContent;
      this.innerXmlStringWriter = new StringWriter();
      try {
        this.innerXml = new XmlWriter(innerXmlStringWriter);
       
        // The XmlWriter constructor doesn't actually throw an IOException, so
        // once that constructor is fixed we can remove this catch block.
      } catch (IOException impossible) {
        throw new AssertionError(impossible);
View Full Code Here


  public XmlWriter getRequestWriter() throws IOException {
    OutputStream requestStream = getRequestStream();
    Writer writer = new OutputStreamWriter(requestStream, "utf-8");
    return new XmlWriter(writer);
  }
View Full Code Here

    XmlBlob cumulative = new XmlBlob();
    Collection<XmlNamespace> namespaces = cumulative.getNamespaces();

    StringWriter w = new StringWriter();
    XmlWriter xw = new XmlWriter(w);

    if (xmlBlob != null) {
      cumulative.setLang(xmlBlob.getLang());
      cumulative.setBase(xmlBlob.getBase());
      namespaces.addAll(xmlBlob.getNamespaces());
      w.write(xmlBlob.getBlob());
    }

    if (manifest != null) {
      for (XmlNamespace ns : manifest.getNamespaceDecls()) {
        XmlNamespace newNs = new XmlNamespace(ns.getAlias(), ns.getUri());
        if (!namespaces.contains(newNs)) {
          namespaces.add(newNs);
        }
      }
    }

    for (Extension ext : nonRepeatingExtensionMap.values()) {
      ext.generate(xw, extProfile);
    }

    for (List<Extension> extList : repeatingExtensionMap.values()) {
      xw.startRepeatingElement();
      for (Extension ext : extList) {
        ext.generate(xw, extProfile);
      }
      xw.endRepeatingElement();
    }

    cumulative.setBlob(w.toString());
    return cumulative;
  }
View Full Code Here

    nonRepeatingExtensionMap.clear();
    repeatingExtensionMap.clear();

    // Prepare a fake XML document from the blob.
    StringWriter sw = new StringWriter();
    XmlWriter w = new XmlWriter(sw);
    XmlBlob.startElement(w, null, "CUMULATIVE_BLOB", blob, null, null);
    XmlBlob.endElement(w, null, "CUMULATIVE_BLOB", blob);

    // Now parse it.
    StringReader sr = new StringReader(sw.toString());
View Full Code Here


  public XmlWriter getRequestWriter() throws IOException {
    OutputStream requestStream = getRequestStream();
    Writer writer = new OutputStreamWriter(requestStream, "utf-8");
    return new XmlWriter(writer);
  }
View Full Code Here

  public String getPlainText() {

    try {

      StringWriter sw = new StringWriter();
      XmlWriter xw = new XmlWriter(sw);
      xw.innerXml(xhtml.getBlob());

      return HtmlToText.htmlToPlainText(sw.toString());

    } catch (IOException e) {
      // IOException isn't very meaningful to callers, so it's better to
View Full Code Here

      // Because RSS doesn't allow child markup, we convert XHTML into an
      // encoded string, just like HTML.

      StringWriter sw = new StringWriter();
      XmlWriter xw = new XmlWriter(sw);
      xw.innerXml(xhtml.getBlob());

      // At this point, sw contains the <xhtml:div> element.
      w.simpleElement(Namespaces.rssNs, elementName, null, sw.toString());
      break;
View Full Code Here

TOP

Related Classes of com.google.gdata.util.common.xml.XmlWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.