public class XmlPrintStream extends IndentedPrintStream
out| Constructor and Description |
|---|
XmlPrintStream(OutputStream outputStream)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
closeElement()
Close an element previously created with openElement().
|
String |
escape(String in)
Translate reserved XML characters to XML entities.
|
String |
escape(String in,
XMLAttribute.Format format)
Translate reserved XML characters to XML entities.
|
void |
openElement(String name)
Open an XML element with the given name.
|
void |
openElement(String name,
Map<?,?> attributes)
Open an XML element with the given name, and attributes.
|
void |
openElement(String name,
Object... attributes)
Open an XML element with the given name, and attributes.
|
void |
printComment(String comment)
Output a comment.
|
void |
printElement(String name)
Output a complete empty element.
|
void |
printElement(String elementName,
Map<?,?> attributes)
Output a complete element with the given attributes.
|
void |
printElement(String elementName,
Object value)
Output a complete element with the given content.
|
void |
printElement(String elementName,
String value,
Map<?,?> attributes)
Output a complete element with the given content and attributes.
|
void |
printElement(String name,
String value,
Object... attributes)
Output an element with the given content (value).
|
static String |
removeNewLines(String textContent)
Replace multiple newline characters with a single space.
|
align, closeBlock, closeBlock, continueBlock, forceNewLine, getLinePrefix, getOffset, getPrintOffsets, indent, isNoIndent, isNoNl, isoNlCr, isRemoveNl, openBlock, openBlock, outdent, print, print, print, print, print, print, print, print, print, print, print, print, print, print, print, print, print, print, print, print, printAlignedBlock, printlines, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, println, setLinePrefix, setNoIndent, setNoNl, setoNlCr, setPrintOffsets, setRemoveNlappend, append, append, checkError, clearError, close, flush, format, format, printf, printf, setError, write, writewritepublic XmlPrintStream(OutputStream outputStream)
outputStream - An OutputStream to which the formatted output will be sent.public void openElement(String name)
name - Name of the XML element to open.public void openElement(String name, Map<?,?> attributes)
name - Name of the XML element to open.attributes - A map of name value pairs which will be used to add attributes to
the element. Normally you can use Map<String,String> but if you want specify the attribute format use
Map<String, XMLAttribute>. In particular, attributes containing json can be processed to avoid escaping of double quote, but
wrapping the attribute in a single quotepublic void openElement(String name, Object... attributes)
name - Name of the element.attributes - Attributes in name value pairs. Normally you can use pair of String,String but
if you want specify the attribute format use pair of String, XMLAttribute. In particular, attributes containing json can be processed to
avoid escaping of double quote, but wrapping the attribute in a single quotepublic void closeElement()
public void printElement(String elementName, Object value)
elementName - Name of element.value - Content of element.public void printElement(String name, String value, Object... attributes)
name - Name of the element.value - Contents of the element.attributes - Alternate names and values of attributes for the element. Normally you can
use pair of String,String but if you want specify the attribute format use pair of String, XMLAttribute. In
particular, attributes containing json can be processed to
avoid escaping of double quote, but wrapping the attribute in a single quotepublic void printElement(String elementName, Map<?,?> attributes)
elementName - Name of element.attributes - A map of name value pairs which will be used to add attributes to
the element. Normally you can use Map<String,String> but if you want specify the
attribute format use Map<String, XMLAttribute>. In particular, attributes containing json can be
processed to avoid escaping of double quote, but wrapping the attribute in a single quotepublic void printElement(String elementName, String value, Map<?,?> attributes)
elementName - Name of element.value - Content of element.attributes - A map of name value pairs which will be used to add attributes to
the element. Normally you can use Map<String,String> but if you want specify the
attribute format use Map<String, XMLAttribute>. In particular, attributes containing json can be
processed to avoid escaping of double quote, but wrapping the attribute in a single quotepublic void printElement(String name)
name - Name of element.public void printComment(String comment)
comment - Comment text.public String escape(String in)
in - Input string.public String escape(String in, XMLAttribute.Format format)
in - Input string.format - Input format. The Json format does not escape ", but it escapes ' !Copyright © 2020 The Symphony Software Foundation. All rights reserved.