Class PrettyPrintXMLWriter
java.lang.Object
org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter
- All Implemented Interfaces:
XMLWriter
XMLWriter with nice indentation.
- Author:
- kama
-
Constructor Summary
ConstructorDescriptionPrettyPrintXMLWriter
(PrintWriter writer) PrettyPrintXMLWriter
(PrintWriter writer, String lineIndent) PrettyPrintXMLWriter
(PrintWriter writer, String encoding, String doctype) PrettyPrintXMLWriter
(PrintWriter writer, String lineIndent, String encoding, String doctype) PrettyPrintXMLWriter
(PrintWriter writer, String lineIndent, String lineSeparator, String encoding, String doctype) PrettyPrintXMLWriter
(Writer writer) PrettyPrintXMLWriter
(Writer writer, String lineIndent) PrettyPrintXMLWriter
(Writer writer, String encoding, String doctype) PrettyPrintXMLWriter
(Writer writer, String lineIndent, String encoding, String doctype) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(String key, String value) Add a XML attribute to the current XML Element.void
End the previously opened element.void
setDocType
(String docType) Sets the DOCTYPE of the document.void
setEncoding
(String encoding) Sets the encoding of the document.void
setLineIndenter
(String lineIndentParameter) void
setLineSeparator
(String lineSeparator) void
startElement
(String elementName) Start an XML Element tag.void
writeMarkup
(String markup) Add preformatted markup to the current element tag.void
Add text to the current element tag.
-
Constructor Details
-
PrettyPrintXMLWriter
- Parameters:
writer
- not nulllineIndent
- can be null, but the normal way is some spaces
-
PrettyPrintXMLWriter
- Parameters:
writer
- not nulllineIndent
- can be null, but the normal way is some spaces.
-
PrettyPrintXMLWriter
- Parameters:
writer
- not null
-
PrettyPrintXMLWriter
- Parameters:
writer
- not null
-
PrettyPrintXMLWriter
- Parameters:
writer
- not nulllineIndent
- can be null, but the normal way is some spacesencoding
- can be null or invaliddoctype
- can be null
-
PrettyPrintXMLWriter
- Parameters:
writer
- not nulllineIndent
- can be null, but the normal way is some spacesencoding
- can be null or invaliddoctype
- can be null
-
PrettyPrintXMLWriter
- Parameters:
writer
- not nullencoding
- can be null or invaliddoctype
- can be null
-
PrettyPrintXMLWriter
- Parameters:
writer
- not nullencoding
- can be null or invaliddoctype
- can be null
-
PrettyPrintXMLWriter
public PrettyPrintXMLWriter(PrintWriter writer, String lineIndent, String lineSeparator, String encoding, String doctype) - Parameters:
writer
- not nulllineIndent
- can be null, but the normal way is some spaces.lineSeparator
- can be null, but the normal way is valid line separatorencoding
- can be null or the encoding to use.doctype
- can be null
-
-
Method Details
-
addAttribute
Add a XML attribute to the current XML Element. This method must get called immediately afterXMLWriter.startElement(String)
.- Specified by:
addAttribute
in interfaceXMLWriter
- Parameters:
key
- The key of the attribute.value
- The value of the attribute.- Throws:
IOException
- if adding the attribute fails.
-
setEncoding
Sets the encoding of the document. If not set, UTF-8 is used.- Specified by:
setEncoding
in interfaceXMLWriter
- Parameters:
encoding
- the encoding
-
setDocType
Sets the DOCTYPE of the document.- Specified by:
setDocType
in interfaceXMLWriter
- Parameters:
docType
- the docType
-
setLineSeparator
- Parameters:
lineSeparator
- the line separator to be output
-
setLineIndenter
- Parameters:
lineIndentParameter
- the line indent parameter
-
startElement
Start an XML Element tag.- Specified by:
startElement
in interfaceXMLWriter
- Parameters:
elementName
- the name of the tag- Throws:
IOException
- if starting the element fails
-
writeText
Add text to the current element tag. This performs XML escaping to guarantee well-formed content.- Specified by:
writeText
in interfaceXMLWriter
- Parameters:
text
- The text which should be written.- Throws:
IOException
- if writing the text fails.
-
writeMarkup
Add preformatted markup to the current element tag.- Specified by:
writeMarkup
in interfaceXMLWriter
- Parameters:
markup
- the text which should be written- Throws:
IOException
- if writing the markup fails
-
endElement
End the previously opened element.- Specified by:
endElement
in interfaceXMLWriter
- Throws:
IOException
- if ending the element fails.- See Also:
-