Package com.yahoo.document.serialization
Class XmlStream
java.lang.Object
com.yahoo.document.serialization.XmlStream
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
endTag()
Deprecated.Ends the last tag created.boolean
Deprecated.Check if all tags have been properly closed.void
Deprecated.Set an indent to use for pretty printing of XML.toString()
Deprecated.
-
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
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
Deprecated. -
beginTag
Deprecated.Add a new XML tag with the given name.- Parameters:
name
- the tag name
-
addAttribute
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 namevalue
- the attribute value
-
addContent
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.
-