2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.xpath.api;
10 import com.google.common.annotations.Beta;
11 import javax.xml.xpath.XPathExpressionException;
12 import org.opendaylight.yangtools.concepts.Immutable;
13 import org.opendaylight.yangtools.yang.common.QName;
16 * An XPath expression.
18 * @author Robert Varga
21 public interface YangXPathExpression extends Immutable {
23 * Return the root {@link YangExpr}.
25 * @return Root expression.
27 YangExpr getRootExpr();
30 * Return the {@link YangXPathMathMode} used in this expression. All {@link YangNumberExpr} objects used by this
31 * expression are expected to be handled by this mode's {@link YangXPathMathSupport}.
33 * @return YangXPathMathMode
35 YangXPathMathMode getMathMode();
38 * Attempt to interpret a {@link YangLiteralExpr} referenced by this expression as a {@link QName}. This method
39 * is required to perform late value binding of the expression when the literal needs to be interpreted as
40 * a reference to an {@code identity}.
43 * The syntax of expr is required to conform to
44 * <a href="https://www.w3.org/TR/REC-xml-names/#NT-QName">XML QName format</a>, as further restricted by
45 * <a href="https://tools.ietf.org/html/rfc7950#section-9.10.3">YANG {@code identityref} Lexical Representation</a>.
48 * Unfortunately we do not know when a literal will need to be interpreted in this way, as that can only be known
51 * @param expr Literal to be reinterpreted
52 * @return YangQNameExpr result of interpretation
53 * @throws XPathExpressionException when the literal cannot be interpreted as a QName
55 YangQNameExpr interpretAsQName(YangLiteralExpr expr) throws XPathExpressionException;
57 // FIXME: this really should be YangInstanceIdentifier without AugmentationIdentifier. Implementations are
58 // strongly encouraged to validate it as such.
59 YangLocationPath interpretAsInstanceIdentifier(YangLiteralExpr expr) throws XPathExpressionException;