Package org.joox

Class Impl

java.lang.Object
org.joox.Impl
All Implemented Interfaces:
Iterable<Element>, Match

class Impl extends Object implements Match
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    A namespace context that is aware of this Impl's configured namespaces, as well as a chained context.
    private static class 
    A simple variable resolver mapping variable names to their respective index in an XPath expression.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Document
     
    private final List<Element>
     
    private final Map<String,String>
     
    private final Impl
     
    static final Pattern
    A selector pattern that can be evaluated using standard DOM API
  • Constructor Summary

    Constructors
    Constructor
    Description
    Impl(Document document, Map<String,String> namespaces)
     
    Impl(Document document, Map<String,String> namespaces, Impl previousMatch)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final Impl
    add(Match... e)
    Add some elements to the set of matched elements
    final Impl
    add(Element... e)
    Add some elements to the set of matched elements
    (package private) final Impl
     
    (package private) final Impl
     
    (package private) final Impl
     
    (package private) final Impl
     
    (package private) final Impl
     
    (package private) final Impl
     
    final Impl
    after(String content)
    Add content after each element in the set of matched elements.
    final Impl
    after(Content content)
    Add content after each element in the set of matched elements.
    final Impl
    after(Match... content)
    Add content after each element in the set of matched elements.
    final Impl
    after(Element... content)
    Add content after each element in the set of matched elements.
    final Impl
    Add the previous set of matched elements to the current one.
    final Impl
    append(String content)
    Append content to the end of each element's content in the set of matched elements.
    final Impl
    append(Content content)
    Append content to the end of each element's content in the set of matched elements.
    final Impl
    append(Match... content)
    Append content to the end of each element's content in the set of matched elements.
    final Impl
    append(Element... content)
    Append content to the end of each element's content in the set of matched elements.
    final String
    attr(String name)
    Get an attribute from the first element in the set of matched elements, or null if the first element does not have that attribute.
    final <T> T
    attr(String name, Class<T> type)
    Get a converted attribute from the first element in the set of matched elements, or null if the first element does not have that attribute.
    final Impl
    attr(String name, String value)
    Set an attribute on all elements in the set of matched elements.
    final Impl
    attr(String name, Content content)
    Set an attribute on all elements in the set of matched elements.
    final List<String>
    attrs(String name)
    Get an attribute from all elements in the set of matched elements
    final <T> List<T>
    attrs(String name, Class<T> type)
    Get a converted attribute from all elements in the set of matched elements
    private final Impl
    axis(boolean all, Filter until, Filter filter, Function<Node,Node> iterate, Consumer<List<Element>> finisher)
     
    final Impl
    before(String content)
    Add content before each element in the set of matched elements.
    final Impl
    before(Content content)
    Add content before each element in the set of matched elements.
    final Impl
    before(Match... content)
    Add content before each element in the set of matched elements.
    final Impl
    before(Element... content)
    Add content before each element in the set of matched elements.
    final String
    Get the CDATA content of the first element in the set of matched elements, or null if there are no matched elements.
    final String
    cdata(int index)
    Get the CDATA content at a given index in the current set of matched elements.
    final <T> T
    cdata(Class<T> type)
    Get the converted CDATA content of the first element in the set of matched elements, or null if there are no matched elements.
    final Impl
    cdata(String content)
    Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).
    final Impl
    cdata(Content content)
    Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).
    final List<String>
    Get all CDATA content of the elements in the set of matched elements.
    final List<String>
    cdatas(int... indexes)
    Get all CDATA content of the elements at given indexes in the set of matched elements.
    final <T> List<T>
    cdatas(Class<T> type)
    Get all converted CDATA content of the elements in the set of matched elements.
    final Impl
    Find the first child of each element in the current set of matched elements.
    final Impl
    child(int index)
    Find the child at a given index of each element in the current set of matched elements.
    final Impl
    child(String selector)
    Find the first matching child of each element in the current set of matched elements
    final Impl
    child(Filter filter)
    Find the first matching child of each element in the current set of matched elements
    final Impl
    Find all children of each element in the current set of matched elements.
    final Impl
    children(int... indexes)
    Find all children of each element at given indexes in the current set of matched elements.
    final Impl
    children(String selector)
    Find all children of each element in the current set of matched elements.
    final Impl
    children(Filter filter)
    Find all children of each element in the current set of matched elements.
    final String
    Get the XML content of the first element in the set of matched elements, or null if there are no matched elements.
    final String
    content(int index)
    Get the XML content at a given index in the current set of matched elements.
    final Impl
    content(Object content)
    Add some JAXB-marshallable XML content to all elements in the set of matched elements (possibly replacing existing content).
    final Impl
    content(String content)
    Add some XML content to all elements in the set of matched elements (possibly replacing existing content).
    final Impl
    content(Content content)
    Add some XML content to all elements in the set of matched elements (possibly replacing existing content).
    private final String
    content(Element element)
     
    final List<String>
    Get all XML content of the elements in the set of matched elements.
    final List<String>
    contents(int... indexes)
    Get all XML content of the elements at given indexes in the set of matched elements.
    final Impl
    Get a copy of the Match wrapper.
    final Document
    Get the underlying document of the set of matched elements.
    final List<Match>
    Get all elements in the set of matched elements in a list of matches, every match representing one element
    final Impl
    each(Iterable<? extends Each> each)
    Execute several callbacks for every element in the current set of matched elements.
    final Impl
    each(Each each)
    Execute a callback for every element in the current set of matched elements.
    final Impl
    each(Each... each)
    Execute several callbacks for every element in the current set of matched elements.
    final Match
    Removes all content from all elements in the set of matched elements.
    private final void
    empty(Element element)
     
    final Impl
    eq(int... indexes)
    Reduce the current set of matched elements to the elements at the given indexes.
    boolean
     
    final Impl
    filter(String selector)
    Reduce the current set of matched elements.
    final Impl
    filter(Filter filter)
    Reduce the current set of matched elements.
    private final List<Element>
    filter0(Filter filter)
     
    final Impl
    Find all descendants of each element in the current set of matched elements.
    final Impl
    find(String selector)
    Find all descendants of each element in the current set of matched elements.
    final Impl
    find(Filter filter)
    Find all descendants of each element in the current set of matched elements.
    final Impl
    Get the first in a set of matched elements.
    final List<Element>
    get()
    Get an the set of matched elements
    final Element
    get(int index)
    Get an element from the set of matched elements at a given index
    final List<Element>
    get(int... indexes)
    Get some elements from the set of matched elements at the given indexes
    final Impl
    has(String selector)
    Reduce the set of matched element to those who have a descendant that matches a selector.
    final Impl
    has(Filter filter)
    Reduce the set of matched element to those who have a descendant that matches a filter.
    int
     
    final String
    id()
    Get the first id value
    final String
    id(int index)
    Get an id value at a given index in the current set of matched elements.
    final <T> T
    id(Class<T> type)
    Get the first converted id value
    final List<String>
    ids()
    Get a list of id values in the current set of matched elements.
    final List<String>
    ids(int... indexes)
    Get a list of id values at given indexes in the current set of matched elements.
    final <T> List<T>
    ids(Class<T> type)
    Get a list of converted id values in the current set of matched elements.
    final boolean
    is(String selector)
    Check if at least one element in the set of matched elements satisfies a selector.
    final boolean
    is(Filter filter)
    Check if at least one element in the set of matched elements satisfies a filter.
    final boolean
    Whether there are any matched elements in the set of matched elements
    private final boolean
    isFast(Filter filter)
     
    final boolean
    Whether there are any matched elements in the set of matched elements
    private boolean
    Temporary utility method to indicate whether the root element is among the matched elements
     
    final Impl
    Get the last in a set of matched elements.
    final Impl
    Reduce the set of matched elements to the ones that are leaf elements
    final <E> List<E>
    map(Mapper<E> map)
    Map the set of matched elements to a list of something
    final Match
    matchAttr(String name, String valueRegex)
    Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regex
    final Match
    matchAttr(String name, String valueRegex, boolean keepMatches)
    Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regex (keepMatches = true), or those whose text content matches a given regex (keepMatches = false)
    final Impl
    Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regex
    final Impl
    matchTag(String regex, boolean keepMatches)
    Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regex (keepMatches = true), or those whose tag name matches a given regex (keepMatches = false)
    final Impl
    Reduce the set of matched elements by filtering out those whose text content doesn't match a given regex
    final Impl
    matchText(String regex, boolean keepMatches)
    Reduce the set of matched elements by filtering out those whose text content doesn't match a given regex (keepMatches = true), or those whose text content matches a given regex (keepMatches = false)
    final Match
    namespace(String namespacePrefix, String namespaceURI)
    Get a new Match with added namespace configuration for subsequent XPath calls
    final String
    Get the namespace prefix of the first element in the current set of matched elements.
    final String
    namespacePrefix(int index)
    Get a namespace prefix of the element at a given index in the current set of matched elements.
    final List<String>
    Get a list of namespace prefixes of the elements in the current set of matched elements.
    final List<String>
    namespacePrefixes(int... indexes)
    Get a list of namespace prefixes of the elements at given indexes in the current set of matched elements.
    final Match
    Get a new Match with added namespace configuration for subsequent XPath calls
    final String
    Get the namespace URI of the first element in the current set of matched elements.
    final String
    namespaceURI(int index)
    Get a namespace URI of the element at a given index in the current set of matched elements.
    final List<String>
    Get a list of namespace URIs of the elements in the current set of matched elements.
    final List<String>
    namespaceURIs(int... indexes)
    Get a list of namespace URIs of the elements at given indexes in the current set of matched elements.
    final Impl
    Get the immediate next sibling of every element in set of matched elements.
    private final Impl
    next(boolean all, Filter until, Filter filter)
     
    final Impl
    next(String selector)
    Get the immediate next sibling of every element in set of matched elements, matching a selector
    final Impl
    next(Filter filter)
    Get the immediate next sibling of every element in set of matched elements, matching a filter
    final Impl
    Get all next siblings of every element in a set of matched elements
    final Impl
    nextAll(String selector)
    Get all next siblings of every element in a set of matched elements, matching a selector
    final Impl
    nextAll(Filter filter)
    Get all next siblings of every element in a set of matched elements, matching a filter
    final Impl
    Get all next siblings of every element in a set of matched elements until the provided selector matches
    final Impl
    nextUntil(String until, String selector)
    Get all next siblings of every element in a set of matched elements, matching a selector, until the provided selector matches
    final Impl
    nextUntil(String until, Filter filter)
    Get all next siblings of every element in a set of matched elements, matching a filter, until the provided selector matches
    final Impl
    Get all next siblings of every element in a set of matched elements until the provided filter matches
    final Impl
    nextUntil(Filter until, String selector)
    Get all next siblings of every element in a set of matched elements, matching a selector until the provided filter matches
    final Impl
    nextUntil(Filter until, Filter filter)
    Get all next siblings of every element in a set of matched elements, matching a filter until the provided filter matches
    final Impl
    not(String selector)
    Remove elements from the set of matched elements.
    final Impl
    not(Filter filter)
    Remove elements from the set of matched elements.
    final Impl
    Get the immediate parent elements of every element in a set of matched elements
    final Impl
    parent(String selector)
    Get the immediate parent elements of every element in a set of matched elements, matching a selector
    final Impl
    parent(Filter filter)
    Get the immediate parent elements of every element in a set of matched elements, matching a filter
    final Impl
    Get all ancestor elements of every element in a set of matched elements
    private final Impl
    parents(boolean all, Filter until, Filter filter)
     
    final Impl
    parents(String selector)
    Get all ancestor elements of every element in a set of matched elements, matching a selector
    final Impl
    parents(Filter filter)
    Get all ancestor elements of every element in a set of matched elements, matching a filter
    final Impl
    Get all ancestors of every element in a set of matched elements until the provided selector matches
    final Impl
    parentsUntil(String until, String selector)
    Get all ancestors of every element in a set of matched elements, matching a selector, until the provided selector matches
    final Impl
    parentsUntil(String until, Filter filter)
    Get all ancestors of every element in a set of matched elements, matching a filter, until the provided selector matches
    final Impl
    Get all ancestors of every element in a set of matched elements until the provided filter matches
    final Impl
    parentsUntil(Filter until, String selector)
    Get all ancestors of every element in a set of matched elements, matching a selector until the provided filter matches
    final Impl
    parentsUntil(Filter until, Filter filter)
    Get all ancestors of every element in a set of matched elements, matching a filter until the provided filter matches
    final Impl
    prepend(String content)
    Prepend content to the beginning of each element's content in the set of matched elements.
    final Impl
    prepend(Content content)
    Prepend content to the beginning of each element's content in the set of matched elements.
    final Impl
    prepend(Match... content)
    Prepend content to the beginning of each element's content in the set of matched elements.
    final Impl
    prepend(Element... content)
    Prepend content to the beginning of each element's content in the set of matched elements.
    final Impl
    Get the immediate previous sibling of every element in set of matched elements.
    private final Impl
    prev(boolean all, Filter until, Filter filter)
     
    final Impl
    prev(String selector)
    Get the immediate previous sibling of every element in set of matched elements, matching a selector
    final Impl
    prev(Filter filter)
    Get the immediate previous sibling of every element in set of matched elements, matching a filter
    final Impl
    Get all previous siblings of every element in a set of matched elements
    final Impl
    prevAll(String selector)
    Get all previous siblings of every element in a set of matched elements, matching a selector
    final Impl
    prevAll(Filter filter)
    Get all previous siblings of every element in a set of matched elements, matching a filter
    final Impl
    Get all previous siblings of every element in a set of matched elements until the provided selector matches
    final Impl
    prevUntil(String until, String selector)
    Get all previous siblings of every element in a set of matched elements, matching a selector, until the provided selector matches
    final Impl
    prevUntil(String until, Filter filter)
    Get all previous siblings of every element in a set of matched elements, matching a filter, until the provided selector matches
    final Impl
    Get all previous siblings of every element in a set of matched elements until the provided filter matches
    final Impl
    prevUntil(Filter until, String selector)
    Get all previous siblings of every element in a set of matched elements, matching a selector until the provided filter matches
    final Impl
    prevUntil(Filter until, Filter filter)
    Get all previous siblings of every element in a set of matched elements, matching a filter until the provided filter matches
    final Impl
    Removes all elements from their parent nodes in the set of matched elements.
    final Impl
    remove(String selector)
    Removes all elements from their parent nodes in the set of matched elements, matching a selector
    final Impl
    remove(Filter filter)
    Removes all elements from their parent nodes in the set of matched elements, matching a filter
    private final void
    remove(Element element)
     
    final Impl
    Remove an attribute from all elements in the set of matched elements.
    final Match
    Rename all tags in the set of matched elements to some new tag name
    final Match
    Rename all tags in the set of matched elements to some new tag name
    final Impl
    Replace all elements in the set of matched elements with some new content.
    final Impl
    Replace all elements in the set of matched elements with some new content.
    final Impl
    replaceWith(Match... content)
    Replace all elements in the set of matched elements with some new content.
    final Impl
    replaceWith(Element... content)
    Replace all elements in the set of matched elements with some new content.
    final Impl
    Reverse the order of the set of matched elements
    final Impl
    Get all siblings of every element in a set of matched elements
    final Impl
    siblings(String selector)
    Get all siblings of every element in a set of matched elements, matching a selector
    final Impl
    siblings(Filter filter)
    Get all siblings of every element in a set of matched elements, matching a filter
    final int
    Get the number of matched elements in the set of matched elements
    final Impl
    slice(int start)
    Reduce the set of matched elements by specifying a range of indexes
    final Impl
    slice(int start, int end)
    Reduce the set of matched elements by specifying a range of indexes
    sort(Comparator<Element> comparator)
    Allows to sort the result with the given comparator.
    final String
    tag()
    Get the tag name of the first element in the current set of matched elements.
    final String
    tag(int index)
    Get a tag name of the element at a given index in the current set of matched elements.
    final List<String>
    Get a list of tag names of the elements in the current set of matched elements.
    final List<String>
    tags(int... indexes)
    Get a list of tag names of the elements at given indexes in the current set of matched elements.
    final String
    Get the text content of the first element in the set of matched elements, or null if there are no matched elements.
    final String
    text(int index)
    Get the text content at a given index in the current set of matched elements.
    final <T> T
    text(Class<T> type)
    Get the converted text content of the first element in the set of matched elements, or null if there are no matched elements.
    final Impl
    text(String content)
    Set some text content to all elements in the set of matched elements (possibly replacing existing content).
    final Impl
    text(Content content)
    Set some text content to all elements in the set of matched elements (possibly replacing existing content).
    final List<String>
    Get all text content of the elements in the set of matched elements.
    final List<String>
    texts(int... indexes)
    Get all text content of the elements at given indexes in the set of matched elements.
    final <T> List<T>
    texts(Class<T> type)
    Get all converted text content of the elements in the set of matched elements.
     
    final Impl
    transform(File transformer)
    Transform all elements in the set of matched elements.
    final Impl
    transform(InputStream transformer)
    Transform all elements in the set of matched elements.
    final Impl
    transform(Reader transformer)
    Transform all elements in the set of matched elements.
    final Impl
    transform(String transformer)
    Transform all elements in the set of matched elements.
    final Impl
    transform(URL transformer)
    Transform all elements in the set of matched elements.
    final Impl
    transform(Source transformer)
    Transform all elements in the set of matched elements.
    final Impl
    transform(Transformer transformer)
    Transform all elements in the set of matched elements.
    final <T> List<T>
    unmarshal(Class<T> type)
    Unmarshal the current set of matched elements into a JAXB-annotated type.
    final <T> List<T>
    unmarshal(Class<T> type, int... indexes)
    Unmarshal the current set of matched elements at given indexes into a JAXB-annotated type.
    final <T> T
    Unmarshal the first element in the current set of matched elements into a JAXB-annotated type.
    final <T> T
    unmarshalOne(Class<T> type, int index)
    Unmarshal the element at a given index in the current set of matched elements into a JAXB-annotated type.
    final Impl
    Removes all elements in the set of matched elements from their parents
    final Impl
    wrap(String content)
    Wrap all elements from their parent nodes in the set of matched elements in a new parent element
    final Impl
    wrap(Content content)
    Wrap all elements in the set of matched elements in a new parent element
    final Match
    write(File file)
    Write the set of matched elements into a file
    final Match
    Write the set of matched elements into a stream
    final Match
    write(Writer writer)
    Write the set of matched elements into a writer
    final String
    Get an XPath expression describing the first element in the current set of matched elements
    final String
    xpath(int index)
    Get an XPath expression describing the element at a given index in the current set of matched elements
    final Impl
    xpath(String expression)
    Match all elements given a certain XPath expression applied to each element in the current set of matched elements.
    final Impl
    xpath(String expression, Object... variables)
    Match all elements given a certain XPath expression applied to each element in the current set of matched elements.
    final List<String>
    Get a list of XPath expressions describing the elements in the current set of matched elements
    final List<String>
    xpaths(int... indexes)
    Get a list of XPath expressions describing the elements at the given indexes in the current set of matched elements

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • document

      private final Document document
    • elements

      private final List<Element> elements
    • previousMatch

      private final Impl previousMatch
    • namespaces

      private final Map<String,String> namespaces
    • SIMPLE_SELECTOR

      public static final Pattern SIMPLE_SELECTOR
      A selector pattern that can be evaluated using standard DOM API
  • Constructor Details

  • Method Details

    • addNodeLists

      final Impl addNodeLists(List<NodeList> lists)
    • addNodeList

      final Impl addNodeList(NodeList list)
    • addUniqueElements

      final Impl addUniqueElements(Element... e)
    • addUniqueElements

      final Impl addUniqueElements(List<Element> e)
    • addElements

      final Impl addElements(Element... e)
    • addElements

      final Impl addElements(Collection<Element> e)
    • iterator

      public final Iterator<Element> iterator()
      Specified by:
      iterator in interface Iterable<Element>
    • namespace

      public final Match namespace(String namespacePrefix, String namespaceURI)
      Description copied from interface: Match
      Get a new Match with added namespace configuration for subsequent XPath calls

      This is a convenience method for Match.namespaces(java.util.Map)

      Specified by:
      namespace in interface Match
      Parameters:
      namespacePrefix - A namespace prefix
      namespaceURI - A namespace URI
      Returns:
      A modified Match
      See Also:
    • namespaces

      public final Match namespaces(Map<String,String> map)
      Description copied from interface: Match
      Get a new Match with added namespace configuration for subsequent XPath calls
      Specified by:
      namespaces in interface Match
      Parameters:
      map - A mapping between prefix and namespace URI
      Returns:
      A modified Match
    • namespaceURI

      public final String namespaceURI()
      Description copied from interface: Match
      Get the namespace URI of the first element in the current set of matched elements.

      This is the same as calling namespaceURI(0)

      This only works if the underlying document is namespace-aware

      Specified by:
      namespaceURI in interface Match
      See Also:
    • namespaceURI

      public final String namespaceURI(int index)
      Description copied from interface: Match
      Get a namespace URI of the element at a given index in the current set of matched elements.

      This only works if the underlying document is namespace-aware

      Specified by:
      namespaceURI in interface Match
      See Also:
    • namespaceURIs

      public final List<String> namespaceURIs()
      Description copied from interface: Match
      Get a list of namespace URIs of the elements in the current set of matched elements.

      This only works if the underlying document is namespace-aware

      Specified by:
      namespaceURIs in interface Match
      See Also:
    • namespaceURIs

      public final List<String> namespaceURIs(int... indexes)
      Description copied from interface: Match
      Get a list of namespace URIs of the elements at given indexes in the current set of matched elements.

      This only works if the underlying document is namespace-aware

      Specified by:
      namespaceURIs in interface Match
      See Also:
    • namespacePrefix

      public final String namespacePrefix()
      Description copied from interface: Match
      Get the namespace prefix of the first element in the current set of matched elements.

      This is the same as calling namespaceURI(0)

      Specified by:
      namespacePrefix in interface Match
    • namespacePrefix

      public final String namespacePrefix(int index)
      Description copied from interface: Match
      Get a namespace prefix of the element at a given index in the current set of matched elements.
      Specified by:
      namespacePrefix in interface Match
    • namespacePrefixes

      public final List<String> namespacePrefixes()
      Description copied from interface: Match
      Get a list of namespace prefixes of the elements in the current set of matched elements.
      Specified by:
      namespacePrefixes in interface Match
    • namespacePrefixes

      public final List<String> namespacePrefixes(int... indexes)
      Description copied from interface: Match
      Get a list of namespace prefixes of the elements at given indexes in the current set of matched elements.
      Specified by:
      namespacePrefixes in interface Match
    • document

      public final Document document()
      Description copied from interface: Match
      Get the underlying document of the set of matched elements.

      This will also return a document if there are no elements in the set of matched elements, either because a new document has been created previously, or the set of matched elements has been reduced to an empty set.

      Specified by:
      document in interface Match
    • get

      public final Element get(int index)
      Description copied from interface: Match
      Get an element from the set of matched elements at a given index

      Negative indexes are possible, too.

      • -1 corresponds to the last element in the set of matched elements.
      • -2 corresponds to the second-last element, etc.
      Specified by:
      get in interface Match
    • get

      public final List<Element> get(int... indexes)
      Description copied from interface: Match
      Get some elements from the set of matched elements at the given indexes

      Negative indexes are possible, too.

      • -1 corresponds to the last element in the set of matched elements.
      • -2 corresponds to the second-last element, etc.
      Specified by:
      get in interface Match
    • get

      public final List<Element> get()
      Description copied from interface: Match
      Get an the set of matched elements
      Specified by:
      get in interface Match
    • size

      public final int size()
      Description copied from interface: Match
      Get the number of matched elements in the set of matched elements
      Specified by:
      size in interface Match
    • isEmpty

      public final boolean isEmpty()
      Description copied from interface: Match
      Whether there are any matched elements in the set of matched elements
      Specified by:
      isEmpty in interface Match
    • isNotEmpty

      public final boolean isNotEmpty()
      Description copied from interface: Match
      Whether there are any matched elements in the set of matched elements
      Specified by:
      isNotEmpty in interface Match
    • add

      public final Impl add(Element... e)
      Description copied from interface: Match
      Add some elements to the set of matched elements
      Specified by:
      add in interface Match
    • add

      public final Impl add(Match... e)
      Description copied from interface: Match
      Add some elements to the set of matched elements
      Specified by:
      add in interface Match
    • reverse

      public final Impl reverse()
      Description copied from interface: Match
      Reverse the order of the set of matched elements
      Specified by:
      reverse in interface Match
    • andSelf

      public final Impl andSelf()
      Description copied from interface: Match
      Add the previous set of matched elements to the current one. This works after any of these methods (including all overloaded variants): In all other cases, this just returns the same match this was called upon. For instance, it does not make sense to first reduce a set of matched elements using Match.eq(int...), and then add the removed elements again, using Match.andSelf().
      Specified by:
      andSelf in interface Match
    • child

      public final Impl child()
      Description copied from interface: Match
      Find the first child of each element in the current set of matched elements.

      This is the same as calling child(0).

      Specified by:
      child in interface Match
    • child

      public final Impl child(String selector)
      Description copied from interface: Match
      Find the first matching child of each element in the current set of matched elements

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      child in interface Match
      See Also:
    • child

      public final Impl child(Filter filter)
      Description copied from interface: Match
      Find the first matching child of each element in the current set of matched elements
      Specified by:
      child in interface Match
    • child

      public final Impl child(int index)
      Description copied from interface: Match
      Find the child at a given index of each element in the current set of matched elements.
      Specified by:
      child in interface Match
    • children

      public final Impl children()
      Description copied from interface: Match
      Find all children of each element in the current set of matched elements.
      Specified by:
      children in interface Match
    • children

      public final Impl children(int... indexes)
      Description copied from interface: Match
      Find all children of each element at given indexes in the current set of matched elements.
      Specified by:
      children in interface Match
    • children

      public final Impl children(String selector)
      Description copied from interface: Match
      Find all children of each element in the current set of matched elements.

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      children in interface Match
      See Also:
    • children

      public final Impl children(Filter filter)
      Description copied from interface: Match
      Find all children of each element in the current set of matched elements.

      The callback Context is populated like this:

      Specified by:
      children in interface Match
    • each

      public final List<Match> each()
      Description copied from interface: Match
      Get all elements in the set of matched elements in a list of matches, every match representing one element
      Specified by:
      each in interface Match
    • each

      public final Impl each(Each each)
      Description copied from interface: Match
      Execute a callback for every element in the current set of matched elements.
      Specified by:
      each in interface Match
    • each

      public final Impl each(Each... each)
      Description copied from interface: Match
      Execute several callbacks for every element in the current set of matched elements.
      Specified by:
      each in interface Match
      See Also:
    • each

      public final Impl each(Iterable<? extends Each> each)
      Description copied from interface: Match
      Execute several callbacks for every element in the current set of matched elements.
      Specified by:
      each in interface Match
      See Also:
    • filter

      public final Impl filter(String selector)
      Description copied from interface: Match
      Reduce the current set of matched elements.

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      filter in interface Match
      See Also:
    • filter

      public final Impl filter(Filter filter)
      Description copied from interface: Match
      Reduce the current set of matched elements.

      The callback Context is populated like this:

      Specified by:
      filter in interface Match
    • filter0

      private final List<Element> filter0(Filter filter)
    • eq

      public final Impl eq(int... indexes)
      Description copied from interface: Match
      Reduce the current set of matched elements to the elements at the given indexes. If the given indexes are not in the range of indexes, the resulting set will be empty.

      Negative indexes are possible, too.

      • -1 corresponds to the last element in the set of matched elements.
      • -2 corresponds to the second-last element, etc.
      Specified by:
      eq in interface Match
    • find

      public final Impl find()
      Description copied from interface: Match
      Find all descendants of each element in the current set of matched elements.
      Specified by:
      find in interface Match
    • find

      public final Impl find(String selector)
      Description copied from interface: Match
      Find all descendants of each element in the current set of matched elements.

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String) Tag names are namespace-unaware. This means that existing namespaces will be ignored
      • CSS selectors can be used to select XML elements using XPath (see CSS2XPath.css2xpath(String))
      The following features are not supported:
      Specified by:
      find in interface Match
      See Also:
    • isRoot

      private boolean isRoot()
      Temporary utility method to indicate whether the root element is among the matched elements
    • find

      public final Impl find(Filter filter)
      Description copied from interface: Match
      Find all descendants of each element in the current set of matched elements.

      The callback Context is populated like this:

      Specified by:
      find in interface Match
    • xpath

      public final Impl xpath(String expression)
      Description copied from interface: Match
      Match all elements given a certain XPath expression applied to each element in the current set of matched elements.

      The XPath expression is evaluated using standard XPath. It must not contain any variables. Use Match.xpath(String, Object...) instead, if you wish to use variables. Note that only matched elements will be considered in the results. You cannot match attributes or text nodes, for instance. Examples:

      • Match all elements : xpath("//*")
      • Match all books : xpath("/library/books/book")
      • Match all book ID's : xpath("//book").ids()
      • Match all book names : xpath("//book/name").texts()
      This doesn't work (not matching elements):
      • Match all book ID's : xpath("//book/@id")
      • Match all book names : xpath("//book/name/text()")

      Using jOOX with Namespaces

      Namespace declarations are supported in XPath expressions. If you wish to use namespace-specific XPath elements, call Match.namespace(String, String) prior to Match.xpath(String)

      Using jOOX with Xalan

      If Xalan is on your classpath, jOOX will automatically load xalan's namespace and function extensions. All functionality supported by http://exslt.org will be available in your XPath expressions. Some examples:

      • Match the book with the highest ID : xpath("//book[number(@id) = math:max(//book/@id)]")
      • Match books written by Orwell : xpath("//book[java:org.joox.test.Functions.byOrwellWithNodes(.)]
      Specified by:
      xpath in interface Match
    • xpath

      public final Impl xpath(String expression, Object... variables)
      Description copied from interface: Match
      Match all elements given a certain XPath expression applied to each element in the current set of matched elements.

      The XPath expression is evaluated using standard XPath. It may contain numerical variables, declared as $1, $2, etc, starting with $1. Other variables, such as $myVar are not supported. You must provide at least one variable in the variables argument for every variable index. Note that only matched elements will be considered in the results. You cannot match attributes or text nodes, for instance. Examples:

      • Match all elements with id greater than 5: xpath("//*[@id > $1]", 5)
      • Match all books with more than two authors and one author is "George Orwell" : xpath("/library/books/book[count(authors/author) > $1][authors/author[text() = $2]]", 2, "George Orwell")
      This doesn't work (not matching elements):
      • Match all book ID's : xpath("//book/@id")
      • Match all book names : xpath("//book/name/text()")

      Using jOOX with Namespaces

      Namespace declarations are supported in XPath expressions. If you wish to use namespace-specific XPath elements, call Match.namespace(String, String) prior to Match.xpath(String)

      Using jOOX with Xalan

      If Xalan is on your classpath, jOOX will automatically load xalan's namespace and function extensions. All functionality supported by http://exslt.org will be available in your XPath expressions. Some examples:

      • Match the book with the highest ID : xpath("//book[number(@id) = math:max(//book/@id)]")
      • Match books written by Orwell : xpath("//book[java:org.joox.test.Functions.byOrwellWithNodes(.)]
      Specified by:
      xpath in interface Match
    • first

      public final Impl first()
      Description copied from interface: Match
      Get the first in a set of matched elements.
      Specified by:
      first in interface Match
    • has

      public final Impl has(String selector)
      Description copied from interface: Match
      Reduce the set of matched element to those who have a descendant that matches a selector.

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      has in interface Match
      See Also:
    • has

      public final Impl has(Filter filter)
      Description copied from interface: Match
      Reduce the set of matched element to those who have a descendant that matches a filter.

      The callback Context is populated like this:

      Specified by:
      has in interface Match
    • is

      public final boolean is(String selector)
      Description copied from interface: Match
      Check if at least one element in the set of matched elements satisfies a selector.

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      is in interface Match
      See Also:
    • is

      public final boolean is(Filter filter)
      Description copied from interface: Match
      Check if at least one element in the set of matched elements satisfies a filter.

      The callback Context is populated like this:

      Specified by:
      is in interface Match
    • last

      public final Impl last()
      Description copied from interface: Match
      Get the last in a set of matched elements.
      Specified by:
      last in interface Match
    • map

      public final <E> List<E> map(Mapper<E> map)
      Description copied from interface: Match
      Map the set of matched elements to a list of something
      Specified by:
      map in interface Match
    • next

      public final Impl next()
      Description copied from interface: Match
      Get the immediate next sibling of every element in set of matched elements.
      Specified by:
      next in interface Match
    • next

      public final Impl next(String selector)
      Description copied from interface: Match
      Get the immediate next sibling of every element in set of matched elements, matching a selector

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      next in interface Match
      See Also:
    • next

      public final Impl next(Filter filter)
      Description copied from interface: Match
      Get the immediate next sibling of every element in set of matched elements, matching a filter

      The callback Context is populated like this:

      Specified by:
      next in interface Match
    • nextAll

      public final Impl nextAll()
      Description copied from interface: Match
      Get all next siblings of every element in a set of matched elements
      Specified by:
      nextAll in interface Match
    • nextAll

      public final Impl nextAll(String selector)
      Description copied from interface: Match
      Get all next siblings of every element in a set of matched elements, matching a selector

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      nextAll in interface Match
      See Also:
    • nextAll

      public final Impl nextAll(Filter filter)
      Description copied from interface: Match
      Get all next siblings of every element in a set of matched elements, matching a filter

      The callback Context is populated like this:

      Specified by:
      nextAll in interface Match
    • nextUntil

      public final Impl nextUntil(String until)
      Description copied from interface: Match
      Get all next siblings of every element in a set of matched elements until the provided selector matches

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      nextUntil in interface Match
      See Also:
    • nextUntil

      public final Impl nextUntil(Filter until)
      Description copied from interface: Match
      Get all next siblings of every element in a set of matched elements until the provided filter matches

      The callback Context is populated like this:

      Specified by:
      nextUntil in interface Match
    • nextUntil

      public final Impl nextUntil(String until, String selector)
      Description copied from interface: Match
      Get all next siblings of every element in a set of matched elements, matching a selector, until the provided selector matches

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      nextUntil in interface Match
      See Also:
    • nextUntil

      public final Impl nextUntil(String until, Filter filter)
      Description copied from interface: Match
      Get all next siblings of every element in a set of matched elements, matching a filter, until the provided selector matches

      The callback Context is populated like this:

      Specified by:
      nextUntil in interface Match
      See Also:
    • nextUntil

      public final Impl nextUntil(Filter until, String selector)
      Description copied from interface: Match
      Get all next siblings of every element in a set of matched elements, matching a selector until the provided filter matches

      The callback Context is populated like this:

      Specified by:
      nextUntil in interface Match
      See Also:
    • nextUntil

      public final Impl nextUntil(Filter until, Filter filter)
      Description copied from interface: Match
      Get all next siblings of every element in a set of matched elements, matching a filter until the provided filter matches

      The callback Context is populated like this:

      Specified by:
      nextUntil in interface Match
      See Also:
    • next

      private final Impl next(boolean all, Filter until, Filter filter)
    • not

      public final Impl not(String selector)
      Description copied from interface: Match
      Remove elements from the set of matched elements.

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      not in interface Match
      See Also:
    • not

      public final Impl not(Filter filter)
      Description copied from interface: Match
      Remove elements from the set of matched elements.

      The callback Context is populated like this:

      Specified by:
      not in interface Match
    • parent

      public final Impl parent()
      Description copied from interface: Match
      Get the immediate parent elements of every element in a set of matched elements
      Specified by:
      parent in interface Match
    • parent

      public final Impl parent(String selector)
      Description copied from interface: Match
      Get the immediate parent elements of every element in a set of matched elements, matching a selector

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      parent in interface Match
      See Also:
    • parent

      public final Impl parent(Filter filter)
      Description copied from interface: Match
      Get the immediate parent elements of every element in a set of matched elements, matching a filter

      The callback Context is populated like this:

      Specified by:
      parent in interface Match
    • parents

      public final Impl parents()
      Description copied from interface: Match
      Get all ancestor elements of every element in a set of matched elements
      Specified by:
      parents in interface Match
    • parents

      public final Impl parents(String selector)
      Description copied from interface: Match
      Get all ancestor elements of every element in a set of matched elements, matching a selector

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      parents in interface Match
      See Also:
    • parents

      public final Impl parents(Filter filter)
      Description copied from interface: Match
      Get all ancestor elements of every element in a set of matched elements, matching a filter

      The callback Context is populated like this:

      Specified by:
      parents in interface Match
    • parentsUntil

      public final Impl parentsUntil(String until)
      Description copied from interface: Match
      Get all ancestors of every element in a set of matched elements until the provided selector matches

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      parentsUntil in interface Match
      See Also:
    • parentsUntil

      public final Impl parentsUntil(Filter until)
      Description copied from interface: Match
      Get all ancestors of every element in a set of matched elements until the provided filter matches

      The callback Context is populated like this:

      Specified by:
      parentsUntil in interface Match
    • parentsUntil

      public final Impl parentsUntil(String until, String selector)
      Description copied from interface: Match
      Get all ancestors of every element in a set of matched elements, matching a selector, until the provided selector matches

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      parentsUntil in interface Match
      See Also:
    • parentsUntil

      public final Impl parentsUntil(String until, Filter filter)
      Description copied from interface: Match
      Get all ancestors of every element in a set of matched elements, matching a filter, until the provided selector matches

      The callback Context is populated like this:

      Specified by:
      parentsUntil in interface Match
      See Also:
    • parentsUntil

      public final Impl parentsUntil(Filter until, String selector)
      Description copied from interface: Match
      Get all ancestors of every element in a set of matched elements, matching a selector until the provided filter matches

      The callback Context is populated like this:

      Specified by:
      parentsUntil in interface Match
      See Also:
    • parentsUntil

      public final Impl parentsUntil(Filter until, Filter filter)
      Description copied from interface: Match
      Get all ancestors of every element in a set of matched elements, matching a filter until the provided filter matches

      The callback Context is populated like this:

      Specified by:
      parentsUntil in interface Match
    • parents

      private final Impl parents(boolean all, Filter until, Filter filter)
    • prev

      public final Impl prev()
      Description copied from interface: Match
      Get the immediate previous sibling of every element in set of matched elements.
      Specified by:
      prev in interface Match
    • prev

      public final Impl prev(String selector)
      Description copied from interface: Match
      Get the immediate previous sibling of every element in set of matched elements, matching a selector

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      prev in interface Match
      See Also:
    • prev

      public final Impl prev(Filter filter)
      Description copied from interface: Match
      Get the immediate previous sibling of every element in set of matched elements, matching a filter

      The callback Context is populated like this:

      Specified by:
      prev in interface Match
    • prevAll

      public final Impl prevAll()
      Description copied from interface: Match
      Get all previous siblings of every element in a set of matched elements
      Specified by:
      prevAll in interface Match
    • prevAll

      public final Impl prevAll(String selector)
      Description copied from interface: Match
      Get all previous siblings of every element in a set of matched elements, matching a selector

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      prevAll in interface Match
      See Also:
    • prevAll

      public final Impl prevAll(Filter filter)
      Description copied from interface: Match
      Get all previous siblings of every element in a set of matched elements, matching a filter

      The callback Context is populated like this:

      Specified by:
      prevAll in interface Match
    • prevUntil

      public final Impl prevUntil(String until)
      Description copied from interface: Match
      Get all previous siblings of every element in a set of matched elements until the provided selector matches

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      prevUntil in interface Match
      See Also:
    • prevUntil

      public final Impl prevUntil(Filter until)
      Description copied from interface: Match
      Get all previous siblings of every element in a set of matched elements until the provided filter matches

      The callback Context is populated like this:

      Specified by:
      prevUntil in interface Match
    • prevUntil

      public final Impl prevUntil(String until, String selector)
      Description copied from interface: Match
      Get all previous siblings of every element in a set of matched elements, matching a selector, until the provided selector matches

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      prevUntil in interface Match
      See Also:
    • prevUntil

      public final Impl prevUntil(String until, Filter filter)
      Description copied from interface: Match
      Get all previous siblings of every element in a set of matched elements, matching a filter, until the provided selector matches

      The callback Context is populated like this:

      Specified by:
      prevUntil in interface Match
      See Also:
    • prevUntil

      public final Impl prevUntil(Filter until, String selector)
      Description copied from interface: Match
      Get all previous siblings of every element in a set of matched elements, matching a selector until the provided filter matches

      The callback Context is populated like this:

      Specified by:
      prevUntil in interface Match
      See Also:
    • prevUntil

      public final Impl prevUntil(Filter until, Filter filter)
      Description copied from interface: Match
      Get all previous siblings of every element in a set of matched elements, matching a filter until the provided filter matches

      The callback Context is populated like this:

      Specified by:
      prevUntil in interface Match
    • prev

      private final Impl prev(boolean all, Filter until, Filter filter)
    • axis

      private final Impl axis(boolean all, Filter until, Filter filter, Function<Node,Node> iterate, Consumer<List<Element>> finisher)
    • siblings

      public final Impl siblings()
      Description copied from interface: Match
      Get all siblings of every element in a set of matched elements
      Specified by:
      siblings in interface Match
    • siblings

      public final Impl siblings(String selector)
      Description copied from interface: Match
      Get all siblings of every element in a set of matched elements, matching a selector

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      siblings in interface Match
      See Also:
    • siblings

      public final Impl siblings(Filter filter)
      Description copied from interface: Match
      Get all siblings of every element in a set of matched elements, matching a filter

      The callback Context is populated like this:

      Specified by:
      siblings in interface Match
    • slice

      public final Impl slice(int start)
      Description copied from interface: Match
      Reduce the set of matched elements by specifying a range of indexes

      This is the same as calling slice(start, Integer.MAX_VALUE)

      Specified by:
      slice in interface Match
    • slice

      public final Impl slice(int start, int end)
      Description copied from interface: Match
      Reduce the set of matched elements by specifying a range of indexes
      Specified by:
      slice in interface Match
    • matchText

      public final Impl matchText(String regex)
      Description copied from interface: Match
      Reduce the set of matched elements by filtering out those whose text content doesn't match a given regex

      This is the same as calling matchText(regex, true)

      Specified by:
      matchText in interface Match
      See Also:
    • matchText

      public final Impl matchText(String regex, boolean keepMatches)
      Description copied from interface: Match
      Reduce the set of matched elements by filtering out those whose text content doesn't match a given regex (keepMatches = true), or those whose text content matches a given regex (keepMatches = false)
      Specified by:
      matchText in interface Match
      See Also:
    • matchTag

      public final Impl matchTag(String regex)
      Description copied from interface: Match
      Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regex

      This is the same as calling matchText(regex, true)

      Specified by:
      matchTag in interface Match
      See Also:
    • matchTag

      public final Impl matchTag(String regex, boolean keepMatches)
      Description copied from interface: Match
      Reduce the set of matched elements by filtering out those whose tag name doesn't match a given regex (keepMatches = true), or those whose tag name matches a given regex (keepMatches = false)
      Specified by:
      matchTag in interface Match
      See Also:
    • matchAttr

      public final Match matchAttr(String name, String valueRegex)
      Description copied from interface: Match
      Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regex

      This is the same as calling matchAttr(name, valueRegex, true)

      Specified by:
      matchAttr in interface Match
      See Also:
    • matchAttr

      public final Match matchAttr(String name, String valueRegex, boolean keepMatches)
      Description copied from interface: Match
      Reduce the set of matched elements by filtering out those whose attribute content doesn't match a given regex (keepMatches = true), or those whose text content matches a given regex (keepMatches = false)
      Specified by:
      matchAttr in interface Match
      See Also:
    • leaf

      public final Impl leaf()
      Description copied from interface: Match
      Reduce the set of matched elements to the ones that are leaf elements
      Specified by:
      leaf in interface Match
      See Also:
    • after

      public final Impl after(String content)
      Description copied from interface: Match
      Add content after each element in the set of matched elements.
      Specified by:
      after in interface Match
    • after

      public final Impl after(Content content)
      Description copied from interface: Match
      Add content after each element in the set of matched elements.

      The callback Context is populated like this:

      Specified by:
      after in interface Match
    • after

      public final Impl after(Match... content)
      Description copied from interface: Match
      Add content after each element in the set of matched elements.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      after in interface Match
    • after

      public final Impl after(Element... content)
      Description copied from interface: Match
      Add content after each element in the set of matched elements.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      after in interface Match
    • before

      public final Impl before(String content)
      Description copied from interface: Match
      Add content before each element in the set of matched elements.
      Specified by:
      before in interface Match
    • before

      public final Impl before(Content content)
      Description copied from interface: Match
      Add content before each element in the set of matched elements.

      The callback Context is populated like this:

      Specified by:
      before in interface Match
    • before

      public final Impl before(Match... content)
      Description copied from interface: Match
      Add content before each element in the set of matched elements.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      before in interface Match
    • before

      public final Impl before(Element... content)
      Description copied from interface: Match
      Add content before each element in the set of matched elements.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      before in interface Match
    • append

      public final Impl append(String content)
      Description copied from interface: Match
      Append content to the end of each element's content in the set of matched elements.
      Specified by:
      append in interface Match
    • append

      public final Impl append(Content content)
      Description copied from interface: Match
      Append content to the end of each element's content in the set of matched elements.

      The callback Context is populated like this:

      Specified by:
      append in interface Match
    • append

      public final Impl append(Match... content)
      Description copied from interface: Match
      Append content to the end of each element's content in the set of matched elements.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      append in interface Match
    • append

      public final Impl append(Element... content)
      Description copied from interface: Match
      Append content to the end of each element's content in the set of matched elements.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      append in interface Match
    • prepend

      public final Impl prepend(String content)
      Description copied from interface: Match
      Prepend content to the beginning of each element's content in the set of matched elements.
      Specified by:
      prepend in interface Match
    • prepend

      public final Impl prepend(Content content)
      Description copied from interface: Match
      Prepend content to the beginning of each element's content in the set of matched elements.

      The callback Context is populated like this:

      Specified by:
      prepend in interface Match
    • prepend

      public final Impl prepend(Match... content)
      Description copied from interface: Match
      Prepend content to the beginning of each element's content in the set of matched elements.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      prepend in interface Match
    • prepend

      public final Impl prepend(Element... content)
      Description copied from interface: Match
      Prepend content to the beginning of each element's content in the set of matched elements.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      prepend in interface Match
    • attr

      public final String attr(String name)
      Description copied from interface: Match
      Get an attribute from the first element in the set of matched elements, or null if the first element does not have that attribute.

      jOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.

      Specified by:
      attr in interface Match
    • attr

      public final <T> T attr(String name, Class<T> type)
      Description copied from interface: Match
      Get a converted attribute from the first element in the set of matched elements, or null if the first element does not have that attribute.

      jOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.

      Specified by:
      attr in interface Match
      See Also:
    • attrs

      public final List<String> attrs(String name)
      Description copied from interface: Match
      Get an attribute from all elements in the set of matched elements

      jOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.

      Specified by:
      attrs in interface Match
    • attrs

      public final <T> List<T> attrs(String name, Class<T> type)
      Description copied from interface: Match
      Get a converted attribute from all elements in the set of matched elements

      jOOX is namespace-unaware. The supplied attribute name will be compared against all attributes, matching the first one that has the given name.

      Specified by:
      attrs in interface Match
      See Also:
    • attr

      public final Impl attr(String name, String value)
      Description copied from interface: Match
      Set an attribute on all elements in the set of matched elements. If value is null, then the attribute is removed. If the attribute already exists, then it is replaced.
      Specified by:
      attr in interface Match
    • attr

      public final Impl attr(String name, Content content)
      Description copied from interface: Match
      Set an attribute on all elements in the set of matched elements. If value returns null, then the attribute is removed. If the attribute already exists, then it is replaced.

      The callback Context is populated like this:

      Specified by:
      attr in interface Match
    • removeAttr

      public final Impl removeAttr(String name)
      Description copied from interface: Match
      Remove an attribute from all elements in the set of matched elements. This is the same as calling attr(name, null).
      Specified by:
      removeAttr in interface Match
    • content

      public final String content()
      Description copied from interface: Match
      Get the XML content of the first element in the set of matched elements, or null if there are no matched elements.

      This is the same as calling content(0)

      Specified by:
      content in interface Match
    • content

      public final String content(int index)
      Description copied from interface: Match
      Get the XML content at a given index in the current set of matched elements.
      Specified by:
      content in interface Match
    • contents

      public final List<String> contents()
      Description copied from interface: Match
      Get all XML content of the elements in the set of matched elements.
      Specified by:
      contents in interface Match
    • contents

      public final List<String> contents(int... indexes)
      Description copied from interface: Match
      Get all XML content of the elements at given indexes in the set of matched elements.
      Specified by:
      contents in interface Match
    • content

      private final String content(Element element)
    • content

      public final Impl content(String content)
      Description copied from interface: Match
      Add some XML content to all elements in the set of matched elements (possibly replacing existing content). If the supplied content is invalid XML or plain text, then it will be added as text just as with Match.text(String)
      Specified by:
      content in interface Match
    • content

      public final Impl content(Object content)
      Description copied from interface: Match
      Add some JAXB-marshallable XML content to all elements in the set of matched elements (possibly replacing existing content).
      Specified by:
      content in interface Match
      See Also:
    • content

      public final Impl content(Content content)
      Description copied from interface: Match
      Add some XML content to all elements in the set of matched elements (possibly replacing existing content). If the supplied content is invalid XML or plain text, then it will be added as text just as with Match.text(String)

      The callback Context is populated like this:

      Specified by:
      content in interface Match
    • text

      public final String text()
      Description copied from interface: Match
      Get the text content of the first element in the set of matched elements, or null if there are no matched elements.

      This is the same as calling text(0)

      Specified by:
      text in interface Match
    • text

      public final String text(int index)
      Description copied from interface: Match
      Get the text content at a given index in the current set of matched elements.
      Specified by:
      text in interface Match
    • text

      public final <T> T text(Class<T> type)
      Description copied from interface: Match
      Get the converted text content of the first element in the set of matched elements, or null if there are no matched elements.
      Specified by:
      text in interface Match
      See Also:
    • texts

      public final List<String> texts()
      Description copied from interface: Match
      Get all text content of the elements in the set of matched elements.
      Specified by:
      texts in interface Match
    • texts

      public final List<String> texts(int... indexes)
      Description copied from interface: Match
      Get all text content of the elements at given indexes in the set of matched elements.
      Specified by:
      texts in interface Match
    • texts

      public final <T> List<T> texts(Class<T> type)
      Description copied from interface: Match
      Get all converted text content of the elements in the set of matched elements.
      Specified by:
      texts in interface Match
      See Also:
    • text

      public final Impl text(String content)
      Description copied from interface: Match
      Set some text content to all elements in the set of matched elements (possibly replacing existing content).
      Specified by:
      text in interface Match
    • text

      public final Impl text(Content content)
      Description copied from interface: Match
      Set some text content to all elements in the set of matched elements (possibly replacing existing content).

      The callback Context is populated like this:

      Specified by:
      text in interface Match
    • cdata

      public final String cdata()
      Description copied from interface: Match
      Get the CDATA content of the first element in the set of matched elements, or null if there are no matched elements.

      This is the same as calling cdata(0) or Match.text().

      Specified by:
      cdata in interface Match
    • cdata

      public final String cdata(int index)
      Description copied from interface: Match
      Get the CDATA content at a given index in the current set of matched elements.

      This is the same as Match.text(int).

      Specified by:
      cdata in interface Match
    • cdata

      public final <T> T cdata(Class<T> type)
      Description copied from interface: Match
      Get the converted CDATA content of the first element in the set of matched elements, or null if there are no matched elements.

      This is the same as Match.text(Class).

      Specified by:
      cdata in interface Match
      See Also:
    • cdatas

      public final List<String> cdatas()
      Description copied from interface: Match
      Get all CDATA content of the elements in the set of matched elements.

      This is the same as Match.texts().

      Specified by:
      cdatas in interface Match
    • cdatas

      public final List<String> cdatas(int... indexes)
      Description copied from interface: Match
      Get all CDATA content of the elements at given indexes in the set of matched elements.

      This is the same as Match.texts(int...).

      Specified by:
      cdatas in interface Match
    • cdatas

      public final <T> List<T> cdatas(Class<T> type)
      Description copied from interface: Match
      Get all converted CDATA content of the elements in the set of matched elements.

      This is the same as Match.texts(Class).

      Specified by:
      cdatas in interface Match
      See Also:
    • cdata

      public final Impl cdata(String content)
      Description copied from interface: Match
      Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).

      Unlike Match.text(Content), this generates a Node.CDATA_SECTION_NODE.

      Specified by:
      cdata in interface Match
    • cdata

      public final Impl cdata(Content content)
      Description copied from interface: Match
      Set some CDATA content to all elements in the set of matched elements (possibly replacing existing content).

      The callback Context is populated like this:

      Unlike Match.text(Content), this generates a Node.CDATA_SECTION_NODE.

      Specified by:
      cdata in interface Match
    • empty

      public final Match empty()
      Description copied from interface: Match
      Removes all content from all elements in the set of matched elements.
      Specified by:
      empty in interface Match
    • remove

      public final Impl remove()
      Description copied from interface: Match
      Removes all elements from their parent nodes in the set of matched elements.
      Specified by:
      remove in interface Match
    • remove

      public final Impl remove(String selector)
      Description copied from interface: Match
      Removes all elements from their parent nodes in the set of matched elements, matching a selector

      The selector provided to this method supports the following features:

      • * can be used to select everything
      • tag names can be used to select XML elements by tag names (see Element.getElementsByTagName(String). Tag names are namespace-unaware. This means that existing namespaces will be ignored
      The following features are not supported:
      Specified by:
      remove in interface Match
      See Also:
    • remove

      public final Impl remove(Filter filter)
      Description copied from interface: Match
      Removes all elements from their parent nodes in the set of matched elements, matching a filter

      The callback Context is populated like this:

      Specified by:
      remove in interface Match
    • remove

      private final void remove(Element element)
    • empty

      private final void empty(Element element)
    • wrap

      public final Impl wrap(String content)
      Description copied from interface: Match
      Wrap all elements from their parent nodes in the set of matched elements in a new parent element

      The resulting set of matched elements contains the newly wrapped elements

      Specified by:
      wrap in interface Match
      See Also:
    • wrap

      public final Impl wrap(Content content)
      Description copied from interface: Match
      Wrap all elements in the set of matched elements in a new parent element

      The resulting set of matched elements contains the newly wrapped elements

      Specified by:
      wrap in interface Match
      See Also:
    • unwrap

      public final Impl unwrap()
      Description copied from interface: Match
      Removes all elements in the set of matched elements from their parents

      The resulting set of matched elements contains the newly unwrapped elements

      Specified by:
      unwrap in interface Match
      See Also:
    • replaceWith

      public final Impl replaceWith(String content)
      Description copied from interface: Match
      Replace all elements in the set of matched elements with some new content.
      Specified by:
      replaceWith in interface Match
    • replaceWith

      public final Impl replaceWith(Content content)
      Description copied from interface: Match
      Replace all elements in the set of matched elements with some new content.
      Specified by:
      replaceWith in interface Match
    • replaceWith

      public final Impl replaceWith(Match... content)
      Description copied from interface: Match
      Replace all elements in the set of matched elements with some new content.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      replaceWith in interface Match
    • replaceWith

      public final Impl replaceWith(Element... content)
      Description copied from interface: Match
      Replace all elements in the set of matched elements with some new content.

      If the added content is already contained in this document, then it is moved. Otherwise, it is cloned. If there are several elements in the set of matched elements, then the added content is duplicated.

      Specified by:
      replaceWith in interface Match
    • rename

      public final Match rename(String tag)
      Description copied from interface: Match
      Rename all tags in the set of matched elements to some new tag name
      Specified by:
      rename in interface Match
    • rename

      public final Match rename(Content tag)
      Description copied from interface: Match
      Rename all tags in the set of matched elements to some new tag name
      Specified by:
      rename in interface Match
    • isFast

      private final boolean isFast(Filter filter)
    • copy

      public final Impl copy()
      Description copied from interface: Match
      Get a copy of the Match wrapper. This is not a deep-copy of wrapped Element objects. Both this and the copy will reference the same Element's
      Specified by:
      copy in interface Match
    • xpath

      public final String xpath()
      Description copied from interface: Match
      Get an XPath expression describing the first element in the current set of matched elements

      This is the same as calling xpath(0)

      Specified by:
      xpath in interface Match
    • xpath

      public final String xpath(int index)
      Description copied from interface: Match
      Get an XPath expression describing the element at a given index in the current set of matched elements
      Specified by:
      xpath in interface Match
    • xpaths

      public final List<String> xpaths()
      Description copied from interface: Match
      Get a list of XPath expressions describing the elements in the current set of matched elements
      Specified by:
      xpaths in interface Match
    • xpaths

      public final List<String> xpaths(int... indexes)
      Description copied from interface: Match
      Get a list of XPath expressions describing the elements at the given indexes in the current set of matched elements
      Specified by:
      xpaths in interface Match
    • tag

      public final String tag()
      Description copied from interface: Match
      Get the tag name of the first element in the current set of matched elements.

      This is the same as calling tag(0)

      Specified by:
      tag in interface Match
    • tag

      public final String tag(int index)
      Description copied from interface: Match
      Get a tag name of the element at a given index in the current set of matched elements.
      Specified by:
      tag in interface Match
    • tags

      public final List<String> tags()
      Description copied from interface: Match
      Get a list of tag names of the elements in the current set of matched elements.
      Specified by:
      tags in interface Match
    • tags

      public final List<String> tags(int... indexes)
      Description copied from interface: Match
      Get a list of tag names of the elements at given indexes in the current set of matched elements.
      Specified by:
      tags in interface Match
    • id

      public final String id()
      Description copied from interface: Match
      Get the first id value

      This is the same as calling id(0)

      Specified by:
      id in interface Match
    • id

      public final String id(int index)
      Description copied from interface: Match
      Get an id value at a given index in the current set of matched elements.

      This is the same as calling eq(index).attr("id")

      Specified by:
      id in interface Match
    • id

      public final <T> T id(Class<T> type)
      Description copied from interface: Match
      Get the first converted id value
      Specified by:
      id in interface Match
      See Also:
    • ids

      public final List<String> ids()
      Description copied from interface: Match
      Get a list of id values in the current set of matched elements.

      This is the same as calling attrs("id")

      Specified by:
      ids in interface Match
    • ids

      public final List<String> ids(int... indexes)
      Description copied from interface: Match
      Get a list of id values at given indexes in the current set of matched elements.
      Specified by:
      ids in interface Match
    • ids

      public final <T> List<T> ids(Class<T> type)
      Description copied from interface: Match
      Get a list of converted id values in the current set of matched elements.
      Specified by:
      ids in interface Match
      See Also:
    • write

      public final Match write(Writer writer) throws IOException
      Description copied from interface: Match
      Write the set of matched elements into a writer

      If the set contains more or less than 1 element, this will result in writing non-well-formed XML

      Specified by:
      write in interface Match
      Throws:
      IOException
    • write

      public final Match write(OutputStream stream) throws IOException
      Description copied from interface: Match
      Write the set of matched elements into a stream

      If the set contains more or less than 1 element, this will result in writing non-well-formed XML

      Specified by:
      write in interface Match
      Throws:
      IOException
    • write

      public final Match write(File file) throws IOException
      Description copied from interface: Match
      Write the set of matched elements into a file

      If the set contains more or less than 1 element, this will result in writing non-well-formed XML

      Specified by:
      write in interface Match
      Throws:
      IOException
    • unmarshal

      public final <T> List<T> unmarshal(Class<T> type)
      Description copied from interface: Match
      Unmarshal the current set of matched elements into a JAXB-annotated type.
      Specified by:
      unmarshal in interface Match
    • unmarshal

      public final <T> List<T> unmarshal(Class<T> type, int... indexes)
      Description copied from interface: Match
      Unmarshal the current set of matched elements at given indexes into a JAXB-annotated type.
      Specified by:
      unmarshal in interface Match
    • unmarshalOne

      public final <T> T unmarshalOne(Class<T> type)
      Description copied from interface: Match
      Unmarshal the first element in the current set of matched elements into a JAXB-annotated type.

      This is the same as calling unmarshalOne(type, 0)

      Specified by:
      unmarshalOne in interface Match
    • unmarshalOne

      public final <T> T unmarshalOne(Class<T> type, int index)
      Description copied from interface: Match
      Unmarshal the element at a given index in the current set of matched elements into a JAXB-annotated type.

      This is the same as calling unmarshalOne(type, 0)

      Specified by:
      unmarshalOne in interface Match
    • transform

      public final Impl transform(Transformer transformer)
      Description copied from interface: Match
      Transform all elements in the set of matched elements.

      This will apply a given Transformer to every element in the set of matched elements. Every element in the set of matched elements will be replaced by its corresponding Result obtained from the transformer.

      Example Input:

       <books>
         <book id="1"/>
         <book id="2"/>
       </books>
       

      Example XSLT:

       <?xml version="1.0" encoding="ISO-8859-1"?>
       <xsl:stylesheet version="1.0"
           xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      
           <xsl:template match="book">
               <book id="">
                   <xsl:apply-templates/>
               </book>
           </xsl:template>
      
           <xsl:template match="@*|*">
               <xsl:copy>
                   <xsl:apply-templates select="*|@*"/>
               </xsl:copy>
           </xsl:template>
       </xsl:stylesheet>
       

      Apply transformation:

       // Applies transformation to the document element:
       $(document).transform("increment.xsl");
      
       // Applies transformation to every book element:
       $(document).find("book").transform("increment.xsl");
       

      Result:

       <books>
         <book id="2"/>
         <book id="3"/>
       </books>
       
      Specified by:
      transform in interface Match
    • transform

      public final Impl transform(Source transformer)
      Description copied from interface: Match
      Transform all elements in the set of matched elements.
      Specified by:
      transform in interface Match
      See Also:
    • transform

      public final Impl transform(InputStream transformer)
      Description copied from interface: Match
      Transform all elements in the set of matched elements.
      Specified by:
      transform in interface Match
      See Also:
    • transform

      public final Impl transform(Reader transformer)
      Description copied from interface: Match
      Transform all elements in the set of matched elements.
      Specified by:
      transform in interface Match
      See Also:
    • transform

      public final Impl transform(URL transformer)
      Description copied from interface: Match
      Transform all elements in the set of matched elements.
      Specified by:
      transform in interface Match
      See Also:
    • transform

      public final Impl transform(File transformer)
      Description copied from interface: Match
      Transform all elements in the set of matched elements.
      Specified by:
      transform in interface Match
      See Also:
    • transform

      public final Impl transform(String transformer)
      Description copied from interface: Match
      Transform all elements in the set of matched elements.
      Specified by:
      transform in interface Match
      See Also:
    • sort

      public Match sort(Comparator<Element> comparator)
      Description copied from interface: Match
      Allows to sort the result with the given comparator.
      Specified by:
      sort in interface Match
      Parameters:
      comparator - The element comparator.
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object