/*
 * @author Ranides Atterwim {@literal <ranides@gmail.com>}
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.xml;

/**
 * XMLContext is used by {@link XMLSelector} predicate.
 * Every node passed to selector is wrapped by this class, because we want to know both node and its position.
 * Selectors can use "index" for example to filter even/odd elements.
 *
 * @author Ranides Atterwim {@literal <ranides@gmail.com>}
 */
public interface XMLContext {

    /**
     * Returns current node passed to {@link XMLSelector} for test/evaluation.
     *
     * @return XMLElement
     */
    XMLElement node();

    /**
     * Returns current node passed to {@link XMLSelector} for test/evaluation.
     * More precisely: it returns collection with one node.
     *
     * @return XMLElements
     */
    default XMLElements nodes() {
        return XMLElements.of(node());
    }

    /**
     * Returns index of current node.
     * Index is the position of this node inside "children" list used by its parent.
     *
     * @return int
     */
    int index();
    
}
