T
- concrete writer, e.g, XMLStreamWriter
or
XMLEventWriter
S
- object to writepublic abstract class XmlWriter<T,S> extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
indent |
protected OutputStream |
out |
private XMLOutputFactory |
outputFactory |
protected static String |
XML_FRAGMENT |
protected String |
XML_VERSION |
Constructor and Description |
---|
XmlWriter() |
Modifier and Type | Method and Description |
---|---|
protected void |
addXlinkHrefAttr(String value) |
protected void |
addXlinkTitleAttr(String value) |
protected abstract void |
attr(QName name,
String value)
Write attribute to stream
|
protected abstract void |
attr(String name,
String value)
Write attribute to stream
|
protected abstract void |
attr(String namespace,
String localName,
String value)
Write attribute to stream
|
protected abstract void |
chars(String chars)
Write characters to stream
|
protected abstract void |
chars(String chars,
boolean escape)
Write characters to stream
|
protected abstract void |
empty(QName name)
Write an empty element to stream
|
protected abstract void |
end()
Write the document end to stream
|
protected abstract void |
end(QName name)
Write the end element to new line
|
protected abstract void |
endInline(QName name)
Write end element to the same line
|
protected abstract void |
finish()
Finish the stream writing, flush and close
|
protected abstract void |
flush()
Flush written elements
|
protected OutputStream |
getOutputStream()
Get the
OutputStream |
protected String |
getReplacement(QName qname)
Create the replacement from
QName |
protected XMLOutputFactory |
getXmlOutputFactory()
Get the
XMLOutputFactory |
protected abstract T |
getXmlWriter()
Get the XML writer
|
protected void |
init(OutputStream out)
Initialize this XML stream writer, calls
init(OutputStream, String) |
protected void |
init(OutputStream out,
EncodingValues encodingValues)
Initialize this XML stream writer, calls
init(OutputStream, String, EncodingValues) |
protected void |
init(OutputStream out,
String encoding)
Initialize this XML stream writer, calls
init(OutputStream, String, EncodingValues) |
protected abstract void |
init(OutputStream out,
String encoding,
EncodingValues encodingValues)
Initialize this XML stream writer
|
protected abstract void |
namespace(String prefix,
String namespace)
Write namespace to stream
|
protected void |
rawText(String text)
Write raw text to stream an adds current indent before writing the text.
|
protected void |
schemaLocation(Set<SchemaLocation> schemaLocations)
Write
SchemaLocation s as xsi:schemaLocations attribute to stream |
protected abstract void |
start(boolean embedded)
Write document start to stream with or without
|
protected abstract void |
start(QName name)
Write start element to stream
|
protected void |
time(TimeInstant time)
Write
TimeInstant to stream |
protected void |
time(TimePosition time)
Write
TimePosition as ISO 8601 to stream |
abstract void |
write(OutputStream out)
Encode and write element to the
OutputStream |
abstract void |
write(OutputStream out,
EncodingValues encodingValues)
Encode and write element to the
OutputStream |
abstract void |
write(S elementToStream,
OutputStream out)
Encode and write the elementToStream to the
OutputStream |
abstract void |
write(S elementToStream,
OutputStream out,
EncodingValues encodingValues)
Encode and write the elementToStream to the
OutputStream |
protected void |
writeIndent(int level)
Write indent to stream
|
protected void |
writeNewLine()
Write new line to stream
|
protected void |
writeXmlObject(org.apache.xmlbeans.XmlObject xmlObject,
QName qname)
Write
XmlObject to stream and replace xml-fragment with
QName |
protected final String XML_VERSION
protected int indent
protected OutputStream out
protected static String XML_FRAGMENT
private final XMLOutputFactory outputFactory
public abstract void write(OutputStream out) throws XMLStreamException, OwsExceptionReport
OutputStream
out
- OutputStream to write the encoded elementXMLStreamException
- If an error occurs when writing to OutputStream
OwsExceptionReport
- If an encoding error occurspublic abstract void write(OutputStream out, EncodingValues encodingValues) throws XMLStreamException, OwsExceptionReport
OutputStream
out
- OutputStream to write the encoded elementencodingValues
- EncodingValues
with additional informationXMLStreamException
- If an error occurs when writing to OutputStream
OwsExceptionReport
- If an encoding error occurspublic abstract void write(S elementToStream, OutputStream out) throws XMLStreamException, OwsExceptionReport
OutputStream
elementToStream
- Element to encode and write to streamout
- OutputStream to write the encoded elementXMLStreamException
- If an error occurs when writing to OutputStream
OwsExceptionReport
- If an encoding error occurspublic abstract void write(S elementToStream, OutputStream out, EncodingValues encodingValues) throws XMLStreamException, OwsExceptionReport
OutputStream
elementToStream
- Element to encode and write to streamout
- OutputStream to write the encoded elementencodingValues
- EncodingValues
with additional informationXMLStreamException
- If an error occurs when writing to OutputStream
OwsExceptionReport
- If an encoding error occursprotected abstract void init(OutputStream out, String encoding, EncodingValues encodingValues) throws XMLStreamException
out
- OutputStream to write the encoded elementencoding
- Encoding, e.g. UTF-8encodingValues
- EncodingValues
with additional informationXMLStreamException
- If an error occurs when initializing the writerprotected abstract T getXmlWriter()
protected abstract void attr(QName name, String value) throws XMLStreamException
name
- Attribute namevalue
- Attribute valueXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void attr(String name, String value) throws XMLStreamException
name
- Attribute namevalue
- Attribute valueXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void attr(String namespace, String localName, String value) throws XMLStreamException
namespace
- Namespace of the attribute namelocalName
- LocalName of the attribute namevalue
- Attribute valueXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void namespace(String prefix, String namespace) throws XMLStreamException
prefix
- Namespace prefixnamespace
- Namespace URIXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void start(QName name) throws XMLStreamException
name
- Element nameXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void start(boolean embedded) throws XMLStreamException
embedded
- if false
, XML version and encoding written to
streamXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void empty(QName name) throws XMLStreamException
name
- Element nameXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void chars(String chars) throws XMLStreamException
chars
- Characters to writeXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void chars(String chars, boolean escape) throws XMLStreamException
chars
- Characters to writeescape
- if the chars should be XML escapedXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void end(QName name) throws XMLStreamException
name
- Element nameXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void endInline(QName name) throws XMLStreamException
name
- Element nameXMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void end() throws XMLStreamException
XMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void finish() throws XMLStreamException
XMLStreamException
- If an error occurs when writing to OutputStream
protected abstract void flush() throws XMLStreamException
XMLStreamException
- If an error occurs when writing to OutputStream
protected void rawText(String text) throws XMLStreamException
text
- Text to write to streamXMLStreamException
- If an error occurs when writing to OutputStream
protected String getReplacement(QName qname)
QName
qname
- QName
to create replacement fromprotected void writeNewLine() throws XMLStreamException
XMLStreamException
- If an error occurs when writing to OutputStream
protected void writeXmlObject(org.apache.xmlbeans.XmlObject xmlObject, QName qname) throws XMLStreamException
XmlObject
to stream and replace xml-fragment with
QName
xmlObject
- XmlObject
to writeqname
- Replacement for xml-fragmentXMLStreamException
- If an error occurs when writing to OutputStream
protected void schemaLocation(Set<SchemaLocation> schemaLocations) throws XMLStreamException
SchemaLocation
s as xsi:schemaLocations attribute to streamschemaLocations
- SchemaLocation
s to writeXMLStreamException
- If an error occurs when writing to OutputStream
protected void writeIndent(int level) throws XMLStreamException
level
- current levelXMLStreamException
- If an error occurs when writing to OutputStream
protected void init(OutputStream out) throws XMLStreamException
init(OutputStream, String)
out
- OutputStream to write the encoded elementXMLStreamException
- If an error occurs when initializing the writerprotected void init(OutputStream out, EncodingValues encodingValues) throws XMLStreamException
init(OutputStream, String, EncodingValues)
out
- OutputStream to write the encoded elementencodingValues
- EncodingValues
with additional informationXMLStreamException
- If an error occurs when initializing the writerprotected void init(OutputStream out, String encoding) throws XMLStreamException
init(OutputStream, String, EncodingValues)
out
- OutputStream to write the encoded elementencoding
- Encoding, e.g. UTF-8XMLStreamException
- If an error occurs when initializing the writerprotected OutputStream getOutputStream()
OutputStream
OutputStream
protected void time(TimeInstant time) throws XMLStreamException
TimeInstant
to streamtime
- TimeInstant
to write to streamXMLStreamException
- If an error occurs when writing to OutputStream
protected void time(TimePosition time) throws XMLStreamException
TimePosition
as ISO 8601 to streamtime
- XMLStreamException
- If an error occurs when writing to OutputStream
protected XMLOutputFactory getXmlOutputFactory()
XMLOutputFactory
XMLOutputFactory
protected void addXlinkHrefAttr(String value) throws XMLStreamException
XMLStreamException
protected void addXlinkTitleAttr(String value) throws XMLStreamException
XMLStreamException
Copyright © 2012-2015 52north.org. All Rights Reserved.