Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.yangutils.datamodel; |
| 17 | |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 18 | import java.util.LinkedList; |
| 19 | import java.util.List; |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 20 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 21 | import org.onosproject.yangutils.parser.Parsable; |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.utils.YangConstructType; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 23 | |
| 24 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 25 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 26 | |
| 27 | /*- |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 28 | * Reference:RFC 6020. |
| 29 | * The "module" statement defines the module's name, |
| 30 | * and groups all statements that belong to the module together. The "module" |
| 31 | * statement's argument is the name of the module, followed by a block of |
| 32 | * sub statements that hold detailed module information. |
| 33 | * The module's sub statements |
| 34 | * |
| 35 | * +--------------+---------+-------------+-----------------------+ |
| 36 | * |sub statement | section | cardinality | data model mapping | |
| 37 | * +--------------+---------+-------------+-----------------------+ |
| 38 | * | anyxml | 7.10 | 0..n | not supported | |
| 39 | * | augment | 7.15 | 0..n | child nodes | |
| 40 | * | choice | 7.9 | 0..n | child nodes | |
| 41 | * | contact | 7.1.8 | 0..1 | string | |
| 42 | * | container | 7.5 | 0..n | child nodes | |
| 43 | * | description | 7.19.3 | 0..1 | string | |
| 44 | * | deviation | 7.18.3 | 0..n | TODO | |
| 45 | * | extension | 7.17 | 0..n | TODO | |
| 46 | * | feature | 7.18.1 | 0..n | TODO | |
| 47 | * | grouping | 7.11 | 0..n | child nodes | |
| 48 | * | identity | 7.16 | 0..n | TODO | |
| 49 | * | import | 7.1.5 | 0..n | list of import info | |
| 50 | * | include | 7.1.6 | 0..n | list of include info | |
| 51 | * | leaf | 7.6 | 0..n | list of leaf info | |
| 52 | * | leaf-list | 7.7 | 0..n | list of leaf-list info| |
| 53 | * | list | 7.8 | 0..n | child nodes | |
| 54 | * | namespace | 7.1.3 | 1 | string/uri | |
| 55 | * | notification | 7.14 | 0..n | TODO | |
| 56 | * | organization | 7.1.7 | 0..1 | string | |
| 57 | * | prefix | 7.1.4 | 1 | string | |
| 58 | * | reference | 7.19.4 | 0..1 | string | |
| 59 | * | revision | 7.1.9 | 0..n | revision | |
| 60 | * | rpc | 7.13 | 0..n | TODO | |
| 61 | * | typedef | 7.3 | 0..n | child nodes | |
| 62 | * | uses | 7.12 | 0..n | child nodes | |
| 63 | * | YANG-version | 7.1.2 | 0..1 | int | |
| 64 | * +--------------+---------+-------------+-----------------------+ |
| 65 | */ |
| 66 | |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 67 | /** |
| 68 | * Data model node to maintain information defined in YANG module. |
| 69 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 70 | public class YangModule extends YangNode |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 71 | implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo { |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * Name of the module. |
| 75 | */ |
| 76 | private String name; |
| 77 | |
| 78 | /** |
| 79 | * Reference:RFC 6020. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 80 | * |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 81 | * The "contact" statement provides contact information for the module. The |
| 82 | * argument is a string that is used to specify contact information for the |
| 83 | * person or persons to whom technical queries concerning this module should |
| 84 | * be sent, such as their name, postal address, telephone number, and |
| 85 | * electronic mail address. |
| 86 | */ |
| 87 | private String contact; |
| 88 | |
| 89 | /** |
| 90 | * Reference:RFC 6020. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 91 | * |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 92 | * The "description" statement takes as an argument a string that contains a |
| 93 | * human-readable textual description of this definition. The text is |
| 94 | * provided in a language (or languages) chosen by the module developer; for |
| 95 | * the sake of interoperability. |
| 96 | */ |
| 97 | private String description; |
| 98 | |
| 99 | /** |
| 100 | * List of YANG modules imported. |
| 101 | */ |
| 102 | private List<YangImport> importList; |
| 103 | |
| 104 | /** |
| 105 | * List of YANG sub-modules included. |
| 106 | */ |
| 107 | private List<YangInclude> includeList; |
| 108 | |
| 109 | /** |
| 110 | * List of leaves at root level in the module. |
| 111 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 112 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * List of leaf-lists at root level in the module. |
| 116 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 117 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * Name space of the module. |
| 121 | */ |
| 122 | private YangNameSpace nameSpace; |
| 123 | |
| 124 | /** |
| 125 | * Reference:RFC 6020. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 126 | * |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 127 | * The "organization" statement defines the party responsible for this |
| 128 | * module. The argument is a string that is used to specify a textual |
| 129 | * description of the organization(s) under whose auspices this module was |
| 130 | * developed. |
| 131 | */ |
| 132 | private String organization; |
| 133 | |
| 134 | /** |
| 135 | * Prefix to refer to the objects in module. |
| 136 | */ |
| 137 | private String prefix; |
| 138 | |
| 139 | /** |
| 140 | * Reference of the module. |
| 141 | */ |
| 142 | private String reference; |
| 143 | |
| 144 | /** |
| 145 | * Revision info of the module. |
| 146 | */ |
| 147 | private YangRevision revision; |
| 148 | |
| 149 | /** |
| 150 | * YANG version. |
| 151 | */ |
| 152 | private byte version; |
| 153 | |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 154 | /*- |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 155 | * Reference RFC 6020. |
| 156 | * |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 157 | * Nested typedefs and groupings. |
| 158 | * Typedefs and groupings may appear nested under many YANG statements, |
| 159 | * allowing these to be lexically scoped by the hierarchy under which |
| 160 | * they appear. This allows types and groupings to be defined near |
| 161 | * where they are used, rather than placing them at the top level of the |
| 162 | * hierarchy. The close proximity increases readability. |
| 163 | * |
| 164 | * Scoping also allows types to be defined without concern for naming |
| 165 | * conflicts between types in different submodules. Type names can be |
| 166 | * specified without adding leading strings designed to prevent name |
| 167 | * collisions within large modules. |
| 168 | * |
| 169 | * Finally, scoping allows the module author to keep types and groupings |
| 170 | * private to their module or submodule, preventing their reuse. Since |
| 171 | * only top-level types and groupings (i.e., those appearing as |
| 172 | * sub-statements to a module or submodule statement) can be used outside |
| 173 | * the module or submodule, the developer has more control over what |
| 174 | * pieces of their module are presented to the outside world, supporting |
| 175 | * the need to hide internal information and maintaining a boundary |
| 176 | * between what is shared with the outside world and what is kept |
| 177 | * private. |
| 178 | * |
| 179 | * Scoped definitions MUST NOT shadow definitions at a higher scope. A |
| 180 | * type or grouping cannot be defined if a higher level in the schema |
| 181 | * hierarchy has a definition with a matching identifier. |
| 182 | * |
| 183 | * A reference to an unprefixed type or grouping, or one which uses the |
| 184 | * prefix of the current module, is resolved by locating the closest |
| 185 | * matching "typedef" or "grouping" statement among the immediate |
| 186 | * sub-statements of each ancestor statement. |
| 187 | */ |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 188 | private List<YangResolutionInfo> unresolvedResolutionList; |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 189 | |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 190 | /** |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 191 | * Create a YANG node of module type. |
| 192 | */ |
| 193 | public YangModule() { |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 194 | |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 195 | super(YangNodeType.MODULE_NODE); |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 196 | unresolvedResolutionList = new LinkedList<YangResolutionInfo>(); |
| 197 | importList = new LinkedList<YangImport>(); |
| 198 | includeList = new LinkedList<YangInclude>(); |
| 199 | listOfLeaf = new LinkedList<YangLeaf>(); |
| 200 | listOfLeafList = new LinkedList<YangLeafList>(); |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 201 | } |
| 202 | |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 203 | /** |
| 204 | * Get name of the module. |
| 205 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 206 | * @return module name |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 207 | */ |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 208 | @Override |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 209 | public String getName() { |
| 210 | return name; |
| 211 | } |
| 212 | |
Vinod Kumar S | 48848f7 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 213 | /** |
| 214 | * Set module name. |
| 215 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 216 | * @param moduleName module name |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 217 | */ |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 218 | @Override |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 219 | public void setName(String moduleName) { |
| 220 | name = moduleName; |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Get the contact details of the module owner. |
| 225 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 226 | * @return the contact details of YANG owner |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 227 | */ |
| 228 | public String getContact() { |
| 229 | return contact; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Set the contact details of the module owner. |
| 234 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 235 | * @param contact the contact details of YANG owner |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 236 | */ |
| 237 | public void setContact(String contact) { |
| 238 | this.contact = contact; |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * Get the description of module. |
| 243 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 244 | * @return the description of YANG module |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 245 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 246 | @Override |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 247 | public String getDescription() { |
| 248 | return description; |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * Set the description of module. |
| 253 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 254 | * @param description set the description of YANG module |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 255 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 256 | @Override |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 257 | public void setDescription(String description) { |
| 258 | this.description = description; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Get the list of imported modules. |
| 263 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 264 | * @return the list of imported modules |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 265 | */ |
| 266 | public List<YangImport> getImportList() { |
| 267 | return importList; |
| 268 | } |
| 269 | |
| 270 | /** |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 271 | * Add the imported module information to the import list. |
| 272 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 273 | * @param importedModule module being imported |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 274 | */ |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 275 | public void addToImportList(YangImport importedModule) { |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 276 | getImportList().add(importedModule); |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 277 | } |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 278 | |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 279 | @Override |
| 280 | public void setImportList(List<YangImport> importList) { |
| 281 | this.importList = importList; |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | /** |
| 285 | * Get the list of included sub modules. |
| 286 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 287 | * @return the included list of sub modules |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 288 | */ |
| 289 | public List<YangInclude> getIncludeList() { |
| 290 | return includeList; |
| 291 | } |
| 292 | |
| 293 | /** |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 294 | * Add the included sub module information to the include list. |
| 295 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 296 | * @param includeModule submodule being included |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 297 | */ |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 298 | public void addToIncludeList(YangInclude includeModule) { |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 299 | getIncludeList().add(includeModule); |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | @Override |
| 303 | public void setIncludeList(List<YangInclude> includeList) { |
| 304 | this.includeList = includeList; |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Get the list of leaves in module. |
| 309 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 310 | * @return the list of leaves |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 311 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 312 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 313 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 314 | return listOfLeaf; |
| 315 | } |
| 316 | |
| 317 | /** |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 318 | * Add a leaf in module. |
| 319 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 320 | * @param leaf the leaf to be added |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 321 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 322 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 323 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 324 | getListOfLeaf().add(leaf); |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Get the list of leaf-list from module. |
| 329 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 330 | * @return the list of leaf-list |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 331 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 332 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 333 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 334 | return listOfLeafList; |
| 335 | } |
| 336 | |
| 337 | /** |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 338 | * Add a leaf-list in module. |
| 339 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 340 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 341 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 342 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 343 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 344 | getListOfLeafList().add(leafList); |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * Get the name space of module elements. |
| 349 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 350 | * @return the nameSpace |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 351 | */ |
| 352 | public YangNameSpace getNameSpace() { |
| 353 | return nameSpace; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Set the name space of module elements. |
| 358 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 359 | * @param nameSpace the nameSpace to set |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 360 | */ |
| 361 | public void setNameSpace(YangNameSpace nameSpace) { |
| 362 | this.nameSpace = nameSpace; |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * Get the modules organization. |
| 367 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 368 | * @return the organization |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 369 | */ |
| 370 | public String getOrganization() { |
| 371 | return organization; |
| 372 | } |
| 373 | |
| 374 | /** |
| 375 | * Set the modules organization. |
| 376 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 377 | * @param org the organization to set |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 378 | */ |
| 379 | public void setOrganization(String org) { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 380 | organization = org; |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | /** |
| 384 | * Get the prefix. |
| 385 | * |
| 386 | * @return the prefix |
| 387 | */ |
| 388 | public String getPrefix() { |
| 389 | return prefix; |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * Set the prefix. |
| 394 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 395 | * @param prefix the prefix to set |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 396 | */ |
| 397 | public void setPrefix(String prefix) { |
| 398 | this.prefix = prefix; |
| 399 | } |
| 400 | |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 401 | @Override |
| 402 | public void resolveSelfFileLinking() throws DataModelException { |
| 403 | // Get the list to be resolved. |
| 404 | List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(); |
| 405 | // Resolve linking for a resolution list. |
| 406 | resolveLinkingForResolutionList(resolutionList, this); |
| 407 | } |
| 408 | |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 409 | /** |
| 410 | * Get the textual reference. |
| 411 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 412 | * @return the reference |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 413 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 414 | @Override |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 415 | public String getReference() { |
| 416 | return reference; |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * Set the textual reference. |
| 421 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 422 | * @param reference the reference to set |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 423 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 424 | @Override |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 425 | public void setReference(String reference) { |
| 426 | this.reference = reference; |
| 427 | } |
| 428 | |
| 429 | /** |
| 430 | * Get the revision. |
| 431 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 432 | * @return the revision |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 433 | */ |
| 434 | public YangRevision getRevision() { |
| 435 | return revision; |
| 436 | } |
| 437 | |
| 438 | /** |
| 439 | * Set the revision. |
| 440 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 441 | * @param revision the revision to set |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 442 | */ |
| 443 | public void setRevision(YangRevision revision) { |
| 444 | this.revision = revision; |
| 445 | } |
| 446 | |
| 447 | /** |
| 448 | * Get the version. |
| 449 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 450 | * @return the version |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 451 | */ |
| 452 | public byte getVersion() { |
| 453 | return version; |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * Set the version. |
| 458 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 459 | * @param version the version to set |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 460 | */ |
| 461 | public void setVersion(byte version) { |
| 462 | this.version = version; |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * Returns the type of the parsed data. |
| 467 | * |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 468 | * @return returns MODULE_DATA |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 469 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 470 | @Override |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 471 | public YangConstructType getYangConstructType() { |
| 472 | return YangConstructType.MODULE_DATA; |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | /** |
| 476 | * Validate the data on entering the corresponding parse tree node. |
| 477 | * |
| 478 | * @throws DataModelException a violation of data model rules |
| 479 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 480 | @Override |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 481 | public void validateDataOnEntry() throws DataModelException { |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 482 | /* |
| 483 | * Module is root in the data model tree, hence there is no entry |
| 484 | * validation |
| 485 | */ |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | /** |
| 489 | * Validate the data on exiting the corresponding parse tree node. |
| 490 | * |
| 491 | * @throws DataModelException a violation of data model rules |
| 492 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 493 | @Override |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 494 | public void validateDataOnExit() throws DataModelException { |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 495 | /* |
| 496 | * TODO: perform symbol linking for the imported or included YANG info. |
| 497 | * TODO: perform symbol resolution for referred YANG entities. |
| 498 | */ |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 499 | } |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 500 | |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 501 | @Override |
| 502 | public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { |
| 503 | // Asks helper to detect colliding child. |
| 504 | detectCollidingChildUtil(identifierName, dataType, this); |
| 505 | } |
| 506 | |
| 507 | @Override |
| 508 | public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { |
| 509 | // Not required as module doesn't have any parent. |
| 510 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 511 | |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 512 | @Override |
| 513 | public List<YangResolutionInfo> getUnresolvedResolutionList() { |
| 514 | return unresolvedResolutionList; |
| 515 | } |
| 516 | |
| 517 | @Override |
| 518 | public void addToResolutionList(YangResolutionInfo resolutionInfo) { |
| 519 | unresolvedResolutionList.add(resolutionInfo); |
| 520 | } |
| 521 | |
| 522 | @Override |
| 523 | public void setResolutionList(List<YangResolutionInfo> resolutionList) { |
| 524 | unresolvedResolutionList = resolutionList; |
| 525 | } |
Vinod Kumar S | 0e12297 | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 526 | } |