Class XMLBuilder


  • public class XMLBuilder
    extends Object
    XML content builder utilities.
    • Method Detail

      • startElement

        public XMLBuilder startElement​(String name,
                                       boolean close)
      • endElement

        public XMLBuilder endElement​(String name,
                                     boolean isEndTagClosed)
      • closeStartElement

        public XMLBuilder closeStartElement()
      • selfCloseElement

        public XMLBuilder selfCloseElement()
      • addSingleAttribute

        public XMLBuilder addSingleAttribute​(DOMAttr attr,
                                             boolean surroundWithQuotes,
                                             boolean prependSpace)
      • addSingleAttribute

        public XMLBuilder addSingleAttribute​(String name,
                                             String value,
                                             boolean surroundWithQuotes)
      • addPrologAttribute

        public XMLBuilder addPrologAttribute​(DOMAttr attr)
        Add prolog attribute It will not perform any linefeeds and only basic indentation.
        Parameters:
        attr - attribute
        Returns:
        this XML Builder
      • addAttribute

        public XMLBuilder addAttribute​(String name,
                                       String value,
                                       int level,
                                       boolean surroundWithQuotes)
        Used when you are knowingly adding multiple attributes. Does linefeeds and indentation.
        Parameters:
        name -
        value -
        level -
        Returns:
      • append

        public void append​(String str)
      • append

        public void append​(char c)
      • addContent

        public XMLBuilder addContent​(String text)
        Returns this XMLBuilder with text added
        Parameters:
        text - the text to add
        Returns:
        this XMLBuilder with text added
      • addContent

        public XMLBuilder addContent​(String text,
                                     boolean isWhitespaceContent,
                                     boolean hasSiblings,
                                     String delimiter)
        Returns this XMLBuilder with text added depending on isWhitespaceContent, hasSiblings and delimiter
        Parameters:
        text - the proposed text to add
        isWhitespaceContent - whether or not the text contains only whitespace content
        hasSiblings - whether or not the corresponding text node has siblings
        delimiter - line delimiter
        Returns:
        this XMLBuilder with text added depending on isWhitespaceContent, hasSiblings and delimiter
      • indent

        public XMLBuilder indent​(int level)
      • endPrologOrPI

        public XMLBuilder endPrologOrPI()
      • trimFinalNewlines

        public void trimFinalNewlines()
        Trims the trailing newlines for the current XML StringBuilder
      • startDTDElementDecl

        public XMLBuilder startDTDElementDecl()
      • startDTDAttlistDecl

        public XMLBuilder startDTDAttlistDecl()
      • addUnindentedParameter

        public XMLBuilder addUnindentedParameter​(String parameter)
      • startDoctypeInternalSubset

        public XMLBuilder startDoctypeInternalSubset()
      • startUnindentedDoctypeInternalSubset

        public XMLBuilder startUnindentedDoctypeInternalSubset()
      • endDoctypeInternalSubset

        public XMLBuilder endDoctypeInternalSubset()
      • isLastLineEmptyOrWhitespace

        public boolean isLastLineEmptyOrWhitespace()
      • length

        public int length()
      • charAt

        public char charAt​(int index)