Class Filters


  • public final class Filters
    extends Object
    Factory class of convenience methods to create Filter instances of common types. Methods that return Filters that act on core JDOM classes (Element, Text, etc.) are simply named after the content they return.

    Filters that match non-core classes (Boolean, Object, etc.) are all prefixed with the letter 'f' (for filter).

    The Filter returned by #fpassthrough() is not really a filter in the sense that it will never filter anything out - everything matches. This can be useful to accomplish some tasks, for example the JDOM XPath API uses it extensively.

    • Method Detail

      • content

        public static final Filter<Content> content()
        Return a Filter that matches any Content data.
        Returns:
        a Filter that matches any Content data.
      • comment

        public static final Filter<Comment> comment()
        Return a Filter that matches any Comment data.
        Returns:
        a Filter that matches any Comment data.
      • cdata

        public static final Filter<CDATA> cdata()
        Return a Filter that matches any CDATA data.
        Returns:
        a Filter that matches any CDATA data.
      • doctype

        public static final Filter<DocType> doctype()
        Return a Filter that matches any DocType data.
        Returns:
        a Filter that matches any DocType data.
      • element

        public static final Filter<Element> element()
        Return a Filter that matches any Element data.
        Returns:
        a Filter that matches any Element data.
      • element

        public static final Filter<Element> element​(String name)
        Return a Filter that matches any Element data with the specified name.
        Parameters:
        name - The name of Elements to match.
        Returns:
        a Filter that matches any Element data with the specified name.
      • element

        public static final Filter<Element> element​(String name,
                                                    Namespace ns)
        Return a Filter that matches any Element data with the specified name and Namespace.
        Parameters:
        name - The name of Elements to match.
        ns - The Namespace to match
        Returns:
        a Filter that matches any Element data with the specified name and Namespace.
      • element

        public static final Filter<Element> element​(Namespace ns)
        Return a Filter that matches any Element data with the specified Namespace.
        Parameters:
        ns - The Namespace to match
        Returns:
        a Filter that matches any Element data with the specified Namespace.
      • text

        public static final Filter<Text> text()
        Return a Filter that matches any Text data (which includes CDATA since that is a subclass of Text).
        Returns:
        a Filter that matches any Text data (which includes CDATA since that is a subclass of Text).
      • textOnly

        public static final Filter<Text> textOnly()
        Return a Filter that matches any Text data (excludes CDATA instances).
        Returns:
        a Filter that matches any Text data (which excludes CDATA instances).