2 * Copyright (c) 2015 Cisco Systems, Inc. and others. 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.common;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
15 * Constant definitions present in RFC documents related to the YANG language.
18 public final class YangConstants {
20 * YANG File Extension, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.1">RFC6020</a>.
22 public static final String RFC6020_YANG_FILE_EXTENSION = ".yang";
25 * YANG Media Type, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.1">RFC6020</a>.
27 public static final String RFC6020_YANG_MAC_FILE_TYPE = "TEXT";
31 * YANG Media Type, as defined in h<a href="https://tools.ietf.org/html/rfc6020#section-14.1">RFC6020</a>.
33 public static final String RFC6020_YANG_MEDIA_TYPE = "application/yang";
36 * YANG namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in String format.
38 public static final String RFC6020_YANG_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:1";
41 * YANG namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in URI format.
43 public static final XMLNamespace RFC6020_YANG_NAMESPACE = XMLNamespace.of(RFC6020_YANG_NAMESPACE_STRING).intern();
46 * Base QNameModule for all YANG statements.
48 public static final QNameModule RFC6020_YANG_MODULE = QNameModule.create(RFC6020_YANG_NAMESPACE).intern();
51 * YIN File Extension, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.2">RFC6020</a>.
53 public static final String RFC6020_YIN_FILE_EXTENSION = ".yin";
56 * YANG Media Type, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.1">RFC6020</a>.
58 public static final String RFC6020_MAC_FILE_TYPE = "TEXT";
61 * YANG Media Type, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.2">RFC6020</a>.
63 public static final String RFC6020_YIN_MEDIA_TYPE = "application/yin+xml";
66 * YIN namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in String format.
68 public static final String RFC6020_YIN_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:yin:1";
71 * YIN namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in URI format.
73 public static final XMLNamespace RFC6020_YIN_NAMESPACE = XMLNamespace.of(RFC6020_YIN_NAMESPACE_STRING).intern();
76 * Base QNameModule for all YIN statements.
78 public static final QNameModule RFC6020_YIN_MODULE = QNameModule.create(RFC6020_YIN_NAMESPACE).intern();
81 * YANG Library NETCONF Capability, as defined in https://tools.ietf.org/html/rfc7950#section-16.
83 public static final URI RFC7950_YANG_LIBRARY_CAPABILITY =
84 URI.create("urn:ietf:params:netconf:capability:yang-library:1.0");
87 * Prefix for YANG-specific XPath functions.
89 public static final String YANG_XPATH_FUNCTIONS_PREFIX = "yang";
92 * NETCONF protocol elements' namespace, as defined in
93 * <a href="https://datatracker.ietf.org/doc/html/rfc4741#section-3.1">RFC4741 section 3.1</a>, in String format.
95 public static final String NETCONF_NAMESPACE_STRING = "urn:ietf:params:xml:ns:netconf:base:1.0";
98 * NETCONF protocol elements' namespace, as defined in
99 * <a href="https://datatracker.ietf.org/doc/html/rfc4741#section-3.1">RFC4741 section 3.1</a>, in String format.
101 public static final XMLNamespace NETCONF_NAMESPACE = XMLNamespace.of(NETCONF_NAMESPACE_STRING).intern();
104 * NETCONF namespace bound to YANG through
105 * <a href="https://datatracker.ietf.org/doc/html/rfc6241#section-10.3">ietf-netconf@2011-06-01.yang</a>.
107 public static final QNameModule RFC6241_YANG_MODULE =
108 QNameModule.create(NETCONF_NAMESPACE, Revision.of("2011-06-01")).intern();
111 * {@code bad-attribute}, value is the name of the attribute.
113 public static final QName BAD_ATTRIBUTE_QNAME = QName.create(RFC6241_YANG_MODULE, "bad-attribute").intern();
115 * {@code bad-element}, value is the name of the element.
117 public static final QName BAD_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "bad-element").intern();
119 * {@code bad-namespace}, value is the name of the namespace.
121 public static final QName BAD_NAMESPACE_QNAME = QName.create(RFC6241_YANG_MODULE, "bad-namespace").intern();
123 * {@code session-id}, value the session identifier, as modeled in {@code SessionIdOrZero}.
125 public static final QName SESSION_ID_QNAME = QName.create(RFC6241_YANG_MODULE, "session-id").intern();
126 @Deprecated(since = "RFC6241")
127 public static final QName ERR_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "err-element").intern();
128 @Deprecated(since = "RFC6241")
129 public static final QName NOOP_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "noop-element").intern();
130 @Deprecated(since = "RFC6241")
131 public static final QName OK_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "ok-element").intern();
133 * {@code missing-choice} as defined in
134 * <a href="https://datatracker.ietf.org/doc/html/rfc6020#section-13.7">RFC6020, section 13.7</a>.
136 public static final QName MISSING_CHOICE_QNAME = QName.create(RFC6020_YANG_MODULE, "missing-choice").intern();
138 * {@code non-unique} as defined in
139 * <a href="https://datatracker.ietf.org/doc/html/rfc6020#section-13.1">RFC6020, section 13.1</a>.
141 public static final QName NON_UNIQUE_QNAME = QName.create(RFC6020_YANG_MODULE, "non-unique").intern();
143 // Dummy template UnqualifiedQName. These are never leaked, but are used for efficient instantiation via
144 // UnqualifiedQName#bindTo()
145 private static final Unqualified DUMMY_OPERATION_INPUT = UnresolvedQName.unqualified("input");
146 private static final Unqualified DUMMY_OPERATION_OUTPUT = UnresolvedQName.unqualified("output");
148 private YangConstants() {
153 * Create a {@link QName} representing the 'input' statement of an operation (RPC or action) within specified
154 * {@link QNameModule}.
156 * @param module Desired module
157 * @return A QName representing action or RPC input.
158 * @throws NullPointerException if {@code module} is null
160 public static QName operationInputQName(final QNameModule module) {
161 return DUMMY_OPERATION_INPUT.bindTo(module);
165 * Create a {@link QName} representing the 'output' statement of an operation (RPC or action) within specified
166 * {@link QNameModule}.
168 * @param module Desired module
169 * @return A QName representing action or RPC output.
170 * @throws NullPointerException if {@code module} is null
172 public static QName operationOutputQName(final QNameModule module) {
173 return DUMMY_OPERATION_OUTPUT.bindTo(module);