Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +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 | 1ede5ab | 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 | |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 18 | import java.util.Iterator; |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +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 | |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +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 | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 30 | |
| 31 | /*- |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 32 | * Reference:RFC 6020. |
| 33 | * The "module" statement defines the module's name, |
| 34 | * and groups all statements that belong to the module together. The "module" |
| 35 | * statement's argument is the name of the module, followed by a block of |
| 36 | * sub statements that hold detailed module information. |
| 37 | * The module's sub statements |
| 38 | * |
| 39 | * +--------------+---------+-------------+-----------------------+ |
| 40 | * |sub statement | section | cardinality | data model mapping | |
| 41 | * +--------------+---------+-------------+-----------------------+ |
| 42 | * | anyxml | 7.10 | 0..n | not supported | |
| 43 | * | augment | 7.15 | 0..n | child nodes | |
| 44 | * | choice | 7.9 | 0..n | child nodes | |
| 45 | * | contact | 7.1.8 | 0..1 | string | |
| 46 | * | container | 7.5 | 0..n | child nodes | |
| 47 | * | description | 7.19.3 | 0..1 | string | |
| 48 | * | deviation | 7.18.3 | 0..n | TODO | |
| 49 | * | extension | 7.17 | 0..n | TODO | |
| 50 | * | feature | 7.18.1 | 0..n | TODO | |
| 51 | * | grouping | 7.11 | 0..n | child nodes | |
| 52 | * | identity | 7.16 | 0..n | TODO | |
| 53 | * | import | 7.1.5 | 0..n | list of import info | |
| 54 | * | include | 7.1.6 | 0..n | list of include info | |
| 55 | * | leaf | 7.6 | 0..n | list of leaf info | |
| 56 | * | leaf-list | 7.7 | 0..n | list of leaf-list info| |
| 57 | * | list | 7.8 | 0..n | child nodes | |
| 58 | * | namespace | 7.1.3 | 1 | string/uri | |
| 59 | * | notification | 7.14 | 0..n | TODO | |
| 60 | * | organization | 7.1.7 | 0..1 | string | |
| 61 | * | prefix | 7.1.4 | 1 | string | |
| 62 | * | reference | 7.19.4 | 0..1 | string | |
| 63 | * | revision | 7.1.9 | 0..n | revision | |
| 64 | * | rpc | 7.13 | 0..n | TODO | |
| 65 | * | typedef | 7.3 | 0..n | child nodes | |
| 66 | * | uses | 7.12 | 0..n | child nodes | |
| 67 | * | YANG-version | 7.1.2 | 0..1 | int | |
| 68 | * +--------------+---------+-------------+-----------------------+ |
| 69 | */ |
| 70 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 71 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 72 | * Represents data model node to maintain information defined in YANG module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 73 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 74 | public class YangModule |
| 75 | extends YangNode |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 76 | implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 77 | RpcNotificationContainer, YangFeatureHolder { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 78 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 79 | private static final long serialVersionUID = 806201610L; |
| 80 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 81 | /** |
| 82 | * Name of the module. |
| 83 | */ |
| 84 | private String name; |
| 85 | |
| 86 | /** |
| 87 | * Reference:RFC 6020. |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 88 | * |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 89 | * The "contact" statement provides contact information for the module. The |
| 90 | * argument is a string that is used to specify contact information for the |
| 91 | * person or persons to whom technical queries concerning this module should |
| 92 | * be sent, such as their name, postal address, telephone number, and |
| 93 | * electronic mail address. |
| 94 | */ |
| 95 | private String contact; |
| 96 | |
| 97 | /** |
| 98 | * Reference:RFC 6020. |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 99 | * |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 100 | * The "description" statement takes as an argument a string that contains a |
| 101 | * human-readable textual description of this definition. The text is |
| 102 | * provided in a language (or languages) chosen by the module developer; for |
| 103 | * the sake of interoperability. |
| 104 | */ |
| 105 | private String description; |
| 106 | |
| 107 | /** |
| 108 | * List of YANG modules imported. |
| 109 | */ |
| 110 | private List<YangImport> importList; |
| 111 | |
| 112 | /** |
| 113 | * List of YANG sub-modules included. |
| 114 | */ |
| 115 | private List<YangInclude> includeList; |
| 116 | |
| 117 | /** |
| 118 | * List of leaves at root level in the module. |
| 119 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 120 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * List of leaf-lists at root level in the module. |
| 124 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 125 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 126 | |
| 127 | /** |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 128 | * List of feature at root level in the module. |
| 129 | */ |
| 130 | private List<YangFeature> listOfFeature; |
| 131 | |
| 132 | /** |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 133 | * Name space of the module. |
| 134 | */ |
| 135 | private YangNameSpace nameSpace; |
| 136 | |
| 137 | /** |
| 138 | * Reference:RFC 6020. |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 139 | * |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 140 | * The "organization" statement defines the party responsible for this |
| 141 | * module. The argument is a string that is used to specify a textual |
| 142 | * description of the organization(s) under whose auspices this module was |
| 143 | * developed. |
| 144 | */ |
| 145 | private String organization; |
| 146 | |
| 147 | /** |
| 148 | * Prefix to refer to the objects in module. |
| 149 | */ |
| 150 | private String prefix; |
| 151 | |
| 152 | /** |
| 153 | * Reference of the module. |
| 154 | */ |
| 155 | private String reference; |
| 156 | |
| 157 | /** |
| 158 | * Revision info of the module. |
| 159 | */ |
| 160 | private YangRevision revision; |
| 161 | |
| 162 | /** |
| 163 | * YANG version. |
| 164 | */ |
| 165 | private byte version; |
| 166 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 167 | /*- |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 168 | * Reference RFC 6020. |
| 169 | * |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 170 | * Nested typedefs and groupings. |
| 171 | * Typedefs and groupings may appear nested under many YANG statements, |
| 172 | * allowing these to be lexically scoped by the hierarchy under which |
| 173 | * they appear. This allows types and groupings to be defined near |
| 174 | * where they are used, rather than placing them at the top level of the |
| 175 | * hierarchy. The close proximity increases readability. |
| 176 | * |
| 177 | * Scoping also allows types to be defined without concern for naming |
| 178 | * conflicts between types in different submodules. Type names can be |
| 179 | * specified without adding leading strings designed to prevent name |
| 180 | * collisions within large modules. |
| 181 | * |
| 182 | * Finally, scoping allows the module author to keep types and groupings |
| 183 | * private to their module or submodule, preventing their reuse. Since |
| 184 | * only top-level types and groupings (i.e., those appearing as |
| 185 | * sub-statements to a module or submodule statement) can be used outside |
| 186 | * the module or submodule, the developer has more control over what |
| 187 | * pieces of their module are presented to the outside world, supporting |
| 188 | * the need to hide internal information and maintaining a boundary |
| 189 | * between what is shared with the outside world and what is kept |
| 190 | * private. |
| 191 | * |
| 192 | * Scoped definitions MUST NOT shadow definitions at a higher scope. A |
| 193 | * type or grouping cannot be defined if a higher level in the schema |
| 194 | * hierarchy has a definition with a matching identifier. |
| 195 | * |
| 196 | * A reference to an unprefixed type or grouping, or one which uses the |
| 197 | * prefix of the current module, is resolved by locating the closest |
| 198 | * matching "typedef" or "grouping" statement among the immediate |
| 199 | * sub-statements of each ancestor statement. |
| 200 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 201 | private List<YangResolutionInfo> derivedTypeResolutionList; |
| 202 | |
| 203 | /** |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 204 | * Uses resolution list. |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 205 | */ |
| 206 | private List<YangResolutionInfo> usesResolutionList; |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 207 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 208 | /** |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 209 | * If-feature resolution list. |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 210 | */ |
| 211 | private List<YangResolutionInfo> ifFeatureResolutionList; |
| 212 | |
| 213 | /** |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 214 | * Leafref resolution list. |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 215 | */ |
| 216 | private List<YangResolutionInfo> leafrefResolutionList; |
| 217 | |
| 218 | /** |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 219 | * Base resolution list. |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 220 | */ |
| 221 | private List<YangResolutionInfo> baseResolutionList; |
| 222 | |
| 223 | /** |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 224 | * Identityref resolution list. |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 225 | */ |
| 226 | private List<YangResolutionInfo> identityrefResolutionList; |
| 227 | |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 228 | /** |
| 229 | * Augment resolution list. |
| 230 | */ |
| 231 | private List<YangResolutionInfo> augmentResolutionList; |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 232 | |
| 233 | /** |
Vidyashree Rama | 07c26bb | 2016-07-28 17:33:15 +0530 | [diff] [blame] | 234 | * Compiler annotation list. |
| 235 | */ |
| 236 | private List<YangCompilerAnnotation> compilerAnnotationList; |
| 237 | |
| 238 | /** |
| 239 | * Extension list. |
Vidyashree Rama | 36f2fab | 2016-07-15 14:06:56 +0530 | [diff] [blame] | 240 | */ |
| 241 | private List<YangExtension> extensionList; |
| 242 | |
| 243 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 244 | * Creates a YANG node of module type. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 245 | */ |
| 246 | public YangModule() { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 247 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 248 | super(YangNodeType.MODULE_NODE); |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 249 | derivedTypeResolutionList = new LinkedList<>(); |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 250 | augmentResolutionList = new LinkedList<>(); |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 251 | usesResolutionList = new LinkedList<>(); |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 252 | ifFeatureResolutionList = new LinkedList<>(); |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 253 | leafrefResolutionList = new LinkedList<>(); |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 254 | baseResolutionList = new LinkedList<>(); |
| 255 | identityrefResolutionList = new LinkedList<>(); |
Vidyashree Rama | 07c26bb | 2016-07-28 17:33:15 +0530 | [diff] [blame] | 256 | compilerAnnotationList = new LinkedList<>(); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 257 | importList = new LinkedList<YangImport>(); |
| 258 | includeList = new LinkedList<YangInclude>(); |
| 259 | listOfLeaf = new LinkedList<YangLeaf>(); |
| 260 | listOfLeafList = new LinkedList<YangLeafList>(); |
Vidyashree Rama | 36f2fab | 2016-07-15 14:06:56 +0530 | [diff] [blame] | 261 | extensionList = new LinkedList<YangExtension>(); |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 262 | } |
| 263 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 264 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 265 | * Returns name of the module. |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 266 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 267 | * @return module name |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 268 | */ |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 269 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 270 | public String getName() { |
| 271 | return name; |
| 272 | } |
| 273 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 274 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 275 | * Sets module name. |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 276 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 277 | * @param moduleName module name |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 278 | */ |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 279 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 280 | public void setName(String moduleName) { |
| 281 | name = moduleName; |
| 282 | } |
| 283 | |
| 284 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 285 | * Returns the contact details of the module owner. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 286 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 287 | * @return the contact details of YANG owner |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 288 | */ |
| 289 | public String getContact() { |
| 290 | return contact; |
| 291 | } |
| 292 | |
| 293 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 294 | * Sets the contact details of the module owner. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 295 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 296 | * @param contact the contact details of YANG owner |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 297 | */ |
| 298 | public void setContact(String contact) { |
| 299 | this.contact = contact; |
| 300 | } |
| 301 | |
| 302 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 303 | * Returns the description of module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 304 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 305 | * @return the description of YANG module |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 306 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 307 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 308 | public String getDescription() { |
| 309 | return description; |
| 310 | } |
| 311 | |
| 312 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 313 | * Sets the description of module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 314 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 315 | * @param description set the description of YANG module |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 316 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 317 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 318 | public void setDescription(String description) { |
| 319 | this.description = description; |
| 320 | } |
| 321 | |
| 322 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 323 | * Returns the list of imported modules. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 324 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 325 | * @return the list of imported modules |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 326 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 327 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 328 | public List<YangImport> getImportList() { |
| 329 | return importList; |
| 330 | } |
| 331 | |
| 332 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 333 | * Adds the imported module information to the import list. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 334 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 335 | * @param importedModule module being imported |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 336 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 337 | @Override |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 338 | public void addToImportList(YangImport importedModule) { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 339 | getImportList().add(importedModule); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 340 | } |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 341 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 342 | @Override |
| 343 | public void setImportList(List<YangImport> importList) { |
| 344 | this.importList = importList; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 348 | * Returns the list of included sub modules. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 349 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 350 | * @return the included list of sub modules |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 351 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 352 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 353 | public List<YangInclude> getIncludeList() { |
| 354 | return includeList; |
| 355 | } |
| 356 | |
| 357 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 358 | * Adds the included sub module information to the include list. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 359 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 360 | * @param includeModule submodule being included |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 361 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 362 | @Override |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 363 | public void addToIncludeList(YangInclude includeModule) { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 364 | getIncludeList().add(includeModule); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | @Override |
| 368 | public void setIncludeList(List<YangInclude> includeList) { |
| 369 | this.includeList = includeList; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 373 | * Returns the list of leaves in module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 374 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 375 | * @return the list of leaves |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 376 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 377 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 378 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 379 | return listOfLeaf; |
| 380 | } |
| 381 | |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 382 | @Override |
| 383 | public void setListOfLeaf(List<YangLeaf> leafsList) { |
| 384 | listOfLeaf = leafsList; |
| 385 | } |
| 386 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 387 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 388 | * Adds a leaf in module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 389 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 390 | * @param leaf the leaf to be added |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 391 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 392 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 393 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 394 | getListOfLeaf().add(leaf); |
| 395 | } |
| 396 | |
| 397 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 398 | * Returns the list of leaf-list from module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 399 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 400 | * @return the list of leaf-list |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 401 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 402 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 403 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 404 | return listOfLeafList; |
| 405 | } |
| 406 | |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 407 | @Override |
| 408 | public void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
| 409 | this.listOfLeafList = listOfLeafList; |
| 410 | } |
| 411 | |
| 412 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 413 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 414 | * Adds a leaf-list in module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 415 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 416 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 417 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 418 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 419 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 420 | getListOfLeafList().add(leafList); |
| 421 | } |
| 422 | |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 423 | @Override |
| 424 | public List<YangFeature> getFeatureList() { |
| 425 | return listOfFeature; |
| 426 | } |
| 427 | |
| 428 | @Override |
| 429 | public void addFeatureList(YangFeature feature) { |
| 430 | if (getFeatureList() == null) { |
| 431 | setListOfFeature(new LinkedList<>()); |
| 432 | } |
| 433 | getFeatureList().add(feature); |
| 434 | } |
| 435 | |
| 436 | @Override |
| 437 | public void setListOfFeature(List<YangFeature> listOfFeature) { |
| 438 | this.listOfFeature = listOfFeature; |
| 439 | } |
| 440 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 441 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 442 | * Returns the name space of module elements. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 443 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 444 | * @return the nameSpace |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 445 | */ |
| 446 | public YangNameSpace getNameSpace() { |
| 447 | return nameSpace; |
| 448 | } |
| 449 | |
| 450 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 451 | * Sets the name space of module elements. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 452 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 453 | * @param nameSpace the nameSpace to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 454 | */ |
| 455 | public void setNameSpace(YangNameSpace nameSpace) { |
| 456 | this.nameSpace = nameSpace; |
| 457 | } |
| 458 | |
| 459 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 460 | * Returns the modules organization. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 461 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 462 | * @return the organization |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 463 | */ |
| 464 | public String getOrganization() { |
| 465 | return organization; |
| 466 | } |
| 467 | |
| 468 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 469 | * Sets the modules organization. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 470 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 471 | * @param org the organization to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 472 | */ |
| 473 | public void setOrganization(String org) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 474 | organization = org; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 478 | * Returns the prefix. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 479 | * |
| 480 | * @return the prefix |
| 481 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 482 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 483 | public String getPrefix() { |
| 484 | return prefix; |
| 485 | } |
| 486 | |
| 487 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 488 | * Sets the prefix. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 489 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 490 | * @param prefix the prefix to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 491 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 492 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 493 | public void setPrefix(String prefix) { |
| 494 | this.prefix = prefix; |
| 495 | } |
| 496 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 497 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 498 | public void resolveSelfFileLinking(ResolvableType type) |
| 499 | throws DataModelException { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 500 | // Get the list to be resolved. |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 501 | List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 502 | // Resolve linking for a resolution list. |
| 503 | resolveLinkingForResolutionList(resolutionList, this); |
| 504 | } |
| 505 | |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 506 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 507 | public void resolveInterFileLinking(ResolvableType type) |
| 508 | throws DataModelException { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 509 | // Get the list to be resolved. |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 510 | List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 511 | // Resolve linking for a resolution list. |
| 512 | linkInterFileReferences(resolutionList, this); |
| 513 | } |
| 514 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 515 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 516 | * Returns the textual reference. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 517 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 518 | * @return the reference |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 519 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 520 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 521 | public String getReference() { |
| 522 | return reference; |
| 523 | } |
| 524 | |
| 525 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 526 | * Sets the textual reference. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 527 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 528 | * @param reference the reference to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 529 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 530 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 531 | public void setReference(String reference) { |
| 532 | this.reference = reference; |
| 533 | } |
| 534 | |
| 535 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 536 | * Returns the revision. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 537 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 538 | * @return the revision |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 539 | */ |
| 540 | public YangRevision getRevision() { |
| 541 | return revision; |
| 542 | } |
| 543 | |
| 544 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 545 | * Sets the revision. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 546 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 547 | * @param revision the revision to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 548 | */ |
| 549 | public void setRevision(YangRevision revision) { |
| 550 | this.revision = revision; |
| 551 | } |
| 552 | |
| 553 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 554 | * Returns the version. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 555 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 556 | * @return the version |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 557 | */ |
| 558 | public byte getVersion() { |
| 559 | return version; |
| 560 | } |
| 561 | |
| 562 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 563 | * Sets the version. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 564 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 565 | * @param version the version to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 566 | */ |
| 567 | public void setVersion(byte version) { |
| 568 | this.version = version; |
| 569 | } |
| 570 | |
| 571 | /** |
Vidyashree Rama | 07c26bb | 2016-07-28 17:33:15 +0530 | [diff] [blame] | 572 | * Adds compiler annotation in compiler-annotation list. |
| 573 | * |
| 574 | * @param compilerAnnotation the compiler-annotation to be added |
| 575 | */ |
| 576 | public void addCompilerAnnotation(YangCompilerAnnotation compilerAnnotation) { |
| 577 | getCompilerAnnotationList().add(compilerAnnotation); |
| 578 | } |
| 579 | |
| 580 | /** |
| 581 | * Returns the compiler annotation list. |
| 582 | * |
| 583 | * @return the compiler annotation list |
| 584 | */ |
| 585 | public List<YangCompilerAnnotation> getCompilerAnnotationList() { |
| 586 | return compilerAnnotationList; |
| 587 | } |
| 588 | |
| 589 | /** |
| 590 | * Sets the compiler-annotation list. |
| 591 | * |
| 592 | * @param compilerAnnotationList the list of compiler-annotation |
| 593 | */ |
| 594 | public void setCompilerAnnotationList(List<YangCompilerAnnotation> compilerAnnotationList) { |
| 595 | this.compilerAnnotationList = compilerAnnotationList; |
| 596 | } |
| 597 | |
| 598 | /** |
Vidyashree Rama | 36f2fab | 2016-07-15 14:06:56 +0530 | [diff] [blame] | 599 | * Adds extension in extension list. |
| 600 | * |
| 601 | * @param extension the extension to be added |
| 602 | */ |
| 603 | public void addExtension(YangExtension extension) { |
| 604 | getExtensionList().add(extension); |
| 605 | } |
| 606 | |
| 607 | /** |
| 608 | * Returns the extension list. |
| 609 | * |
| 610 | * @return the extension list |
| 611 | */ |
| 612 | public List<YangExtension> getExtensionList() { |
| 613 | return extensionList; |
| 614 | } |
| 615 | |
| 616 | /** |
| 617 | * Sets the extension list. |
| 618 | * |
| 619 | * @param extensionList the list of extension |
| 620 | */ |
| 621 | public void setExtensionList(List<YangExtension> extensionList) { |
| 622 | this.extensionList = extensionList; |
| 623 | } |
| 624 | |
| 625 | /** |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 626 | * Returns the type of the parsed data. |
| 627 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 628 | * @return returns MODULE_DATA |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 629 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 630 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 631 | public YangConstructType getYangConstructType() { |
| 632 | return YangConstructType.MODULE_DATA; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 636 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 637 | * |
| 638 | * @throws DataModelException a violation of data model rules |
| 639 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 640 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 641 | public void validateDataOnEntry() |
| 642 | throws DataModelException { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 643 | /* |
| 644 | * Module is root in the data model tree, hence there is no entry |
| 645 | * validation |
| 646 | */ |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 650 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 651 | * |
| 652 | * @throws DataModelException a violation of data model rules |
| 653 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 654 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 655 | public void validateDataOnExit() |
| 656 | throws DataModelException { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 657 | /* |
| 658 | * TODO: perform symbol linking for the imported or included YANG info. |
| 659 | * TODO: perform symbol resolution for referred YANG entities. |
| 660 | */ |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 661 | } |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 662 | |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 663 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 664 | public void detectCollidingChild(String identifierName, YangConstructType dataType) |
| 665 | throws DataModelException { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 666 | // Asks helper to detect colliding child. |
| 667 | detectCollidingChildUtil(identifierName, dataType, this); |
| 668 | } |
| 669 | |
| 670 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 671 | public void detectSelfCollision(String identifierName, YangConstructType dataType) |
| 672 | throws DataModelException { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 673 | // Not required as module doesn't have any parent. |
| 674 | } |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 675 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 676 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 677 | public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) { |
| 678 | if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) { |
| 679 | return derivedTypeResolutionList; |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 680 | } else if (type == ResolvableType.YANG_USES) { |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 681 | return usesResolutionList; |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 682 | } else if (type == ResolvableType.YANG_AUGMENT) { |
| 683 | return augmentResolutionList; |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 684 | } else if (type == ResolvableType.YANG_IF_FEATURE) { |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 685 | return ifFeatureResolutionList; |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 686 | } else if (type == ResolvableType.YANG_LEAFREF) { |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 687 | return leafrefResolutionList; |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 688 | } else if (type == ResolvableType.YANG_BASE) { |
| 689 | return baseResolutionList; |
| 690 | } else { |
| 691 | return identityrefResolutionList; |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 692 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 696 | public void addToResolutionList(YangResolutionInfo resolutionInfo, |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 697 | ResolvableType type) { |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 698 | if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) { |
| 699 | derivedTypeResolutionList.add(resolutionInfo); |
| 700 | } else if (type == ResolvableType.YANG_USES) { |
| 701 | usesResolutionList.add(resolutionInfo); |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 702 | } else if (type == ResolvableType.YANG_IF_FEATURE) { |
| 703 | ifFeatureResolutionList.add(resolutionInfo); |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 704 | } else if (type == ResolvableType.YANG_LEAFREF) { |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 705 | leafrefResolutionList.add(resolutionInfo); |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 706 | } else if (type == ResolvableType.YANG_BASE) { |
| 707 | baseResolutionList.add(resolutionInfo); |
Vidyashree Rama | 36f2fab | 2016-07-15 14:06:56 +0530 | [diff] [blame] | 708 | } else if (type == ResolvableType.YANG_AUGMENT) { |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 709 | augmentResolutionList.add(resolutionInfo); |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 710 | } else if (type == ResolvableType.YANG_IDENTITYREF) { |
| 711 | identityrefResolutionList.add(resolutionInfo); |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 712 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 716 | public void setResolutionList(List<YangResolutionInfo> resolutionList, |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 717 | ResolvableType type) { |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 718 | if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) { |
| 719 | derivedTypeResolutionList = resolutionList; |
| 720 | } else if (type == ResolvableType.YANG_USES) { |
| 721 | usesResolutionList = resolutionList; |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 722 | } else if (type == ResolvableType.YANG_IF_FEATURE) { |
| 723 | ifFeatureResolutionList.add((YangResolutionInfo) resolutionList); |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 724 | } else if (type == ResolvableType.YANG_LEAFREF) { |
| 725 | leafrefResolutionList = resolutionList; |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 726 | } else if (type == ResolvableType.YANG_BASE) { |
| 727 | baseResolutionList = resolutionList; |
Vidyashree Rama | 36f2fab | 2016-07-15 14:06:56 +0530 | [diff] [blame] | 728 | } else if (type == ResolvableType.YANG_AUGMENT) { |
Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 729 | augmentResolutionList = resolutionList; |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 730 | } else if (type == ResolvableType.YANG_IDENTITYREF) { |
| 731 | identityrefResolutionList = resolutionList; |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 732 | } |
| 733 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 734 | } |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 735 | |
| 736 | @Override |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 737 | public void addReferencesToImportList(Set<YangNode> yangNodeSet) |
| 738 | throws DataModelException { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 739 | Iterator<YangImport> importInfoIterator = getImportList().iterator(); |
| 740 | // Run through the imported list to add references. |
| 741 | while (importInfoIterator.hasNext()) { |
| 742 | YangImport yangImport = importInfoIterator.next(); |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 743 | yangImport.addReferenceToImport(yangNodeSet); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 744 | } |
| 745 | } |
| 746 | |
| 747 | @Override |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 748 | public void addReferencesToIncludeList(Set<YangNode> yangNodeSet) |
| 749 | throws DataModelException { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 750 | Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator(); |
| 751 | // Run through the included list to add references. |
| 752 | while (includeInfoIterator.hasNext()) { |
| 753 | YangInclude yangInclude = includeInfoIterator.next(); |
| 754 | YangSubModule subModule = null; |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 755 | subModule = yangInclude.addReferenceToInclude(yangNodeSet); |
| 756 | |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 757 | // Check if the referred sub-modules parent is self |
| 758 | if (!(subModule.getBelongsTo().getModuleNode() == this)) { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 759 | yangInclude.reportIncludeError(); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 760 | } |
| 761 | } |
| 762 | } |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 763 | } |