eefd658750a134d094d07054357c56fa42c17da3
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / YangConstants.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  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.common;
9
10 import java.net.URI;
11
12 /**
13  * Constant definitions present in RFC documents related to the YANG language.
14  */
15 public final class YangConstants {
16     /**
17      * YANG File Extension, as defined in https://tools.ietf.org/html/rfc6020#section-14.1.
18      */
19     public static final String RFC6020_YANG_FILE_EXTENSION = ".yang";
20
21     /**
22      * YANG Media Type, as defined in https://tools.ietf.org/html/rfc6020#section-14.1.
23      */
24     public static final String RFC6020_YANG_MAC_FILE_TYPE = "TEXT";
25
26
27     /**
28      * YANG Media Type, as defined in https://tools.ietf.org/html/rfc6020#section-14.1.
29      */
30     public static final String RFC6020_YANG_MEDIA_TYPE = "application/yang";
31
32     /**
33      * YANG namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in String format.
34      */
35     public static final String RFC6020_YANG_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:1";
36
37     /**
38      * YANG namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in URI format.
39      */
40     public static final URI RFC6020_YANG_NAMESPACE = URI.create(RFC6020_YANG_NAMESPACE_STRING);
41
42     /**
43      * Base QNameModule for all YANG statements.
44      */
45     public static final QNameModule RFC6020_YANG_MODULE = QNameModule.create(RFC6020_YANG_NAMESPACE).intern();
46
47     /**
48      * YIN File Extension, as defined in https://tools.ietf.org/html/rfc6020#section-14.2.
49      */
50     public static final String RFC6020_YIN_FILE_EXTENSION = ".yin";
51
52     /**
53      * YANG Media Type, as defined in https://tools.ietf.org/html/rfc6020#section-14.1.
54      */
55     public static final String RFC6020_MAC_FILE_TYPE = "TEXT";
56
57     /**
58      * YANG Media Type, as defined in https://tools.ietf.org/html/rfc6020#section-14.1.
59      */
60     public static final String RFC6020_YIN_MEDIA_TYPE = "application/xml+yin";
61
62     /**
63      * YIN namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in String format.
64      */
65     public static final String RFC6020_YIN_NAMESPACE_STRING = "urn:ietf:params:xml:ns:yang:yin:1";
66
67     /**
68      * YIN namespace, as defined in https://tools.ietf.org/html/rfc6020#section-14, in URI format.
69      */
70     public static final URI RFC6020_YIN_NAMESPACE = URI.create(RFC6020_YIN_NAMESPACE_STRING);
71
72     /**
73      * Base QNameModule for all YIN statements.
74      */
75     public static final QNameModule RFC6020_YIN_MODULE = QNameModule.create(RFC6020_YIN_NAMESPACE).intern();
76
77     /**
78      * YANG Library NETCONF Capability, as defined in https://tools.ietf.org/html/rfc7950#section-16.
79      */
80     public static final URI RFC7950_YANG_LIBRARY_CAPABILITY =
81         URI.create("urn:ietf:params:netconf:capability:yang-library:1.0");
82
83     /**
84      * Prefix for YANG-specific XPath functions.
85      */
86     public static final String YANG_XPATH_FUNCTIONS_PREFIX = "yang";
87
88     // Dummy template QNames. These are never leaked, but are used for efficient instantiation via QName#withModule()
89     private static final QName DUMMY_OPERATION_INPUT = QName.create("DUMMY", "input");
90     private static final QName DUMMY_OPERATION_OUTPUT = QName.create("DUMMY", "output");
91
92     private YangConstants() {
93         throw new UnsupportedOperationException("Utility class");
94     }
95
96     /**
97      * Create a {@link QName} representing the 'input' statement of an operation (RPC or action) within specified
98      * {@link QNameModule}.
99      *
100      * @param module Desired module
101      * @return A QName representing action or RPC input.
102      */
103     public static QName operationInputQName(final QNameModule module) {
104         return DUMMY_OPERATION_INPUT.withModule(module);
105     }
106
107     /**
108      * Create a {@link QName} representing the 'output' statement of an operation (RPC or action) within specified
109      * {@link QNameModule}.
110      *
111      * @param module Desired module
112      * @return A QName representing action or RPC output.
113      */
114     public static QName operationOutputQName(final QNameModule module) {
115         return DUMMY_OPERATION_OUTPUT.withModule(module);
116     }
117 }