Class ElementUtils


  • public abstract class ElementUtils
    extends java.lang.Object

    Abstract ElementUtils class.

    Version:
    $Id: $
    Author:
    Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
    • Constructor Summary

      Constructors 
      Constructor Description
      ElementUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.jdom.Element contains​(org.jdom.Element root, java.lang.String name)
      return the FIRST element with name equals to the passed key
      static org.jdom.Element contains​(org.jdom.Element root, java.lang.String name, int deep)
      return the FIRST element with name equals to the passed key
      static org.jdom.Element contains​(org.jdom.Element root, java.lang.String name, java.lang.String val)
      contains
      static org.jdom.Element contains​(org.jdom.Element root, org.jdom.Element el)
      contains
      static org.jdom.Element contains​(org.jdom.Element root, org.jdom.filter.Filter filter)
      contains
      static boolean remove​(org.jdom.Element root, org.jdom.Element el)
      remove
      static java.util.List<org.jdom.Element> search​(org.jdom.Element root, org.jdom.filter.Filter filter)
      search
      static java.util.List<org.jdom.Element> search​(org.jdom.Element root, org.jdom.filter.Filter filter, int depth)
      Use contains(Element, Filter) for an infinite depth search
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ElementUtils

        public ElementUtils()
    • Method Detail

      • remove

        public static boolean remove​(org.jdom.Element root,
                                     org.jdom.Element el)
                              throws java.lang.IllegalArgumentException

        remove

        Parameters:
        root - the root where to start searching to element to remove
        el - the element to remove (will be set to null since this node is unusable after removal)
        Returns:
        true if the element EQUALS to the 'el' starting from root (including) is found, false if object 'el' is not found
        Throws:
        java.lang.IllegalArgumentException - if any.
      • search

        public static java.util.List<org.jdom.Element> search​(org.jdom.Element root,
                                                              org.jdom.filter.Filter filter,
                                                              int depth)
                                                       throws java.lang.IllegalArgumentException
        Use contains(Element, Filter) for an infinite depth search
        Parameters:
        root - a Element object.
        filter - a Filter object.
        depth - the max depth to search.
        Returns:
        a List object.
        Throws:
        java.lang.IllegalArgumentException - if any.
      • search

        public static java.util.List<org.jdom.Element> search​(org.jdom.Element root,
                                                              org.jdom.filter.Filter filter)

        search

        Parameters:
        root - a Element object.
        filter - a Filter object.
        Returns:
        a List object.
      • contains

        public static org.jdom.Element contains​(org.jdom.Element root,
                                                org.jdom.filter.Filter filter)
                                         throws java.lang.IllegalArgumentException

        contains

        Parameters:
        root - a Element object.
        filter - a Filter object.
        Returns:
        the FIRST element matching the passed filter or null
        Throws:
        java.lang.IllegalArgumentException - if any.
      • contains

        public static org.jdom.Element contains​(org.jdom.Element root,
                                                java.lang.String name,
                                                java.lang.String val)
                                         throws java.lang.IllegalArgumentException

        contains

        Parameters:
        root - a Element object.
        name - a String object.
        val - a String object.
        Returns:
        the FIRST element EQUALS to a node with name and a text value starting from root or null
        Throws:
        java.lang.IllegalArgumentException - if any.
      • contains

        public static org.jdom.Element contains​(org.jdom.Element root,
                                                java.lang.String name)
        return the FIRST element with name equals to the passed key
        Parameters:
        root - a Element object.
        name - a String object.
        Returns:
        a Element object.
      • contains

        public static org.jdom.Element contains​(org.jdom.Element root,
                                                java.lang.String name,
                                                int deep)
                                         throws java.lang.IllegalArgumentException
        return the FIRST element with name equals to the passed key
        Parameters:
        root - a Element object.
        name - a String object.
        deep - a int.
        Returns:
        a Element object.
        Throws:
        java.lang.IllegalArgumentException - if any.
      • contains

        public static org.jdom.Element contains​(org.jdom.Element root,
                                                org.jdom.Element el)
                                         throws java.lang.IllegalArgumentException

        contains

        Parameters:
        root - a Element object.
        el - a Element object.
        Returns:
        the FIRST element EQUALS to the 'el' starting from root or null This tests for equality of this Content object to the supplied object. Content items are considered equal only if they are referentially equal (i.e. the same object).
        Throws:
        java.lang.IllegalArgumentException - if any.