org.apache.maven.shared.utils.xml
Interface XMLWriter

All Known Implementing Classes:
PrettyPrintXMLWriter

public interface XMLWriter

Interface for tools writing XML files. XMLWriters are not thread safe and must not be accessed concurrently.


Method Summary
 void addAttribute(String key, String value)
          Add a XML attribute to the current XML Element.
 void endElement()
          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 startElement(String name)
          Start an XML Element tag.
 void writeMarkup(String text)
          Add a preformatted markup to the current element tag
 void writeText(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(String encoding)
Sets the encoding of the document. If not set, UTF-8 is being used

Parameters:
encoding - the encoding
Throws:
IllegalStateException - if the generation of the document has already started

setDocType

void setDocType(String docType)
Sets the docType of the document.

Parameters:
docType - the docType
Throws:
IllegalStateException - if the generation of the document has already started

startElement

void startElement(String name)
Start an XML Element tag.

Parameters:
name -

addAttribute

void addAttribute(String key,
                  String value)
Add a XML attribute to the current XML Element. This method must get called immediately after startElement(String)

Parameters:
key -
value -
Throws:
IllegalStateException - if no element tag is currently in process

writeText

void writeText(String text)
Add a value text to the current element tag This will perform XML escaping to guarantee valid content

Parameters:
text -
Throws:
IllegalStateException - if no element tag got started yet

writeMarkup

void writeMarkup(String text)
Add a preformatted markup to the current element tag

Parameters:
text -
Throws:
IllegalStateException - if no element tag got started yet

endElement

void endElement()
End the previously opened element.

See Also:
startElement(String)


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.