Package org.testng.reporters
Class XMLStringBuffer
java.lang.Object
org.testng.reporters.XMLStringBuffer
This class allows you to generate an XML text document by pushing and popping tags from a stack
maintained internally.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringTab space indent for XML documentprivate Stringstatic final StringEnd of line, value of 'line.separator' system property or '\n'private static final Patternprivate IBufferThe buffer to hold the xml documentprivate StringA string of space character representing the current indentation.The stack of tags to make sure XML document is well formed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddComment(String comment) voidaddEmptyElement(String tagName) Add an empty element tag (e.g.voidaddEmptyElement(String tagName, String... attributes) voidaddEmptyElement(String tagName, Properties attributes) Add an empty element tag (e.g.voidaddOptional(String tagName, Boolean value) Add an optional Boolean element to the current tag.voidaddOptional(String tagName, Boolean value, Properties attributes) Add an optional Boolean element to the current tag.voidaddOptional(String tagName, String value) Add an optional String element to the current tag.voidaddOptional(String tagName, String value, String... attributes) voidaddOptional(String tagName, String value, Properties attributes) Add an optional String element to the current tag.voidaddRequired(String tagName, String value) Add a required element to the current tag.voidaddRequired(String tagName, String value, String... attributes) voidaddRequired(String tagName, String value, Properties attributes) Add a required element to the current tag.voidprivate PropertiescreateProperties(String[] attributes) private voidprivate voidvoidpop()Pop the last pushed element without verifying it if matches the previously pushed tag.voidPop the last pushed element and throws an AssertionError if it doesn't match the corresponding tag that was pushed earlier.voidPush a new tag.voidPush a new tag.voidvoidpush(String tagName, String schema, Properties attributes) Push a new tag.voidpush(String tagName, Properties attributes) Push a new tag.voidsetDefaultComment(String defaultComment) voidsetDocType(String docType) Set the doctype for this document.voidsetXmlDetails(String v, String enc) Set the xml version and encoding for this document.voidtoXML()
-
Field Details
-
EOL
End of line, value of 'line.separator' system property or '\n' -
DEFAULT_INDENT_INCREMENT
Tab space indent for XML document- See Also:
-
m_buffer
The buffer to hold the xml document -
m_tagStack
The stack of tags to make sure XML document is well formed. -
m_currentIndent
A string of space character representing the current indentation. -
defaultComment
-
INVALID_XML_CHARS
-
-
Constructor Details
-
XMLStringBuffer
public XMLStringBuffer() -
XMLStringBuffer
- Parameters:
start- A string of spaces indicating the indentation at which to start the generation. This constructor will not insert an<?xmlprologue.
-
XMLStringBuffer
- Parameters:
buffer- The StringBuffer to use internally to represent the document.start- A string of spaces indicating the indentation at which to start the generation.
-
-
Method Details
-
init
-
init
private void init(IBuffer buffer, String start, @Nullable String version, @Nullable String encoding) - Parameters:
start- A string of spaces indicating the indentation at which to start the generation.
-
setXmlDetails
Set the xml version and encoding for this document.- Parameters:
v- the XML versionenc- the XML encoding
-
setDocType
Set the doctype for this document.- Parameters:
docType- The DOCTYPE string, without the "<!DOCTYPE " ">"
-
push
Push a new tag. Its value is stored and will be compared against the parameter passed to pop().- Parameters:
tagName- The name of the tag.schema- The schema to use (can be null or an empty string).attributes- A Properties file representing the attributes (or null)
-
push
Push a new tag. Its value is stored and will be compared against the parameter passed to pop().- Parameters:
tagName- The name of the tag.schema- The schema to use (can be null or an empty string).
-
push
Push a new tag. Its value is stored and will be compared against the parameter passed to pop().- Parameters:
tagName- The name of the tag.attributes- A Properties file representing the attributes (or null)
-
push
-
createProperties
-
push
Push a new tag. Its value is stored and will be compared against the parameter passed to pop().- Parameters:
tagName- The name of the tag.
-
pop
public void pop()Pop the last pushed element without verifying it if matches the previously pushed tag. -
pop
Pop the last pushed element and throws an AssertionError if it doesn't match the corresponding tag that was pushed earlier.- Parameters:
tagName- The name of the tag this pop() is supposed to match.
-
addRequired
Add a required element to the current tag. An opening and closing tag will be generated even if value is null.- Parameters:
tagName- The name of the tagvalue- The value for this tag
-
addRequired
Add a required element to the current tag. An opening and closing tag will be generated even if value is null.- Parameters:
tagName- The name of the tagvalue- The value for this tagattributes- A Properties file containing the attributes (or null)
-
addRequired
-
addOptional
Add an optional String element to the current tag. If value is null, nothing is added.- Parameters:
tagName- The name of the tagvalue- The value for this tagattributes- A Properties file containing the attributes (or null)
-
addOptional
-
addOptional
Add an optional String element to the current tag. If value is null, nothing is added.- Parameters:
tagName- The name of the tagvalue- The value for this tag
-
addOptional
Add an optional Boolean element to the current tag. If value is null, nothing is added.- Parameters:
tagName- The name of the tagvalue- The value for this tagattributes- A Properties file containing the attributes (or null)
-
addOptional
Add an optional Boolean element to the current tag. If value is null, nothing is added.- Parameters:
tagName- The name of the tagvalue- The value for this tag
-
addEmptyElement
Add an empty element tag (e.g.<foo/>)- Parameters:
tagName- The name of the tag
-
addEmptyElement
Add an empty element tag (e.g.>foo/<)- Parameters:
tagName- The name of the tagattributes- A Properties file containing the attributes (or null)
-
addEmptyElement
-
addComment
-
addString
-
setDefaultComment
-
addCDATA
-
getStringBuffer
- Returns:
- The StringBuffer used to create the document.
-
toXML
- Returns:
- The String representation of the XML for this XMLStringBuffer.
-
getCurrentIndent
-
toWriter
-