Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +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 | |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 18 | import java.util.Iterator; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 19 | import java.util.LinkedList; |
| 20 | import java.util.List; |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 21 | import java.util.Set; |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 22 | |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 24 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
| 25 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 26 | |
| 27 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 28 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.linkInterFileReferences; |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 29 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList; |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 30 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 31 | /* |
| 32 | * Reference RFC 6020. |
| 33 | * |
| 34 | * While the primary unit in YANG is a module, a YANG module can itself |
| 35 | * be constructed out of several submodules. Submodules allow a module |
| 36 | * designer to split a complex model into several pieces where all the |
| 37 | * submodules contribute to a single namespace, which is defined by the |
| 38 | * module that includes the submodules. |
| 39 | * |
| 40 | * The "submodule" statement defines the submodule's name, and groups |
| 41 | * all statements that belong to the submodule together. The |
| 42 | * "submodule" statement's argument is the name of the submodule, |
| 43 | * followed by a block of sub-statements that hold detailed submodule |
| 44 | * information. |
| 45 | * |
| 46 | * The submodule's sub-statements |
| 47 | * |
| 48 | * +--------------+---------+-------------+------------------+ |
| 49 | * | substatement | section | cardinality |data model mapping| |
| 50 | * +--------------+---------+-------------+------------------+ |
| 51 | * | anyxml | 7.10 | 0..n | - not supported | |
| 52 | * | augment | 7.15 | 0..n | - child nodes | |
| 53 | * | belongs-to | 7.2.2 | 1 | - YangBelongsTo | |
| 54 | * | choice | 7.9 | 0..n | - child nodes | |
| 55 | * | contact | 7.1.8 | 0..1 | - string | |
| 56 | * | container | 7.5 | 0..n | - child nodes | |
| 57 | * | description | 7.19.3 | 0..1 | - string | |
| 58 | * | deviation | 7.18.3 | 0..n | - TODO | |
| 59 | * | extension | 7.17 | 0..n | - TODO | |
| 60 | * | feature | 7.18.1 | 0..n | - TODO | |
| 61 | * | grouping | 7.11 | 0..n | - child nodes | |
| 62 | * | identity | 7.16 | 0..n | - TODO | |
| 63 | * | import | 7.1.5 | 0..n | - YangImport | |
| 64 | * | include | 7.1.6 | 0..n | - YangInclude | |
| 65 | * | leaf | 7.6 | 0..n | - YangLeaf | |
| 66 | * | leaf-list | 7.7 | 0..n | - YangLeafList | |
| 67 | * | list | 7.8 | 0..n | - child nodes | |
| 68 | * | notification | 7.14 | 0..n | - TODO | |
| 69 | * | organization | 7.1.7 | 0..1 | - string | |
| 70 | * | reference | 7.19.4 | 0..1 | - string | |
| 71 | * | revision | 7.1.9 | 0..n | - string | |
| 72 | * | rpc | 7.13 | 0..n | - TODO | |
| 73 | * | typedef | 7.3 | 0..n | - child nodes | |
| 74 | * | uses | 7.12 | 0..n | - child nodes | |
| 75 | * | YANG-version | 7.1.2 | 0..1 | - int | |
| 76 | * +--------------+---------+-------------+------------------+ |
| 77 | */ |
Gaurav Agrawal | 5652766 | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 78 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 79 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 80 | * Represents data model node to maintain information defined in YANG sub-module. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 81 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 82 | public class YangSubModule |
| 83 | extends YangNode |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 84 | implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, |
| 85 | RpcNotificationContainer { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 86 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 87 | private static final long serialVersionUID = 806201614L; |
| 88 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 89 | /** |
| 90 | * Name of sub module. |
| 91 | */ |
| 92 | private String name; |
| 93 | |
| 94 | /** |
| 95 | * Module to which it belongs to. |
| 96 | */ |
| 97 | private YangBelongsTo belongsTo; |
| 98 | |
| 99 | /** |
| 100 | * Reference RFC 6020. |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 101 | * <p> |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 102 | * The "contact" statement provides contact information for the module. The |
| 103 | * argument is a string that is used to specify contact information for the |
| 104 | * person or persons to whom technical queries concerning this module should |
| 105 | * be sent, such as their name, postal address, telephone number, and |
| 106 | * electronic mail address. |
| 107 | */ |
| 108 | private String contact; |
| 109 | |
| 110 | /** |
| 111 | * Description. |
| 112 | */ |
| 113 | private String description; |
| 114 | |
| 115 | /** |
| 116 | * List of YANG modules imported. |
| 117 | */ |
| 118 | private List<YangImport> importList; |
| 119 | |
| 120 | /** |
| 121 | * List of YANG sub-modules included. |
| 122 | */ |
| 123 | private List<YangInclude> includeList; |
| 124 | |
| 125 | /** |
| 126 | * List of leaves at root level in the sub-module. |
| 127 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 128 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * List of leaf-lists at root level in the sub-module. |
| 132 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 133 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 134 | |
| 135 | /** |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 136 | * Organization owner of the sub-module. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 137 | */ |
| 138 | private String organization; |
| 139 | |
| 140 | /** |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 141 | * Reference of the sub-module. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 142 | */ |
| 143 | private String reference; |
| 144 | |
| 145 | /** |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 146 | * Revision info of the sub-module. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 147 | */ |
| 148 | private YangRevision revision; |
| 149 | |
| 150 | /** |
| 151 | * YANG version. |
| 152 | */ |
| 153 | private byte version; |
| 154 | |
| 155 | /** |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 156 | * Prefix of parent module. |
| 157 | */ |
| 158 | private String prefix; |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 159 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 160 | /*- |
| 161 | * Reference RFC 6020. |
| 162 | * |
| 163 | * Nested typedefs and groupings. |
| 164 | * Typedefs and groupings may appear nested under many YANG statements, |
| 165 | * allowing these to be lexically scoped by the hierarchy under which |
| 166 | * they appear. This allows types and groupings to be defined near |
| 167 | * where they are used, rather than placing them at the top level of the |
| 168 | * hierarchy. The close proximity increases readability. |
| 169 | * |
| 170 | * Scoping also allows types to be defined without concern for naming |
| 171 | * conflicts between types in different submodules. Type names can be |
| 172 | * specified without adding leading strings designed to prevent name |
| 173 | * collisions within large modules. |
| 174 | * |
| 175 | * Finally, scoping allows the module author to keep types and groupings |
| 176 | * private to their module or submodule, preventing their reuse. Since |
| 177 | * only top-level types and groupings (i.e., those appearing as |
| 178 | * sub-statements to a module or submodule statement) can be used outside |
| 179 | * the module or submodule, the developer has more control over what |
| 180 | * pieces of their module are presented to the outside world, supporting |
| 181 | * the need to hide internal information and maintaining a boundary |
| 182 | * between what is shared with the outside world and what is kept |
| 183 | * private. |
| 184 | * |
| 185 | * Scoped definitions MUST NOT shadow definitions at a higher scope. A |
| 186 | * type or grouping cannot be defined if a higher level in the schema |
| 187 | * hierarchy has a definition with a matching identifier. |
| 188 | * |
| 189 | * A reference to an unprefixed type or grouping, or one which uses the |
| 190 | * prefix of the current module, is resolved by locating the closest |
| 191 | * matching "typedef" or "grouping" statement among the immediate |
| 192 | * sub-statements of each ancestor statement. |
| 193 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 194 | private List<YangResolutionInfo> derivedTypeResolutionList; |
| 195 | |
| 196 | /** |
| 197 | * uses resolution list. |
| 198 | */ |
| 199 | private List<YangResolutionInfo> usesResolutionList; |
Gaurav Agrawal | 5652766 | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 200 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 201 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 202 | * Creates a sub module node. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 203 | */ |
| 204 | public YangSubModule() { |
| 205 | super(YangNodeType.SUB_MODULE_NODE); |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 206 | derivedTypeResolutionList = new LinkedList<>(); |
| 207 | usesResolutionList = new LinkedList<>(); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 208 | importList = new LinkedList<YangImport>(); |
| 209 | includeList = new LinkedList<YangInclude>(); |
| 210 | listOfLeaf = new LinkedList<YangLeaf>(); |
| 211 | listOfLeafList = new LinkedList<YangLeafList>(); |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 212 | } |
| 213 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 214 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 215 | * Returns the YANG name of the sub module. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 216 | * |
| 217 | * @return YANG name of the sub module |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 218 | */ |
| 219 | @Override |
| 220 | public String getName() { |
| 221 | return name; |
| 222 | } |
| 223 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 224 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 225 | * Sets YANG name of the sub module. |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 226 | * |
| 227 | * @param subModuleName YANG name of the sub module |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 228 | */ |
| 229 | @Override |
| 230 | public void setName(String subModuleName) { |
| 231 | name = subModuleName; |
| 232 | } |
| 233 | |
| 234 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 235 | * Returns the module info. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 236 | * |
| 237 | * @return the belongs to info |
| 238 | */ |
| 239 | public YangBelongsTo getBelongsTo() { |
| 240 | return belongsTo; |
| 241 | } |
| 242 | |
| 243 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 244 | * Sets the module info. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 245 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 246 | * @param belongsTo module info to set |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 247 | */ |
| 248 | public void setBelongsTo(YangBelongsTo belongsTo) { |
| 249 | this.belongsTo = belongsTo; |
| 250 | } |
| 251 | |
| 252 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 253 | * Returns the contact. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 254 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 255 | * @return the contact |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 256 | */ |
| 257 | public String getContact() { |
| 258 | return contact; |
| 259 | } |
| 260 | |
| 261 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 262 | * Sets the contact. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 263 | * |
| 264 | * @param contact the contact to set |
| 265 | */ |
| 266 | public void setContact(String contact) { |
| 267 | this.contact = contact; |
| 268 | } |
| 269 | |
| 270 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 271 | * Returns the description. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 272 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 273 | * @return the description |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 274 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 275 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 276 | public String getDescription() { |
| 277 | return description; |
| 278 | } |
| 279 | |
| 280 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 281 | * Sets the description. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 282 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 283 | * @param description set the description |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 284 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 285 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 286 | public void setDescription(String description) { |
| 287 | this.description = description; |
| 288 | } |
| 289 | |
| 290 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 291 | * Returns the list of imported modules. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 292 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 293 | * @return the list of imported modules |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 294 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 295 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 296 | public List<YangImport> getImportList() { |
| 297 | return importList; |
| 298 | } |
| 299 | |
| 300 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 301 | * Adds the imported module information to the import list. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 302 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 303 | * @param importedModule module being imported |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 304 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 305 | @Override |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 306 | public void addToImportList(YangImport importedModule) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 307 | getImportList().add(importedModule); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 308 | } |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 309 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 310 | @Override |
| 311 | public void setImportList(List<YangImport> importList) { |
| 312 | this.importList = importList; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 316 | * Returns the list of included sub modules. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 317 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 318 | * @return the included list of sub modules |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 319 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 320 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 321 | public List<YangInclude> getIncludeList() { |
| 322 | return includeList; |
| 323 | } |
| 324 | |
| 325 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 326 | * Returns the included sub module information to the include list. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 327 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 328 | * @param includeModule submodule being included |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 329 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 330 | @Override |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 331 | public void addToIncludeList(YangInclude includeModule) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 332 | getIncludeList().add(includeModule); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | @Override |
| 336 | public void setIncludeList(List<YangInclude> includeList) { |
| 337 | this.includeList = includeList; |
| 338 | } |
| 339 | |
| 340 | @Override |
| 341 | public String getPrefix() { |
| 342 | return prefix; |
| 343 | } |
| 344 | |
| 345 | @Override |
| 346 | public void setPrefix(String prefix) { |
| 347 | this.prefix = prefix; |
| 348 | } |
| 349 | |
| 350 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 351 | public void resolveSelfFileLinking(ResolvableType type) |
| 352 | throws DataModelException { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 353 | // Get the list to be resolved. |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 354 | List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 355 | // Resolve linking for a resolution list. |
| 356 | resolveLinkingForResolutionList(resolutionList, this); |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 357 | } |
| 358 | |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 359 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 360 | public void resolveInterFileLinking(ResolvableType type) |
| 361 | throws DataModelException { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 362 | // Get the list to be resolved. |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 363 | List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 364 | // Resolve linking for a resolution list. |
| 365 | linkInterFileReferences(resolutionList, this); |
| 366 | } |
| 367 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 368 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 369 | * Returns the list of leaves. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 370 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 371 | * @return the list of leaves |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 372 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 373 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 374 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 375 | return listOfLeaf; |
| 376 | } |
| 377 | |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 378 | @Override |
| 379 | public void setListOfLeaf(List<YangLeaf> leafsList) { |
| 380 | listOfLeaf = leafsList; |
| 381 | } |
| 382 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 383 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 384 | * Adds a leaf. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 385 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 386 | * @param leaf the leaf to be added |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 387 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 388 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 389 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 390 | getListOfLeaf().add(leaf); |
| 391 | } |
| 392 | |
| 393 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 394 | * Returns the list of leaf-list. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 395 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 396 | * @return the list of leaf-list |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 397 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 398 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 399 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 400 | return listOfLeafList; |
| 401 | } |
| 402 | |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 403 | @Override |
| 404 | public void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
| 405 | this.listOfLeafList = listOfLeafList; |
| 406 | } |
| 407 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 408 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 409 | * Adds a leaf-list. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 410 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 411 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 412 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 413 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 414 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 415 | getListOfLeafList().add(leafList); |
| 416 | } |
| 417 | |
| 418 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 419 | * Returns the sub-modules organization. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 420 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 421 | * @return the organization |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 422 | */ |
| 423 | public String getOrganization() { |
| 424 | return organization; |
| 425 | } |
| 426 | |
| 427 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 428 | * Sets the sub-modules organization. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 429 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 430 | * @param org the organization to set |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 431 | */ |
| 432 | public void setOrganization(String org) { |
| 433 | organization = org; |
| 434 | } |
| 435 | |
| 436 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 437 | * Returns the textual reference. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 438 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 439 | * @return the reference |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 440 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 441 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 442 | public String getReference() { |
| 443 | return reference; |
| 444 | } |
| 445 | |
| 446 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 447 | * Sets the textual reference. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 448 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 449 | * @param reference the reference to set |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 450 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 451 | @Override |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 452 | public void setReference(String reference) { |
| 453 | this.reference = reference; |
| 454 | } |
| 455 | |
| 456 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 457 | * Returns the revision. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 458 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 459 | * @return the revision |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 460 | */ |
| 461 | public YangRevision getRevision() { |
| 462 | return revision; |
| 463 | } |
| 464 | |
| 465 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 466 | * Sets the revision. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 467 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 468 | * @param revision the revision to set |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 469 | */ |
| 470 | public void setRevision(YangRevision revision) { |
| 471 | this.revision = revision; |
| 472 | } |
| 473 | |
| 474 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 475 | * Returns the version. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 476 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 477 | * @return the version |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 478 | */ |
| 479 | public byte getVersion() { |
| 480 | return version; |
| 481 | } |
| 482 | |
| 483 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 484 | * Sets the version. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 485 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 486 | * @param version the version to set |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 487 | */ |
| 488 | public void setVersion(byte version) { |
| 489 | this.version = version; |
| 490 | } |
| 491 | |
| 492 | /** |
| 493 | * Returns the type of the parsed data. |
| 494 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 495 | * @return returns SUB_MODULE_DATA |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 496 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 497 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 498 | public YangConstructType getYangConstructType() { |
| 499 | return YangConstructType.SUB_MODULE_DATA; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 503 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 504 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 505 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 506 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 507 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 508 | public void validateDataOnEntry() |
| 509 | throws DataModelException { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 510 | // TODO auto-generated method stub, to be implemented by parser |
| 511 | } |
| 512 | |
| 513 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 514 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 515 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 516 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 517 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 518 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 519 | public void validateDataOnExit() |
| 520 | throws DataModelException { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 521 | // TODO auto-generated method stub, to be implemented by parser |
| 522 | } |
| 523 | |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 524 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 525 | public void detectCollidingChild(String identifierName, YangConstructType dataType) |
| 526 | throws DataModelException { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 527 | // Asks helper to detect colliding child. |
| 528 | detectCollidingChildUtil(identifierName, dataType, this); |
| 529 | } |
| 530 | |
| 531 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 532 | public void detectSelfCollision(String identifierName, YangConstructType dataType) |
| 533 | throws DataModelException { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 534 | // Not required as module doesn't have any parent. |
| 535 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 536 | |
| 537 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 538 | public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) { |
| 539 | if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) { |
| 540 | return derivedTypeResolutionList; |
| 541 | } else { |
| 542 | return usesResolutionList; |
| 543 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 547 | public void addToResolutionList(YangResolutionInfo resolutionInfo, |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 548 | ResolvableType type) { |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 549 | if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) { |
| 550 | derivedTypeResolutionList.add(resolutionInfo); |
| 551 | } else if (type == ResolvableType.YANG_USES) { |
| 552 | usesResolutionList.add(resolutionInfo); |
| 553 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 557 | public void setResolutionList(List<YangResolutionInfo> resolutionList, |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 558 | ResolvableType type) { |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 559 | if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) { |
| 560 | derivedTypeResolutionList = resolutionList; |
| 561 | } else if (type == ResolvableType.YANG_USES) { |
| 562 | usesResolutionList = resolutionList; |
| 563 | } |
| 564 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 565 | } |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 566 | |
| 567 | /** |
| 568 | * Links the sub-module with module. |
| 569 | * |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 570 | * @param yangNodeSet YANG file information set |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 571 | * @throws DataModelException a violation in data model rule |
| 572 | */ |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 573 | public void linkWithModule(Set<YangNode> yangNodeSet) |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 574 | throws DataModelException { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 575 | getBelongsTo().linkWithModule(yangNodeSet); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | @Override |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 579 | public void addReferencesToIncludeList(Set<YangNode> yangNodeSet) |
| 580 | throws DataModelException { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 581 | Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator(); |
| 582 | // Run through the included list to add references. |
| 583 | while (includeInfoIterator.hasNext()) { |
| 584 | YangInclude yangInclude = includeInfoIterator.next(); |
| 585 | YangSubModule subModule = null; |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 586 | subModule = yangInclude.addReferenceToInclude(yangNodeSet); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 587 | // Check if the referred sub-modules parent is self |
| 588 | if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 589 | yangInclude.reportIncludeError(); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 590 | } |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | @Override |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 595 | public void addReferencesToImportList(Set<YangNode> yangNodeSet) |
| 596 | throws DataModelException { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 597 | Iterator<YangImport> importInfoIterator = getImportList().iterator(); |
| 598 | // Run through the imported list to add references. |
| 599 | while (importInfoIterator.hasNext()) { |
| 600 | YangImport yangImport = importInfoIterator.next(); |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 601 | yangImport.addReferenceToImport(yangNodeSet); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 602 | } |
| 603 | } |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 604 | } |