Gaurav Agrawal
Committed by Gerrit Code Review

[ONOS-4670] Removal of Data Model dependencies on Linker

Change-Id: I3f9c5af30198ea31d743e06cea1764dcb306ec32
Showing 50 changed files with 430 additions and 304 deletions
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.linker; 17 +package org.onosproject.yangutils.datamodel;
18 18
19 /** 19 /**
20 * Type of the resolvable info. 20 * Type of the resolvable info.
......
...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel; ...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel;
18 import java.util.Set; 18 import java.util.Set;
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 import org.onosproject.yangutils.parser.Parsable; 20 import org.onosproject.yangutils.parser.Parsable;
21 -import org.onosproject.yangutils.plugin.manager.YangFileInfo;
22 import org.onosproject.yangutils.utils.YangConstructType; 21 import org.onosproject.yangutils.utils.YangConstructType;
23 22
24 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode; 23 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode;
...@@ -194,13 +193,13 @@ public class YangBelongsTo implements Parsable, LocationInfo { ...@@ -194,13 +193,13 @@ public class YangBelongsTo implements Parsable, LocationInfo {
194 /** 193 /**
195 * Links the belongs to with a module. 194 * Links the belongs to with a module.
196 * 195 *
197 - * @param yangFileInfoSet YANG file information set 196 + * @param yangNodeSet YANG file information set
198 * @throws DataModelException a violation in data model rule 197 * @throws DataModelException a violation in data model rule
199 */ 198 */
200 - public void linkWithModule(Set<YangFileInfo> yangFileInfoSet) 199 + public void linkWithModule(Set<YangNode> yangNodeSet)
201 throws DataModelException { 200 throws DataModelException {
202 String belongsToModuleName = getBelongsToModuleName(); 201 String belongsToModuleName = getBelongsToModuleName();
203 - YangNode moduleNode = findReferredNode(yangFileInfoSet, belongsToModuleName); 202 + YangNode moduleNode = findReferredNode(yangNodeSet, belongsToModuleName);
204 if (moduleNode != null) { 203 if (moduleNode != null) {
205 if (moduleNode instanceof YangModule) { 204 if (moduleNode instanceof YangModule) {
206 setModuleNode(moduleNode); 205 setModuleNode(moduleNode);
......
...@@ -33,9 +33,9 @@ import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; ...@@ -33,9 +33,9 @@ import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
33 import static org.onosproject.yangutils.datamodel.YangDataTypes.UNION; 33 import static org.onosproject.yangutils.datamodel.YangDataTypes.UNION;
34 import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED; 34 import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
35 import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED; 35 import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
36 -import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType; 36 +import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.isOfRangeRestrictedType;
37 -import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction; 37 +import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processLengthRestriction;
38 -import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRestriction; 38 +import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processRangeRestriction;
39 39
40 /** 40 /**
41 * Represents the derived information. 41 * Represents the derived information.
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 +
17 +package org.onosproject.yangutils.datamodel;
18 +
19 +/**
20 + * Abstraction of information about entity being resolved.
21 + *
22 + * @param <T> type of entity being resolved, uses / grouping
23 + */
24 +public interface YangEntityToResolveInfo<T> {
25 +
26 + /**
27 + * Retrieves the entity to be resolved.
28 + *
29 + * @return entity to be resolved
30 + */
31 + T getEntityToResolve();
32 +
33 + /**
34 + * Sets entity to be resolved.
35 + *
36 + * @param entityToResolve entity to be resolved
37 + */
38 + void setEntityToResolve(T entityToResolve);
39 +
40 + /**
41 + * Retrieves the parent node which contains the entity to be resolved.
42 + *
43 + * @return parent node which contains the entity to be resolved
44 + */
45 + YangNode getHolderOfEntityToResolve();
46 +
47 + /**
48 + * Sets parent node which contains the entity to be resolved.
49 + *
50 + * @param holderOfEntityToResolve parent node which contains the entity to
51 + * be resolved
52 + */
53 + void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve);
54 +}
...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel; ...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel;
18 import java.util.Set; 18 import java.util.Set;
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 import org.onosproject.yangutils.parser.Parsable; 20 import org.onosproject.yangutils.parser.Parsable;
21 -import org.onosproject.yangutils.plugin.manager.YangFileInfo;
22 import org.onosproject.yangutils.utils.YangConstructType; 21 import org.onosproject.yangutils.utils.YangConstructType;
23 22
24 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode; 23 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode;
...@@ -237,10 +236,10 @@ public class YangImport ...@@ -237,10 +236,10 @@ public class YangImport
237 /** 236 /**
238 * Adds reference to an import. 237 * Adds reference to an import.
239 * 238 *
240 - * @param yangFileInfoSet YANG file info set 239 + * @param yangNodeSet YANG file info set
241 * @throws DataModelException a violation of data model rules 240 * @throws DataModelException a violation of data model rules
242 */ 241 */
243 - public void addReferenceToImport(Set<YangFileInfo> yangFileInfoSet) throws DataModelException { 242 + public void addReferenceToImport(Set<YangNode> yangNodeSet) throws DataModelException {
244 String importedModuleName = getModuleName(); 243 String importedModuleName = getModuleName();
245 String importedModuleRevision = getRevision(); 244 String importedModuleRevision = getRevision();
246 YangNode moduleNode = null; 245 YangNode moduleNode = null;
...@@ -250,7 +249,7 @@ public class YangImport ...@@ -250,7 +249,7 @@ public class YangImport
250 */ 249 */
251 if (importedModuleRevision != null) { 250 if (importedModuleRevision != null) {
252 String importedModuleNameWithRevision = importedModuleName + "@" + importedModuleRevision; 251 String importedModuleNameWithRevision = importedModuleName + "@" + importedModuleRevision;
253 - moduleNode = findReferredNode(yangFileInfoSet, importedModuleNameWithRevision); 252 + moduleNode = findReferredNode(yangNodeSet, importedModuleNameWithRevision);
254 } 253 }
255 254
256 /* 255 /*
...@@ -258,7 +257,7 @@ public class YangImport ...@@ -258,7 +257,7 @@ public class YangImport
258 * without revision if can't find with revision. 257 * without revision if can't find with revision.
259 */ 258 */
260 if (moduleNode == null) { 259 if (moduleNode == null) {
261 - moduleNode = findReferredNode(yangFileInfoSet, importedModuleName); 260 + moduleNode = findReferredNode(yangNodeSet, importedModuleName);
262 } 261 }
263 262
264 if (moduleNode != null) { 263 if (moduleNode != null) {
......
...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel; ...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel;
18 import java.util.Set; 18 import java.util.Set;
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 import org.onosproject.yangutils.parser.Parsable; 20 import org.onosproject.yangutils.parser.Parsable;
21 -import org.onosproject.yangutils.plugin.manager.YangFileInfo;
22 import org.onosproject.yangutils.utils.YangConstructType; 21 import org.onosproject.yangutils.utils.YangConstructType;
23 22
24 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode; 23 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.findReferredNode;
...@@ -173,11 +172,11 @@ public class YangInclude ...@@ -173,11 +172,11 @@ public class YangInclude
173 /** 172 /**
174 * Adds reference to an include. 173 * Adds reference to an include.
175 * 174 *
176 - * @param yangFileInfoSet YANG file info set 175 + * @param yangNodeSet YANG node set
177 * @return YANG sub module node 176 * @return YANG sub module node
178 * @throws DataModelException a violation of data model rules 177 * @throws DataModelException a violation of data model rules
179 */ 178 */
180 - public YangSubModule addReferenceToInclude(Set<YangFileInfo> yangFileInfoSet) throws DataModelException { 179 + public YangSubModule addReferenceToInclude(Set<YangNode> yangNodeSet) throws DataModelException {
181 String includedSubModuleName = getSubModuleName(); 180 String includedSubModuleName = getSubModuleName();
182 String includedSubModuleRevision = getRevision(); 181 String includedSubModuleRevision = getRevision();
183 YangNode subModuleNode = null; 182 YangNode subModuleNode = null;
...@@ -188,7 +187,7 @@ public class YangInclude ...@@ -188,7 +187,7 @@ public class YangInclude
188 */ 187 */
189 if (includedSubModuleRevision != null) { 188 if (includedSubModuleRevision != null) {
190 String includedSubModuleNameWithRevision = includedSubModuleName + "@" + includedSubModuleRevision; 189 String includedSubModuleNameWithRevision = includedSubModuleName + "@" + includedSubModuleRevision;
191 - subModuleNode = findReferredNode(yangFileInfoSet, includedSubModuleNameWithRevision); 190 + subModuleNode = findReferredNode(yangNodeSet, includedSubModuleNameWithRevision);
192 } 191 }
193 192
194 /* 193 /*
...@@ -196,7 +195,7 @@ public class YangInclude ...@@ -196,7 +195,7 @@ public class YangInclude
196 * without revision if can't find with revision. 195 * without revision if can't find with revision.
197 */ 196 */
198 if (subModuleNode == null) { 197 if (subModuleNode == null) {
199 - subModuleNode = findReferredNode(yangFileInfoSet, includedSubModuleName); 198 + subModuleNode = findReferredNode(yangNodeSet, includedSubModuleName);
200 } 199 }
201 200
202 if (subModuleNode != null) { 201 if (subModuleNode != null) {
......
...@@ -26,7 +26,7 @@ package org.onosproject.yangutils.datamodel; ...@@ -26,7 +26,7 @@ package org.onosproject.yangutils.datamodel;
26 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 26 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
27 import org.onosproject.yangutils.parser.Parsable; 27 import org.onosproject.yangutils.parser.Parsable;
28 import org.onosproject.yangutils.utils.YangConstructType; 28 import org.onosproject.yangutils.utils.YangConstructType;
29 -import org.onosproject.yangutils.utils.builtindatatype.YangUint64; 29 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
30 30
31 /** 31 /**
32 * Represents the restriction for length data type. 32 * Represents the restriction for length data type.
......
...@@ -19,14 +19,8 @@ import java.util.Iterator; ...@@ -19,14 +19,8 @@ import java.util.Iterator;
19 import java.util.LinkedList; 19 import java.util.LinkedList;
20 import java.util.List; 20 import java.util.List;
21 import java.util.Set; 21 import java.util.Set;
22 -
23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 -import org.onosproject.yangutils.linker.exceptions.LinkerException;
25 -import org.onosproject.yangutils.linker.ResolvableType;
26 -import org.onosproject.yangutils.linker.YangReferenceResolver;
27 -import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
28 import org.onosproject.yangutils.parser.Parsable; 23 import org.onosproject.yangutils.parser.Parsable;
29 -import org.onosproject.yangutils.plugin.manager.YangFileInfo;
30 import org.onosproject.yangutils.utils.YangConstructType; 24 import org.onosproject.yangutils.utils.YangConstructType;
31 25
32 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; 26 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
...@@ -88,7 +82,7 @@ public class YangModule ...@@ -88,7 +82,7 @@ public class YangModule
88 82
89 /** 83 /**
90 * Reference:RFC 6020. 84 * Reference:RFC 6020.
91 - * 85 + * <p>
92 * The "contact" statement provides contact information for the module. The 86 * The "contact" statement provides contact information for the module. The
93 * argument is a string that is used to specify contact information for the 87 * argument is a string that is used to specify contact information for the
94 * person or persons to whom technical queries concerning this module should 88 * person or persons to whom technical queries concerning this module should
...@@ -99,7 +93,7 @@ public class YangModule ...@@ -99,7 +93,7 @@ public class YangModule
99 93
100 /** 94 /**
101 * Reference:RFC 6020. 95 * Reference:RFC 6020.
102 - * 96 + * <p>
103 * The "description" statement takes as an argument a string that contains a 97 * The "description" statement takes as an argument a string that contains a
104 * human-readable textual description of this definition. The text is 98 * human-readable textual description of this definition. The text is
105 * provided in a language (or languages) chosen by the module developer; for 99 * provided in a language (or languages) chosen by the module developer; for
...@@ -134,7 +128,7 @@ public class YangModule ...@@ -134,7 +128,7 @@ public class YangModule
134 128
135 /** 129 /**
136 * Reference:RFC 6020. 130 * Reference:RFC 6020.
137 - * 131 + * <p>
138 * The "organization" statement defines the party responsible for this 132 * The "organization" statement defines the party responsible for this
139 * module. The argument is a string that is used to specify a textual 133 * module. The argument is a string that is used to specify a textual
140 * description of the organization(s) under whose auspices this module was 134 * description of the organization(s) under whose auspices this module was
...@@ -209,8 +203,8 @@ public class YangModule ...@@ -209,8 +203,8 @@ public class YangModule
209 public YangModule() { 203 public YangModule() {
210 204
211 super(YangNodeType.MODULE_NODE); 205 super(YangNodeType.MODULE_NODE);
212 - derivedTypeResolutionList = new LinkedList<YangResolutionInfo>(); 206 + derivedTypeResolutionList = new LinkedList<>();
213 - usesResolutionList = new LinkedList<YangResolutionInfo>(); 207 + usesResolutionList = new LinkedList<>();
214 importList = new LinkedList<YangImport>(); 208 importList = new LinkedList<YangImport>();
215 includeList = new LinkedList<YangInclude>(); 209 includeList = new LinkedList<YangInclude>();
216 listOfLeaf = new LinkedList<YangLeaf>(); 210 listOfLeaf = new LinkedList<YangLeaf>();
...@@ -589,40 +583,32 @@ public class YangModule ...@@ -589,40 +583,32 @@ public class YangModule
589 } 583 }
590 584
591 @Override 585 @Override
592 - public void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet) 586 + public void addReferencesToImportList(Set<YangNode> yangNodeSet)
593 - throws LinkerException { 587 + throws DataModelException {
594 Iterator<YangImport> importInfoIterator = getImportList().iterator(); 588 Iterator<YangImport> importInfoIterator = getImportList().iterator();
595 // Run through the imported list to add references. 589 // Run through the imported list to add references.
596 while (importInfoIterator.hasNext()) { 590 while (importInfoIterator.hasNext()) {
597 YangImport yangImport = importInfoIterator.next(); 591 YangImport yangImport = importInfoIterator.next();
598 - try { 592 + yangImport.addReferenceToImport(yangNodeSet);
599 - yangImport.addReferenceToImport(yangFileInfoSet);
600 - } catch (DataModelException e) {
601 - throw new LinkerException(e.getMessage());
602 - }
603 } 593 }
604 } 594 }
605 595
606 @Override 596 @Override
607 - public void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet) 597 + public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
608 - throws LinkerException { 598 + throws DataModelException {
609 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator(); 599 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
610 // Run through the included list to add references. 600 // Run through the included list to add references.
611 while (includeInfoIterator.hasNext()) { 601 while (includeInfoIterator.hasNext()) {
612 YangInclude yangInclude = includeInfoIterator.next(); 602 YangInclude yangInclude = includeInfoIterator.next();
613 YangSubModule subModule = null; 603 YangSubModule subModule = null;
614 try { 604 try {
615 - subModule = yangInclude.addReferenceToInclude(yangFileInfoSet); 605 + subModule = yangInclude.addReferenceToInclude(yangNodeSet);
616 } catch (DataModelException e) { 606 } catch (DataModelException e) {
617 - throw new LinkerException(e.getMessage()); 607 + throw e;
618 } 608 }
619 // Check if the referred sub-modules parent is self 609 // Check if the referred sub-modules parent is self
620 if (!(subModule.getBelongsTo().getModuleNode() == this)) { 610 if (!(subModule.getBelongsTo().getModuleNode() == this)) {
621 - try {
622 yangInclude.reportIncludeError(); 611 yangInclude.reportIncludeError();
623 - } catch (DataModelException e) {
624 - throw new LinkerException(e.getMessage());
625 - }
626 } 612 }
627 } 613 }
628 } 614 }
......
...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and ...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
13 limitations under the License.*/ 13 limitations under the License.*/
14 package org.onosproject.yangutils.datamodel; 14 package org.onosproject.yangutils.datamodel;
15 15
16 -import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo; 16 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangBuiltInDataTypeInfo;
17 17
18 /** 18 /**
19 * Represents single interval information of a range. 19 * Represents single interval information of a range.
......
...@@ -21,9 +21,9 @@ import java.util.List; ...@@ -21,9 +21,9 @@ import java.util.List;
21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 import org.onosproject.yangutils.parser.Parsable; 22 import org.onosproject.yangutils.parser.Parsable;
23 import org.onosproject.yangutils.utils.YangConstructType; 23 import org.onosproject.yangutils.utils.YangConstructType;
24 -import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo; 24 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangBuiltInDataTypeInfo;
25 25
26 -import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString; 26 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString;
27 import static com.google.common.base.Preconditions.checkNotNull; 27 import static com.google.common.base.Preconditions.checkNotNull;
28 28
29 /*- 29 /*-
......
...@@ -14,17 +14,11 @@ ...@@ -14,17 +14,11 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.linker; 17 +package org.onosproject.yangutils.datamodel;
18 18
19 import java.util.List; 19 import java.util.List;
20 import java.util.Set; 20 import java.util.Set;
21 -
22 -import org.onosproject.yangutils.datamodel.YangImport;
23 -import org.onosproject.yangutils.datamodel.YangInclude;
24 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
25 -import org.onosproject.yangutils.linker.exceptions.LinkerException;
26 -import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
27 -import org.onosproject.yangutils.plugin.manager.YangFileInfo;
28 22
29 /** 23 /**
30 * Abstraction of YANG dependency resolution information. Abstracted to obtain the 24 * Abstraction of YANG dependency resolution information. Abstracted to obtain the
...@@ -133,18 +127,18 @@ public interface YangReferenceResolver { ...@@ -133,18 +127,18 @@ public interface YangReferenceResolver {
133 /** 127 /**
134 * Adds references to include. 128 * Adds references to include.
135 * 129 *
136 - * @param yangFileInfoSet YANG file info set 130 + * @param yangNodeSet YANG node info set
137 - * @throws LinkerException a violation of linker rules 131 + * @throws DataModelException a violation of data model rules
138 */ 132 */
139 - void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet) 133 + void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
140 - throws LinkerException; 134 + throws DataModelException;
141 135
142 /** 136 /**
143 * Adds references to import. 137 * Adds references to import.
144 * 138 *
145 - * @param yangFileInfoSet YANG file info set 139 + * @param yangNodeSet YANG node info set
146 - * @throws LinkerException a violation of linker rules 140 + * @throws DataModelException a violation of data model rules
147 */ 141 */
148 - void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet) 142 + void addReferencesToImportList(Set<YangNode> yangNodeSet)
149 - throws LinkerException; 143 + throws DataModelException;
150 } 144 }
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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 +
17 +package org.onosproject.yangutils.datamodel;
18 +
19 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 +
21 +/**
22 + * Abstraction of resolution object which will be resolved by linker.
23 + *
24 + * @param <T> type of resolution entity uses / type
25 + */
26 +public interface YangResolutionInfo<T> extends LocationInfo {
27 +
28 + /**
29 + * Resolves linking with all the ancestors node for a resolution info.
30 + *
31 + * @param dataModelRootNode module/sub-module node
32 + * @throws DataModelException DataModelException a violation of data model
33 + * rules
34 + */
35 + void resolveLinkingForResolutionInfo(YangReferenceResolver dataModelRootNode)
36 + throws DataModelException;
37 +
38 + /**
39 + * Retrieves information about the entity that needs to be resolved.
40 + *
41 + * @return information about the entity that needs to be resolved
42 + */
43 + YangEntityToResolveInfo<T> getEntityToResolveInfo();
44 +
45 + /**
46 + * Performs inter file linking of uses/type referring to typedef/grouping
47 + * of other YANG file.
48 + *
49 + * @param dataModelRootNode module/sub-module node
50 + * @throws DataModelException a violation in data model rule
51 + */
52 + void linkInterFile(YangReferenceResolver dataModelRootNode)
53 + throws DataModelException;
54 +}
...@@ -19,7 +19,7 @@ package org.onosproject.yangutils.datamodel; ...@@ -19,7 +19,7 @@ package org.onosproject.yangutils.datamodel;
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 import org.onosproject.yangutils.parser.Parsable; 20 import org.onosproject.yangutils.parser.Parsable;
21 import org.onosproject.yangutils.utils.YangConstructType; 21 import org.onosproject.yangutils.utils.YangConstructType;
22 -import org.onosproject.yangutils.utils.builtindatatype.YangUint64; 22 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
23 23
24 /*- 24 /*-
25 * Reference RFC 6020. 25 * Reference RFC 6020.
......
...@@ -19,14 +19,8 @@ import java.util.Iterator; ...@@ -19,14 +19,8 @@ import java.util.Iterator;
19 import java.util.LinkedList; 19 import java.util.LinkedList;
20 import java.util.List; 20 import java.util.List;
21 import java.util.Set; 21 import java.util.Set;
22 -
23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 -import org.onosproject.yangutils.linker.exceptions.LinkerException;
25 -import org.onosproject.yangutils.linker.ResolvableType;
26 -import org.onosproject.yangutils.linker.YangReferenceResolver;
27 -import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
28 import org.onosproject.yangutils.parser.Parsable; 23 import org.onosproject.yangutils.parser.Parsable;
29 -import org.onosproject.yangutils.plugin.manager.YangFileInfo;
30 import org.onosproject.yangutils.utils.YangConstructType; 24 import org.onosproject.yangutils.utils.YangConstructType;
31 25
32 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; 26 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
...@@ -206,8 +200,8 @@ public class YangSubModule ...@@ -206,8 +200,8 @@ public class YangSubModule
206 */ 200 */
207 public YangSubModule() { 201 public YangSubModule() {
208 super(YangNodeType.SUB_MODULE_NODE); 202 super(YangNodeType.SUB_MODULE_NODE);
209 - derivedTypeResolutionList = new LinkedList<YangResolutionInfo>(); 203 + derivedTypeResolutionList = new LinkedList<>();
210 - usesResolutionList = new LinkedList<YangResolutionInfo>(); 204 + usesResolutionList = new LinkedList<>();
211 importList = new LinkedList<YangImport>(); 205 importList = new LinkedList<YangImport>();
212 includeList = new LinkedList<YangInclude>(); 206 includeList = new LinkedList<YangInclude>();
213 listOfLeaf = new LinkedList<YangLeaf>(); 207 listOfLeaf = new LinkedList<YangLeaf>();
...@@ -570,50 +564,38 @@ public class YangSubModule ...@@ -570,50 +564,38 @@ public class YangSubModule
570 /** 564 /**
571 * Links the sub-module with module. 565 * Links the sub-module with module.
572 * 566 *
573 - * @param yangFileInfoSet YANG file information set 567 + * @param yangNodeSet YANG file information set
574 * @throws DataModelException a violation in data model rule 568 * @throws DataModelException a violation in data model rule
575 */ 569 */
576 - public void linkWithModule(Set<YangFileInfo> yangFileInfoSet) 570 + public void linkWithModule(Set<YangNode> yangNodeSet)
577 throws DataModelException { 571 throws DataModelException {
578 - getBelongsTo().linkWithModule(yangFileInfoSet); 572 + getBelongsTo().linkWithModule(yangNodeSet);
579 } 573 }
580 574
581 @Override 575 @Override
582 - public void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet) 576 + public void addReferencesToIncludeList(Set<YangNode> yangNodeSet)
583 - throws LinkerException { 577 + throws DataModelException {
584 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator(); 578 Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator();
585 // Run through the included list to add references. 579 // Run through the included list to add references.
586 while (includeInfoIterator.hasNext()) { 580 while (includeInfoIterator.hasNext()) {
587 YangInclude yangInclude = includeInfoIterator.next(); 581 YangInclude yangInclude = includeInfoIterator.next();
588 YangSubModule subModule = null; 582 YangSubModule subModule = null;
589 - try { 583 + subModule = yangInclude.addReferenceToInclude(yangNodeSet);
590 - subModule = yangInclude.addReferenceToInclude(yangFileInfoSet);
591 - } catch (DataModelException e) {
592 - throw new LinkerException(e.getMessage());
593 - }
594 // Check if the referred sub-modules parent is self 584 // Check if the referred sub-modules parent is self
595 if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) { 585 if (!(subModule.getBelongsTo().getModuleNode() == getBelongsTo().getModuleNode())) {
596 - try {
597 yangInclude.reportIncludeError(); 586 yangInclude.reportIncludeError();
598 - } catch (DataModelException e) {
599 - throw new LinkerException(e.getMessage());
600 - }
601 } 587 }
602 } 588 }
603 } 589 }
604 590
605 @Override 591 @Override
606 - public void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet) 592 + public void addReferencesToImportList(Set<YangNode> yangNodeSet)
607 - throws LinkerException { 593 + throws DataModelException {
608 Iterator<YangImport> importInfoIterator = getImportList().iterator(); 594 Iterator<YangImport> importInfoIterator = getImportList().iterator();
609 // Run through the imported list to add references. 595 // Run through the imported list to add references.
610 while (importInfoIterator.hasNext()) { 596 while (importInfoIterator.hasNext()) {
611 YangImport yangImport = importInfoIterator.next(); 597 YangImport yangImport = importInfoIterator.next();
612 - try { 598 + yangImport.addReferenceToImport(yangNodeSet);
613 - yangImport.addReferenceToImport(yangFileInfoSet);
614 - } catch (DataModelException e) {
615 - throw new LinkerException(e.getMessage());
616 - }
617 } 599 }
618 } 600 }
619 } 601 }
......
...@@ -19,7 +19,6 @@ package org.onosproject.yangutils.datamodel; ...@@ -19,7 +19,6 @@ package org.onosproject.yangutils.datamodel;
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 import org.onosproject.yangutils.linker.Resolvable; 20 import org.onosproject.yangutils.linker.Resolvable;
21 import org.onosproject.yangutils.linker.ResolvableStatus; 21 import org.onosproject.yangutils.linker.ResolvableStatus;
22 -import org.onosproject.yangutils.linker.exceptions.LinkerException;
23 import org.onosproject.yangutils.parser.Parsable; 22 import org.onosproject.yangutils.parser.Parsable;
24 import org.onosproject.yangutils.utils.YangConstructType; 23 import org.onosproject.yangutils.utils.YangConstructType;
25 24
...@@ -248,25 +247,25 @@ public class YangType<T> ...@@ -248,25 +247,25 @@ public class YangType<T>
248 247
249 @Override 248 @Override
250 public void resolve() 249 public void resolve()
251 - throws LinkerException { 250 + throws DataModelException {
252 /* 251 /*
253 * Check whether the data type is derived. 252 * Check whether the data type is derived.
254 */ 253 */
255 if (getDataType() != DERIVED) { 254 if (getDataType() != DERIVED) {
256 - throw new LinkerException("Linker Error: Resolve should only be called for derived data types."); 255 + throw new DataModelException("Linker Error: Resolve should only be called for derived data types.");
257 } 256 }
258 257
259 // Check if the derived info is present. 258 // Check if the derived info is present.
260 YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) getDataTypeExtendedInfo(); 259 YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) getDataTypeExtendedInfo();
261 if (derivedInfo == null) { 260 if (derivedInfo == null) {
262 - throw new LinkerException("Linker Error: Derived information is missing."); 261 + throw new DataModelException("Linker Error: Derived information is missing.");
263 } 262 }
264 263
265 // Initiate the resolution 264 // Initiate the resolution
266 try { 265 try {
267 setResolvableStatus(derivedInfo.resolve()); 266 setResolvableStatus(derivedInfo.resolve());
268 } catch (DataModelException e) { 267 } catch (DataModelException e) {
269 - throw new LinkerException(e.getMessage()); 268 + throw new DataModelException(e.getMessage());
270 } 269 }
271 } 270 }
272 } 271 }
......
...@@ -17,11 +17,9 @@ package org.onosproject.yangutils.datamodel; ...@@ -17,11 +17,9 @@ package org.onosproject.yangutils.datamodel;
17 17
18 import java.util.LinkedList; 18 import java.util.LinkedList;
19 import java.util.List; 19 import java.util.List;
20 -
21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 20 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 import org.onosproject.yangutils.linker.Resolvable; 21 import org.onosproject.yangutils.linker.Resolvable;
23 import org.onosproject.yangutils.linker.ResolvableStatus; 22 import org.onosproject.yangutils.linker.ResolvableStatus;
24 -import org.onosproject.yangutils.linker.exceptions.LinkerException;
25 import org.onosproject.yangutils.parser.Parsable; 23 import org.onosproject.yangutils.parser.Parsable;
26 import org.onosproject.yangutils.utils.YangConstructType; 24 import org.onosproject.yangutils.utils.YangConstructType;
27 25
...@@ -283,18 +281,18 @@ public class YangUses ...@@ -283,18 +281,18 @@ public class YangUses
283 281
284 @Override 282 @Override
285 public void resolve() 283 public void resolve()
286 - throws LinkerException { 284 + throws DataModelException {
287 285
288 YangGrouping referredGrouping = getRefGroup(); 286 YangGrouping referredGrouping = getRefGroup();
289 287
290 if (referredGrouping == null) { 288 if (referredGrouping == null) {
291 - throw new LinkerException("Linker Exception: YANG uses linker error, cannot resolve uses"); 289 + throw new DataModelException("YANG uses linker error, cannot resolve uses");
292 } 290 }
293 291
294 YangNode usesParentNode = getParentNodeInGenCode(this); 292 YangNode usesParentNode = getParentNodeInGenCode(this);
295 if (!(usesParentNode instanceof YangLeavesHolder) 293 if (!(usesParentNode instanceof YangLeavesHolder)
296 || !(usesParentNode instanceof CollisionDetector)) { 294 || !(usesParentNode instanceof CollisionDetector)) {
297 - throw new LinkerException("Linker Exception: YANG uses holder construct is wrong"); 295 + throw new DataModelException("YANG uses holder construct is wrong");
298 } 296 }
299 297
300 YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode; 298 YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode;
...@@ -343,7 +341,7 @@ public class YangUses ...@@ -343,7 +341,7 @@ public class YangUses
343 * @param usesHolder holder of uses 341 * @param usesHolder holder of uses
344 */ 342 */
345 private void addResolvedUsesInfoOfGrouping(YangUses usesInGrouping, 343 private void addResolvedUsesInfoOfGrouping(YangUses usesInGrouping,
346 - YangLeavesHolder usesHolder) { 344 + YangLeavesHolder usesHolder) throws DataModelException {
347 for (YangNode usesResolvedNode : 345 for (YangNode usesResolvedNode :
348 usesInGrouping.getUsesResolvedNodeList()) { 346 usesInGrouping.getUsesResolvedNodeList()) {
349 addNodeOfGrouping(usesResolvedNode); 347 addNodeOfGrouping(usesResolvedNode);
...@@ -367,11 +365,12 @@ public class YangUses ...@@ -367,11 +365,12 @@ public class YangUses
367 * @param listOfLeaves list of leaves to be cloned 365 * @param listOfLeaves list of leaves to be cloned
368 * @param usesParentNode parent of the cloned location 366 * @param usesParentNode parent of the cloned location
369 * @return cloned list of leaves 367 * @return cloned list of leaves
368 + * @throws DataModelException a violation in data model rule
370 */ 369 */
371 private List<YangLeaf> cloneLeavesList(List<YangLeaf> listOfLeaves, 370 private List<YangLeaf> cloneLeavesList(List<YangLeaf> listOfLeaves,
372 - YangLeavesHolder usesParentNode) { 371 + YangLeavesHolder usesParentNode) throws DataModelException {
373 if ((listOfLeaves == null) || listOfLeaves.size() == 0) { 372 if ((listOfLeaves == null) || listOfLeaves.size() == 0) {
374 - throw new LinkerException("No leaves to clone"); 373 + throw new DataModelException("No leaves to clone");
375 } 374 }
376 375
377 List<YangLeaf> newLeavesList = new LinkedList<YangLeaf>(); 376 List<YangLeaf> newLeavesList = new LinkedList<YangLeaf>();
...@@ -382,7 +381,7 @@ public class YangUses ...@@ -382,7 +381,7 @@ public class YangUses
382 YangConstructType.LEAF_DATA); 381 YangConstructType.LEAF_DATA);
383 clonedLeaf = leaf.clone(); 382 clonedLeaf = leaf.clone();
384 } catch (CloneNotSupportedException | DataModelException e) { 383 } catch (CloneNotSupportedException | DataModelException e) {
385 - throw new LinkerException(e.getMessage()); 384 + throw new DataModelException(e.getMessage());
386 } 385 }
387 386
388 clonedLeaf.setContainedIn(usesParentNode); 387 clonedLeaf.setContainedIn(usesParentNode);
...@@ -400,9 +399,9 @@ public class YangUses ...@@ -400,9 +399,9 @@ public class YangUses
400 * @return cloned list of leaf list 399 * @return cloned list of leaf list
401 */ 400 */
402 private List<YangLeafList> cloneListOfLeafList(List<YangLeafList> listOfLeafList, 401 private List<YangLeafList> cloneListOfLeafList(List<YangLeafList> listOfLeafList,
403 - YangLeavesHolder usesParentNode) { 402 + YangLeavesHolder usesParentNode) throws DataModelException {
404 if ((listOfLeafList == null) || listOfLeafList.size() == 0) { 403 if ((listOfLeafList == null) || listOfLeafList.size() == 0) {
405 - throw new LinkerException("No leaf lists to clone"); 404 + throw new DataModelException("No leaf lists to clone");
406 } 405 }
407 406
408 List<YangLeafList> newListOfLeafList = new LinkedList<YangLeafList>(); 407 List<YangLeafList> newListOfLeafList = new LinkedList<YangLeafList>();
...@@ -413,7 +412,7 @@ public class YangUses ...@@ -413,7 +412,7 @@ public class YangUses
413 YangConstructType.LEAF_LIST_DATA); 412 YangConstructType.LEAF_LIST_DATA);
414 clonedLeafList = leafList.clone(); 413 clonedLeafList = leafList.clone();
415 } catch (CloneNotSupportedException | DataModelException e) { 414 } catch (CloneNotSupportedException | DataModelException e) {
416 - throw new LinkerException(e.getMessage()); 415 + throw new DataModelException(e.getMessage());
417 } 416 }
418 417
419 clonedLeafList.setContainedIn(usesParentNode); 418 clonedLeafList.setContainedIn(usesParentNode);
......
...@@ -18,20 +18,18 @@ package org.onosproject.yangutils.datamodel.utils; ...@@ -18,20 +18,18 @@ package org.onosproject.yangutils.datamodel.utils;
18 18
19 import java.util.List; 19 import java.util.List;
20 import java.util.Set; 20 import java.util.Set;
21 -
22 import org.onosproject.yangutils.datamodel.CollisionDetector; 21 import org.onosproject.yangutils.datamodel.CollisionDetector;
22 +import org.onosproject.yangutils.datamodel.ResolvableType;
23 import org.onosproject.yangutils.datamodel.YangLeaf; 23 import org.onosproject.yangutils.datamodel.YangLeaf;
24 import org.onosproject.yangutils.datamodel.YangLeafList; 24 import org.onosproject.yangutils.datamodel.YangLeafList;
25 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 25 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
26 import org.onosproject.yangutils.datamodel.YangNode; 26 import org.onosproject.yangutils.datamodel.YangNode;
27 +import org.onosproject.yangutils.datamodel.YangReferenceResolver;
28 +import org.onosproject.yangutils.datamodel.YangResolutionInfo;
27 import org.onosproject.yangutils.datamodel.YangRpc; 29 import org.onosproject.yangutils.datamodel.YangRpc;
28 import org.onosproject.yangutils.datamodel.YangType; 30 import org.onosproject.yangutils.datamodel.YangType;
29 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 31 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
30 -import org.onosproject.yangutils.linker.ResolvableType;
31 -import org.onosproject.yangutils.linker.YangReferenceResolver;
32 -import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
33 import org.onosproject.yangutils.parser.Parsable; 32 import org.onosproject.yangutils.parser.Parsable;
34 -import org.onosproject.yangutils.plugin.manager.YangFileInfo;
35 import org.onosproject.yangutils.utils.YangConstructType; 33 import org.onosproject.yangutils.utils.YangConstructType;
36 34
37 /** 35 /**
...@@ -226,19 +224,18 @@ public final class DataModelUtils { ...@@ -226,19 +224,18 @@ public final class DataModelUtils {
226 /** 224 /**
227 * Returns referred node in a given set. 225 * Returns referred node in a given set.
228 * 226 *
229 - * @param yangFileInfoSet YANG file info set 227 + * @param yangNodeSet YANG node set
230 * @param refNodeName name of the node which is referred 228 * @param refNodeName name of the node which is referred
231 * @return referred node's reference 229 * @return referred node's reference
232 */ 230 */
233 - public static YangNode findReferredNode(Set<YangFileInfo> yangFileInfoSet, String refNodeName) { 231 + public static YangNode findReferredNode(Set<YangNode> yangNodeSet, String refNodeName) {
234 /* 232 /*
235 * Run through the YANG files to see which YANG file matches the 233 * Run through the YANG files to see which YANG file matches the
236 * referred node name. 234 * referred node name.
237 */ 235 */
238 - for (YangFileInfo yangFileInfo : yangFileInfoSet) { 236 + for (YangNode yangNode : yangNodeSet) {
239 - YangNode yangNode = yangFileInfo.getRootNode();
240 if (yangNode.getName().equals(refNodeName)) { 237 if (yangNode.getName().equals(refNodeName)) {
241 - return yangFileInfo.getRootNode(); 238 + return yangNode;
242 } 239 }
243 } 240 }
244 return null; 241 return null;
......
...@@ -14,16 +14,15 @@ ...@@ -14,16 +14,15 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils; 17 +package org.onosproject.yangutils.datamodel.utils;
18 18
19 import java.util.regex.Pattern; 19 import java.util.regex.Pattern;
20 import org.onosproject.yangutils.datamodel.YangDataTypes; 20 import org.onosproject.yangutils.datamodel.YangDataTypes;
21 import org.onosproject.yangutils.datamodel.YangRangeInterval; 21 import org.onosproject.yangutils.datamodel.YangRangeInterval;
22 import org.onosproject.yangutils.datamodel.YangRangeRestriction; 22 import org.onosproject.yangutils.datamodel.YangRangeRestriction;
23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 -import org.onosproject.yangutils.parser.exceptions.ParserException; 24 +import org.onosproject.yangutils.utils.YangConstructType;
25 -import org.onosproject.yangutils.utils.builtindatatype.DataTypeException; 25 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangBuiltInDataTypeInfo;
26 -import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo;
27 26
28 import static org.onosproject.yangutils.datamodel.YangDataTypes.DECIMAL64; 27 import static org.onosproject.yangutils.datamodel.YangDataTypes.DECIMAL64;
29 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT16; 28 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT16;
...@@ -34,13 +33,11 @@ import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT16; ...@@ -34,13 +33,11 @@ import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT16;
34 import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT32; 33 import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT32;
35 import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT64; 34 import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT64;
36 import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT8; 35 import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT8;
37 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 36 +import static org.onosproject.yangutils.utils.UtilConstants.ADD;
38 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; 37 +import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
39 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
40 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
41 import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA; 38 import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA;
42 import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA; 39 import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA;
43 -import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString; 40 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString;
44 41
45 /** 42 /**
46 * Represents restriction resolver which provide common utility used by parser 43 * Represents restriction resolver which provide common utility used by parser
...@@ -71,11 +68,13 @@ public final class RestrictionResolver { ...@@ -71,11 +68,13 @@ public final class RestrictionResolver {
71 * @param curRangeString caller type's range string 68 * @param curRangeString caller type's range string
72 * @param effectiveType effective type, when called from linker 69 * @param effectiveType effective type, when called from linker
73 * @return YANG range restriction 70 * @return YANG range restriction
71 + * @throws DataModelException a violation in data model rule
74 */ 72 */
75 public static YangRangeRestriction processRangeRestriction(YangRangeRestriction refRangeRestriction, 73 public static YangRangeRestriction processRangeRestriction(YangRangeRestriction refRangeRestriction,
76 int lineNumber, int charPositionInLine, 74 int lineNumber, int charPositionInLine,
77 boolean hasReferredRestriction, 75 boolean hasReferredRestriction,
78 - String curRangeString, YangDataTypes effectiveType) { 76 + String curRangeString, YangDataTypes effectiveType)
77 + throws DataModelException {
79 YangBuiltInDataTypeInfo<?> startValue; 78 YangBuiltInDataTypeInfo<?> startValue;
80 YangBuiltInDataTypeInfo<?> endValue; 79 YangBuiltInDataTypeInfo<?> endValue;
81 YangRangeRestriction rangeRestriction = new YangRangeRestriction(); 80 YangRangeRestriction rangeRestriction = new YangRangeRestriction();
...@@ -90,12 +89,12 @@ public final class RestrictionResolver { ...@@ -90,12 +89,12 @@ public final class RestrictionResolver {
90 String[] rangeBoundary = rangePart.trim().split(Pattern.quote(INTERVAL)); 89 String[] rangeBoundary = rangePart.trim().split(Pattern.quote(INTERVAL));
91 90
92 if (rangeBoundary.length > MAX_RANGE_BOUNDARY) { 91 if (rangeBoundary.length > MAX_RANGE_BOUNDARY) {
93 - ParserException parserException = new ParserException("YANG file error : " + 92 + DataModelException dataModelException = new DataModelException("YANG file error : " +
94 YangConstructType.getYangConstructType(RANGE_DATA) + " " + rangeArgument + 93 YangConstructType.getYangConstructType(RANGE_DATA) + " " + rangeArgument +
95 " is not valid."); 94 " is not valid.");
96 - parserException.setLine(lineNumber); 95 + dataModelException.setLine(lineNumber);
97 - parserException.setCharPosition(charPositionInLine); 96 + dataModelException.setCharPosition(charPositionInLine);
98 - throw parserException; 97 + throw dataModelException;
99 } 98 }
100 99
101 if (rangeBoundary.length == MIN_RANGE_BOUNDARY) { 100 if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
...@@ -125,11 +124,11 @@ public final class RestrictionResolver { ...@@ -125,11 +124,11 @@ public final class RestrictionResolver {
125 } else { 124 } else {
126 endValue = getDataObjectFromString(endInterval, effectiveType); 125 endValue = getDataObjectFromString(endInterval, effectiveType);
127 } 126 }
128 - } catch (DataTypeException | DataModelException e) { 127 + } catch (Exception e) {
129 - ParserException parserException = new ParserException(e.getMessage()); 128 + DataModelException dataModelException = new DataModelException(e.getMessage());
130 - parserException.setLine(lineNumber); 129 + dataModelException.setLine(lineNumber);
131 - parserException.setCharPosition(charPositionInLine); 130 + dataModelException.setCharPosition(charPositionInLine);
132 - throw parserException; 131 + throw dataModelException;
133 } 132 }
134 133
135 rangeInterval.setStartValue(startValue); 134 rangeInterval.setStartValue(startValue);
...@@ -137,12 +136,10 @@ public final class RestrictionResolver { ...@@ -137,12 +136,10 @@ public final class RestrictionResolver {
137 136
138 try { 137 try {
139 rangeRestriction.addRangeRestrictionInterval(rangeInterval); 138 rangeRestriction.addRangeRestrictionInterval(rangeInterval);
140 - } catch (DataModelException e) { 139 + } catch (DataModelException dataModelException) {
141 - ParserException parserException = new ParserException(constructExtendedListenerErrorMessage( 140 + dataModelException.setLine(lineNumber);
142 - UNHANDLED_PARSED_DATA, RANGE_DATA, rangeArgument, ENTRY, e.getMessage())); 141 + dataModelException.setCharPosition(charPositionInLine);
143 - parserException.setLine(lineNumber); 142 + throw dataModelException;
144 - parserException.setCharPosition(charPositionInLine);
145 - throw parserException;
146 } 143 }
147 } 144 }
148 return rangeRestriction; 145 return rangeRestriction;
...@@ -157,11 +154,12 @@ public final class RestrictionResolver { ...@@ -157,11 +154,12 @@ public final class RestrictionResolver {
157 * @param hasReferredRestriction whether has referred restriction 154 * @param hasReferredRestriction whether has referred restriction
158 * @param curLengthString caller type's length string 155 * @param curLengthString caller type's length string
159 * @return YANG range restriction 156 * @return YANG range restriction
157 + * @throws DataModelException a violation in data model rule
160 */ 158 */
161 public static YangRangeRestriction processLengthRestriction(YangRangeRestriction refLengthRestriction, 159 public static YangRangeRestriction processLengthRestriction(YangRangeRestriction refLengthRestriction,
162 int lineNumber, int charPositionInLine, 160 int lineNumber, int charPositionInLine,
163 boolean hasReferredRestriction, 161 boolean hasReferredRestriction,
164 - String curLengthString) { 162 + String curLengthString) throws DataModelException {
165 163
166 YangBuiltInDataTypeInfo<?> startValue; 164 YangBuiltInDataTypeInfo<?> startValue;
167 YangBuiltInDataTypeInfo<?> endValue; 165 YangBuiltInDataTypeInfo<?> endValue;
...@@ -177,12 +175,12 @@ public final class RestrictionResolver { ...@@ -177,12 +175,12 @@ public final class RestrictionResolver {
177 String[] rangeBoundary = rangePart.trim().split(Pattern.quote(INTERVAL)); 175 String[] rangeBoundary = rangePart.trim().split(Pattern.quote(INTERVAL));
178 176
179 if (rangeBoundary.length > MAX_RANGE_BOUNDARY) { 177 if (rangeBoundary.length > MAX_RANGE_BOUNDARY) {
180 - ParserException parserException = new ParserException("YANG file error : " + 178 + DataModelException dataModelException = new DataModelException("YANG file error : " +
181 YangConstructType.getYangConstructType(LENGTH_DATA) + " " + rangeArgument + 179 YangConstructType.getYangConstructType(LENGTH_DATA) + " " + rangeArgument +
182 " is not valid."); 180 " is not valid.");
183 - parserException.setLine(lineNumber); 181 + dataModelException.setLine(lineNumber);
184 - parserException.setCharPosition(charPositionInLine); 182 + dataModelException.setCharPosition(charPositionInLine);
185 - throw parserException; 183 + throw dataModelException;
186 } 184 }
187 185
188 if (rangeBoundary.length == MIN_RANGE_BOUNDARY) { 186 if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
...@@ -212,11 +210,11 @@ public final class RestrictionResolver { ...@@ -212,11 +210,11 @@ public final class RestrictionResolver {
212 } else { 210 } else {
213 endValue = getDataObjectFromString(endInterval, YangDataTypes.UINT64); 211 endValue = getDataObjectFromString(endInterval, YangDataTypes.UINT64);
214 } 212 }
215 - } catch (DataTypeException | DataModelException e) { 213 + } catch (Exception e) {
216 - ParserException parserException = new ParserException(e.getMessage()); 214 + DataModelException dataModelException = new DataModelException(e.getMessage());
217 - parserException.setLine(lineNumber); 215 + dataModelException.setLine(lineNumber);
218 - parserException.setCharPosition(charPositionInLine); 216 + dataModelException.setCharPosition(charPositionInLine);
219 - throw parserException; 217 + throw dataModelException;
220 } 218 }
221 219
222 rangeInterval.setStartValue(startValue); 220 rangeInterval.setStartValue(startValue);
...@@ -224,12 +222,10 @@ public final class RestrictionResolver { ...@@ -224,12 +222,10 @@ public final class RestrictionResolver {
224 222
225 try { 223 try {
226 lengthRestriction.addRangeRestrictionInterval(rangeInterval); 224 lengthRestriction.addRangeRestrictionInterval(rangeInterval);
227 - } catch (DataModelException e) { 225 + } catch (DataModelException dataModelException) {
228 - ParserException parserException = new ParserException(constructExtendedListenerErrorMessage( 226 + dataModelException.setLine(lineNumber);
229 - UNHANDLED_PARSED_DATA, LENGTH_DATA, rangeArgument, ENTRY, e.getMessage())); 227 + dataModelException.setCharPosition(charPositionInLine);
230 - parserException.setLine(lineNumber); 228 + throw dataModelException;
231 - parserException.setCharPosition(charPositionInLine);
232 - throw parserException;
233 } 229 }
234 } 230 }
235 return lengthRestriction; 231 return lengthRestriction;
...@@ -252,4 +248,21 @@ public final class RestrictionResolver { ...@@ -252,4 +248,21 @@ public final class RestrictionResolver {
252 || dataType == UINT64 248 || dataType == UINT64
253 || dataType == DECIMAL64); 249 || dataType == DECIMAL64);
254 } 250 }
251 +
252 + /**
253 + * Removes doubles quotes and concatenates if string has plus symbol.
254 + *
255 + * @param yangStringData string from yang file
256 + * @return concatenated string after removing double quotes
257 + */
258 + private static String removeQuotesAndHandleConcat(String yangStringData) {
259 +
260 + yangStringData = yangStringData.replace("\"", EMPTY_STRING);
261 + String[] tmpData = yangStringData.split(Pattern.quote(ADD));
262 + StringBuilder builder = new StringBuilder();
263 + for (String yangString : tmpData) {
264 + builder.append(yangString);
265 + }
266 + return builder.toString();
267 + }
255 } 268 }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.yangutils.utils.builtindatatype; 16 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
17 17
18 import org.onosproject.yangutils.datamodel.YangDataTypes; 18 import org.onosproject.yangutils.datamodel.YangDataTypes;
19 19
...@@ -34,8 +34,8 @@ public final class BuiltInTypeObjectFactory { ...@@ -34,8 +34,8 @@ public final class BuiltInTypeObjectFactory {
34 * 34 *
35 * @param valueInStr value represented in string 35 * @param valueInStr value represented in string
36 * @param builtInType built in data type 36 * @param builtInType built in data type
37 - * @return the target data type object with the value initialized
38 * @param <T> the data type of the target object 37 * @param <T> the data type of the target object
38 + * @return the target data type object with the value initialized
39 */ 39 */
40 public static <T extends YangBuiltInDataTypeInfo<?>> T getDataObjectFromString(String valueInStr, 40 public static <T extends YangBuiltInDataTypeInfo<?>> T getDataObjectFromString(String valueInStr,
41 YangDataTypes builtInType) { 41 YangDataTypes builtInType) {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 /** 19 /**
20 * Base class for exceptions in data type. 20 * Base class for exceptions in data type.
......
...@@ -14,10 +14,9 @@ ...@@ -14,10 +14,9 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import java.util.Objects; 19 import java.util.Objects;
20 -
21 import com.google.common.base.MoreObjects; 20 import com.google.common.base.MoreObjects;
22 21
23 /** 22 /**
......
...@@ -14,10 +14,9 @@ ...@@ -14,10 +14,9 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import java.util.Objects; 19 import java.util.Objects;
20 -
21 import com.google.common.base.MoreObjects; 20 import com.google.common.base.MoreObjects;
22 21
23 /** 22 /**
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.yangutils.utils.builtindatatype; 16 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
17 17
18 import org.onosproject.yangutils.datamodel.YangDataTypes; 18 import org.onosproject.yangutils.datamodel.YangDataTypes;
19 19
......
...@@ -14,10 +14,9 @@ ...@@ -14,10 +14,9 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import java.util.Objects; 19 import java.util.Objects;
20 -
21 import com.google.common.base.MoreObjects; 20 import com.google.common.base.MoreObjects;
22 21
23 /** 22 /**
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
20 20
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
20 20
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
20 20
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
20 20
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
20 20
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
20 20
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import java.math.BigInteger; 19 import java.math.BigInteger;
20 import java.util.regex.Pattern; 20 import java.util.regex.Pattern;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.utils.builtindatatype; 17 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
18 18
19 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
20 20
......
...@@ -17,4 +17,4 @@ ...@@ -17,4 +17,4 @@
17 /** 17 /**
18 * Utilities for YANG built in data types. 18 * Utilities for YANG built in data types.
19 */ 19 */
20 -package org.onosproject.yangutils.utils.builtindatatype; 20 +package org.onosproject.yangutils.datamodel.utils.builtindatatype;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
16 16
17 package org.onosproject.yangutils.linker; 17 package org.onosproject.yangutils.linker;
18 18
19 -import org.onosproject.yangutils.linker.exceptions.LinkerException; 19 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 20
21 /** 21 /**
22 * Abstraction of YANG resolvable information. Abstracted to obtain the 22 * Abstraction of YANG resolvable information. Abstracted to obtain the
...@@ -47,8 +47,8 @@ public interface Resolvable { ...@@ -47,8 +47,8 @@ public interface Resolvable {
47 /** 47 /**
48 * Resolves the linking. 48 * Resolves the linking.
49 * 49 *
50 - * @throws LinkerException linker error 50 + * @throws DataModelException data model exception
51 */ 51 */
52 void resolve() 52 void resolve()
53 - throws LinkerException; 53 + throws DataModelException;
54 } 54 }
......
...@@ -15,17 +15,18 @@ ...@@ -15,17 +15,18 @@
15 */ 15 */
16 package org.onosproject.yangutils.linker.impl; 16 package org.onosproject.yangutils.linker.impl;
17 17
18 +import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo;
18 import org.onosproject.yangutils.datamodel.YangNode; 19 import org.onosproject.yangutils.datamodel.YangNode;
19 import org.onosproject.yangutils.datamodel.YangType; 20 import org.onosproject.yangutils.datamodel.YangType;
20 import org.onosproject.yangutils.datamodel.YangUses; 21 import org.onosproject.yangutils.datamodel.YangUses;
21 import org.onosproject.yangutils.linker.exceptions.LinkerException; 22 import org.onosproject.yangutils.linker.exceptions.LinkerException;
22 23
23 /** 24 /**
24 - * Represents information about entity being resolved. 25 + * Represents implementation of information about entity being resolved.
25 * 26 *
26 * @param <T> type of entity being resolved, uses / grouping 27 * @param <T> type of entity being resolved, uses / grouping
27 */ 28 */
28 -public class YangEntityToResolveInfo<T> { 29 +public class YangEntityToResolveInfoImpl<T> implements YangEntityToResolveInfo<T> {
29 30
30 // Parsable node for which resolution is to be performed. 31 // Parsable node for which resolution is to be performed.
31 private T entityToResolve; 32 private T entityToResolve;
...@@ -33,39 +34,22 @@ public class YangEntityToResolveInfo<T> { ...@@ -33,39 +34,22 @@ public class YangEntityToResolveInfo<T> {
33 // Holder of the YANG construct for which resolution has to be carried out. 34 // Holder of the YANG construct for which resolution has to be carried out.
34 private YangNode holderOfEntityToResolve; 35 private YangNode holderOfEntityToResolve;
35 36
36 - /** 37 + @Override
37 - * Retrieves the entity to be resolved.
38 - *
39 - * @return entity to be resolved
40 - */
41 public T getEntityToResolve() { 38 public T getEntityToResolve() {
42 return entityToResolve; 39 return entityToResolve;
43 } 40 }
44 41
45 - /** 42 + @Override
46 - * Sets entity to be resolved.
47 - *
48 - * @param entityToResolve entity to be resolved
49 - */
50 public void setEntityToResolve(T entityToResolve) { 43 public void setEntityToResolve(T entityToResolve) {
51 this.entityToResolve = entityToResolve; 44 this.entityToResolve = entityToResolve;
52 } 45 }
53 46
54 - /** 47 + @Override
55 - * Retrieves the parent node which contains the entity to be resolved.
56 - *
57 - * @return parent node which contains the entity to be resolved
58 - */
59 public YangNode getHolderOfEntityToResolve() { 48 public YangNode getHolderOfEntityToResolve() {
60 return holderOfEntityToResolve; 49 return holderOfEntityToResolve;
61 } 50 }
62 51
63 - /** 52 + @Override
64 - * Sets parent node which contains the entity to be resolved.
65 - *
66 - * @param holderOfEntityToResolve parent node which contains the entity to
67 - * be resolved
68 - */
69 public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) { 53 public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) {
70 this.holderOfEntityToResolve = holderOfEntityToResolve; 54 this.holderOfEntityToResolve = holderOfEntityToResolve;
71 } 55 }
......
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
16 16
17 package org.onosproject.yangutils.linker.impl; 17 package org.onosproject.yangutils.linker.impl;
18 18
19 +import java.util.HashSet;
19 import java.util.Set; 20 import java.util.Set;
20 - 21 +import org.onosproject.yangutils.datamodel.ResolvableType;
21 import org.onosproject.yangutils.datamodel.YangNode; 22 import org.onosproject.yangutils.datamodel.YangNode;
23 +import org.onosproject.yangutils.datamodel.YangReferenceResolver;
22 import org.onosproject.yangutils.datamodel.YangSubModule; 24 import org.onosproject.yangutils.datamodel.YangSubModule;
23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 25 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 -import org.onosproject.yangutils.linker.ResolvableType;
25 import org.onosproject.yangutils.linker.YangLinker; 26 import org.onosproject.yangutils.linker.YangLinker;
26 -import org.onosproject.yangutils.linker.YangReferenceResolver;
27 import org.onosproject.yangutils.linker.exceptions.LinkerException; 27 import org.onosproject.yangutils.linker.exceptions.LinkerException;
28 import org.onosproject.yangutils.plugin.manager.YangFileInfo; 28 import org.onosproject.yangutils.plugin.manager.YangFileInfo;
29 29
...@@ -34,9 +34,39 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; ...@@ -34,9 +34,39 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
34 */ 34 */
35 public class YangLinkerManager 35 public class YangLinkerManager
36 implements YangLinker { 36 implements YangLinker {
37 +
38 + /*
39 + * Set of all the YANG nodes, corresponding to the YANG files parsed by
40 + * parser.
41 + */
42 + Set<YangNode> yangNodeSet = new HashSet<>();
43 +
44 + /**
45 + * Returns set of YANG node.
46 + *
47 + * @return set of YANG node
48 + */
49 + public Set<YangNode> getYangNodeSet() {
50 + return yangNodeSet;
51 + }
52 +
53 + /**
54 + * Creates YANG nodes set.
55 + *
56 + * @param yangFileInfoSet YANG file information set
57 + */
58 + public void createYangNodeSet(Set<YangFileInfo> yangFileInfoSet) {
59 + for (YangFileInfo yangFileInfo : yangFileInfoSet) {
60 + getYangNodeSet().add(yangFileInfo.getRootNode());
61 + }
62 + }
63 +
37 @Override 64 @Override
38 public void resolveDependencies(Set<YangFileInfo> yangFileInfoSet) { 65 public void resolveDependencies(Set<YangFileInfo> yangFileInfoSet) {
39 66
67 + // Create YANG node set.
68 + createYangNodeSet(yangFileInfoSet);
69 +
40 // Carry out linking of sub module with module. 70 // Carry out linking of sub module with module.
41 linkSubModulesToParentModule(yangFileInfoSet); 71 linkSubModulesToParentModule(yangFileInfoSet);
42 72
...@@ -64,7 +94,7 @@ public class YangLinkerManager ...@@ -64,7 +94,7 @@ public class YangLinkerManager
64 YangNode yangNode = yangFileInfo.getRootNode(); 94 YangNode yangNode = yangFileInfo.getRootNode();
65 if (yangNode instanceof YangSubModule) { 95 if (yangNode instanceof YangSubModule) {
66 try { 96 try {
67 - ((YangSubModule) yangNode).linkWithModule(yangFileInfoSet); 97 + ((YangSubModule) yangNode).linkWithModule(getYangNodeSet());
68 } catch (DataModelException e) { 98 } catch (DataModelException e) {
69 String errorInfo = "YANG file error: " + yangFileInfo.getYangFileName() + " at line: " 99 String errorInfo = "YANG file error: " + yangFileInfo.getYangFileName() + " at line: "
70 + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE 100 + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
...@@ -85,7 +115,14 @@ public class YangLinkerManager ...@@ -85,7 +115,14 @@ public class YangLinkerManager
85 for (YangFileInfo yangFileInfo : yangFileInfoSet) { 115 for (YangFileInfo yangFileInfo : yangFileInfoSet) {
86 YangNode yangNode = yangFileInfo.getRootNode(); 116 YangNode yangNode = yangFileInfo.getRootNode();
87 if (yangNode instanceof YangReferenceResolver) { 117 if (yangNode instanceof YangReferenceResolver) {
88 - ((YangReferenceResolver) yangNode).addReferencesToImportList(yangFileInfoSet); 118 + try {
119 + ((YangReferenceResolver) yangNode).addReferencesToImportList(getYangNodeSet());
120 + } catch (DataModelException e) {
121 + String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: "
122 + + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
123 + + e.getMessage();
124 + throw new LinkerException(errorInfo);
125 + }
89 } 126 }
90 } 127 }
91 } 128 }
...@@ -100,7 +137,14 @@ public class YangLinkerManager ...@@ -100,7 +137,14 @@ public class YangLinkerManager
100 for (YangFileInfo yangFileInfo : yangFileInfoSet) { 137 for (YangFileInfo yangFileInfo : yangFileInfoSet) {
101 YangNode yangNode = yangFileInfo.getRootNode(); 138 YangNode yangNode = yangFileInfo.getRootNode();
102 if (yangNode instanceof YangReferenceResolver) { 139 if (yangNode instanceof YangReferenceResolver) {
103 - ((YangReferenceResolver) yangNode).addReferencesToIncludeList(yangFileInfoSet); 140 + try {
141 + ((YangReferenceResolver) yangNode).addReferencesToIncludeList(getYangNodeSet());
142 + } catch (DataModelException e) {
143 + String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: "
144 + + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE
145 + + e.getMessage();
146 + throw new LinkerException(errorInfo);
147 + }
104 } 148 }
105 } 149 }
106 } 150 }
......
...@@ -17,14 +17,14 @@ ...@@ -17,14 +17,14 @@
17 package org.onosproject.yangutils.linker.impl; 17 package org.onosproject.yangutils.linker.impl;
18 18
19 import java.util.Stack; 19 import java.util.Stack;
20 -
21 -import org.onosproject.yangutils.datamodel.LocationInfo;
22 import org.onosproject.yangutils.datamodel.YangDataTypes; 20 import org.onosproject.yangutils.datamodel.YangDataTypes;
23 import org.onosproject.yangutils.datamodel.YangDerivedInfo; 21 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
24 import org.onosproject.yangutils.datamodel.YangGrouping; 22 import org.onosproject.yangutils.datamodel.YangGrouping;
25 import org.onosproject.yangutils.datamodel.YangImport; 23 import org.onosproject.yangutils.datamodel.YangImport;
26 import org.onosproject.yangutils.datamodel.YangInclude; 24 import org.onosproject.yangutils.datamodel.YangInclude;
27 import org.onosproject.yangutils.datamodel.YangNode; 25 import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangReferenceResolver;
27 +import org.onosproject.yangutils.datamodel.YangResolutionInfo;
28 import org.onosproject.yangutils.datamodel.YangType; 28 import org.onosproject.yangutils.datamodel.YangType;
29 import org.onosproject.yangutils.datamodel.YangTypeDef; 29 import org.onosproject.yangutils.datamodel.YangTypeDef;
30 import org.onosproject.yangutils.datamodel.YangUses; 30 import org.onosproject.yangutils.datamodel.YangUses;
...@@ -32,7 +32,6 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; ...@@ -32,7 +32,6 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
32 import org.onosproject.yangutils.linker.Resolvable; 32 import org.onosproject.yangutils.linker.Resolvable;
33 import org.onosproject.yangutils.linker.ResolvableStatus; 33 import org.onosproject.yangutils.linker.ResolvableStatus;
34 import org.onosproject.yangutils.linker.YangLinkingPhase; 34 import org.onosproject.yangutils.linker.YangLinkingPhase;
35 -import org.onosproject.yangutils.linker.YangReferenceResolver;
36 35
37 import static org.onosproject.yangutils.linker.ResolvableStatus.INTER_FILE_LINKED; 36 import static org.onosproject.yangutils.linker.ResolvableStatus.INTER_FILE_LINKED;
38 import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED; 37 import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
...@@ -41,21 +40,22 @@ import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED; ...@@ -41,21 +40,22 @@ import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
41 import static org.onosproject.yangutils.linker.ResolvableStatus.UNRESOLVED; 40 import static org.onosproject.yangutils.linker.ResolvableStatus.UNRESOLVED;
42 import static org.onosproject.yangutils.linker.YangLinkingPhase.INTER_FILE; 41 import static org.onosproject.yangutils.linker.YangLinkingPhase.INTER_FILE;
43 import static org.onosproject.yangutils.linker.YangLinkingPhase.INTRA_FILE; 42 import static org.onosproject.yangutils.linker.YangLinkingPhase.INTRA_FILE;
44 -import static org.onosproject.yangutils.utils.UtilConstants.TYPEDEF_LINKER_ERROR;
45 import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR; 43 import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR;
44 +import static org.onosproject.yangutils.utils.UtilConstants.TYPEDEF_LINKER_ERROR;
46 45
47 /** 46 /**
48 - * Represents resolution object which will be resolved by linker. 47 + * Represents implementation of resolution object which will be resolved by
48 + * linker.
49 * 49 *
50 * @param <T> type of resolution entity uses / type 50 * @param <T> type of resolution entity uses / type
51 */ 51 */
52 -public class YangResolutionInfo<T> 52 +public class YangResolutionInfoImpl<T>
53 - implements LocationInfo { 53 + implements YangResolutionInfo<T> {
54 54
55 /** 55 /**
56 * Information about the entity that needs to be resolved. 56 * Information about the entity that needs to be resolved.
57 */ 57 */
58 - private YangEntityToResolveInfo<T> entityToResolveInfo; 58 + private YangEntityToResolveInfoImpl<T> entityToResolveInfo;
59 59
60 /** 60 /**
61 * Error line number. 61 * Error line number.
...@@ -77,14 +77,14 @@ public class YangResolutionInfo<T> ...@@ -77,14 +77,14 @@ public class YangResolutionInfo<T>
77 * Stack for type/uses is maintained for hierarchical references, this is 77 * Stack for type/uses is maintained for hierarchical references, this is
78 * used during resolution. 78 * used during resolution.
79 */ 79 */
80 - private Stack<YangEntityToResolveInfo<T>> partialResolvedStack; 80 + private Stack<YangEntityToResolveInfoImpl<T>> partialResolvedStack;
81 81
82 /** 82 /**
83 * It is private to ensure the overloaded method be invoked to create an 83 * It is private to ensure the overloaded method be invoked to create an
84 * object. 84 * object.
85 */ 85 */
86 @SuppressWarnings("unused") 86 @SuppressWarnings("unused")
87 - private YangResolutionInfo() { 87 + private YangResolutionInfoImpl() {
88 88
89 } 89 }
90 90
...@@ -96,8 +96,8 @@ public class YangResolutionInfo<T> ...@@ -96,8 +96,8 @@ public class YangResolutionInfo<T>
96 * @param lineNumber error line number 96 * @param lineNumber error line number
97 * @param charPositionInLine error character position in line 97 * @param charPositionInLine error character position in line
98 */ 98 */
99 - public YangResolutionInfo(T dataNode, YangNode holderNode, int lineNumber, int charPositionInLine) { 99 + public YangResolutionInfoImpl(T dataNode, YangNode holderNode, int lineNumber, int charPositionInLine) {
100 - setEntityToResolveInfo(new YangEntityToResolveInfo<>()); 100 + setEntityToResolveInfo(new YangEntityToResolveInfoImpl<>());
101 getEntityToResolveInfo().setEntityToResolve(dataNode); 101 getEntityToResolveInfo().setEntityToResolve(dataNode);
102 getEntityToResolveInfo().setHolderOfEntityToResolve(holderNode); 102 getEntityToResolveInfo().setHolderOfEntityToResolve(holderNode);
103 this.setLineNumber(lineNumber); 103 this.setLineNumber(lineNumber);
...@@ -105,13 +105,7 @@ public class YangResolutionInfo<T> ...@@ -105,13 +105,7 @@ public class YangResolutionInfo<T>
105 setPartialResolvedStack(new Stack<>()); 105 setPartialResolvedStack(new Stack<>());
106 } 106 }
107 107
108 - /** 108 + @Override
109 - * Resolves linking with all the ancestors node for a resolution info.
110 - *
111 - * @param dataModelRootNode module/sub-module node
112 - * @throws DataModelException DataModelException a violation of data model
113 - * rules
114 - */
115 public void resolveLinkingForResolutionInfo(YangReferenceResolver dataModelRootNode) 109 public void resolveLinkingForResolutionInfo(YangReferenceResolver dataModelRootNode)
116 throws DataModelException { 110 throws DataModelException {
117 111
...@@ -431,11 +425,12 @@ public class YangResolutionInfo<T> ...@@ -431,11 +425,12 @@ public class YangResolutionInfo<T>
431 if (((YangTypeDef) referredNode).getTypeDefBaseType().getDataType() 425 if (((YangTypeDef) referredNode).getTypeDefBaseType().getDataType()
432 == YangDataTypes.DERIVED) { 426 == YangDataTypes.DERIVED) {
433 427
434 - YangEntityToResolveInfo<YangType<?>> unResolvedEntityInfo = new YangEntityToResolveInfo<>(); 428 + YangEntityToResolveInfoImpl<YangType<?>> unResolvedEntityInfo
429 + = new YangEntityToResolveInfoImpl<>();
435 unResolvedEntityInfo.setEntityToResolve(((YangTypeDef) referredNode) 430 unResolvedEntityInfo.setEntityToResolve(((YangTypeDef) referredNode)
436 .getTypeDefBaseType()); 431 .getTypeDefBaseType());
437 unResolvedEntityInfo.setHolderOfEntityToResolve(referredNode); 432 unResolvedEntityInfo.setHolderOfEntityToResolve(referredNode);
438 - addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo); 433 + addInPartialResolvedStack((YangEntityToResolveInfoImpl<T>) unResolvedEntityInfo);
439 } 434 }
440 435
441 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) { 436 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
...@@ -462,10 +457,10 @@ public class YangResolutionInfo<T> ...@@ -462,10 +457,10 @@ public class YangResolutionInfo<T>
462 YangNode curNode = node.getChild(); 457 YangNode curNode = node.getChild();
463 while (curNode != null) { 458 while (curNode != null) {
464 if (curNode instanceof YangUses) { 459 if (curNode instanceof YangUses) {
465 - YangEntityToResolveInfo<YangUses> unResolvedEntityInfo = new YangEntityToResolveInfo<>(); 460 + YangEntityToResolveInfoImpl<YangUses> unResolvedEntityInfo = new YangEntityToResolveInfoImpl<>();
466 unResolvedEntityInfo.setEntityToResolve((YangUses) curNode); 461 unResolvedEntityInfo.setEntityToResolve((YangUses) curNode);
467 unResolvedEntityInfo.setHolderOfEntityToResolve(node); 462 unResolvedEntityInfo.setHolderOfEntityToResolve(node);
468 - addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo); 463 + addInPartialResolvedStack((YangEntityToResolveInfoImpl<T>) unResolvedEntityInfo);
469 464
470 } 465 }
471 curNode = curNode.getNextSibling(); 466 curNode = curNode.getNextSibling();
...@@ -478,7 +473,7 @@ public class YangResolutionInfo<T> ...@@ -478,7 +473,7 @@ public class YangResolutionInfo<T>
478 * 473 *
479 * @return partial resolved YANG construct stack 474 * @return partial resolved YANG construct stack
480 */ 475 */
481 - private Stack<YangEntityToResolveInfo<T>> getPartialResolvedStack() { 476 + private Stack<YangEntityToResolveInfoImpl<T>> getPartialResolvedStack() {
482 return partialResolvedStack; 477 return partialResolvedStack;
483 } 478 }
484 479
...@@ -487,7 +482,7 @@ public class YangResolutionInfo<T> ...@@ -487,7 +482,7 @@ public class YangResolutionInfo<T>
487 * 482 *
488 * @param partialResolvedStack partial resolved YANG construct stack 483 * @param partialResolvedStack partial resolved YANG construct stack
489 */ 484 */
490 - private void setPartialResolvedStack(Stack<YangEntityToResolveInfo<T>> partialResolvedStack) { 485 + private void setPartialResolvedStack(Stack<YangEntityToResolveInfoImpl<T>> partialResolvedStack) {
491 this.partialResolvedStack = partialResolvedStack; 486 this.partialResolvedStack = partialResolvedStack;
492 } 487 }
493 488
...@@ -496,7 +491,7 @@ public class YangResolutionInfo<T> ...@@ -496,7 +491,7 @@ public class YangResolutionInfo<T>
496 * 491 *
497 * @param partialResolvedInfo partial resolved YANG construct stack 492 * @param partialResolvedInfo partial resolved YANG construct stack
498 */ 493 */
499 - private void addInPartialResolvedStack(YangEntityToResolveInfo<T> partialResolvedInfo) { 494 + private void addInPartialResolvedStack(YangEntityToResolveInfoImpl<T> partialResolvedInfo) {
500 getPartialResolvedStack().push(partialResolvedInfo); 495 getPartialResolvedStack().push(partialResolvedInfo);
501 } 496 }
502 497
...@@ -510,12 +505,8 @@ public class YangResolutionInfo<T> ...@@ -510,12 +505,8 @@ public class YangResolutionInfo<T>
510 return getPartialResolvedStack().peek().getEntityToResolve(); 505 return getPartialResolvedStack().peek().getEntityToResolve();
511 } 506 }
512 507
513 - /** 508 + @Override
514 - * Retrieves information about the entity that needs to be resolved. 509 + public YangEntityToResolveInfoImpl<T> getEntityToResolveInfo() {
515 - *
516 - * @return information about the entity that needs to be resolved
517 - */
518 - public YangEntityToResolveInfo<T> getEntityToResolveInfo() {
519 return entityToResolveInfo; 510 return entityToResolveInfo;
520 } 511 }
521 512
...@@ -525,7 +516,7 @@ public class YangResolutionInfo<T> ...@@ -525,7 +516,7 @@ public class YangResolutionInfo<T>
525 * @param entityToResolveInfo information about the entity that needs to be 516 * @param entityToResolveInfo information about the entity that needs to be
526 * resolved 517 * resolved
527 */ 518 */
528 - private void setEntityToResolveInfo(YangEntityToResolveInfo<T> entityToResolveInfo) { 519 + private void setEntityToResolveInfo(YangEntityToResolveInfoImpl<T> entityToResolveInfo) {
529 this.entityToResolveInfo = entityToResolveInfo; 520 this.entityToResolveInfo = entityToResolveInfo;
530 } 521 }
531 522
...@@ -569,13 +560,7 @@ public class YangResolutionInfo<T> ...@@ -569,13 +560,7 @@ public class YangResolutionInfo<T>
569 this.curReferenceResolver = curReferenceResolver; 560 this.curReferenceResolver = curReferenceResolver;
570 } 561 }
571 562
572 - /** 563 + @Override
573 - * Performs inter file linking of uses/type referring to typedef/grouping
574 - * of other YANG file.
575 - *
576 - * @param dataModelRootNode module/sub-module node
577 - * @throws DataModelException a violation in data model rule
578 - */
579 public void linkInterFile(YangReferenceResolver dataModelRootNode) 564 public void linkInterFile(YangReferenceResolver dataModelRootNode)
580 throws DataModelException { 565 throws DataModelException {
581 566
......
...@@ -20,6 +20,7 @@ import org.onosproject.yangutils.datamodel.YangDerivedInfo; ...@@ -20,6 +20,7 @@ import org.onosproject.yangutils.datamodel.YangDerivedInfo;
20 import org.onosproject.yangutils.datamodel.YangRangeRestriction; 20 import org.onosproject.yangutils.datamodel.YangRangeRestriction;
21 import org.onosproject.yangutils.datamodel.YangStringRestriction; 21 import org.onosproject.yangutils.datamodel.YangStringRestriction;
22 import org.onosproject.yangutils.datamodel.YangType; 22 import org.onosproject.yangutils.datamodel.YangType;
23 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 import org.onosproject.yangutils.parser.Parsable; 24 import org.onosproject.yangutils.parser.Parsable;
24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 25 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
25 import org.onosproject.yangutils.parser.exceptions.ParserException; 26 import org.onosproject.yangutils.parser.exceptions.ParserException;
...@@ -29,6 +30,7 @@ import org.onosproject.yangutils.utils.YangConstructType; ...@@ -29,6 +30,7 @@ import org.onosproject.yangutils.utils.YangConstructType;
29 import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY; 30 import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY;
30 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 31 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
31 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; 32 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
33 +import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processLengthRestriction;
32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
...@@ -36,7 +38,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp ...@@ -36,7 +38,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; 38 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
37 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
38 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 40 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
39 -import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction;
40 import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA; 41 import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA;
41 import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA; 42 import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
42 43
...@@ -125,8 +126,16 @@ public final class LengthRestrictionListener { ...@@ -125,8 +126,16 @@ public final class LengthRestrictionListener {
125 throw parserException; 126 throw parserException;
126 } 127 }
127 128
128 - YangRangeRestriction lengthRestriction = processLengthRestriction(null, ctx.getStart().getLine(), 129 + YangRangeRestriction lengthRestriction = null;
130 + try {
131 + lengthRestriction = processLengthRestriction(null, ctx.getStart().getLine(),
129 ctx.getStart().getCharPositionInLine(), false, ctx.length().getText()); 132 ctx.getStart().getCharPositionInLine(), false, ctx.length().getText());
133 + } catch (DataModelException e) {
134 + ParserException parserException = new ParserException(e.getMessage());
135 + parserException.setCharPosition(e.getCharPositionInLine());
136 + parserException.setLine(e.getLineNumber());
137 + throw parserException;
138 + }
130 139
131 if (type.getDataType() == STRING) { 140 if (type.getDataType() == STRING) {
132 YangStringRestriction stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo(); 141 YangStringRestriction stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo();
......
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
16 16
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 +import org.onosproject.yangutils.datamodel.ResolvableType;
19 import org.onosproject.yangutils.datamodel.YangModule; 20 import org.onosproject.yangutils.datamodel.YangModule;
21 +import org.onosproject.yangutils.datamodel.YangReferenceResolver;
20 import org.onosproject.yangutils.datamodel.YangRevision; 22 import org.onosproject.yangutils.datamodel.YangRevision;
21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 -import org.onosproject.yangutils.linker.ResolvableType; 24 +import org.onosproject.yangutils.linker.exceptions.LinkerException;
23 -import org.onosproject.yangutils.linker.YangReferenceResolver;
24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 25 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
25 import org.onosproject.yangutils.parser.exceptions.ParserException; 26 import org.onosproject.yangutils.parser.exceptions.ParserException;
26 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 27 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
...@@ -29,8 +30,7 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G ...@@ -29,8 +30,7 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G
29 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangModuleNode; 30 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangModuleNode;
30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
32 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction 33 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
33 - .constructListenerErrorMessage;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; 35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
...@@ -123,10 +123,10 @@ public final class ModuleListener { ...@@ -123,10 +123,10 @@ public final class ModuleListener {
123 ((YangReferenceResolver) listener.getParsedDataStack() 123 ((YangReferenceResolver) listener.getParsedDataStack()
124 .peek()).resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); 124 .peek()).resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
125 } catch (DataModelException e) { 125 } catch (DataModelException e) {
126 - ParserException parserException = new ParserException(e.getMessage()); 126 + LinkerException linkerException = new LinkerException(e.getMessage());
127 - parserException.setLine(e.getLineNumber()); 127 + linkerException.setLine(e.getLineNumber());
128 - parserException.setCharPosition(e.getCharPositionInLine()); 128 + linkerException.setCharPosition(e.getCharPositionInLine());
129 - throw parserException; 129 + throw linkerException;
130 } 130 }
131 } 131 }
132 } 132 }
......
...@@ -19,12 +19,15 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -19,12 +19,15 @@ package org.onosproject.yangutils.parser.impl.listeners;
19 import org.onosproject.yangutils.datamodel.YangDerivedInfo; 19 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
20 import org.onosproject.yangutils.datamodel.YangRangeRestriction; 20 import org.onosproject.yangutils.datamodel.YangRangeRestriction;
21 import org.onosproject.yangutils.datamodel.YangType; 21 import org.onosproject.yangutils.datamodel.YangType;
22 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 import org.onosproject.yangutils.parser.Parsable; 23 import org.onosproject.yangutils.parser.Parsable;
23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
24 import org.onosproject.yangutils.parser.exceptions.ParserException; 25 import org.onosproject.yangutils.parser.exceptions.ParserException;
25 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 26 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
26 27
27 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 28 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
29 +import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.isOfRangeRestrictedType;
30 +import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processRangeRestriction;
28 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
29 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
...@@ -32,8 +35,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp ...@@ -32,8 +35,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; 35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 37 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
35 -import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType;
36 -import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRestriction;
37 import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA; 38 import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA;
38 import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA; 39 import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
39 40
...@@ -119,8 +120,16 @@ public final class RangeRestrictionListener { ...@@ -119,8 +120,16 @@ public final class RangeRestrictionListener {
119 throw parserException; 120 throw parserException;
120 } 121 }
121 122
122 - YangRangeRestriction rangeRestriction = processRangeRestriction(null, ctx.getStart().getLine(), 123 + YangRangeRestriction rangeRestriction = null;
124 + try {
125 + rangeRestriction = processRangeRestriction(null, ctx.getStart().getLine(),
123 ctx.getStart().getCharPositionInLine(), false, ctx.range().getText(), type.getDataType()); 126 ctx.getStart().getCharPositionInLine(), false, ctx.range().getText(), type.getDataType());
127 + } catch (DataModelException e) {
128 + ParserException parserException = new ParserException(e.getMessage());
129 + parserException.setCharPosition(e.getCharPositionInLine());
130 + parserException.setLine(e.getLineNumber());
131 + throw parserException;
132 + }
124 133
125 if (rangeRestriction != null) { 134 if (rangeRestriction != null) {
126 type.setDataTypeExtendedInfo(rangeRestriction); 135 type.setDataTypeExtendedInfo(rangeRestriction);
......
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
16 16
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 +import org.onosproject.yangutils.datamodel.ResolvableType;
20 +import org.onosproject.yangutils.datamodel.YangReferenceResolver;
19 import org.onosproject.yangutils.datamodel.YangRevision; 21 import org.onosproject.yangutils.datamodel.YangRevision;
20 import org.onosproject.yangutils.datamodel.YangSubModule; 22 import org.onosproject.yangutils.datamodel.YangSubModule;
21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 -import org.onosproject.yangutils.linker.ResolvableType; 24 +import org.onosproject.yangutils.linker.exceptions.LinkerException;
23 -import org.onosproject.yangutils.linker.YangReferenceResolver;
24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 25 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
25 import org.onosproject.yangutils.parser.exceptions.ParserException; 26 import org.onosproject.yangutils.parser.exceptions.ParserException;
26 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 27 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
...@@ -29,8 +30,7 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G ...@@ -29,8 +30,7 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G
29 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangSubModuleNode; 30 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangSubModuleNode;
30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
32 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction 33 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
33 - .constructListenerErrorMessage;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; 35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
...@@ -128,10 +128,10 @@ public final class SubModuleListener { ...@@ -128,10 +128,10 @@ public final class SubModuleListener {
128 ((YangReferenceResolver) listener.getParsedDataStack().peek()) 128 ((YangReferenceResolver) listener.getParsedDataStack().peek())
129 .resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); 129 .resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
130 } catch (DataModelException e) { 130 } catch (DataModelException e) {
131 - ParserException parserException = new ParserException(e.getMessage()); 131 + LinkerException linkerException = new LinkerException(e.getMessage());
132 - parserException.setLine(e.getLineNumber()); 132 + linkerException.setLine(e.getLineNumber());
133 - parserException.setCharPosition(e.getCharPositionInLine()); 133 + linkerException.setCharPosition(e.getCharPositionInLine());
134 - throw parserException; 134 + throw linkerException;
135 } 135 }
136 } 136 }
137 } 137 }
......
...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.datamodel.YangType; ...@@ -26,7 +26,7 @@ import org.onosproject.yangutils.datamodel.YangType;
26 import org.onosproject.yangutils.datamodel.YangTypeDef; 26 import org.onosproject.yangutils.datamodel.YangTypeDef;
27 import org.onosproject.yangutils.datamodel.YangUnion; 27 import org.onosproject.yangutils.datamodel.YangUnion;
28 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 28 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
29 -import org.onosproject.yangutils.linker.impl.YangResolutionInfo; 29 +import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl;
30 import org.onosproject.yangutils.parser.Parsable; 30 import org.onosproject.yangutils.parser.Parsable;
31 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 31 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
32 import org.onosproject.yangutils.parser.exceptions.ParserException; 32 import org.onosproject.yangutils.parser.exceptions.ParserException;
...@@ -131,7 +131,7 @@ public final class TypeListener { ...@@ -131,7 +131,7 @@ public final class TypeListener {
131 type.setResolvableStatus(UNRESOLVED); 131 type.setResolvableStatus(UNRESOLVED);
132 132
133 // Add resolution information to the list 133 // Add resolution information to the list
134 - YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type, 134 + YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangType>(type,
135 (YangNode) parentNodeOfLeaf, errorLine, errorPosition); 135 (YangNode) parentNodeOfLeaf, errorLine, errorPosition);
136 addToResolutionList(resolutionInfo, ctx); 136 addToResolutionList(resolutionInfo, ctx);
137 } 137 }
...@@ -161,8 +161,8 @@ public final class TypeListener { ...@@ -161,8 +161,8 @@ public final class TypeListener {
161 ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); 161 ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
162 162
163 // Add resolution information to the list 163 // Add resolution information to the list
164 - YangResolutionInfo resolutionInfo = 164 + YangResolutionInfoImpl resolutionInfo =
165 - new YangResolutionInfo<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine, 165 + new YangResolutionInfoImpl<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine,
166 errorPosition); 166 errorPosition);
167 addToResolutionList(resolutionInfo, ctx); 167 addToResolutionList(resolutionInfo, ctx);
168 } 168 }
...@@ -191,8 +191,8 @@ public final class TypeListener { ...@@ -191,8 +191,8 @@ public final class TypeListener {
191 type.setResolvableStatus(UNRESOLVED); 191 type.setResolvableStatus(UNRESOLVED);
192 192
193 // Add resolution information to the list 193 // Add resolution information to the list
194 - YangResolutionInfo resolutionInfo = 194 + YangResolutionInfoImpl resolutionInfo =
195 - new YangResolutionInfo<YangType>(type, unionNode, errorLine, errorPosition); 195 + new YangResolutionInfoImpl<YangType>(type, unionNode, errorLine, errorPosition);
196 addToResolutionList(resolutionInfo, ctx); 196 addToResolutionList(resolutionInfo, ctx);
197 } 197 }
198 198
...@@ -214,8 +214,8 @@ public final class TypeListener { ...@@ -214,8 +214,8 @@ public final class TypeListener {
214 type.setResolvableStatus(UNRESOLVED); 214 type.setResolvableStatus(UNRESOLVED);
215 215
216 // Add resolution information to the list 216 // Add resolution information to the list
217 - YangResolutionInfo resolutionInfo = 217 + YangResolutionInfoImpl resolutionInfo =
218 - new YangResolutionInfo<YangType>(type, typeDef, errorLine, errorPosition); 218 + new YangResolutionInfoImpl<YangType>(type, typeDef, errorLine, errorPosition);
219 addToResolutionList(resolutionInfo, ctx); 219 addToResolutionList(resolutionInfo, ctx);
220 } 220 }
221 break; 221 break;
...@@ -256,7 +256,7 @@ public final class TypeListener { ...@@ -256,7 +256,7 @@ public final class TypeListener {
256 * @param resolutionInfo resolution information 256 * @param resolutionInfo resolution information
257 * @param ctx context object of the grammar rule 257 * @param ctx context object of the grammar rule
258 */ 258 */
259 - private static void addToResolutionList(YangResolutionInfo<YangType> resolutionInfo, 259 + private static void addToResolutionList(YangResolutionInfoImpl<YangType> resolutionInfo,
260 GeneratedYangParser.TypeStatementContext ctx) { 260 GeneratedYangParser.TypeStatementContext ctx) {
261 try { 261 try {
262 addResolutionInfo(resolutionInfo); 262 addResolutionInfo(resolutionInfo);
......
...@@ -26,10 +26,10 @@ import org.onosproject.yangutils.datamodel.YangNode; ...@@ -26,10 +26,10 @@ import org.onosproject.yangutils.datamodel.YangNode;
26 import org.onosproject.yangutils.datamodel.YangNodeIdentifier; 26 import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
27 import org.onosproject.yangutils.datamodel.YangNotification; 27 import org.onosproject.yangutils.datamodel.YangNotification;
28 import org.onosproject.yangutils.datamodel.YangOutput; 28 import org.onosproject.yangutils.datamodel.YangOutput;
29 -import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
30 import org.onosproject.yangutils.datamodel.YangSubModule; 29 import org.onosproject.yangutils.datamodel.YangSubModule;
31 import org.onosproject.yangutils.datamodel.YangUses; 30 import org.onosproject.yangutils.datamodel.YangUses;
32 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 31 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
32 +import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl;
33 import org.onosproject.yangutils.parser.Parsable; 33 import org.onosproject.yangutils.parser.Parsable;
34 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 34 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
35 import org.onosproject.yangutils.parser.exceptions.ParserException; 35 import org.onosproject.yangutils.parser.exceptions.ParserException;
...@@ -184,7 +184,7 @@ public final class UsesListener { ...@@ -184,7 +184,7 @@ public final class UsesListener {
184 } 184 }
185 185
186 // Add resolution information to the list 186 // Add resolution information to the list
187 - YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangUses>(uses, 187 + YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangUses>(uses,
188 (YangNode) parentNode, errorLine, 188 (YangNode) parentNode, errorLine,
189 errorPosition); 189 errorPosition);
190 addToResolutionList(resolutionInfo, ctx); 190 addToResolutionList(resolutionInfo, ctx);
...@@ -210,7 +210,7 @@ public final class UsesListener { ...@@ -210,7 +210,7 @@ public final class UsesListener {
210 * @param resolutionInfo resolution information. 210 * @param resolutionInfo resolution information.
211 * @param ctx context object of the grammar rule 211 * @param ctx context object of the grammar rule
212 */ 212 */
213 - private static void addToResolutionList(YangResolutionInfo<YangUses> resolutionInfo, 213 + private static void addToResolutionList(YangResolutionInfoImpl<YangUses> resolutionInfo,
214 GeneratedYangParser.UsesStatementContext ctx) { 214 GeneratedYangParser.UsesStatementContext ctx) {
215 215
216 try { 216 try {
......
...@@ -1098,7 +1098,7 @@ public final class UtilConstants { ...@@ -1098,7 +1098,7 @@ public final class UtilConstants {
1098 /** 1098 /**
1099 * Static attribute for YANG types package. 1099 * Static attribute for YANG types package.
1100 */ 1100 */
1101 - public static final String YANG_TYPES_PKG = "org.onosproject.yangutils.utils.builtindatatype"; 1101 + public static final String YANG_TYPES_PKG = "org.onosproject.yangutils.datamodel.utils.builtindatatype";
1102 1102
1103 /** 1103 /**
1104 * Static attribute for MathContext class. 1104 * Static attribute for MathContext class.
......
...@@ -19,7 +19,6 @@ package org.onosproject.yangutils.linker; ...@@ -19,7 +19,6 @@ package org.onosproject.yangutils.linker;
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.Iterator; 20 import java.util.Iterator;
21 import java.util.ListIterator; 21 import java.util.ListIterator;
22 -
23 import org.apache.maven.plugin.MojoExecutionException; 22 import org.apache.maven.plugin.MojoExecutionException;
24 import org.junit.Test; 23 import org.junit.Test;
25 import org.onosproject.yangutils.datamodel.YangDataTypes; 24 import org.onosproject.yangutils.datamodel.YangDataTypes;
...@@ -71,6 +70,9 @@ public class InterFileLinkingTest { ...@@ -71,6 +70,9 @@ public class InterFileLinkingTest {
71 YangNode refNode = null; 70 YangNode refNode = null;
72 YangNode selfNode = null; 71 YangNode selfNode = null;
73 72
73 + // Create YANG node set
74 + yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
75 +
74 // Add references to import list. 76 // Add references to import list.
75 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); 77 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
76 78
...@@ -137,6 +139,9 @@ public class InterFileLinkingTest { ...@@ -137,6 +139,9 @@ public class InterFileLinkingTest {
137 YangNode refNode = null; 139 YangNode refNode = null;
138 YangNode selfNode = null; 140 YangNode selfNode = null;
139 141
142 + // Create YANG node set
143 + yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
144 +
140 // Add references to import list. 145 // Add references to import list.
141 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); 146 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
142 147
...@@ -211,6 +216,9 @@ public class InterFileLinkingTest { ...@@ -211,6 +216,9 @@ public class InterFileLinkingTest {
211 YangNode refNode = null; 216 YangNode refNode = null;
212 YangNode selfNode = null; 217 YangNode selfNode = null;
213 218
219 + // Create YANG node set
220 + yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
221 +
214 // Carry out linking of sub module with module. 222 // Carry out linking of sub module with module.
215 yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet()); 223 yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet());
216 224
...@@ -280,6 +288,9 @@ public class InterFileLinkingTest { ...@@ -280,6 +288,9 @@ public class InterFileLinkingTest {
280 YangNode refNode = null; 288 YangNode refNode = null;
281 YangNode selfNode = null; 289 YangNode selfNode = null;
282 290
291 + // Create YANG node set
292 + yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
293 +
283 // Carry out linking of sub module with module. 294 // Carry out linking of sub module with module.
284 yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet()); 295 yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet());
285 296
...@@ -357,6 +368,9 @@ public class InterFileLinkingTest { ...@@ -357,6 +368,9 @@ public class InterFileLinkingTest {
357 YangNode refNode = null; 368 YangNode refNode = null;
358 YangNode selfNode = null; 369 YangNode selfNode = null;
359 370
371 + // Create YANG node set
372 + yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
373 +
360 // Add references to import list. 374 // Add references to import list.
361 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); 375 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
362 376
...@@ -423,6 +437,9 @@ public class InterFileLinkingTest { ...@@ -423,6 +437,9 @@ public class InterFileLinkingTest {
423 YangNode refNode = null; 437 YangNode refNode = null;
424 YangNode selfNode = null; 438 YangNode selfNode = null;
425 439
440 + // Create YANG node set
441 + yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
442 +
426 // Add references to import list. 443 // Add references to import list.
427 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); 444 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
428 445
...@@ -490,6 +507,9 @@ public class InterFileLinkingTest { ...@@ -490,6 +507,9 @@ public class InterFileLinkingTest {
490 YangNode refNode2 = null; 507 YangNode refNode2 = null;
491 YangNode selfNode = null; 508 YangNode selfNode = null;
492 509
510 + // Create YANG node set
511 + yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
512 +
493 // Add references to import list. 513 // Add references to import list.
494 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); 514 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
495 515
...@@ -554,6 +574,9 @@ public class InterFileLinkingTest { ...@@ -554,6 +574,9 @@ public class InterFileLinkingTest {
554 YangNode refNode1 = null; 574 YangNode refNode1 = null;
555 YangNode selfNode = null; 575 YangNode selfNode = null;
556 576
577 + // Create YANG node set
578 + yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
579 +
557 // Add references to import list. 580 // Add references to import list.
558 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet()); 581 yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
559 582
......
...@@ -26,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangList; ...@@ -26,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangList;
26 import org.onosproject.yangutils.datamodel.YangModule; 26 import org.onosproject.yangutils.datamodel.YangModule;
27 import org.onosproject.yangutils.datamodel.YangNode; 27 import org.onosproject.yangutils.datamodel.YangNode;
28 import org.onosproject.yangutils.datamodel.YangTypeDef; 28 import org.onosproject.yangutils.datamodel.YangTypeDef;
29 +import org.onosproject.yangutils.linker.exceptions.LinkerException;
29 import org.onosproject.yangutils.parser.exceptions.ParserException; 30 import org.onosproject.yangutils.parser.exceptions.ParserException;
30 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 31 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
31 32
...@@ -33,12 +34,12 @@ import static org.hamcrest.CoreMatchers.nullValue; ...@@ -33,12 +34,12 @@ import static org.hamcrest.CoreMatchers.nullValue;
33 import static org.hamcrest.MatcherAssert.assertThat; 34 import static org.hamcrest.MatcherAssert.assertThat;
34 import static org.hamcrest.core.Is.is; 35 import static org.hamcrest.core.Is.is;
35 import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY; 36 import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY;
36 -import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
37 -import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
38 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 37 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
39 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32; 38 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
40 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; 39 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
41 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; 40 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
41 +import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
42 +import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
42 43
43 /** 44 /**
44 * Test cases for testing "type" intra file linking. 45 * Test cases for testing "type" intra file linking.
...@@ -488,9 +489,9 @@ public class IntraFileTypeLinkingTest { ...@@ -488,9 +489,9 @@ public class IntraFileTypeLinkingTest {
488 * Check self resolution when type referred typedef is not available in 489 * Check self resolution when type referred typedef is not available in
489 * file. 490 * file.
490 */ 491 */
491 - @Test(expected = ParserException.class) 492 + @Test(expected = LinkerException.class)
492 public void processSelfResolutionWhenTypeReferredTypedefNotDefined() 493 public void processSelfResolutionWhenTypeReferredTypedefNotDefined()
493 - throws IOException, ParserException { 494 + throws IOException, LinkerException {
494 495
495 YangNode node = 496 YangNode node =
496 manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang"); 497 manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang");
...@@ -500,9 +501,9 @@ public class IntraFileTypeLinkingTest { ...@@ -500,9 +501,9 @@ public class IntraFileTypeLinkingTest {
500 * Checks self resolution when typedef and leaf using type are at different 501 * Checks self resolution when typedef and leaf using type are at different
501 * level where typedef is is not an ancestor of type. 502 * level where typedef is is not an ancestor of type.
502 */ 503 */
503 - @Test(expected = ParserException.class) 504 + @Test(expected = LinkerException.class)
504 public void processSelfFileLinkingTypedefNotFound() 505 public void processSelfFileLinkingTypedefNotFound()
505 - throws IOException, ParserException { 506 + throws IOException, LinkerException {
506 507
507 YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang"); 508 YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang");
508 } 509 }
...@@ -510,9 +511,9 @@ public class IntraFileTypeLinkingTest { ...@@ -510,9 +511,9 @@ public class IntraFileTypeLinkingTest {
510 /** 511 /**
511 * Checks hierarchical self resolution with self resolution failure scenario. 512 * Checks hierarchical self resolution with self resolution failure scenario.
512 */ 513 */
513 - @Test(expected = ParserException.class) 514 + @Test(expected = LinkerException.class)
514 public void processSelfFileLinkingWithHierarchicalTypeFailureScenario() 515 public void processSelfFileLinkingWithHierarchicalTypeFailureScenario()
515 - throws IOException, ParserException { 516 + throws IOException, LinkerException {
516 517
517 YangNode node = 518 YangNode node =
518 manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang"); 519 manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang");
......
...@@ -19,7 +19,6 @@ package org.onosproject.yangutils.linker; ...@@ -19,7 +19,6 @@ package org.onosproject.yangutils.linker;
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.List; 20 import java.util.List;
21 import java.util.ListIterator; 21 import java.util.ListIterator;
22 -
23 import org.junit.Rule; 22 import org.junit.Rule;
24 import org.junit.Test; 23 import org.junit.Test;
25 import org.junit.rules.ExpectedException; 24 import org.junit.rules.ExpectedException;
...@@ -581,9 +580,9 @@ public class IntraFileUsesLinkingTest { ...@@ -581,9 +580,9 @@ public class IntraFileUsesLinkingTest {
581 */ 580 */
582 @Test 581 @Test
583 public void processSelfResolutionNestedGroupingWithUnresolvedUses() 582 public void processSelfResolutionNestedGroupingWithUnresolvedUses()
584 - throws IOException, ParserException { 583 + throws IOException, LinkerException {
585 584
586 - thrown.expect(ParserException.class); 585 + thrown.expect(LinkerException.class);
587 thrown.expectMessage( 586 thrown.expectMessage(
588 "YANG file error: Unable to find base grouping for given uses"); 587 "YANG file error: Unable to find base grouping for given uses");
589 588
......
...@@ -30,21 +30,21 @@ import org.onosproject.yangutils.datamodel.YangRangeRestriction; ...@@ -30,21 +30,21 @@ import org.onosproject.yangutils.datamodel.YangRangeRestriction;
30 import org.onosproject.yangutils.datamodel.YangStringRestriction; 30 import org.onosproject.yangutils.datamodel.YangStringRestriction;
31 import org.onosproject.yangutils.datamodel.YangTypeDef; 31 import org.onosproject.yangutils.datamodel.YangTypeDef;
32 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 32 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
33 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt32;
34 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
33 import org.onosproject.yangutils.linker.exceptions.LinkerException; 35 import org.onosproject.yangutils.linker.exceptions.LinkerException;
34 import org.onosproject.yangutils.parser.exceptions.ParserException; 36 import org.onosproject.yangutils.parser.exceptions.ParserException;
35 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 37 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
36 -import org.onosproject.yangutils.utils.builtindatatype.YangInt32;
37 -import org.onosproject.yangutils.utils.builtindatatype.YangUint64;
38 38
39 import static org.hamcrest.CoreMatchers.nullValue; 39 import static org.hamcrest.CoreMatchers.nullValue;
40 import static org.hamcrest.MatcherAssert.assertThat; 40 import static org.hamcrest.MatcherAssert.assertThat;
41 import static org.hamcrest.core.Is.is; 41 import static org.hamcrest.core.Is.is;
42 import static org.hamcrest.core.IsNull.notNullValue; 42 import static org.hamcrest.core.IsNull.notNullValue;
43 -import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
44 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 43 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
45 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32; 44 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
46 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; 45 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
47 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; 46 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
47 +import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
48 48
49 /** 49 /**
50 * Test cases for testing restriction resolution. 50 * Test cases for testing restriction resolution.
...@@ -412,7 +412,7 @@ public final class RestrictionResolutionTest { ...@@ -412,7 +412,7 @@ public final class RestrictionResolutionTest {
412 /** 412 /**
413 * Checks range restriction in typedef and not stricter in referred type. 413 * Checks range restriction in typedef and not stricter in referred type.
414 */ 414 */
415 - @Test(expected = ParserException.class) 415 + @Test(expected = LinkerException.class)
416 public void processRangeRestrictionInRefTypeAndTypedefInValid() 416 public void processRangeRestrictionInRefTypeAndTypedefInValid()
417 throws IOException, ParserException, DataModelException { 417 throws IOException, ParserException, DataModelException {
418 YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang"); 418 YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang");
......
...@@ -34,7 +34,7 @@ import org.onosproject.yangutils.datamodel.YangStringRestriction; ...@@ -34,7 +34,7 @@ import org.onosproject.yangutils.datamodel.YangStringRestriction;
34 import org.onosproject.yangutils.datamodel.YangTypeDef; 34 import org.onosproject.yangutils.datamodel.YangTypeDef;
35 import org.onosproject.yangutils.parser.exceptions.ParserException; 35 import org.onosproject.yangutils.parser.exceptions.ParserException;
36 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 36 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
37 -import org.onosproject.yangutils.utils.builtindatatype.YangUint64; 37 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
38 38
39 import static org.hamcrest.MatcherAssert.assertThat; 39 import static org.hamcrest.MatcherAssert.assertThat;
40 import static org.hamcrest.core.Is.is; 40 import static org.hamcrest.core.Is.is;
......
...@@ -31,7 +31,7 @@ import org.onosproject.yangutils.datamodel.YangRangeInterval; ...@@ -31,7 +31,7 @@ import org.onosproject.yangutils.datamodel.YangRangeInterval;
31 import org.onosproject.yangutils.datamodel.YangRangeRestriction; 31 import org.onosproject.yangutils.datamodel.YangRangeRestriction;
32 import org.onosproject.yangutils.parser.exceptions.ParserException; 32 import org.onosproject.yangutils.parser.exceptions.ParserException;
33 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 33 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
34 -import org.onosproject.yangutils.utils.builtindatatype.YangInt32; 34 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt32;
35 35
36 import static org.hamcrest.MatcherAssert.assertThat; 36 import static org.hamcrest.MatcherAssert.assertThat;
37 import static org.hamcrest.core.Is.is; 37 import static org.hamcrest.core.Is.is;
......