Package org.n52.svalbard.write
Class XmlStreamWriter<S>
java.lang.Object
org.n52.svalbard.write.XmlStreamWriter<S>
- Type Parameters:
S- object to write
- Direct Known Subclasses:
AbstractGetDataAvailabilityStreamWriter,AbstractOmV20XmlStreamWriter,AbstractSwesXmlStreamWriter,AqdGetObservationResponseXmlStreamWriter,EReportingHeaderEncoder,InspireXmlStreamWriter,RdfStreamWriter,RelatedOfferingXmlStreamWriter,Soap12XmlStreamWriter,Wsdlv11XmlStreamWriter
Abstract XML stream writer.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXmlStreamWriter(EncodingContext context, OutputStream outputStream, S element) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddXlinkHrefAttr(String value) protected voidaddXlinkTitleAttr(String value) protected voidWrite attribute to stream.protected voidWrite attribute to stream.protected voidWrite attribute to stream.protected voidWrite characters to stream.protected voidWrite characters to stream.protected voidWrite an empty element to stream.protected voidend()Write the document end to stream.protected voidWrite the end element to new line.protected voidWrite end element to the same line.protected voidfinish()Finish the stream writing, flush and close.protected voidflush()Flush written elements.protected EncodingContextGet the encoding context.protected Sprotected <T,S> Encoder <T, S> getEncoder(String namespace, Object o) protected <T,S> Encoder <T, S> getEncoder(EncoderKey key) Get encoder forEncoderKey.protected OutputStreamGet the underlying output stream.protected StringgetReplacement(QName qname) Create the replacement fromQName.protected org.apache.xmlbeans.XmlOptionsGet the XML options.protected booleanprotected voidWrite namespace to stream.protected voidWrite raw text to stream an adds current indent before writing the text (and before each subsequent line).protected voidschemaLocation(Set<SchemaLocation> schemaLocations) WriteSchemaLocations as xsi:schemaLocations attribute to stream.protected voidstart()Write document start to stream with or without.protected voidWrite start element to stream.protected voidtime(TimeInstant time) WriteTimeInstantto stream.protected voidtime(TimePosition time) WriteTimePositionas ISO 8601 to stream.tryGetEncoder(EncoderKey key) Try to get encoder forEncoderKey.abstract voidwrite()Encode and write element to theOutputStream.protected voidwriteXmlObject(org.apache.xmlbeans.XmlObject xmlObject) WriteXmlObjectto stream and replace xml-fragment withQName.protected voidwriteXmlObject(org.apache.xmlbeans.XmlObject xmlObject, QName qname) WriteXmlObjectto stream and replace xml-fragment withQName.
-
Field Details
-
XML_FRAGMENT
- See Also:
-
-
Constructor Details
-
XmlStreamWriter
public XmlStreamWriter(EncodingContext context, OutputStream outputStream, S element) throws XMLStreamException - Throws:
XMLStreamException
-
-
Method Details
-
getElement
-
getXmlOptions
protected org.apache.xmlbeans.XmlOptions getXmlOptions()Get the XML options.- Returns:
- the xml options
-
getOutputStream
Get the underlying output stream. This will flush this writer.- Returns:
- the output stream
- Throws:
XMLStreamException- if the flush fails
-
getContext
Get the encoding context.- Returns:
- the context
-
attr
Write attribute to stream.- Parameters:
name- Attribute namevalue- Attribute value- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
attr
Write attribute to stream.- Parameters:
name- Attribute namevalue- Attribute value- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
attr
Write attribute to stream.- Parameters:
namespace- namespace of the attribute namelocalName- LocalName of the attribute namevalue- Attribute value- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
namespace
Write namespace to stream.- Parameters:
prefix- Namespace prefixnamespace- Namespace URI- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
start
Write start element to stream.- Parameters:
name- Element name- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
start
Write document start to stream with or without.- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
empty
Write an empty element to stream.- Parameters:
name- Element name- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
chars
Write characters to stream.- Parameters:
chars- Characters to write- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
chars
Write characters to stream.- Parameters:
chars- Characters to writeescape- if the chars should be XML escaped- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
end
Write the end element to new line.- Parameters:
name- Element name- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
end
Write the document end to stream.- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
endInline
Write end element to the same line.- Parameters:
name- Element name- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
finish
Finish the stream writing, flush and close.- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
flush
Flush written elements.- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
write
Encode and write element to theOutputStream.- Throws:
XMLStreamException- If an error occurs when writing toOutputStreamEncodingException- If an encoding error occurs
-
rawText
Write raw text to stream an adds current indent before writing the text (and before each subsequent line).- Parameters:
text- Text to write to stream- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
getReplacement
Create the replacement fromQName.- Parameters:
qname-QNameto create replacement from- Returns:
- Created replacement
-
writeXmlObject
protected void writeXmlObject(org.apache.xmlbeans.XmlObject xmlObject, QName qname) throws XMLStreamException WriteXmlObjectto stream and replace xml-fragment withQName.- Parameters:
xmlObject-XmlObjectto writeqname- Replacement for xml-fragment- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
writeXmlObject
WriteXmlObjectto stream and replace xml-fragment withQName.- Parameters:
xmlObject-XmlObjectto write- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
schemaLocation
WriteSchemaLocations as xsi:schemaLocations attribute to stream.- Parameters:
schemaLocations-SchemaLocations to write- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
time
WriteTimeInstantto stream.- Parameters:
time-TimeInstantto write to stream- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
time
WriteTimePositionas ISO 8601 to stream.- Parameters:
time-TimePositionto write as ISO 8601 to stream- Throws:
XMLStreamException- If an error occurs when writing toOutputStream
-
addXlinkHrefAttr
- Throws:
XMLStreamException
-
addXlinkTitleAttr
- Throws:
XMLStreamException
-
tryGetEncoder
Try to get encoder forEncoderKey.- Type Parameters:
T- the resulting type, the "Target"S- the input type, the "Source"- Parameters:
key- Encoder key to get encoder for- Returns:
- Matching encoder
-
getEncoder
Get encoder forEncoderKey.- Type Parameters:
T- the resulting type, the "Target"S- the input type, the "Source"- Parameters:
key- Encoder key to get encoder for- Returns:
- Matching encoder
- Throws:
NoEncoderForKeyException- If no matching encoder was found
-
getEncoder
protected <T,S> Encoder<T,S> getEncoder(String namespace, Object o) throws NoEncoderForKeyException - Throws:
NoEncoderForKeyException
-
getEncoder
-
isAddSchemaLocation
protected boolean isAddSchemaLocation() -
getEncodeNamespace
-