blob: b079d3fc4348b6306807ee2be9316aac76661222 [file] [log] [blame]
Vinod Kumar S19f39c72016-02-09 20:12:31 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S19f39c72016-02-09 20:12:31 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.yangutils.datamodel;
17
18import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
19import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053020import org.onosproject.yangutils.utils.YangConstructType;
Vinod Kumar S19f39c72016-02-09 20:12:31 +053021
22/*
23 * Reference:RFC 6020.
24 * The "import" statement makes definitions from one module available
25 * inside another module or submodule. The argument is the name of the
26 * module to import, and the statement is followed by a block of
27 * sub statements that holds detailed import information.
28 * When a module is imported, the importing module may:
29 * o use any grouping and typedef defined at the top level in the
30 * imported module or its submodules.
31 *
32 * o use any extension, feature, and identity defined in the imported
33 * module or its submodules.
34 *
35 * o use any node in the imported module's schema tree in "must",
36 * "path", and "when" statements, or as the target node in "augment"
37 * and "deviation" statements.
38 *
39 * The mandatory "prefix" sub statement assigns a prefix for the imported
40 * module that is scoped to the importing module or submodule. Multiple
41 * "import" statements may be specified to import from different
42 * modules.
43 * When the optional "revision-date" sub-statement is present, any
44 * typedef, grouping, extension, feature, and identity referenced by
45 * definitions in the local module are taken from the specified revision
46 * of the imported module. It is an error if the specified revision of
47 * the imported module does not exist. If no "revision-date"
48 * sub-statement is present, it is undefined from which revision of the
49 * module they are taken.
50 *
51 * Multiple revisions of the same module MUST NOT be imported.
52 *
53 * The import's Substatements
54 *
55 * +---------------+---------+-------------+------------------+
56 * | substatement | section | cardinality |data model mapping|
57 * +---------------+---------+-------------+------------------+
58 * | prefix | 7.1.4 | 1 | string |
59 * | revision-date | 7.1.5.1 | 0..1 | string |
60 * +---------------+---------+-------------+------------------+
61 */
62/**
Bharat saraswald9822e92016-04-05 15:13:44 +053063 * Represents the information about the imported modules.
Vinod Kumar S19f39c72016-02-09 20:12:31 +053064 */
65public class YangImport implements Parsable {
66
67 /**
68 * Name of the module that is being imported.
69 */
70 private String name;
71
72 /**
73 * Prefix used to identify the entities from the imported module.
74 */
75 private String prefixId;
76
77 /**
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +053078 * Resolution information root node which is also the data model root node.
79 */
80 private HasResolutionInfo resolutionInfoNode;
81
82 /**
Vinod Kumar S19f39c72016-02-09 20:12:31 +053083 * Reference:RFC 6020.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053084 *
Vinod Kumar S19f39c72016-02-09 20:12:31 +053085 * The import's "revision-date" statement is used to specify the exact
86 * version of the module to import. The "revision-date" statement MUST match
87 * the most recent "revision" statement in the imported module. organization
88 * which defined the YANG module.
89 */
90 private String revision;
91
92 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053093 * Creates a YANG import.
Vinod Kumar S19f39c72016-02-09 20:12:31 +053094 */
95 public YangImport() {
96
97 }
98
99 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530100 * Returns the imported module name.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530101 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530102 * @return the module name
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530103 */
104 public String getModuleName() {
105 return name;
106 }
107
108 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530109 * Sets module name.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530110 *
111 * @param moduleName the module name to set
112 */
113 public void setModuleName(String moduleName) {
114 name = moduleName;
115 }
116
117 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530118 * Returns the prefix used to identify the entities from the imported module.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530119 *
120 * @return the prefix used to identify the entities from the imported
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530121 * module
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530122 */
123 public String getPrefixId() {
124 return prefixId;
125 }
126
127 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530128 * Sets prefix identifier.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530129 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530130 * @param prefixId set the prefix identifier of the imported module
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530131 */
132 public void setPrefixId(String prefixId) {
133 this.prefixId = prefixId;
134 }
135
136 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530137 * Returns the revision of the imported module.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530138 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530139 * @return the revision of the imported module
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530140 */
141 public String getRevision() {
142 return revision;
143 }
144
145 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530146 * Sets the revision of the imported module.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530147 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530148 * @param rev set the revision of the imported module
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530149 */
150 public void setRevision(String rev) {
151 revision = rev;
152 }
153
154 /**
155 * Returns the type of the parsed data.
156 *
157 * @return returns IMPORT_DATA
158 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530159 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530160 public YangConstructType getYangConstructType() {
161 return YangConstructType.IMPORT_DATA;
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530162 }
163
164 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530165 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530166 *
167 * @throws DataModelException a violation of data model rules
168 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530169 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530170 public void validateDataOnEntry() throws DataModelException {
171 // TODO auto-generated method stub, to be implemented by parser
172
173 }
174
175 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530176 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530177 *
178 * @throws DataModelException a violation of data model rules
179 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530180 @Override
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530181 public void validateDataOnExit() throws DataModelException {
182 // TODO auto-generated method stub, to be implemented by parser
183
184 }
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530185
186 /**
187 * Returns the resolution information node.
188 *
189 * @return the resolution information node
190 */
191 public HasResolutionInfo getResolutionInfoNode() {
192 return resolutionInfoNode;
193 }
194
195 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530196 * Sets the dresolution information node.
Gaurav Agrawald9d6cc82016-03-29 02:17:23 +0530197 *
198 * @param resolutionInfoNode the resolution information node
199 */
200 public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) {
201 this.resolutionInfoNode = resolutionInfoNode;
202 }
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530203}