Package org.eclipse.lemminx.xpath.matcher

## Class XPathMatcher

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractList<E>
    - - java.util.ArrayList<IXPathNodeMatcher>
      - - org.eclipse.lemminx.xpath.matcher.XPathMatcher

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Iterable<IXPathNodeMatcher>`, `Collection<IXPathNodeMatcher>`, `List<IXPathNodeMatcher>`, `RandomAccess`

    public class XPathMatcher
    extends ArrayList<IXPathNodeMatcher>

XPath matcher is used to match if a DOM Node match a XPath expression. It is initialized with an XPath expression :

- static expression like //element, //element/@attr, //element/text()
- expression with wildcard like //element[@id='$0']

See Also:
  Serialized Form

### Field Summary

### Fields inherited from class java.util.AbstractList

`modCount`

### Constructor Summary

Constructors
`XPathMatcher​(String xpathExpression)` Constructor of XPath Matcher with a XPath expression.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected XPathElementMatcher` `createAnyElementMatcher()` Create XPath any element matcher.
`protected XPathAttributeMatcher` `createAttributeMatcher​(XPathElementMatcher elementmatcher, String attrName, String attrValue)` Create the XPath attribute matcher.
`int` `getNbWildCard()` Returns the number of wilcard used in the XPath expression and -1 if there is no wildcard.
`IXPathNodeMatcher.MatcherType` `getNodeSelectorType()` Returns the type (element, attribute, text) of the node to select.
`List<String>` `getWildcardValues​(Node selectedNode)` Returns list of wildcard values of the given DOM Node.
`boolean` `match​(Node node)` Returns true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise.
`boolean` `match​(Node node, Collection<String> wildcardValues)` Returns true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise.

### Methods inherited from class java.util.ArrayList

`add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize`

### Methods inherited from class java.util.AbstractCollection

`containsAll, toString`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.Collection

`parallelStream, stream, toArray`

### Methods inherited from interface java.util.List

`containsAll`

### Constructor Detail

#### XPathMatcher

    public XPathMatcher​(String xpathExpression)

Constructor of XPath Matcher with a XPath expression.

Parameters:
  `xpathExpression` -

### Method Detail

#### match

    public boolean match​(Node node)

Returns true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise.

Parameters:
  `node` - the DOM Node to match.
Returns:
  true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise.

#### match

    public boolean match​(Node node,
                         Collection<String> wildcardValues)

Returns true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise. This method use wilcard values if XPath expression contains wildcard (like [@id='$0'].

Parameters:
  `node` - the DOM Node to match.
  `wildcardValues` - the list of wildcard values and null otherwise.
Returns:

#### getWildcardValues

    public List<String> getWildcardValues​(Node selectedNode)

Returns list of wildcard values of the given DOM Node.

Parameters:
  `selectedNode` -
Returns:

#### getNbWildCard

    public int getNbWildCard()

Returns the number of wilcard used in the XPath expression and -1 if there is no wildcard.

Returns:

#### createAnyElementMatcher

    protected XPathElementMatcher createAnyElementMatcher()

Create XPath any element matcher.

Returns:
  the XPath any element matcher.

#### createAttributeMatcher

    protected XPathAttributeMatcher createAttributeMatcher​(XPathElementMatcher elementmatcher,
                                                           String attrName,
                                                           String attrValue)

Create the XPath attribute matcher.

Parameters:
  `elementmatcher` - the parent element matcher.
  `attrName` - the attribute name to match.
  `attrValue` - the attribute value to match.
Returns:
  the XPath attribute matcher.

#### getNodeSelectorType

    public IXPathNodeMatcher.MatcherType getNodeSelectorType()

Returns the type (element, attribute, text) of the node to select.

Returns:
  the type (element, attribute, text) of the node to select.o