Package org.jacoco.report.internal.xml
Class XMLElement
java.lang.Object
org.jacoco.report.internal.xml.XMLElement
- Direct Known Subclasses:
HTMLElement
,ReportElement
Simple API to create well formed XML streams with minimal memory overhead. A
XMLElement
instance represents a single element in a XML document.
XMLElement
can be used directly or might be subclassed for schema
specific convenience methods.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private static final String
DOCTYPE declaration templateprivate static final String
XML header templateprivate static final String
XML header template for standalone documentsprivate XMLElement
private final String
private boolean
private final boolean
protected final Writer
Writer for content output -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
XMLElement
(Writer writer, String name, boolean root) XMLElement
(String name, String pubId, String system, boolean standalone, String encoding, OutputStream output) Creates a root element of a XML document.protected
XMLElement
(String name, XMLElement parent) Creates a new child element within a XML document. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addChildElement
(XMLElement child) final void
Adds an attribute to this element.final void
Adds an attribute to this element.final void
Adds an attribute to this element.final void
close()
Closes this element if it has not been closed before.Creates a new child element for this element.private void
private void
final void
Adds the given text as a child to this node.
-
Field Details
-
HEADER
XML header template- See Also:
-
HEADER_STANDALONE
XML header template for standalone documents- See Also:
-
DOCTYPE
DOCTYPE declaration template- See Also:
-
writer
Writer for content output -
name
-
openTagDone
private boolean openTagDone -
closed
private boolean closed -
lastchild
-
root
private final boolean root
-
-
Constructor Details
-
XMLElement
- Throws:
IOException
-
XMLElement
public XMLElement(String name, String pubId, String system, boolean standalone, String encoding, OutputStream output) throws IOException Creates a root element of a XML document.- Parameters:
name
- element namepubId
- optional schema public identifiersystem
- optional schema system identifierstandalone
- iftrue
the document is declared as standaloneencoding
- character encoding used for outputoutput
- output stream will be closed if the root element is closed- Throws:
IOException
- in case of problems with the underlying output
-
XMLElement
Creates a new child element within a XML document. May only be called before the parent element has been closed.- Parameters:
name
- element nameparent
- parent of this element- Throws:
IOException
- in case of problems with the underlying output or if the parent element is already closed
-
-
Method Details
-
addChildElement
- Throws:
IOException
-
finishOpenTag
- Throws:
IOException
-
quote
- Throws:
IOException
-
attr
Adds an attribute to this element. May only be called before an child element is added or this element has been closed. The attribute value will be quoted. If the value isnull
the attribute will not be added.- Parameters:
name
- attribute namevalue
- attribute value ornull
- Throws:
IOException
- in case of problems with the underlying output or if the element is already closed.
-
attr
Adds an attribute to this element. May only be called before an child element is added or this element has been closed. The attribute value is the decimal representation of the given int value.- Parameters:
name
- attribute namevalue
- attribute value- Throws:
IOException
- in case of problems with the underlying output or if the element is already closed.
-
attr
Adds an attribute to this element. May only be called before an child element is added or this element has been closed. The attribute value is the decimal representation of the given long value.- Parameters:
name
- attribute namevalue
- attribute value- Throws:
IOException
- in case of problems with the underlying output or if the element is already closed.
-
text
Adds the given text as a child to this node. The text will be quoted. May only be called before this element has been closed.- Parameters:
text
- text to add- Throws:
IOException
- in case of problems with the underlying output or if the element is already closed.
-
element
Creates a new child element for this element. Might be overridden in subclasses to return a instance of the subclass.- Parameters:
name
- name of the child element- Returns:
- child element instance
- Throws:
IOException
- in case of problems with the underlying output
-
close
Closes this element if it has not been closed before.- Throws:
IOException
- in case of problems with the underlying output
-