de.smartics.ci.config.utils
Class JDomUtils

Package class diagram package JDomUtils
java.lang.Object
  extended by de.smartics.ci.config.utils.JDomUtils

public final class JDomUtils
     
     
extends Object

Helper functions to deal with JDom instances.


Method Summary
static String calcXPath(org.jdom.Element rootElement, org.jdom.Element element)
          Calculates the XPath for the given element.
static void merge(org.jdom.Document target, org.jdom.Document toBeMerged)
          Merges the distinct information from the two documents.
static void merge(org.jdom.Element target, org.jdom.Element toBeMerged)
          Merges the distinct information from the two elements.
static String toString(org.jdom.Document document)
          Returns the string representation of the XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

merge

public static void merge(org.jdom.Document target,
                         org.jdom.Document toBeMerged)
                  throws de.smartics.util.lang.NullArgumentException,
                         org.jdom.JDOMException
Merges the distinct information from the two documents.

Note that not the contents of the element is checked to determine if the contents are equal. The merging algorithm simply checks the element names and assumes that two elements are the same, if they have the same name and are on the same level.

Parameters:
target - the document to add information, if missing.
toBeMerged - the information to add to the target, if missing.
Throws:
de.smartics.util.lang.NullArgumentException - if either target or toBeMerged is null.
org.jdom.JDOMException - on any problem encountered while merging.

merge

public static void merge(org.jdom.Element target,
                         org.jdom.Element toBeMerged)
                  throws org.jdom.JDOMException
Merges the distinct information from the two elements.

Note that not the contents of the element is checked to determine if the contents are equal. The merging algorithm simply checks the element names and assumes that two elements are the same, if they have the same name and are on the same level.

Parameters:
target - the element to add information, if missing.
toBeMerged - the information to add to the target, if missing.
Throws:
org.jdom.JDOMException - on any problem encountered while merging.

calcXPath

public static String calcXPath(org.jdom.Element rootElement,
                               org.jdom.Element element)
Calculates the XPath for the given element.

Parameters:
rootElement - the root element to the element whose path is to be calculated. The returned XPath is relative to the element. May be null if a path from the document root is requested.
element - the element relative to the rootElement.
Returns:
the XPath relative to rootElement to the element.

toString

public static String toString(org.jdom.Document document)
Returns the string representation of the XML document.

Parameters:
document - the XML document to create its string representation.
Returns:
the string representation of the XML document.


Copyright © 2012 Kronseder & Reiner GmbH - smartics. All Rights Reserved.