Package org.apache.rat.report.xml.writer
Interface IXmlWriter
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
XmlWriter
Simple interface for creating basic XML documents.
Performs basic validation and escaping.
Not namespace aware.
-
Method Summary
Modifier and TypeMethodDescriptionattribute
(CharSequence name, CharSequence value) Writes an attribute of an element.cdata
(CharSequence content) Writes CDATA content.Closes all pending elements.Closes the last element written.closeElement
(CharSequence name) Closes all open elements back to and including the named element.comment
(CharSequence text) Writes a commentcontent
(CharSequence content) Writes content.openElement
(CharSequence elementName) Writes the start of an element.default IXmlWriter
openElement
(XmlElements.Elements element) Writes the start of an element.Starts a document by writing a prolog.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
startDocument
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 writtenIOException
-
openElement
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 a xml elementOperationNotAllowedException
- if called after the first element has been closedIOException
-
openElement
Writes the start of an element.- Parameters:
element
- 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 closedIOException
-
comment
Writes a comment- Parameters:
text
- the comment text- Returns:
- this object
- Throws:
OperationNotAllowedException
- if called after the first element has been closedIOException
-
attribute
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 a xml attribute or if a value for the attribute has already been writtenOperationNotAllowedException
- if called aftercontent(CharSequence)
orcloseElement()
or before any call toopenElement(CharSequence)
IOException
-
content
Writes content. Note that this method does not support CDATA. This method automatically escapes characters.- 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 closedIOException
-
cdata
Writes CDATA content. This method DOES NOT automatically escape characters. It will remove enclosed CDATA closing strings (e.g.]]>
)- 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 closedIOException
-
closeElement
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 closedIOException
-
closeElement
Closes all open elements back to and including the named element.- Parameters:
name
- the last element to close- Returns:
- this object
- Throws:
OperationNotAllowedException
- if called before any call toopenElement(java.lang.CharSequence)
or after the first element has been closedIOException
-
closeDocument
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)
IOException
-