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