Package org.apache.ws.commons.serialize
Interface XMLWriter
- All Superinterfaces:
ContentHandler
- All Known Implementing Classes:
CharSetXMLWriter,OrderedAttributeXMLWriter,PassThroughXMLWriter,XMLWriterImpl
A simple serializer for XML documents, which is writing to
an instance of
Writer.-
Method Summary
Modifier and TypeMethodDescriptionbooleancanEncode(char pChar) Returns whether the XMLWriter can encode the charactercwithout an escape sequence like &#ddd;.Returns the writers encoding.Returns the string being used to indent an XML element by one level.Returns the line terminator.Returns the targetWriter.booleanReturns, whether an XML declaration is being generated.booleanReturns, whether the methodContentHandler.endDocument()should do a flush on the target stream.booleanReturns, whether theXMLWriteris indenting (pretty printing).voidsetDeclarating(boolean pDeclarating) Sets, whether an XML declaration is being generated.voidsetEncoding(String pEncoding) Sets the writers encoding.voidsetFlushing(boolean pFlushing) Sets, whether the methodContentHandler.endDocument()should do a flush on the target stream.voidsetIndenting(boolean pIndenting) Returns, whether theXMLWriteris indenting (pretty printing).voidsetIndentString(String pIndentString) Sets the string being used to indent an XML element by one level.voidsetLineFeed(String pLineFeed) Sets the line terminator.voidSets the targetWriter.Methods inherited from interface org.xml.sax.ContentHandler
characters, declaration, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
-
Method Details
-
setEncoding
Sets the writers encoding.- Parameters:
pEncoding- Writers encoding, by default null, in which case UTF-8 is being used.
-
getEncoding
String getEncoding()Returns the writers encoding.- Returns:
- Writers encoding, by default null, in which case UTF-8 is being used.
-
setDeclarating
void setDeclarating(boolean pDeclarating) Sets, whether an XML declaration is being generated.- Parameters:
pDeclarating- Whether an XML declaration is generated. Defaults to false.
-
isDeclarating
boolean isDeclarating()Returns, whether an XML declaration is being generated.- Returns:
- Whether an XML declaration is generated. Defaults to false.
-
setWriter
Sets the targetWriter. This is typically an instance ofBufferedWriter, which is connected to an instance ofOutputStreamWriterwith an encoding matching the XML documents encoding.- Parameters:
pWriter- The target writer.
-
getWriter
Writer getWriter()Returns the targetWriter. This is typically an instance ofBufferedWriter, which is connected to an instance ofOutputStreamWriterwith an encoding matching the XML documents encoding.- Returns:
- The target writer.
-
canEncode
boolean canEncode(char pChar) Returns whether the XMLWriter can encode the character
cwithout an escape sequence like &#ddd;.- Parameters:
pChar- The character being checked for escaping.- Returns:
- Whether to encode the character.
-
setIndenting
void setIndenting(boolean pIndenting) Returns, whether theXMLWriteris indenting (pretty printing). If you want indenting, you should consider to invoke the methodssetIndentString(java.lang.String)andsetLineFeed(java.lang.String)as well.- Parameters:
pIndenting- Whether indentation is enabled. Defaults to false.
-
isIndenting
boolean isIndenting()Returns, whether theXMLWriteris indenting (pretty printing). If you want indenting, you should consider to invoke the methodssetIndentString(java.lang.String)andsetLineFeed(java.lang.String)as well.- Returns:
- Whether indentation is enabled. Defaults to false.
-
setIndentString
Sets the string being used to indent an XML element by one level. Ignored, if indentation is disabled.- Parameters:
pIndentString- The indentation string, by default " " (two blanks).
-
getIndentString
String getIndentString()Returns the string being used to indent an XML element by one level. Ignored, if indentation is disabled.- Returns:
- The indentation string, by default " " (two blanks).
-
setLineFeed
Sets the line terminator. Ignored, if indentation is disabled.- Parameters:
pLineFeed- The line terminator, by default "\n" (Line Feed). You might prefer "\r\n" (Carriage Return, Line Feed), which is the default on Windows and related operating systems.
-
getLineFeed
String getLineFeed()Returns the line terminator. Ignored, if indentation is disabled.- Returns:
- The line terminator, by default "\n" (Line Feed). You might prefer "\r\n" (Carriage Return, Line Feed), which is the default on Windows and related operating systems.
-
setFlushing
void setFlushing(boolean pFlushing) Sets, whether the methodContentHandler.endDocument()should do a flush on the target stream.- Parameters:
pFlushing- True, if a flush should be done. Defaults to false.
-
isFlushing
boolean isFlushing()Returns, whether the methodContentHandler.endDocument()should do a flush on the target stream.- Returns:
- True, if a flush should be done. Defaults to false.
-