Class JDomUtils
java.lang.Object
org.apache.maven.cling.invoker.mvnup.goals.JDomUtils
Utility class for JDOM operations.
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringdetectBaseIndentationUnit(org.jdom2.Element element) Detects the base indentation unit used in the document by analyzing indentation patterns.static StringdetectIndentation(org.jdom2.Element element) Detects the indentation used for a given element by analyzing its parent's content.static org.jdom2.ElementinsertContentElement(org.jdom2.Element parent, String name, String content) Inserts a new content element with the given name and text content.static org.jdom2.ElementinsertNewElement(String name, org.jdom2.Element root) Inserts a new child element to the given root element.static org.jdom2.ElementinsertNewElement(String name, org.jdom2.Element root, int index) Inserts a new child element to the given root element at the given index.
- 
Method Details- 
insertNewElementInserts a new child element to the given root element. The position where the element is inserted is calculated using the element order configuration. When no order is defined for the element, the new element is append as last element (before the closing tag of the root element). In the root element, the new element is always prepended by a text element containing a linebreak followed by the indentation characters. The indentation characters are (tried to be) detected from the root element (seedetectIndentation(Element)).- Parameters:
- name- the name of the new element.
- root- the root element.
- Returns:
- the new element.
 
- 
insertNewElementInserts a new child element to the given root element at the given index. For details seeinsertNewElement(String, Element)- Parameters:
- name- the name of the new element.
- root- the root element.
- index- the index where the element should be inserted.
- Returns:
- the new element.
 
- 
insertContentElementpublic static org.jdom2.Element insertContentElement(org.jdom2.Element parent, String name, String content) Inserts a new content element with the given name and text content.- Parameters:
- parent- the parent element
- name- the name of the new element
- content- the text content
- Returns:
- the new element
 
- 
detectIndentationDetects the indentation used for a given element by analyzing its parent's content. This method examines the whitespace preceding the element to determine the indentation pattern. It supports different indentation styles (2 spaces, 4 spaces, tabs, etc.).- Parameters:
- element- the element to analyze
- Returns:
- the detected indentation or a default indentation if none can be detected.
 
- 
detectBaseIndentationUnitDetects the base indentation unit used in the document by analyzing indentation patterns. This method traverses the document tree to find the most common indentation style.- Parameters:
- element- any element in the document to analyze
- Returns:
- the detected base indentation unit (e.g., " ", " ", "\t")
 
 
-