Interface XMLWriter
-
- All Known Implementing Classes:
PrettyPrintXMLWriter
public interface XMLWriterInterface for tools writing XML files. XMLWriters are not thread safe and must not be accessed concurrently.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddAttribute(java.lang.String key, java.lang.String value)Add a XML attribute to the current XML Element.voidendElement()End the previously opened element.voidsetDocType(java.lang.String docType)Sets the docType of the document.voidsetEncoding(java.lang.String encoding)Sets the encoding of the document.voidstartElement(java.lang.String name)Start an XML Element tag.voidwriteMarkup(java.lang.String text)Add a preformatted markup to the current element tagvoidwriteText(java.lang.String text)Add a value text to the current element tag This will perform XML escaping to guarantee valid content
-
-
-
Method Detail
-
setEncoding
void setEncoding(java.lang.String encoding)
Sets the encoding of the document. If not set, UTF-8 is being used- Parameters:
encoding- the encoding- Throws:
java.lang.IllegalStateException- if the generation of the document has already started
-
setDocType
void setDocType(java.lang.String docType)
Sets the docType of the document.- Parameters:
docType- the docType- Throws:
java.lang.IllegalStateException- if the generation of the document has already started
-
startElement
void startElement(java.lang.String name) throws java.io.IOExceptionStart an XML Element tag.- Parameters:
name- The name of the tag.- Throws:
java.io.IOException- if starting the element fails.
-
addAttribute
void addAttribute(java.lang.String key, java.lang.String value) throws java.io.IOExceptionAdd a XML attribute to the current XML Element. This method must get called immediately afterstartElement(String)- Parameters:
key- The key of the attribute.value- The value of the attribute.- Throws:
java.lang.IllegalStateException- if no element tag is currently in processjava.io.IOException- if adding the attribute fails.
-
writeText
void writeText(java.lang.String text) throws java.io.IOExceptionAdd a value text to the current element tag This will perform XML escaping to guarantee valid content- Parameters:
text- The text which should be written.- Throws:
java.lang.IllegalStateException- if no element tag got started yetjava.io.IOException- if writing the text fails.
-
writeMarkup
void writeMarkup(java.lang.String text) throws java.io.IOExceptionAdd a preformatted markup to the current element tag- Parameters:
text- The text which should be written.- Throws:
java.lang.IllegalStateException- if no element tag got started yetjava.io.IOException- if writing the markup fails.
-
endElement
void endElement() throws java.io.IOExceptionEnd the previously opened element.- Throws:
java.io.IOException- if ending the element fails.- See Also:
startElement(String)
-
-