Class XmlStream

java.lang.Object
com.yahoo.document.serialization.XmlStream

@Deprecated public class XmlStream extends Object
Deprecated.
Class for writing XML in a simplified way.

Give a writer for it to write the XML directly to. If none is given a StringWriter is used so you can call toString() on the class to get the XML.

You build XML by calling beginTag(name), addAttribute(id, value), endTag(). Remember to close all your tags, or you'll get an exception when calling toString(). If writing directly to a writer, call isFinalized to verify that all tags have been closed.

The XML escaping tools only give an interface for escape from and to a string value. Thus writing of all data here is also just available through strings.

Author:
Haakon Humberset
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
    Create an XmlStream writing to a StringWriter.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAttribute(String key, Object value)
    Deprecated.
    Add a new XML attribute to the last tag started.
    void
    addContent(String content)
    Deprecated.
    Add content to the last tag.
    void
    Deprecated.
    Add a new XML tag with the given name.
    void
    Deprecated.
    Ends the last tag created.
    boolean
    Deprecated.
    Check if all tags have been properly closed.
    void
    setIndent(String indent)
    Deprecated.
    Set an indent to use for pretty printing of XML.
    Deprecated.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • XmlStream

      public XmlStream()
      Deprecated.
      Create an XmlStream writing to a StringWriter. Fetch XML through toString() once you're done creating it.
  • Method Details

    • setIndent

      public void setIndent(String indent)
      Deprecated.
      Set an indent to use for pretty printing of XML. Default is no indent.
      Parameters:
      indent - the initial indentation
    • isFinalized

      public boolean isFinalized()
      Deprecated.
      Check if all tags have been properly closed.
      Returns:
      true if all tags are closed
    • toString

      public String toString()
      Deprecated.
      Overrides:
      toString in class Object
    • beginTag

      public void beginTag(String name)
      Deprecated.
      Add a new XML tag with the given name.
      Parameters:
      name - the tag name
    • addAttribute

      public void addAttribute(String key, Object value)
      Deprecated.
      Add a new XML attribute to the last tag started. The tag cannot already have had content added to it, or been ended. If a null value is added, the attribute will be skipped.
      Parameters:
      key - the attribute name
      value - the attribute value
    • addContent

      public void addContent(String content)
      Deprecated.
      Add content to the last tag.
      Parameters:
      content - the content to add to the last tag
    • endTag

      public void endTag()
      Deprecated.
      Ends the last tag created.