Vinod Kumar S

YANG Grouping Linker Support

Change-Id: I2fec0c0bb4d1584e82ffba3228106897ccad2bf5
Showing 40 changed files with 437 additions and 164 deletions
...@@ -26,7 +26,7 @@ public interface Resolvable { ...@@ -26,7 +26,7 @@ public interface Resolvable {
26 * Returns the status of resolution. If completely resolved returns enum 26 * Returns the status of resolution. If completely resolved returns enum
27 * value "RESOLVED", if not returns "UNRESOLVED", in case reference of 27 * value "RESOLVED", if not returns "UNRESOLVED", in case reference of
28 * grouping/typedef is added to uses/type but it's not resolved 28 * grouping/typedef is added to uses/type but it's not resolved
29 - * "PARTIALLY_RESOLVED" is returned. 29 + * "INTRA_FILE_RESOLVED" is returned.
30 * 30 *
31 * @return status of resolution 31 * @return status of resolution
32 */ 32 */
...@@ -36,7 +36,7 @@ public interface Resolvable { ...@@ -36,7 +36,7 @@ public interface Resolvable {
36 * Set the status of type/uses resolution. If completely resolved set enum 36 * Set the status of type/uses resolution. If completely resolved set enum
37 * value "RESOLVED", if not set it to "UNRESOLVED", in case reference of 37 * value "RESOLVED", if not set it to "UNRESOLVED", in case reference of
38 * grouping/typedef is added to uses/type but it's not resolved 38 * grouping/typedef is added to uses/type but it's not resolved
39 - * "PARTIALLY_RESOLVED" should be set. 39 + * "INTRA_FILE_RESOLVED" should be set.
40 * 40 *
41 * @param resolvableStatus status of resolution 41 * @param resolvableStatus status of resolution
42 */ 42 */
......
...@@ -22,17 +22,24 @@ package org.onosproject.yangutils.datamodel; ...@@ -22,17 +22,24 @@ package org.onosproject.yangutils.datamodel;
22 public enum ResolvableStatus { 22 public enum ResolvableStatus {
23 23
24 /** 24 /**
25 - * Identifies that resolvable entity is resolved.
26 - */
27 - RESOLVED,
28 -
29 - /**
30 * Identifies that resolvable entity is unresolved. 25 * Identifies that resolvable entity is unresolved.
31 */ 26 */
32 UNRESOLVED, 27 UNRESOLVED,
33 28
34 /** 29 /**
35 - * Identifies that resolvable entity is partially resolved. 30 + * Identifies that resolvable entity's reference is linked.
31 + */
32 + LINKED,
33 +
34 + /**
35 + * Identifies that resolvable entity is IntraFile resolved (i.e. complete
36 + * linking with in the intra file).
36 */ 37 */
37 - PARTIALLY_RESOLVED; 38 + INTRA_FILE_RESOLVED,
39 +
40 + /**
41 + * Identifies that resolvable entity is resolved.
42 + */
43 + RESOLVED;
44 +
38 } 45 }
......
...@@ -75,6 +75,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -75,6 +75,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
75 * | when | 7.19.5 | 0..1 |-TODO | 75 * | when | 7.19.5 | 0..1 |-TODO |
76 * +--------------+---------+-------------+------------------+ 76 * +--------------+---------+-------------+------------------+
77 */ 77 */
78 +
78 /** 79 /**
79 * Representation of data model node to maintain information defined in YANG augment. 80 * Representation of data model node to maintain information defined in YANG augment.
80 */ 81 */
......
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 +package org.onosproject.yangutils.datamodel;
17 +
18 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
19 +
20 +/**
21 + * Represents information about entity being resolved.
22 + */
23 +public class YangEntityToResolveInfo<T> {
24 +
25 + // Parsable node for which resolution is to be performed.
26 + private T entityToResolve;
27 +
28 + // Holder of the YANG construct for which resolution has to be carried out.
29 + private YangNode holderOfEntityToResolve;
30 +
31 + /**
32 + * Retrieves the entity to be resolved.
33 + *
34 + * @return entity to be resolved
35 + */
36 + public T getEntityToResolve() {
37 + return entityToResolve;
38 + }
39 +
40 + /**
41 + * Sets entity to be resolved.
42 + *
43 + * @param entityToResolve entity to be resolved
44 + */
45 + public void setEntityToResolve(T entityToResolve) {
46 + this.entityToResolve = entityToResolve;
47 + }
48 +
49 + /**
50 + * Retrieves the parent node which contains the entity to be resolved.
51 + *
52 + * @return parent node which contains the entity to be resolved
53 + */
54 + public YangNode getHolderOfEntityToResolve() {
55 + return holderOfEntityToResolve;
56 + }
57 +
58 + /**
59 + * Sets parent node which contains the entity to be resolved.
60 + *
61 + * @param holderOfEntityToResolve parent node which contains the entity to be resolved
62 + */
63 + public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) {
64 + this.holderOfEntityToResolve = holderOfEntityToResolve;
65 + }
66 +
67 +
68 + public String getEntityPrefix()
69 + throws DataModelException {
70 + if (getEntityToResolve() == null) {
71 + return null;
72 + }
73 +
74 + String prefix;
75 + T entityToResolve = (T) getEntityToResolve();
76 + if (entityToResolve instanceof YangType) {
77 + prefix = ((YangType<?>) entityToResolve).getPrefix();
78 + } else if (entityToResolve instanceof YangUses) {
79 + prefix = ((YangUses) entityToResolve).getPrefix();
80 + } else {
81 + throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
82 + }
83 + return prefix;
84 + }
85 +}
...@@ -59,10 +59,12 @@ import org.onosproject.yangutils.utils.YangConstructType; ...@@ -59,10 +59,12 @@ import org.onosproject.yangutils.utils.YangConstructType;
59 * | revision-date | 7.1.5.1 | 0..1 | string | 59 * | revision-date | 7.1.5.1 | 0..1 | string |
60 * +---------------+---------+-------------+------------------+ 60 * +---------------+---------+-------------+------------------+
61 */ 61 */
62 +
62 /** 63 /**
63 * Represents the information about the imported modules. 64 * Represents the information about the imported modules.
64 */ 65 */
65 -public class YangImport implements Parsable { 66 +public class YangImport
67 + implements Parsable {
66 68
67 /** 69 /**
68 * Name of the module that is being imported. 70 * Name of the module that is being imported.
...@@ -75,11 +77,6 @@ public class YangImport implements Parsable { ...@@ -75,11 +77,6 @@ public class YangImport implements Parsable {
75 private String prefixId; 77 private String prefixId;
76 78
77 /** 79 /**
78 - * Resolution information root node which is also the data model root node.
79 - */
80 - private HasResolutionInfo resolutionInfoNode;
81 -
82 - /**
83 * Reference:RFC 6020. 80 * Reference:RFC 6020.
84 * 81 *
85 * The import's "revision-date" statement is used to specify the exact 82 * The import's "revision-date" statement is used to specify the exact
...@@ -118,7 +115,7 @@ public class YangImport implements Parsable { ...@@ -118,7 +115,7 @@ public class YangImport implements Parsable {
118 * Returns the prefix used to identify the entities from the imported module. 115 * Returns the prefix used to identify the entities from the imported module.
119 * 116 *
120 * @return the prefix used to identify the entities from the imported 117 * @return the prefix used to identify the entities from the imported
121 - * module 118 + * module
122 */ 119 */
123 public String getPrefixId() { 120 public String getPrefixId() {
124 return prefixId; 121 return prefixId;
...@@ -167,7 +164,8 @@ public class YangImport implements Parsable { ...@@ -167,7 +164,8 @@ public class YangImport implements Parsable {
167 * @throws DataModelException a violation of data model rules 164 * @throws DataModelException a violation of data model rules
168 */ 165 */
169 @Override 166 @Override
170 - public void validateDataOnEntry() throws DataModelException { 167 + public void validateDataOnEntry()
168 + throws DataModelException {
171 // TODO auto-generated method stub, to be implemented by parser 169 // TODO auto-generated method stub, to be implemented by parser
172 170
173 } 171 }
...@@ -178,26 +176,9 @@ public class YangImport implements Parsable { ...@@ -178,26 +176,9 @@ public class YangImport implements Parsable {
178 * @throws DataModelException a violation of data model rules 176 * @throws DataModelException a violation of data model rules
179 */ 177 */
180 @Override 178 @Override
181 - public void validateDataOnExit() throws DataModelException { 179 + public void validateDataOnExit()
180 + throws DataModelException {
182 // TODO auto-generated method stub, to be implemented by parser 181 // TODO auto-generated method stub, to be implemented by parser
183 182
184 } 183 }
185 -
186 - /**
187 - * Returns the resolution information node.
188 - *
189 - * @return the resolution information node
190 - */
191 - public HasResolutionInfo getResolutionInfoNode() {
192 - return resolutionInfoNode;
193 - }
194 -
195 - /**
196 - * Sets the dresolution information node.
197 - *
198 - * @param resolutionInfoNode the resolution information node
199 - */
200 - public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) {
201 - this.resolutionInfoNode = resolutionInfoNode;
202 - }
203 } 184 }
......
...@@ -33,10 +33,12 @@ import org.onosproject.yangutils.utils.YangConstructType; ...@@ -33,10 +33,12 @@ import org.onosproject.yangutils.utils.YangConstructType;
33 * | revision-date | 7.1.5.1 | 0..1 | string | 33 * | revision-date | 7.1.5.1 | 0..1 | string |
34 * +---------------+---------+-------------+------------------+ 34 * +---------------+---------+-------------+------------------+
35 */ 35 */
36 +
36 /** 37 /**
37 * Represents the information about the included sub-modules. 38 * Represents the information about the included sub-modules.
38 */ 39 */
39 -public class YangInclude implements Parsable { 40 +public class YangInclude
41 + implements Parsable {
40 42
41 /** 43 /**
42 * Name of the sub-module that is being included. 44 * Name of the sub-module that is being included.
...@@ -50,11 +52,6 @@ public class YangInclude implements Parsable { ...@@ -50,11 +52,6 @@ public class YangInclude implements Parsable {
50 private String revision; 52 private String revision;
51 53
52 /** 54 /**
53 - * Resolution information root node which is also the data model root node.
54 - */
55 - private HasResolutionInfo resolutionInfoNode;
56 -
57 - /**
58 * Creates a YANG include. 55 * Creates a YANG include.
59 */ 56 */
60 public YangInclude() { 57 public YangInclude() {
...@@ -112,7 +109,8 @@ public class YangInclude implements Parsable { ...@@ -112,7 +109,8 @@ public class YangInclude implements Parsable {
112 * @throws DataModelException a violation of data model rules 109 * @throws DataModelException a violation of data model rules
113 */ 110 */
114 @Override 111 @Override
115 - public void validateDataOnEntry() throws DataModelException { 112 + public void validateDataOnEntry()
113 + throws DataModelException {
116 // TODO auto-generated method stub, to be implemented by parser 114 // TODO auto-generated method stub, to be implemented by parser
117 115
118 } 116 }
...@@ -123,26 +121,10 @@ public class YangInclude implements Parsable { ...@@ -123,26 +121,10 @@ public class YangInclude implements Parsable {
123 * @throws DataModelException a violation of data model rules 121 * @throws DataModelException a violation of data model rules
124 */ 122 */
125 @Override 123 @Override
126 - public void validateDataOnExit() throws DataModelException { 124 + public void validateDataOnExit()
125 + throws DataModelException {
127 // TODO auto-generated method stub, to be implemented by parser 126 // TODO auto-generated method stub, to be implemented by parser
128 127
129 } 128 }
130 129
131 - /**
132 - * Returns the resolution information node.
133 - *
134 - * @return the resolution information node
135 - */
136 - public HasResolutionInfo getResolutionInfoNode() {
137 - return resolutionInfoNode;
138 - }
139 -
140 - /**
141 - * Sets the dresolution information node.
142 - *
143 - * @param resolutionInfoNode the resolution information node
144 - */
145 - public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) {
146 - this.resolutionInfoNode = resolutionInfoNode;
147 - }
148 } 130 }
......
...@@ -104,9 +104,9 @@ public class YangRpc extends YangNode implements YangCommonInfo, Parsable, ...@@ -104,9 +104,9 @@ public class YangRpc extends YangNode implements YangCommonInfo, Parsable,
104 104
105 @Override 105 @Override
106 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 106 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
107 - if (this.getName().equals(identifierName)) { 107 + if (getName().equals(identifierName)) {
108 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as rpc \"" 108 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as rpc \""
109 - + this.getName() + "\""); 109 + + getName() + "\"");
110 } 110 }
111 } 111 }
112 112
......
...@@ -20,6 +20,8 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; ...@@ -20,6 +20,8 @@ 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 22
23 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.INTRA_FILE_RESOLVED;
24 +
23 /* 25 /*
24 * Reference:RFC 6020. 26 * Reference:RFC 6020.
25 * The "type" statement takes as an argument a string that is the name 27 * The "type" statement takes as an argument a string that is the name
...@@ -49,7 +51,8 @@ import org.onosproject.yangutils.utils.YangConstructType; ...@@ -49,7 +51,8 @@ import org.onosproject.yangutils.utils.YangConstructType;
49 * 51 *
50 * @param <T> YANG data type info 52 * @param <T> YANG data type info
51 */ 53 */
52 -public class YangType<T> implements Parsable, Resolvable { 54 +public class YangType<T>
55 + implements Parsable, Resolvable {
53 56
54 /** 57 /**
55 * YANG node identifier. 58 * YANG node identifier.
...@@ -89,7 +92,7 @@ public class YangType<T> implements Parsable, Resolvable { ...@@ -89,7 +92,7 @@ public class YangType<T> implements Parsable, Resolvable {
89 * Status of resolution. If completely resolved enum value is "RESOLVED", 92 * Status of resolution. If completely resolved enum value is "RESOLVED",
90 * if not enum value is "UNRESOLVED", in case reference of grouping/typedef 93 * if not enum value is "UNRESOLVED", in case reference of grouping/typedef
91 * is added to uses/type but it's not resolved value of enum should be 94 * is added to uses/type but it's not resolved value of enum should be
92 - * "PARTIALLY_RESOLVED". 95 + * "INTRA_FILE_RESOLVED".
93 */ 96 */
94 private ResolvableStatus resolvableStatus; 97 private ResolvableStatus resolvableStatus;
95 98
...@@ -262,7 +265,8 @@ public class YangType<T> implements Parsable, Resolvable { ...@@ -262,7 +265,8 @@ public class YangType<T> implements Parsable, Resolvable {
262 * @throws DataModelException a violation of data model rules 265 * @throws DataModelException a violation of data model rules
263 */ 266 */
264 @Override 267 @Override
265 - public void validateDataOnEntry() throws DataModelException { 268 + public void validateDataOnEntry()
269 + throws DataModelException {
266 // TODO auto-generated method stub, to be implemented by parser 270 // TODO auto-generated method stub, to be implemented by parser
267 271
268 } 272 }
...@@ -273,7 +277,8 @@ public class YangType<T> implements Parsable, Resolvable { ...@@ -273,7 +277,8 @@ public class YangType<T> implements Parsable, Resolvable {
273 * @throws DataModelException a violation of data model rules 277 * @throws DataModelException a violation of data model rules
274 */ 278 */
275 @Override 279 @Override
276 - public void validateDataOnExit() throws DataModelException { 280 + public void validateDataOnExit()
281 + throws DataModelException {
277 // TODO auto-generated method stub, to be implemented by parser 282 // TODO auto-generated method stub, to be implemented by parser
278 283
279 } 284 }
...@@ -290,6 +295,20 @@ public class YangType<T> implements Parsable, Resolvable { ...@@ -290,6 +295,20 @@ public class YangType<T> implements Parsable, Resolvable {
290 295
291 @Override 296 @Override
292 public void resolve() { 297 public void resolve() {
293 - //TODO: implement the method. 298 + /*
299 + Inherit the Restriction from the referred typedef definition.
300 + */
301 + if (getDataType() != YangDataTypes.DERIVED) {
302 + throw new RuntimeException("Resolve should only be called for derrived data types");
303 + }
304 +
305 + YangDerivedInfo<?> derrivedInfo = (YangDerivedInfo<?>) getDataTypeExtendedInfo();
306 + YangType<?> baseType = derrivedInfo.getReferredTypeDef().getTypeDefBaseType();
307 + if (YangDataTypes.DERIVED == baseType.getDataType()) {
308 + if (baseType.getResolvableStatus() == INTRA_FILE_RESOLVED) {
309 + setResolvableStatus(INTRA_FILE_RESOLVED);
310 + }
311 + }
312 + //TODO:
294 } 313 }
295 } 314 }
......
...@@ -179,7 +179,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { ...@@ -179,7 +179,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
179 * 179 *
180 * @return the data type 180 * @return the data type
181 */ 181 */
182 - public YangType<?> getDataType() { 182 + public YangType<?> getTypeDefBaseType() {
183 return dataType; 183 return dataType;
184 } 184 }
185 185
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
16 16
17 package org.onosproject.yangutils.datamodel; 17 package org.onosproject.yangutils.datamodel;
18 18
19 +import java.util.LinkedList;
20 +import java.util.List;
21 +
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 import org.onosproject.yangutils.parser.Parsable; 23 import org.onosproject.yangutils.parser.Parsable;
21 import org.onosproject.yangutils.utils.YangConstructType; 24 import org.onosproject.yangutils.utils.YangConstructType;
22 25
23 -import java.util.LinkedList;
24 -import java.util.List;
25 -
26 /* 26 /*
27 * Reference RFC 6020. 27 * Reference RFC 6020.
28 * 28 *
......
...@@ -48,10 +48,13 @@ import org.onosproject.yangutils.utils.YangConstructType; ...@@ -48,10 +48,13 @@ import org.onosproject.yangutils.utils.YangConstructType;
48 * | when | 7.19.5 | 0..1 | -TODO | 48 * | when | 7.19.5 | 0..1 | -TODO |
49 * +--------------+---------+-------------+------------------+ 49 * +--------------+---------+-------------+------------------+
50 */ 50 */
51 +
51 /** 52 /**
52 * Represents data model node to maintain information defined in YANG uses. 53 * Represents data model node to maintain information defined in YANG uses.
53 */ 54 */
54 -public class YangUses extends YangNode implements YangCommonInfo, Parsable, Resolvable { 55 +public class YangUses
56 + extends YangNode
57 + implements YangCommonInfo, Parsable, Resolvable {
55 58
56 /** 59 /**
57 * YANG node identifier. 60 * YANG node identifier.
...@@ -82,7 +85,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable, Reso ...@@ -82,7 +85,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable, Reso
82 * Status of resolution. If completely resolved enum value is "RESOLVED", 85 * Status of resolution. If completely resolved enum value is "RESOLVED",
83 * if not enum value is "UNRESOLVED", in case reference of grouping/typedef 86 * if not enum value is "UNRESOLVED", in case reference of grouping/typedef
84 * is added to uses/type but it's not resolved value of enum should be 87 * is added to uses/type but it's not resolved value of enum should be
85 - * "PARTIALLY_RESOLVED". 88 + * "INTRA_FILE_RESOLVED".
86 */ 89 */
87 private ResolvableStatus resolvableStatus; 90 private ResolvableStatus resolvableStatus;
88 91
...@@ -189,7 +192,8 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable, Reso ...@@ -189,7 +192,8 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable, Reso
189 * @throws DataModelException a violation of data model rules 192 * @throws DataModelException a violation of data model rules
190 */ 193 */
191 @Override 194 @Override
192 - public void validateDataOnEntry() throws DataModelException { 195 + public void validateDataOnEntry()
196 + throws DataModelException {
193 // TODO auto-generated method stub, to be implemented by parser 197 // TODO auto-generated method stub, to be implemented by parser
194 } 198 }
195 199
...@@ -199,7 +203,8 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable, Reso ...@@ -199,7 +203,8 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable, Reso
199 * @throws DataModelException a violation of data model rules 203 * @throws DataModelException a violation of data model rules
200 */ 204 */
201 @Override 205 @Override
202 - public void validateDataOnExit() throws DataModelException { 206 + public void validateDataOnExit()
207 + throws DataModelException {
203 // TODO auto-generated method stub, to be implemented by parser 208 // TODO auto-generated method stub, to be implemented by parser
204 } 209 }
205 210
......
...@@ -20,6 +20,7 @@ import java.util.List; ...@@ -20,6 +20,7 @@ import java.util.List;
20 20
21 import org.onosproject.yangutils.datamodel.CollisionDetector; 21 import org.onosproject.yangutils.datamodel.CollisionDetector;
22 import org.onosproject.yangutils.datamodel.HasResolutionInfo; 22 import org.onosproject.yangutils.datamodel.HasResolutionInfo;
23 +import org.onosproject.yangutils.datamodel.YangImport;
23 import org.onosproject.yangutils.datamodel.YangLeaf; 24 import org.onosproject.yangutils.datamodel.YangLeaf;
24 import org.onosproject.yangutils.datamodel.YangLeafList; 25 import org.onosproject.yangutils.datamodel.YangLeafList;
25 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 26 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
...@@ -28,6 +29,7 @@ import org.onosproject.yangutils.datamodel.YangResolutionInfo; ...@@ -28,6 +29,7 @@ import org.onosproject.yangutils.datamodel.YangResolutionInfo;
28 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 29 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
29 import org.onosproject.yangutils.utils.YangConstructType; 30 import org.onosproject.yangutils.utils.YangConstructType;
30 31
32 +
31 /** 33 /**
32 * Represents utilities for data model tree. 34 * Represents utilities for data model tree.
33 */ 35 */
...@@ -43,7 +45,7 @@ public final class DataModelUtils { ...@@ -43,7 +45,7 @@ public final class DataModelUtils {
43 * Detects the colliding identifier name in a given YANG node and its child. 45 * Detects the colliding identifier name in a given YANG node and its child.
44 * 46 *
45 * @param identifierName name for which collision detection is to be 47 * @param identifierName name for which collision detection is to be
46 - * checked 48 + * checked
47 * @param dataType type of YANG node asking for detecting collision 49 * @param dataType type of YANG node asking for detecting collision
48 * @param node instance of calling node 50 * @param node instance of calling node
49 * @throws DataModelException a violation of data model rules 51 * @throws DataModelException a violation of data model rules
...@@ -77,7 +79,7 @@ public final class DataModelUtils { ...@@ -77,7 +79,7 @@ public final class DataModelUtils {
77 * 79 *
78 * @param leavesHolder leaves node against which collision to be checked 80 * @param leavesHolder leaves node against which collision to be checked
79 * @param identifierName name for which collision detection is to be 81 * @param identifierName name for which collision detection is to be
80 - * checked 82 + * checked
81 * @throws DataModelException a violation of data model rules 83 * @throws DataModelException a violation of data model rules
82 */ 84 */
83 private static void detectCollidingLeaf(YangLeavesHolder leavesHolder, String identifierName) 85 private static void detectCollidingLeaf(YangLeavesHolder leavesHolder, String identifierName)
...@@ -96,7 +98,7 @@ public final class DataModelUtils { ...@@ -96,7 +98,7 @@ public final class DataModelUtils {
96 * 98 *
97 * @param leavesHolder leaves node against which collision to be checked 99 * @param leavesHolder leaves node against which collision to be checked
98 * @param identifierName name for which collision detection is to be 100 * @param identifierName name for which collision detection is to be
99 - * checked 101 + * checked
100 * @throws DataModelException a violation of data model rules 102 * @throws DataModelException a violation of data model rules
101 */ 103 */
102 private static void detectCollidingLeafList(YangLeavesHolder leavesHolder, String identifierName) 104 private static void detectCollidingLeafList(YangLeavesHolder leavesHolder, String identifierName)
...@@ -114,13 +116,17 @@ public final class DataModelUtils { ...@@ -114,13 +116,17 @@ public final class DataModelUtils {
114 * Add a resolution information. 116 * Add a resolution information.
115 * 117 *
116 * @param resolutionInfo information about the YANG construct which has to 118 * @param resolutionInfo information about the YANG construct which has to
117 - * be resolved 119 + * be resolved
118 * @throws DataModelException a violation of data model rules 120 * @throws DataModelException a violation of data model rules
119 */ 121 */
120 - public static void addResolutionInfo(YangResolutionInfo resolutionInfo) throws DataModelException { 122 + public static void addResolutionInfo(YangResolutionInfo resolutionInfo)
123 + throws DataModelException {
124 +
125 +
121 126
122 /* get the module node to add maintain the list of nested reference */ 127 /* get the module node to add maintain the list of nested reference */
123 - YangNode curNode = resolutionInfo.getHolderOfEntityToResolve(); 128 + YangNode curNode = resolutionInfo.getEntityToResolveInfo()
129 + .getHolderOfEntityToResolve();
124 while (!(curNode instanceof HasResolutionInfo)) { 130 while (!(curNode instanceof HasResolutionInfo)) {
125 curNode = curNode.getParent(); 131 curNode = curNode.getParent();
126 if (curNode == null) { 132 if (curNode == null) {
...@@ -128,25 +134,58 @@ public final class DataModelUtils { ...@@ -128,25 +134,58 @@ public final class DataModelUtils {
128 } 134 }
129 } 135 }
130 HasResolutionInfo resolutionNode = (HasResolutionInfo) curNode; 136 HasResolutionInfo resolutionNode = (HasResolutionInfo) curNode;
137 +
138 + if (!isPrefixValid(resolutionInfo.getEntityToResolveInfo().getEntityPrefix(),
139 + resolutionNode)) {
140 + throw new DataModelException("The prefix used is not valid");
141 + }
131 resolutionNode.addToResolutionList(resolutionInfo); 142 resolutionNode.addToResolutionList(resolutionInfo);
132 } 143 }
133 144
145 + private static boolean isPrefixValid(String entityPrefix, HasResolutionInfo resolutionNode) {
146 + if (entityPrefix == null) {
147 + return true;
148 + }
149 +
150 + if (resolutionNode.getPrefix().contentEquals(entityPrefix)) {
151 + return true;
152 + }
153 +
154 + if (resolutionNode.getImportList() != null) {
155 + for (YangImport importedInfo : resolutionNode.getImportList()) {
156 + if (importedInfo.getPrefixId().contentEquals(entityPrefix)) {
157 + return true;
158 + }
159 + }
160 + }
161 +
162 + if (resolutionNode.getIncludeList() != null) {
163 + /**
164 + * TODO: check if the prefix matches with the imported data
165 +
166 + for (YangInclude includedInfo : resolutionNode.getIncludeList()) {
167 + if (includedInfo.contentEquals(prefix)) {
168 + return true;
169 + }
170 + }*/
171 + }
172 +
173 + return false;
174 + }
175 +
134 /** 176 /**
135 * Resolve linking for a resolution list. 177 * Resolve linking for a resolution list.
136 * 178 *
137 * @param resolutionList resolution list for which linking to be done 179 * @param resolutionList resolution list for which linking to be done
138 - * @param resolutionInfoNode module/sub-module node 180 + * @param dataModelRootNode module/sub-module node
139 * @throws DataModelException a violation of data model rules 181 * @throws DataModelException a violation of data model rules
140 */ 182 */
141 public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList, 183 public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList,
142 - HasResolutionInfo resolutionInfoNode) 184 + HasResolutionInfo dataModelRootNode)
143 throws DataModelException { 185 throws DataModelException {
144 186
145 for (YangResolutionInfo resolutionInfo : resolutionList) { 187 for (YangResolutionInfo resolutionInfo : resolutionList) {
146 - if (resolutionInfo.getPrefix() == null || 188 + resolutionInfo.resolveLinkingForResolutionInfo(dataModelRootNode.getPrefix());
147 - resolutionInfo.getPrefix().equals(resolutionInfoNode.getPrefix())) {
148 - resolutionInfo.resolveLinkingForResolutionInfo(resolutionInfoNode.getPrefix());
149 - }
150 } 189 }
151 } 190 }
152 } 191 }
......
...@@ -20,6 +20,7 @@ import org.onosproject.yangutils.datamodel.YangCase; ...@@ -20,6 +20,7 @@ import org.onosproject.yangutils.datamodel.YangCase;
20 import org.onosproject.yangutils.datamodel.YangChoice; 20 import org.onosproject.yangutils.datamodel.YangChoice;
21 import org.onosproject.yangutils.datamodel.YangContainer; 21 import org.onosproject.yangutils.datamodel.YangContainer;
22 import org.onosproject.yangutils.datamodel.YangGrouping; 22 import org.onosproject.yangutils.datamodel.YangGrouping;
23 +import org.onosproject.yangutils.datamodel.YangLeaf;
23 import org.onosproject.yangutils.datamodel.YangList; 24 import org.onosproject.yangutils.datamodel.YangList;
24 import org.onosproject.yangutils.datamodel.YangModule; 25 import org.onosproject.yangutils.datamodel.YangModule;
25 import org.onosproject.yangutils.datamodel.YangSubModule; 26 import org.onosproject.yangutils.datamodel.YangSubModule;
...@@ -34,6 +35,7 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase; ...@@ -34,6 +35,7 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase;
34 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice; 35 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice;
35 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer; 36 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer;
36 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; 37 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping;
38 +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeaf;
37 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList; 39 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList;
38 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; 40 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
39 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; 41 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
...@@ -51,7 +53,7 @@ import org.onosproject.yangutils.translator.exception.TranslatorException; ...@@ -51,7 +53,7 @@ import org.onosproject.yangutils.translator.exception.TranslatorException;
51 public final class YangDataModelFactory { 53 public final class YangDataModelFactory {
52 54
53 /** 55 /**
54 - * Creates a YANG data model factory object. 56 + * Utility class, hence private to prevent creating objects.
55 */ 57 */
56 private YangDataModelFactory() { 58 private YangDataModelFactory() {
57 } 59 }
...@@ -261,6 +263,23 @@ public final class YangDataModelFactory { ...@@ -261,6 +263,23 @@ public final class YangDataModelFactory {
261 * generated 263 * generated
262 * @return the corresponding inherited node based on the target language 264 * @return the corresponding inherited node based on the target language
263 */ 265 */
266 + public static YangLeaf getYangLeaf(GeneratedLanguage targetLanguage) {
267 + switch (targetLanguage) {
268 + case JAVA_GENERATION: {
269 + return new YangJavaLeaf();
270 + }
271 + default: {
272 + throw new RuntimeException("Only YANG to Java is supported.");
273 + }
274 + }
275 + }
276 + /**
277 + * Returns based on the target language generate the inherited data model node.
278 + *
279 + * @param targetLanguage target language in which YANG mapping needs to be
280 + * generated
281 + * @return the corresponding inherited node based on the target language
282 + */
264 public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) { 283 public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) {
265 switch (targetLanguage) { 284 switch (targetLanguage) {
266 case JAVA_GENERATION: { 285 case JAVA_GENERATION: {
......
...@@ -40,8 +40,9 @@ import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA ...@@ -40,8 +40,9 @@ import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA
40 */ 40 */
41 41
42 /** 42 /**
43 - * Represents listener based call back function corresponding to the "description" 43 + * Represents listener based call back function corresponding to the
44 - * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. 44 + * "description" rule defined in ANTLR grammar file for corresponding ABNF rule
45 + * in RFC 6020.
45 */ 46 */
46 public final class DescriptionListener { 47 public final class DescriptionListener {
47 48
...@@ -52,15 +53,14 @@ public final class DescriptionListener { ...@@ -52,15 +53,14 @@ public final class DescriptionListener {
52 } 53 }
53 54
54 /** 55 /**
55 - * It is called when parser receives an input matching the grammar 56 + * It is called when parser receives an input matching the grammar rule
56 - * rule (description), perform validations and updates the data model 57 + * (description), perform validations and updates the data model tree.
57 - * tree.
58 * 58 *
59 * @param listener listener's object 59 * @param listener listener's object
60 * @param ctx context object of the grammar rule 60 * @param ctx context object of the grammar rule
61 */ 61 */
62 public static void processDescriptionEntry(TreeWalkListener listener, 62 public static void processDescriptionEntry(TreeWalkListener listener,
63 - GeneratedYangParser.DescriptionStatementContext ctx) { 63 + GeneratedYangParser.DescriptionStatementContext ctx) {
64 64
65 // Check for stack to be non empty. 65 // Check for stack to be non empty.
66 checkStackIsNotEmpty(listener, MISSING_HOLDER, DESCRIPTION_DATA, ctx.string().getText(), ENTRY); 66 checkStackIsNotEmpty(listener, MISSING_HOLDER, DESCRIPTION_DATA, ctx.string().getText(), ENTRY);
......
...@@ -45,8 +45,8 @@ import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA; ...@@ -45,8 +45,8 @@ import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA;
45 */ 45 */
46 46
47 /** 47 /**
48 - * Represesnts listener based call back function corresponding to the "key" 48 + * Represesnts listener based call back function corresponding to the "key" rule
49 - * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. 49 + * defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
50 */ 50 */
51 public final class KeyListener { 51 public final class KeyListener {
52 52
...@@ -57,15 +57,14 @@ public final class KeyListener { ...@@ -57,15 +57,14 @@ public final class KeyListener {
57 } 57 }
58 58
59 /** 59 /**
60 - * It is called when parser receives an input matching the grammar 60 + * It is called when parser receives an input matching the grammar rule
61 - * rule (key), perform validations and updates the data model 61 + * (key), perform validations and updates the data model tree.
62 - * tree.
63 * 62 *
64 * @param listener listener's object 63 * @param listener listener's object
65 * @param ctx context object of the grammar rule 64 * @param ctx context object of the grammar rule
66 */ 65 */
67 public static void processKeyEntry(TreeWalkListener listener, 66 public static void processKeyEntry(TreeWalkListener listener,
68 - GeneratedYangParser.KeyStatementContext ctx) { 67 + GeneratedYangParser.KeyStatementContext ctx) {
69 68
70 // Check for stack to be non empty. 69 // Check for stack to be non empty.
71 checkStackIsNotEmpty(listener, MISSING_HOLDER, KEY_DATA, ctx.key().getText(), ENTRY); 70 checkStackIsNotEmpty(listener, MISSING_HOLDER, KEY_DATA, ctx.key().getText(), ENTRY);
...@@ -94,7 +93,7 @@ public final class KeyListener { ...@@ -94,7 +93,7 @@ public final class KeyListener {
94 } 93 }
95 } else { 94 } else {
96 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, KEY_DATA, ctx.key().getText(), 95 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, KEY_DATA, ctx.key().getText(),
97 - ENTRY)); 96 + ENTRY));
98 } 97 }
99 } 98 }
100 } 99 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -27,10 +27,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; ...@@ -27,10 +27,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
27 import org.onosproject.yangutils.parser.exceptions.ParserException; 27 import org.onosproject.yangutils.parser.exceptions.ParserException;
28 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 28 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
29 29
30 +import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
31 +import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangLeaf;
30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; 32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
33 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 35 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
36 + .constructListenerErrorMessage;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 37 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
35 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;
36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
...@@ -108,7 +111,7 @@ public final class LeafListener { ...@@ -108,7 +111,7 @@ public final class LeafListener {
108 int charPositionInLine = ctx.getStart().getCharPositionInLine(); 111 int charPositionInLine = ctx.getStart().getCharPositionInLine();
109 detectCollidingChildUtil(listener, line, charPositionInLine, identifier, LEAF_DATA); 112 detectCollidingChildUtil(listener, line, charPositionInLine, identifier, LEAF_DATA);
110 113
111 - YangLeaf leaf = new YangLeaf(); 114 + YangLeaf leaf = getYangLeaf(JAVA_GENERATION);
112 leaf.setLeafName(identifier); 115 leaf.setLeafName(identifier);
113 116
114 Parsable tmpData = listener.getParsedDataStack().peek(); 117 Parsable tmpData = listener.getParsedDataStack().peek();
...@@ -142,7 +145,7 @@ public final class LeafListener { ...@@ -142,7 +145,7 @@ public final class LeafListener {
142 listener.getParsedDataStack().pop(); 145 listener.getParsedDataStack().pop();
143 } else { 146 } else {
144 throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_DATA, 147 throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_DATA,
145 - ctx.identifier().getText(), EXIT)); 148 + ctx.identifier().getText(), EXIT));
146 } 149 }
147 } 150 }
148 151
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
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.ResolutionType;
20 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
21 import org.onosproject.yangutils.datamodel.YangDerivedInfo; 20 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
22 import org.onosproject.yangutils.datamodel.YangLeaf; 21 import org.onosproject.yangutils.datamodel.YangLeaf;
...@@ -34,11 +33,14 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; ...@@ -34,11 +33,14 @@ import org.onosproject.yangutils.parser.exceptions.ParserException;
34 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 33 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
35 import org.onosproject.yangutils.utils.YangConstructType; 34 import org.onosproject.yangutils.utils.YangConstructType;
36 35
36 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.UNRESOLVED;
37 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo; 37 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo;
38 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 38 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
40 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; 40 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
41 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 41 + .constructExtendedListenerErrorMessage;
42 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
43 + .constructListenerErrorMessage;
42 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 44 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
43 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; 45 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
44 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 46 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
...@@ -123,17 +125,15 @@ public final class TypeListener { ...@@ -123,17 +125,15 @@ public final class TypeListener {
123 ctx.string().getText(), EXIT)); 125 ctx.string().getText(), EXIT));
124 } 126 }
125 127
126 - // Get the prefix information
127 - String prefix = ((YangType<?>) type).getPrefix();
128 -
129 // Create empty derived info and attach it to type extended info. 128 // Create empty derived info and attach it to type extended info.
130 YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>(); 129 YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>();
131 ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); 130 ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
132 131
132 + type.setResolvableStatus(UNRESOLVED);
133 +
133 // Add resolution information to the list 134 // Add resolution information to the list
134 YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type, 135 YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type,
135 - ResolutionType.TYPEDEF_RESOLUTION, (YangNode) parentNodeOfLeaf, prefix, errorLine, 136 + (YangNode) parentNodeOfLeaf, errorLine, errorPosition);
136 - errorPosition);
137 addToResolutionList(resolutionInfo, ctx); 137 addToResolutionList(resolutionInfo, ctx);
138 } 138 }
139 break; 139 break;
...@@ -165,9 +165,9 @@ public final class TypeListener { ...@@ -165,9 +165,9 @@ public final class TypeListener {
165 ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); 165 ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
166 166
167 // Add resolution information to the list 167 // Add resolution information to the list
168 - YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type, 168 + YangResolutionInfo resolutionInfo =
169 - ResolutionType.TYPEDEF_RESOLUTION, (YangNode) parentNodeOfLeafList, prefix, errorLine, 169 + new YangResolutionInfo<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine,
170 - errorPosition); 170 + errorPosition);
171 addToResolutionList(resolutionInfo, ctx); 171 addToResolutionList(resolutionInfo, ctx);
172 } 172 }
173 break; 173 break;
...@@ -201,8 +201,8 @@ public final class TypeListener { ...@@ -201,8 +201,8 @@ public final class TypeListener {
201 ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); 201 ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
202 202
203 // Add resolution information to the list 203 // Add resolution information to the list
204 - YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type, 204 + YangResolutionInfo resolutionInfo =
205 - ResolutionType.TYPEDEF_RESOLUTION, (YangNode) typeDef, prefix, errorLine, errorPosition); 205 + new YangResolutionInfo<YangType>(type, (YangNode) typeDef, errorLine, errorPosition);
206 addToResolutionList(resolutionInfo, ctx); 206 addToResolutionList(resolutionInfo, ctx);
207 } 207 }
208 break; 208 break;
...@@ -244,7 +244,7 @@ public final class TypeListener { ...@@ -244,7 +244,7 @@ public final class TypeListener {
244 * @param ctx context object of the grammar rule 244 * @param ctx context object of the grammar rule
245 */ 245 */
246 private static void addToResolutionList(YangResolutionInfo<YangType> resolutionInfo, 246 private static void addToResolutionList(YangResolutionInfo<YangType> resolutionInfo,
247 - GeneratedYangParser.TypeStatementContext ctx) { 247 + GeneratedYangParser.TypeStatementContext ctx) {
248 try { 248 try {
249 addResolutionInfo(resolutionInfo); 249 addResolutionInfo(resolutionInfo);
250 } catch (DataModelException e) { 250 } catch (DataModelException e) {
......
...@@ -205,7 +205,7 @@ public final class ListenerUtil { ...@@ -205,7 +205,7 @@ public final class ListenerUtil {
205 205
206 Calendar date = Calendar.getInstance(); 206 Calendar date = Calendar.getInstance();
207 SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); 207 SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
208 - String dateForRevision = ((dateFormat.format(date.getTime())).replaceAll(SLASH, HYPHEN)).replaceAll(SPACE, 208 + String dateForRevision = dateFormat.format(date.getTime()).replaceAll(SLASH, HYPHEN).replaceAll(SPACE,
209 EMPTY_STRING); 209 EMPTY_STRING);
210 return dateForRevision; 210 return dateForRevision;
211 } 211 }
...@@ -218,8 +218,8 @@ public final class ListenerUtil { ...@@ -218,8 +218,8 @@ public final class ListenerUtil {
218 * @param ctx yang construct's context to get the line number and character position 218 * @param ctx yang construct's context to get the line number and character position
219 * @return valid node identifier 219 * @return valid node identifier
220 */ 220 */
221 - public static YangNodeIdentifier getValidNodeIdentifier(String nodeIdentifierString, YangConstructType 221 + public static YangNodeIdentifier getValidNodeIdentifier(String nodeIdentifierString,
222 - yangConstruct, ParserRuleContext ctx) { 222 + YangConstructType yangConstruct, ParserRuleContext ctx) {
223 String tmpIdentifierString = removeQuotesAndHandleConcat(nodeIdentifierString); 223 String tmpIdentifierString = removeQuotesAndHandleConcat(nodeIdentifierString);
224 String[] tmpData = tmpIdentifierString.split(Pattern.quote(COLON)); 224 String[] tmpData = tmpIdentifierString.split(Pattern.quote(COLON));
225 if (tmpData.length == 1) { 225 if (tmpData.length == 1) {
......
1 +/*
2 + * Copyright 2016 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 +package org.onosproject.yangutils.translator.tojava;
17 +
18 +/**
19 + * Maintain the java qualified access details for an attribute or a class.
20 + */
21 +public interface HasJavaQualifiedTypeInfo {
22 +
23 + /**
24 + * Obtain the java qualified details.
25 + *
26 + * @return java qualified type details
27 + */
28 + JavaQualifiedTypeInfo getJavaQualifiedInfo();
29 +
30 + /**
31 + * Assign the qualified type info.
32 + *
33 + * @param typeInfo qualified type information
34 + */
35 + void setJavaQualifiedInfo(JavaQualifiedTypeInfo typeInfo);
36 +}
...@@ -1055,7 +1055,7 @@ public class TempJavaCodeFragmentFiles { ...@@ -1055,7 +1055,7 @@ public class TempJavaCodeFragmentFiles {
1055 public void addTypeDefAttributeToTempFiles(YangNode curNode) throws IOException { 1055 public void addTypeDefAttributeToTempFiles(YangNode curNode) throws IOException {
1056 1056
1057 JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfTypeDef(curNode, 1057 JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfTypeDef(curNode,
1058 - ((YangTypeDef) curNode).getDataType(), 1058 + ((YangTypeDef) curNode).getTypeDefBaseType(),
1059 ((YangTypeDef) curNode).getName(), false); 1059 ((YangTypeDef) curNode).getName(), false);
1060 addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); 1060 addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo);
1061 } 1061 }
......
1 +/*
2 + * Copyright 2016 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 +package org.onosproject.yangutils.translator.tojava.javamodel;
17 +
18 +import org.onosproject.yangutils.datamodel.YangLeaf;
19 +import org.onosproject.yangutils.translator.tojava.HasJavaQualifiedTypeInfo;
20 +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
21 +
22 +/**
23 + * Maintains java information corresponding to the YANG leaf.
24 + */
25 +public class YangJavaLeaf extends YangLeaf
26 + implements HasJavaQualifiedTypeInfo {
27 +
28 + private JavaQualifiedTypeInfo javaQualifiedAccess;
29 +
30 + /**
31 + * Create a YANG leaf object with java qualified access details.
32 + */
33 + public YangJavaLeaf() {
34 + super();
35 + setJavaQualifiedInfo(new JavaQualifiedTypeInfo());
36 + }
37 +
38 + @Override
39 + public JavaQualifiedTypeInfo getJavaQualifiedInfo() {
40 + return javaQualifiedAccess;
41 + }
42 +
43 + @Override
44 + public void setJavaQualifiedInfo(JavaQualifiedTypeInfo typeInfo) {
45 + javaQualifiedAccess = typeInfo;
46 +
47 + }
48 +
49 +}
...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.linker; ...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.linker;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.ListIterator; 20 import java.util.ListIterator;
21 +
21 import org.junit.Test; 22 import org.junit.Test;
22 import org.onosproject.yangutils.datamodel.ResolvableStatus; 23 import org.onosproject.yangutils.datamodel.ResolvableStatus;
23 import org.onosproject.yangutils.datamodel.YangContainer; 24 import org.onosproject.yangutils.datamodel.YangContainer;
...@@ -46,7 +47,8 @@ public class IntraFileTypeLinkingTest { ...@@ -46,7 +47,8 @@ public class IntraFileTypeLinkingTest {
46 * Checks self resolution when typedef and leaf using type are siblings. 47 * Checks self resolution when typedef and leaf using type are siblings.
47 */ 48 */
48 @Test 49 @Test
49 - public void processSelfResolutionWhenTypeAndTypedefAtRootLevel() throws IOException, ParserException { 50 + public void processSelfResolutionWhenTypeAndTypedefAtRootLevel()
51 + throws IOException, ParserException {
50 52
51 YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang"); 53 YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang");
52 54
...@@ -79,7 +81,8 @@ public class IntraFileTypeLinkingTest { ...@@ -79,7 +81,8 @@ public class IntraFileTypeLinkingTest {
79 * level where typedef is at the root. 81 * level where typedef is at the root.
80 */ 82 */
81 @Test 83 @Test
82 - public void processSelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy() throws IOException, ParserException { 84 + public void processSelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy()
85 + throws IOException, ParserException {
83 86
84 YangNode node = 87 YangNode node =
85 manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang"); 88 manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang");
...@@ -118,7 +121,8 @@ public class IntraFileTypeLinkingTest { ...@@ -118,7 +121,8 @@ public class IntraFileTypeLinkingTest {
118 * of type. 121 * of type.
119 */ 122 */
120 @Test 123 @Test
121 - public void processSelfFileLinkingTypedefAtRootIsAfterContainerHavingType() throws IOException, ParserException { 124 + public void processSelfFileLinkingTypedefAtRootIsAfterContainerHavingType()
125 + throws IOException, ParserException {
122 126
123 YangNode node = 127 YangNode node =
124 manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang"); 128 manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang");
...@@ -157,7 +161,8 @@ public class IntraFileTypeLinkingTest { ...@@ -157,7 +161,8 @@ public class IntraFileTypeLinkingTest {
157 * holder of type. 161 * holder of type.
158 */ 162 */
159 @Test 163 @Test
160 - public void processSelfFileLinkingTypedefAtMiddleLevelAfterParentHolder() throws IOException, ParserException { 164 + public void processSelfFileLinkingTypedefAtMiddleLevelAfterParentHolder()
165 + throws IOException, ParserException {
161 166
162 YangNode node = 167 YangNode node =
163 manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang"); 168 manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang");
...@@ -194,7 +199,8 @@ public class IntraFileTypeLinkingTest { ...@@ -194,7 +199,8 @@ public class IntraFileTypeLinkingTest {
194 * Checks self resolution when typedef hierarchical references are present. 199 * Checks self resolution when typedef hierarchical references are present.
195 */ 200 */
196 @Test 201 @Test
197 - public void processSelfFileLinkingWithTypdefHierarchicalReference() throws IOException, ParserException { 202 + public void processSelfFileLinkingWithTypdefHierarchicalReference()
203 + throws IOException, ParserException {
198 204
199 YangNode node = 205 YangNode node =
200 manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang"); 206 manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang");
...@@ -227,16 +233,16 @@ public class IntraFileTypeLinkingTest { ...@@ -227,16 +233,16 @@ public class IntraFileTypeLinkingTest {
227 233
228 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); 234 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
229 235
230 - assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 236 + assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
231 is((YangTypeDef) yangContainer.getChild().getNextSibling())); 237 is((YangTypeDef) yangContainer.getChild().getNextSibling()));
232 - assertThat((typeDef1.getDataType().getResolvableStatus()), 238 + assertThat((typeDef1.getTypeDefBaseType().getResolvableStatus()),
233 is(ResolvableStatus.RESOLVED)); 239 is(ResolvableStatus.RESOLVED));
234 240
235 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); 241 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
236 242
237 - assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 243 + assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
238 is((YangTypeDef) node.getChild())); 244 is((YangTypeDef) node.getChild()));
239 - assertThat((typeDef2.getDataType().getResolvableStatus()), 245 + assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()),
240 is(ResolvableStatus.RESOLVED)); 246 is(ResolvableStatus.RESOLVED));
241 } 247 }
242 248
...@@ -245,7 +251,8 @@ public class IntraFileTypeLinkingTest { ...@@ -245,7 +251,8 @@ public class IntraFileTypeLinkingTest {
245 * with last type is unresolved. 251 * with last type is unresolved.
246 */ 252 */
247 @Test 253 @Test
248 - public void processSelfFileLinkingWithTypdefHierarchicalRefUnresolved() throws IOException, ParserException { 254 + public void processSelfFileLinkingWithTypdefHierarchicalRefUnresolved()
255 + throws IOException, ParserException {
249 256
250 YangNode node = 257 YangNode node =
251 manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang"); 258 manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang");
...@@ -274,28 +281,29 @@ public class IntraFileTypeLinkingTest { ...@@ -274,28 +281,29 @@ public class IntraFileTypeLinkingTest {
274 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 281 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
275 is((YangTypeDef) yangList.getChild())); 282 is((YangTypeDef) yangList.getChild()));
276 assertThat((leafInfo.getDataType().getResolvableStatus()), 283 assertThat((leafInfo.getDataType().getResolvableStatus()),
277 - is(ResolvableStatus.PARTIALLY_RESOLVED)); 284 + is(ResolvableStatus.INTRA_FILE_RESOLVED));
278 285
279 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); 286 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
280 287
281 - assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 288 + assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
282 is((YangTypeDef) yangContainer.getChild().getNextSibling())); 289 is((YangTypeDef) yangContainer.getChild().getNextSibling()));
283 - assertThat((typeDef1.getDataType().getResolvableStatus()), 290 + assertThat((typeDef1.getTypeDefBaseType().getResolvableStatus()),
284 - is(ResolvableStatus.PARTIALLY_RESOLVED)); 291 + is(ResolvableStatus.INTRA_FILE_RESOLVED));
285 292
286 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); 293 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
287 294
288 - assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 295 + assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
289 is((YangTypeDef) node.getChild())); 296 is((YangTypeDef) node.getChild()));
290 - assertThat((typeDef2.getDataType().getResolvableStatus()), 297 + assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()),
291 - is(ResolvableStatus.PARTIALLY_RESOLVED)); 298 + is(ResolvableStatus.INTRA_FILE_RESOLVED));
292 } 299 }
293 300
294 /** 301 /**
295 * Checks self resolution when type uses prefix of self module. 302 * Checks self resolution when type uses prefix of self module.
296 */ 303 */
297 @Test 304 @Test
298 - public void processSelfFileLinkingWithTypeWithSelfModulePrefix() throws IOException, ParserException { 305 + public void processSelfFileLinkingWithTypeWithSelfModulePrefix()
306 + throws IOException, ParserException {
299 307
300 YangNode node = 308 YangNode node =
301 manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang"); 309 manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang");
...@@ -328,16 +336,16 @@ public class IntraFileTypeLinkingTest { ...@@ -328,16 +336,16 @@ public class IntraFileTypeLinkingTest {
328 336
329 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); 337 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
330 338
331 - assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 339 + assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
332 is((YangTypeDef) yangContainer.getChild().getNextSibling())); 340 is((YangTypeDef) yangContainer.getChild().getNextSibling()));
333 - assertThat((typeDef1.getDataType().getResolvableStatus()), 341 + assertThat((typeDef1.getTypeDefBaseType().getResolvableStatus()),
334 is(ResolvableStatus.RESOLVED)); 342 is(ResolvableStatus.RESOLVED));
335 343
336 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); 344 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
337 345
338 - assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 346 + assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
339 is((YangTypeDef) node.getChild())); 347 is((YangTypeDef) node.getChild()));
340 - assertThat((typeDef2.getDataType().getResolvableStatus()), 348 + assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()),
341 is(ResolvableStatus.RESOLVED)); 349 is(ResolvableStatus.RESOLVED));
342 } 350 }
343 351
...@@ -346,7 +354,8 @@ public class IntraFileTypeLinkingTest { ...@@ -346,7 +354,8 @@ public class IntraFileTypeLinkingTest {
346 * some uses external prefix. 354 * some uses external prefix.
347 */ 355 */
348 @Test 356 @Test
349 - public void processSelfFileLinkingWithTypeWithSelfAndExternalPrefixMix() throws IOException, ParserException { 357 + public void processSelfFileLinkingWithTypeWithSelfAndExternalPrefixMix()
358 + throws IOException, ParserException {
350 359
351 YangNode node = 360 YangNode node =
352 manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang"); 361 manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang");
...@@ -375,15 +384,15 @@ public class IntraFileTypeLinkingTest { ...@@ -375,15 +384,15 @@ public class IntraFileTypeLinkingTest {
375 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 384 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
376 is((YangTypeDef) yangList.getChild())); 385 is((YangTypeDef) yangList.getChild()));
377 assertThat((leafInfo.getDataType().getResolvableStatus()), 386 assertThat((leafInfo.getDataType().getResolvableStatus()),
378 - is(ResolvableStatus.PARTIALLY_RESOLVED)); 387 + is(ResolvableStatus.INTRA_FILE_RESOLVED));
379 388
380 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); 389 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
381 390
382 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); 391 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
383 392
384 - assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 393 + assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
385 is((YangTypeDef) node.getChild())); 394 is((YangTypeDef) node.getChild()));
386 - assertThat((typeDef2.getDataType().getResolvableStatus()), 395 + assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()),
387 is(ResolvableStatus.RESOLVED)); 396 is(ResolvableStatus.RESOLVED));
388 } 397 }
389 398
...@@ -392,7 +401,8 @@ public class IntraFileTypeLinkingTest { ...@@ -392,7 +401,8 @@ public class IntraFileTypeLinkingTest {
392 * file. 401 * file.
393 */ 402 */
394 @Test(expected = ParserException.class) 403 @Test(expected = ParserException.class)
395 - public void processSelfResolutionWhenTypeReferredTypedefNotDefined() throws IOException, ParserException { 404 + public void processSelfResolutionWhenTypeReferredTypedefNotDefined()
405 + throws IOException, ParserException {
396 406
397 YangNode node = 407 YangNode node =
398 manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang"); 408 manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang");
...@@ -403,7 +413,8 @@ public class IntraFileTypeLinkingTest { ...@@ -403,7 +413,8 @@ public class IntraFileTypeLinkingTest {
403 * level where typedef is is not an ancestor of type. 413 * level where typedef is is not an ancestor of type.
404 */ 414 */
405 @Test(expected = ParserException.class) 415 @Test(expected = ParserException.class)
406 - public void processSelfFileLinkingTypedefNotFound() throws IOException, ParserException { 416 + public void processSelfFileLinkingTypedefNotFound()
417 + throws IOException, ParserException {
407 418
408 YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang"); 419 YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang");
409 } 420 }
...@@ -412,7 +423,8 @@ public class IntraFileTypeLinkingTest { ...@@ -412,7 +423,8 @@ public class IntraFileTypeLinkingTest {
412 * Checks hierarchical self resolution with self resolution failure scenario. 423 * Checks hierarchical self resolution with self resolution failure scenario.
413 */ 424 */
414 @Test(expected = ParserException.class) 425 @Test(expected = ParserException.class)
415 - public void processSelfFileLinkingWithHierarchicalTypeFailureScenario() throws IOException, ParserException { 426 + public void processSelfFileLinkingWithHierarchicalTypeFailureScenario()
427 + throws IOException, ParserException {
416 428
417 YangNode node = 429 YangNode node =
418 manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang"); 430 manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang");
......
...@@ -106,6 +106,6 @@ public class InputListenerTest { ...@@ -106,6 +106,6 @@ public class InputListenerTest {
106 YangTypeDef typeDef = (YangTypeDef) yangInput.getChild(); 106 YangTypeDef typeDef = (YangTypeDef) yangInput.getChild();
107 assertThat(typeDef.getName(), is("my-type")); 107 assertThat(typeDef.getName(), is("my-type"));
108 assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); 108 assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
109 - assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32)); 109 + assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32));
110 } 110 }
111 } 111 }
......
...@@ -128,7 +128,7 @@ public class LengthRestrictionListenerTest { ...@@ -128,7 +128,7 @@ public class LengthRestrictionListenerTest {
128 assertThat(yangNode.getName(), is("Test")); 128 assertThat(yangNode.getName(), is("Test"));
129 129
130 YangTypeDef typedef = (YangTypeDef) yangNode.getChild(); 130 YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
131 - YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getDataType() 131 + YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getTypeDefBaseType()
132 .getDataTypeExtendedInfo(); 132 .getDataTypeExtendedInfo();
133 133
134 YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction(); 134 YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
...@@ -234,4 +234,4 @@ public class LengthRestrictionListenerTest { ...@@ -234,4 +234,4 @@ public class LengthRestrictionListenerTest {
234 " 18446744073709551615."); 234 " 18446744073709551615.");
235 YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidInterval.yang"); 235 YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidInterval.yang");
236 } 236 }
237 -}
...\ No newline at end of file ...\ No newline at end of file
237 +}
......
...@@ -108,6 +108,6 @@ public class OutputListenerTest { ...@@ -108,6 +108,6 @@ public class OutputListenerTest {
108 assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); 108 assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
109 assertThat(typeDef.getName(), is("my-type")); 109 assertThat(typeDef.getName(), is("my-type"));
110 assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); 110 assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
111 - assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32)); 111 + assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32));
112 } 112 }
113 -}
...\ No newline at end of file ...\ No newline at end of file
113 +}
......
...@@ -108,7 +108,7 @@ public class PatternRestrictionListenerTest { ...@@ -108,7 +108,7 @@ public class PatternRestrictionListenerTest {
108 assertThat(yangNode.getName(), is("Test")); 108 assertThat(yangNode.getName(), is("Test"));
109 109
110 YangTypeDef typedef = (YangTypeDef) yangNode.getChild(); 110 YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
111 - YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getDataType() 111 + YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getTypeDefBaseType()
112 .getDataTypeExtendedInfo(); 112 .getDataTypeExtendedInfo();
113 113
114 YangPatternRestriction yangPatternRestriction = stringRestriction.getPatternRestriction(); 114 YangPatternRestriction yangPatternRestriction = stringRestriction.getPatternRestriction();
...@@ -166,4 +166,4 @@ public class PatternRestrictionListenerTest { ...@@ -166,4 +166,4 @@ public class PatternRestrictionListenerTest {
166 .getPatternList().listIterator(); 166 .getPatternList().listIterator();
167 assertThat(patternListIterator.next(), is("-[0-9]+|[0-9]+")); 167 assertThat(patternListIterator.next(), is("-[0-9]+|[0-9]+"));
168 } 168 }
169 -}
...\ No newline at end of file ...\ No newline at end of file
169 +}
......
...@@ -61,6 +61,6 @@ public class RpcListenerTest { ...@@ -61,6 +61,6 @@ public class RpcListenerTest {
61 YangTypeDef typeDef = (YangTypeDef) yangRpc.getChild(); 61 YangTypeDef typeDef = (YangTypeDef) yangRpc.getChild();
62 assertThat(typeDef.getName(), is("my-type")); 62 assertThat(typeDef.getName(), is("my-type"));
63 assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); 63 assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
64 - assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32)); 64 + assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32));
65 } 65 }
66 } 66 }
......
...@@ -2,6 +2,9 @@ module Test { ...@@ -2,6 +2,9 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 leaf invalid-interval { 8 leaf invalid-interval {
6 type P:hello; 9 type P:hello;
7 } 10 }
......
...@@ -2,6 +2,9 @@ module Test { ...@@ -2,6 +2,9 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 list valid { 8 list valid {
6 key address; 9 key address;
7 grouping endpoint { 10 grouping endpoint {
......
...@@ -2,20 +2,23 @@ module Test { ...@@ -2,20 +2,23 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 grouping endpoint { 8 grouping endpoint {
6 leaf address { 9 leaf address {
7 - type ip-address; 10 + type P:ip-address;
8 } 11 }
9 leaf port { 12 leaf port {
10 - type port-number; 13 + type P:port-number;
11 } 14 }
12 } 15 }
13 grouping endpoint { 16 grouping endpoint {
14 leaf address { 17 leaf address {
15 - type ip-address; 18 + type P:pip-address;
16 } 19 }
17 leaf port { 20 leaf port {
18 - type port-number; 21 + type P:port-number;
19 } 22 }
20 } 23 }
21 } 24 }
......
...@@ -2,6 +2,9 @@ module Test { ...@@ -2,6 +2,9 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 list valid { 8 list valid {
6 key address; 9 key address;
7 leaf address { 10 leaf address {
......
...@@ -2,6 +2,9 @@ module Test { ...@@ -2,6 +2,9 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 container valid { 8 container valid {
6 grouping endpoint { 9 grouping endpoint {
7 leaf address { 10 leaf address {
......
...@@ -2,6 +2,9 @@ module Test { ...@@ -2,6 +2,9 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 list valid { 8 list valid {
6 key address; 9 key address;
7 leaf address { 10 leaf address {
......
...@@ -2,6 +2,9 @@ module Test { ...@@ -2,6 +2,9 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 grouping endpoint { 8 grouping endpoint {
6 leaf address { 9 leaf address {
7 type P:ip-address; 10 type P:ip-address;
......
...@@ -2,6 +2,9 @@ module Test { ...@@ -2,6 +2,9 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 typedef Percentage { 8 typedef Percentage {
6 type P:Per; 9 type P:Per;
7 } 10 }
......
...@@ -2,6 +2,9 @@ module Test { ...@@ -2,6 +2,9 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 typedef Percentage { 8 typedef Percentage {
6 type int32; 9 type int32;
7 } 10 }
......
...@@ -2,6 +2,9 @@ module Test { ...@@ -2,6 +2,9 @@ module Test {
2 yang-version 1; 2 yang-version 1;
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 list valid { 8 list valid {
6 key address; 9 key address;
7 leaf address { 10 leaf address {
......
...@@ -6,6 +6,9 @@ module Test { ...@@ -6,6 +6,9 @@ module Test {
6 import interface-module { 6 import interface-module {
7 prefix "if"; 7 prefix "if";
8 } 8 }
9 + import ietf-yang-types {
10 + prefix "P";
11 + }
9 augment "/if:interfaces/if:ifEntry" { 12 augment "/if:interfaces/if:ifEntry" {
10 when "if:ifType='ds0'"; 13 when "if:ifType='ds0'";
11 leaf ds0ChannelNumber { 14 leaf ds0ChannelNumber {
......
...@@ -2,6 +2,9 @@ module rock { ...@@ -2,6 +2,9 @@ module rock {
2 namespace "http://example.net/rock"; 2 namespace "http://example.net/rock";
3 prefix "rock"; 3 prefix "rock";
4 4
5 + import ietf-yang-types {
6 + prefix "P";
7 + }
5 notification link-failure { 8 notification link-failure {
6 description "A link failure has been detected"; 9 description "A link failure has been detected";
7 status deprecated; 10 status deprecated;
......