Populate model/ hierarchy
[yangtools.git] / yang / yang-xpath-api / src / main / java / org / opendaylight / yangtools / yang / xpath / api / YangXPathParser.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.xpath.api;
9
10 import com.google.common.annotations.Beta;
11 import javax.xml.xpath.XPathExpressionException;
12 import org.opendaylight.yangtools.yang.common.YangNamespaceContext;
13
14 /**
15  * Interface for converting a String into a {@link YangXPathExpression}. Implementations of this interface are expected
16  * to be NOT thread-safe.
17  *
18  * @author Robert Varga
19  */
20 @Beta
21 public interface YangXPathParser {
22     /**
23      * A {@link YangXPathParser} bound to a {@link YangNamespaceContext}, producing Qualified-bound Expressions.
24      */
25     interface QualifiedBound extends YangXPathParser {
26         @Override
27         YangXPathExpression.QualifiedBound parseExpression(String xpath) throws XPathExpressionException;
28     }
29
30     /**
31      * A {@link YangXPathParser} bound to a {@link YangNamespaceContext} and a default namespace, producing
32      * Unqualified-bound Expressions.
33      */
34     interface UnqualifiedBound extends QualifiedBound {
35         @Override
36         YangXPathExpression.UnqualifiedBound parseExpression(String xpath) throws XPathExpressionException;
37     }
38
39     /**
40      * Parse a string containing an XPath expression.
41      *
42      * @param xpath XPath expression string
43      * @return A parsed {@link YangXPathExpression}
44      * @throws NullPointerException if {@code xpath} is null
45      * @throws XPathExpressionException when the expression cannot be parsed
46      */
47     YangXPathExpression parseExpression(String xpath) throws XPathExpressionException;
48 }