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