Package org.eclipse.lemminx.utils
Class XMLBuilder
- java.lang.Object
-
- org.eclipse.lemminx.utils.XMLBuilder
-
public class XMLBuilder extends Object
XML content builder utilities.
-
-
Constructor Summary
Constructors Constructor Description XMLBuilder(SharedSettings sharedSettings, String whitespacesIndent, String lineDelimiter)XMLBuilder(SharedSettings sharedSettings, String whitespacesIndent, String lineDelimiter, Collection<IFormatterParticipant> formatterParticipants)
-
Method Summary
-
-
-
Constructor Detail
-
XMLBuilder
public XMLBuilder(SharedSettings sharedSettings, String whitespacesIndent, String lineDelimiter)
-
XMLBuilder
public XMLBuilder(SharedSettings sharedSettings, String whitespacesIndent, String lineDelimiter, Collection<IFormatterParticipant> formatterParticipants)
-
-
Method Detail
-
appendSpace
public XMLBuilder appendSpace()
-
startElement
public XMLBuilder startElement(String prefix, String name, boolean close)
-
startElement
public XMLBuilder startElement(String name, boolean close)
-
endElement
public XMLBuilder endElement(String name, boolean isEndTagClosed)
-
endElement
public XMLBuilder endElement(String name)
-
endElement
public XMLBuilder endElement(String prefix, String name)
-
endElement
public XMLBuilder endElement(String prefix, String name, boolean isEndTagClosed)
-
closeStartElement
public XMLBuilder closeStartElement()
-
selfCloseElement
public XMLBuilder selfCloseElement()
-
addSingleAttribute
public XMLBuilder addSingleAttribute(DOMAttr attr)
-
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:
-
addAttribute
public XMLBuilder addAttribute(DOMAttr attr, int level)
-
append
public void append(String str)
-
append
public void append(char c)
-
linefeed
public XMLBuilder linefeed()
-
addContent
public XMLBuilder addContent(String text)
Returns this XMLBuilder withtextadded- Parameters:
text- the text to add- Returns:
- this XMLBuilder with
textadded
-
addContent
public XMLBuilder addContent(String text, boolean isWhitespaceContent, boolean hasSiblings, String delimiter)
Returns this XMLBuilder withtextadded depending onisWhitespaceContent,hasSiblingsanddelimiter- Parameters:
text- the proposed text to addisWhitespaceContent- whether or not the text contains only whitespace contenthasSiblings- whether or not the corresponding text node has siblingsdelimiter- line delimiter- Returns:
- this XMLBuilder with
textadded depending onisWhitespaceContent,hasSiblingsanddelimiter
-
indent
public XMLBuilder indent(int level)
-
startPrologOrPI
public XMLBuilder startPrologOrPI(String tagName)
-
addContentPI
public XMLBuilder addContentPI(String content)
-
endPrologOrPI
public XMLBuilder endPrologOrPI()
-
trimFinalNewlines
public void trimFinalNewlines()
Trims the trailing newlines for the current XML StringBuilder
-
startCDATA
public XMLBuilder startCDATA()
-
addContentCDATA
public XMLBuilder addContentCDATA(String content)
-
endCDATA
public XMLBuilder endCDATA()
-
startComment
public XMLBuilder startComment(DOMComment comment)
-
addContentComment
public XMLBuilder addContentComment(String content)
-
addDeclTagStart
public XMLBuilder addDeclTagStart(DTDDeclNode tag)
-
addDeclTagStart
public XMLBuilder addDeclTagStart(String declTagName)
-
startDoctype
public XMLBuilder startDoctype()
-
startDTDElementDecl
public XMLBuilder startDTDElementDecl()
-
startDTDAttlistDecl
public XMLBuilder startDTDAttlistDecl()
-
addParameter
public XMLBuilder addParameter(String parameter)
-
addUnindentedParameter
public XMLBuilder addUnindentedParameter(String parameter)
-
startDoctypeInternalSubset
public XMLBuilder startDoctypeInternalSubset()
-
startUnindentedDoctypeInternalSubset
public XMLBuilder startUnindentedDoctypeInternalSubset()
-
endDoctypeInternalSubset
public XMLBuilder endDoctypeInternalSubset()
-
endComment
public XMLBuilder endComment()
-
endDoctype
public XMLBuilder endDoctype()
-
isLastLineEmptyOrWhitespace
public boolean isLastLineEmptyOrWhitespace()
-
length
public int length()
-
charAt
public char charAt(int index)
-
getSharedSettings
public SharedSettings getSharedSettings()
-
-