public class XBXmlEncoder
extends java.io.Writer
Modifier and Type | Field and Description |
---|---|
static int |
XMLINDENT |
Constructor and Description |
---|
XBXmlEncoder(java.io.OutputStream out)
Create an XBXmlEncoder on top of the given output (byte) stream.
|
XBXmlEncoder(java.io.OutputStream out,
java.lang.String charsetName)
Create an XBXmlEncoder on top of the given output (byte) stream.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
checkWellFormedElementAndContent(java.lang.String xmlFragment)
Parse the given XML fragment to ensure it is well-formed.
|
void |
close() |
void |
enableUniqueAttrChecking()
For the current element only, turn on unique attribute checking.
|
void |
encodeAttr(java.lang.String name,
java.lang.String nsUri,
java.lang.String prefix,
java.lang.String value)
This method encodes an XML attribute value.
|
void |
encodeAttrs(java.util.List attrs)
This method encodes the attributes in the given list.
|
void |
encodeChars(java.lang.String data)
Encode characters, applying escaping.
|
void |
encodeCharsNoEscaping(java.lang.String data)
Encode characters, as is (without escaping).
|
void |
encodeEndElement()
This method closes an element.
|
void |
encodeNamespace(XBXmlNamespace namespace)
Encode the given namespace on the next start element tag.
|
void |
encodeStartDocument()
This method encodes standard header information at the beginning
of the XML document.
|
void |
encodeStartElement(java.lang.String elemName,
java.lang.String nsUri,
java.lang.String nsPrefix)
This method encodes an XML start element tag.
|
void |
encodeXsiType(javax.xml.namespace.QName typeQName)
Encode an xsi:type attribute for the given QName
Eg.
|
void |
flush() |
void |
setCanonicalXML(boolean value)
Turn Canonical XML behavior on/off.
|
void |
setIndent(int value)
This method sets the number of spaces per indentation.
|
void |
setNamespaces(XBXmlNamespace[] namespaces)
Set the namespaces that should be encoded in the root element.
|
void |
write(char[] cbuf,
int off,
int len) |
void |
write(int c) |
void |
write(java.lang.String str,
int off,
int len) |
public static final int XMLINDENT
public XBXmlEncoder(java.io.OutputStream out)
out
- public XBXmlEncoder(java.io.OutputStream out, java.lang.String charsetName)
out
- charsetName
- Characters will be encoded according to the given
charset name (see java.nio.charset.Charset class).public java.lang.String checkWellFormedElementAndContent(java.lang.String xmlFragment)
xmlFragment
- public void enableUniqueAttrChecking()
public void encodeAttr(java.lang.String name, java.lang.String nsUri, java.lang.String prefix, java.lang.String value) throws XBException
name
- Attribute namensUri
- The attribute's namespace (empty if none)prefix
- Suggested prefixvalue
- Attribute value in string form.XBException
public void encodeAttrs(java.util.List attrs) throws XBException
attrs
- The attributes to encode. List<XBAttributeBase>XBException
public void encodeChars(java.lang.String data)
public void encodeCharsNoEscaping(java.lang.String data)
public void encodeNamespace(XBXmlNamespace namespace)
public void encodeStartElement(java.lang.String elemName, java.lang.String nsUri, java.lang.String nsPrefix)
elemName
- The name of element.nsUri
- The element's namespace (possibly empty)nsPrefix
- A suggested prefix for nsUriXBException
- Thrown, if operation is failed.public void encodeEndElement()
public void encodeXsiType(javax.xml.namespace.QName typeQName)
public void setIndent(int value)
value
- Number of spaces per indentation level.public void encodeStartDocument()
XBException
- Thrown, if operation is failed.public void setCanonicalXML(boolean value)
value
- true to turn Canonical XML behavior onpublic void setNamespaces(XBXmlNamespace[] namespaces)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Writer
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.Writer
java.io.IOException
public void write(int c) throws java.io.IOException
write
in class java.io.Writer
java.io.IOException
public void write(java.lang.String str, int off, int len) throws java.io.IOException
write
in class java.io.Writer
java.io.IOException
public void write(char[] cbuf, int off, int len) throws java.io.IOException
write
in class java.io.Writer
java.io.IOException