Package org.apache.calcite.util
Class XmlOutput
java.lang.Object
org.apache.calcite.util.XmlOutput
Streaming XML output.
 
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 SummaryConstructorsConstructorDescriptionXmlOutput(PrintWriter out) Constructs a new XmlOutput based on aPrintWriter.Constructs a new XmlOutput based on anyWriter.
- 
Method SummaryModifier and TypeMethodDescriptionvoidWrites an attribute.voidbeginBeginTag(String tagName) voidIf we are currently inside the start tag, finishes it off.voidStarts writing a new tag to the stream.voidWrites a CDATA section (ascdata(String)).voidWrites a CDATA section.voidWrites content.voidWrites an empty tag to the stream.voidendBeginTag(String tagName) voidCompletes a tag.booleanbooleanvoidheader()Write header.voidWrite header, take version as input.intReturns the total number of tags written.voidSends a string directly to the output stream, without escaping any characters.voidsetAlwaysQuoteCData(boolean alwaysQuoteCData) Sets whether to always quote cdata segments (even if they don't contain special characters).voidsetCompact(boolean compact) Sets or unsets the compact mode.voidsetGlob(boolean glob) Sets whether to detect that tags are empty.voidsetIgnorePcdata(boolean ignorePcdata) Sets whether to ignore unquoted text, such as whitespace.voidsetIndentString(String indentString) Sets the string to print for each level of indentation.voidWrites a String tag; a tag containing nothing but a CDATA section.
- 
Constructor Details- 
XmlOutputConstructs a new XmlOutput based on anyWriter.- Parameters:
- out- the writer to which this XmlOutput generates results.
 
- 
XmlOutputConstructs a new XmlOutput based on aPrintWriter.- Parameters:
- out- the writer to which this XmlOutput generates results.
 
 
- 
- 
Method Details- 
setCompactpublic void setCompact(boolean compact) Sets or unsets the compact mode. Compact mode causes the generated XML to be free of extraneous whitespace and other unnecessary characters.- Parameters:
- compact- true to turn on compact mode, or false to turn it off.
 
- 
getCompactpublic boolean getCompact()
- 
setIndentStringSets the string to print for each level of indentation. The default is a tab. The value must not benull. Set this to the empty string to achieve no indentation (note thatsetCompact(boolean)(true)
- 
setGlobpublic void setGlob(boolean glob) Sets whether to detect that tags are empty.
- 
setAlwaysQuoteCDatapublic void setAlwaysQuoteCData(boolean alwaysQuoteCData) Sets whether to always quote cdata segments (even if they don't contain special characters).
- 
setIgnorePcdatapublic void setIgnorePcdata(boolean ignorePcdata) Sets whether to ignore unquoted text, such as whitespace.
- 
getIgnorePcdatapublic boolean getIgnorePcdata()
- 
printSends a string directly to the output stream, without escaping any characters. Use with caution!
- 
beginTagpublic void beginTag(String tagName, @Nullable org.apache.calcite.util.XmlOutput.XMLAttrVector attributes) Starts writing a new tag to the stream. The tag's name must be given and its attributes should be specified by a fully constructed AttrVector object.- Parameters:
- tagName- the name of the tag to write.
- attributes- an XMLAttrVector containing the attributes to include in the tag.
 
- 
beginBeginTag
- 
endBeginTag
- 
attributeWrites an attribute.
- 
beginNodepublic void beginNode()If we are currently inside the start tag, finishes it off.
- 
endTagCompletes a tag. This outputs the end tag corresponding to the last exposed beginTag. The tag name must match the name of the corresponding beginTag.- Parameters:
- tagName- the name of the end tag to write.
 
- 
emptyTagWrites an empty tag to the stream. An empty tag is one with no tags inside it, although it may still have attributes.- Parameters:
- tagName- the name of the empty tag.
- attributes- an XMLAttrVector containing the attributes to include in the tag.
 
- 
cdataWrites a CDATA section. Such sections always appear on their own line. The nature in which the CDATA section is written depends on the actual string content with respect to these special characters/sequences:- &
- "
- '
- <
- >
 ]]>is special.- Content containing no special characters will be left as-is.
- Content containing one or more special characters but not the
 sequence ]]>will be enclosed in a CDATA section.
- Content containing special characters AND at least one
 ]]>sequence will be left as-is but have all of its special characters encoded as entities.
 
- 
cdataWrites a CDATA section (ascdata(String)).- Parameters:
- data- string to write
- quote- if true, quote in a- <![CDATA[...- ]]>regardless of the content of- data; if false, quote only if the content needs it
 
- 
stringTagWrites a String tag; a tag containing nothing but a CDATA section.
- 
contentWrites content.
- 
headerpublic void header()Write header. Use default version 1.0.
- 
headerWrite header, take version as input.
- 
numTagsWrittenpublic int numTagsWritten()Returns the total number of tags written.- Returns:
- the total number of tags written to the XML stream.
 
 
-