All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sortpom.wrapper.ElementUtil Maven / Gradle / Ivy

package sortpom.wrapper;

import org.jdom.Element;

/**
 * Contains utility methods for Xml elements
 *
 * @author bjorn
 * @since 2013-10-21
 */
final class ElementUtil {
    /** Hidden constructor */
    private ElementUtil() {
    }

    /** Returns fully qualified name for an Xml element. */
    static String getDeepName(final Element element) {
        if (element == null) {
            return "";
        }
        return getDeepName(element.getParentElement()) + '/' + element.getName();
    }

    /** Returns true if an elements parents name is same as argument */
    static boolean isElementParentName(Element element, String name) {
        Element parent = element.getParentElement();
        if (parent == null) {
            return false;
        }
        return isElementName(parent, name);
    }

    /** Returns true if an elements name is same as argument */
    static boolean isElementName(Element element, String name) {
        return element.getName().equals(name);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy