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;
10 import org.eclipse.jdt.annotation.NonNullByDefault;
11 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
14 * Constant definitions present in RFC documents related to the YANG language.
17 public final class YangConstants {
19 * YANG File Extension, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.1">RFC6020</a>.
21 public static final String RFC6020_YANG_FILE_EXTENSION = ".yang";
23 * YANG Media Type, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.1">RFC6020</a>.
25 public static final String RFC6020_YANG_MAC_FILE_TYPE = "TEXT";
27 * YANG Media Type, as defined in h<a href="https://tools.ietf.org/html/rfc6020#section-14.1">RFC6020</a>.
29 public static final String RFC6020_YANG_MEDIA_TYPE = "application/yang";
31 * YANG namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in String format.
33 public static final String RFC6020_YANG_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:1";
35 * YANG namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in URI format.
37 public static final XMLNamespace RFC6020_YANG_NAMESPACE = XMLNamespace.of(RFC6020_YANG_NAMESPACE_STRING).intern();
39 * Base QNameModule for all YANG statements.
41 public static final QNameModule RFC6020_YANG_MODULE = QNameModule.create(RFC6020_YANG_NAMESPACE).intern();
43 * YIN File Extension, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.2">RFC6020</a>.
45 public static final String RFC6020_YIN_FILE_EXTENSION = ".yin";
47 * YANG Media Type, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.1">RFC6020</a>.
49 public static final String RFC6020_MAC_FILE_TYPE = "TEXT";
51 * YANG Media Type, as defined in <a href="https://tools.ietf.org/html/rfc6020#section-14.2">RFC6020</a>.
53 public static final String RFC6020_YIN_MEDIA_TYPE = "application/yin+xml";
55 * YIN namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in String format.
57 public static final String RFC6020_YIN_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:yin:1";
59 * YIN namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in URI format.
61 public static final XMLNamespace RFC6020_YIN_NAMESPACE = XMLNamespace.of(RFC6020_YIN_NAMESPACE_STRING).intern();
63 * Base QNameModule for all YIN statements.
65 public static final QNameModule RFC6020_YIN_MODULE = QNameModule.create(RFC6020_YIN_NAMESPACE).intern();
67 * Prefix for YANG-specific XPath functions.
69 public static final String YANG_XPATH_FUNCTIONS_PREFIX = "yang";
71 * NETCONF protocol elements' namespace, as defined in
72 * <a href="https://datatracker.ietf.org/doc/html/rfc4741#section-3.1">RFC4741 section 3.1</a>, in String format.
74 public static final String NETCONF_NAMESPACE_STRING = "urn:ietf:params:xml:ns:netconf:base:1.0";
76 * NETCONF protocol elements' namespace, as defined in
77 * <a href="https://datatracker.ietf.org/doc/html/rfc4741#section-3.1">RFC4741 section 3.1</a>, in String format.
79 public static final XMLNamespace NETCONF_NAMESPACE = XMLNamespace.of(NETCONF_NAMESPACE_STRING).intern();
81 * NETCONF namespace bound to YANG through
82 * <a href="https://datatracker.ietf.org/doc/html/rfc6241#section-10.3">ietf-netconf@2011-06-01.yang</a>.
84 public static final QNameModule RFC6241_YANG_MODULE =
85 QNameModule.create(NETCONF_NAMESPACE, Revision.of("2011-06-01")).intern();
87 * {@code bad-attribute}, value is the name of the attribute.
89 public static final QName BAD_ATTRIBUTE_QNAME = QName.create(RFC6241_YANG_MODULE, "bad-attribute").intern();
91 * {@code bad-element}, value is the name of the element.
93 public static final QName BAD_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "bad-element").intern();
95 * {@code bad-namespace}, value is the name of the namespace.
97 public static final QName BAD_NAMESPACE_QNAME = QName.create(RFC6241_YANG_MODULE, "bad-namespace").intern();
99 * {@code session-id}, value the session identifier, as modeled in {@code SessionIdOrZero}.
101 public static final QName SESSION_ID_QNAME = QName.create(RFC6241_YANG_MODULE, "session-id").intern();
102 @Deprecated(since = "RFC6241")
103 public static final QName ERR_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "err-element").intern();
104 @Deprecated(since = "RFC6241")
105 public static final QName NOOP_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "noop-element").intern();
106 @Deprecated(since = "RFC6241")
107 public static final QName OK_ELEMENT_QNAME = QName.create(RFC6241_YANG_MODULE, "ok-element").intern();
109 * {@code missing-choice} as defined in
110 * <a href="https://datatracker.ietf.org/doc/html/rfc6020#section-13.7">RFC6020, section 13.7</a>.
112 public static final QName MISSING_CHOICE_QNAME = QName.create(RFC6020_YANG_MODULE, "missing-choice").intern();
114 * {@code non-unique} as defined in
115 * <a href="https://datatracker.ietf.org/doc/html/rfc6020#section-13.1">RFC6020, section 13.1</a>.
117 public static final QName NON_UNIQUE_QNAME = QName.create(RFC6020_YANG_MODULE, "non-unique").intern();
119 // Dummy template UnqualifiedQName. These are never leaked, but are used for efficient instantiation via
120 // UnqualifiedQName#bindTo()
121 private static final Unqualified DUMMY_OPERATION_INPUT = Unqualified.of("input");
122 private static final Unqualified DUMMY_OPERATION_OUTPUT = Unqualified.of("output");
124 private YangConstants() {
129 * Create a {@link QName} representing the 'input' statement of an operation (RPC or action) within specified
130 * {@link QNameModule}.
132 * @param module Desired module
133 * @return A QName representing action or RPC input.
134 * @throws NullPointerException if {@code module} is null
136 public static QName operationInputQName(final QNameModule module) {
137 return DUMMY_OPERATION_INPUT.bindTo(module);
141 * Create a {@link QName} representing the 'output' statement of an operation (RPC or action) within specified
142 * {@link QNameModule}.
144 * @param module Desired module
145 * @return A QName representing action or RPC output.
146 * @throws NullPointerException if {@code module} is null
148 public static QName operationOutputQName(final QNameModule module) {
149 return DUMMY_OPERATION_OUTPUT.bindTo(module);