public class XmlOutput extends Object
Use this class to write XML to any streaming source. While the class itself is unstructured and doesn't enforce any DTD specification, use of the class does ensure that the output is syntactically valid XML.
| Constructor and Description |
|---|
XmlOutput(PrintWriter out)
Constructs a new XmlOutput based on a
PrintWriter. |
XmlOutput(Writer out)
Constructs a new XmlOutput based on any
Writer. |
| Modifier and Type | Method and Description |
|---|---|
void |
attribute(String name,
String value)
Writes an attribute.
|
void |
beginBeginTag(String tagName) |
void |
beginNode()
If we are currently inside the start tag, finishes it off.
|
void |
beginTag(String tagName,
org.apache.calcite.util.XmlOutput.XMLAttrVector attributes)
Starts writing a new tag to the stream.
|
void |
cdata(String data)
Writes a CDATA section.
|
void |
cdata(String data,
boolean quote)
Writes a CDATA section (as
cdata(String)). |
void |
content(String content)
Writes content.
|
void |
emptyTag(String tagName,
org.apache.calcite.util.XmlOutput.XMLAttrVector attributes)
Writes an empty tag to the stream.
|
void |
endBeginTag(String tagName) |
void |
endTag(String tagName)
Completes a tag.
|
boolean |
getCompact() |
boolean |
getIgnorePcdata() |
void |
header()
Write header.
|
void |
header(String version)
Write header, take version as input.
|
int |
numTagsWritten()
Get the total number of tags written
|
void |
print(String s)
Sends a string directly to the output stream, without escaping any
characters.
|
void |
setAlwaysQuoteCData(boolean alwaysQuoteCData)
Sets whether to always quote cdata segments (even if they don't contain
special characters).
|
void |
setCompact(boolean compact)
Sets or unsets the compact mode.
|
void |
setGlob(boolean glob)
Sets whether to detect that tags are empty.
|
void |
setIgnorePcdata(boolean ignorePcdata)
Sets whether to ignore unquoted text, such as whitespace.
|
void |
setIndentString(String indentString)
Sets the string to print for each level of indentation.
|
void |
stringTag(String name,
String data)
Writes a String tag; a tag containing nothing but a CDATA section.
|
public XmlOutput(Writer out)
Writer.out - the writer to which this XmlOutput generates results.public XmlOutput(PrintWriter out)
PrintWriter.out - the writer to which this XmlOutput generates results.public void setCompact(boolean compact)
compact - true to turn on compact mode, or false to turn it off.public boolean getCompact()
public void setIndentString(String indentString)
null. Set this to the empty
string to achieve no indentation (note that
setCompact(boolean)(true) removes indentation and
newlines).public void setGlob(boolean glob)
public void setAlwaysQuoteCData(boolean alwaysQuoteCData)
public void setIgnorePcdata(boolean ignorePcdata)
public boolean getIgnorePcdata()
public void print(String s)
public void beginTag(String tagName, org.apache.calcite.util.XmlOutput.XMLAttrVector attributes)
tagName - the name of the tag to write.attributes - an XMLAttrVector containing the attributes to include
in the tag.public void beginBeginTag(String tagName)
public void endBeginTag(String tagName)
public void beginNode()
public void endTag(String tagName)
tagName - the name of the end tag to write.public void emptyTag(String tagName, org.apache.calcite.util.XmlOutput.XMLAttrVector attributes)
tagName - the name of the empty tag.attributes - an XMLAttrVector containing the attributes to
include in the tag.public void cdata(String data)
&
"
'
<
>
]]> is special.
]]> will be enclosed in a CDATA section.
]]> sequence will be left as-is but have all of its
special characters encoded as entities.
public void cdata(String data, boolean quote)
cdata(String)).data - string to writequote - if true, quote in a <![CDATA[
... ]]> regardless of the content of
data; if false, quote only if the content needs itpublic void stringTag(String name, String data)
public void content(String content)
public void header()
public void header(String version)
public int numTagsWritten()
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.