Package org.apache.rat.report.xml.writer
Interface IXmlWriter
-
- All Known Implementing Classes:
XmlWriter
public interface IXmlWriter
Simple interface for creating basic xml documents. Performs basic validation and escaping. Not namespace aware (may reconsider this later).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IXmlWriter
attribute(java.lang.CharSequence name, java.lang.CharSequence value)
Writes an attribute of an element.IXmlWriter
closeDocument()
Closes all pending elements.IXmlWriter
closeElement()
Closes the last element written.IXmlWriter
content(java.lang.CharSequence content)
Writes content.IXmlWriter
openElement(java.lang.CharSequence elementName)
Writes the start of an element.IXmlWriter
startDocument()
Starts a document by writing a prolog.
-
-
-
Method Detail
-
startDocument
IXmlWriter startDocument() throws java.io.IOException
Starts a document by writing a prolog. Calling this method is optional. When writing a document fragment, it should not be called.- Returns:
- this object
- Throws:
OperationNotAllowedException
- if called after the first element has been written or once a prolog has already been writtenjava.io.IOException
-
openElement
IXmlWriter openElement(java.lang.CharSequence elementName) throws java.io.IOException
Writes the start of an element.- Parameters:
elementName
- the name of the element, not null- Returns:
- this object
- Throws:
InvalidXmlException
- if the name is not valid for an xml elementOperationNotAllowedException
- if called after the first element has been closedjava.io.IOException
-
attribute
IXmlWriter attribute(java.lang.CharSequence name, java.lang.CharSequence value) throws java.io.IOException
Writes an attribute of an element. Note that this is only allowed directly afteropenElement(CharSequence)
orattribute(java.lang.CharSequence, java.lang.CharSequence)
.- Parameters:
name
- the attribute name, not nullvalue
- the attribute value, not null- Returns:
- this object
- Throws:
InvalidXmlException
- if the name is not valid for an xml attribute or if a value for the attribute has already been writtenOperationNotAllowedException
- if called aftercontent(CharSequence)
orcloseElement()
or before any call toopenElement(CharSequence)
java.io.IOException
-
content
IXmlWriter content(java.lang.CharSequence content) throws java.io.IOException
Writes content. Calling this method will automatically Note that this method does not use CDATA.- Parameters:
content
- the content to write- Returns:
- this object
- Throws:
OperationNotAllowedException
- if called before any call toopenElement(java.lang.CharSequence)
or after the first element has been closedjava.io.IOException
-
closeElement
IXmlWriter closeElement() throws java.io.IOException
Closes the last element written.- Returns:
- this object
- Throws:
OperationNotAllowedException
- if called before any call toopenElement(java.lang.CharSequence)
or after the first element has been closedjava.io.IOException
-
closeDocument
IXmlWriter closeDocument() throws java.io.IOException
Closes all pending elements. When appropriate, resources are also flushed and closed. No exception is raised when called upon a document whose root element has already been closed.- Returns:
- this object
- Throws:
OperationNotAllowedException
- if called before any call toopenElement(java.lang.CharSequence)
java.io.IOException
-
-