Vinod Kumar S

YANG Grouping Linker Support

Change-Id: I2fec0c0bb4d1584e82ffba3228106897ccad2bf5
Showing 40 changed files with 701 additions and 518 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. 25 + * Identifies that resolvable entity is unresolved.
26 */ 26 */
27 - RESOLVED, 27 + UNRESOLVED,
28 28
29 /** 29 /**
30 - * Identifies that resolvable entity is unresolved. 30 + * Identifies that resolvable entity's reference is linked.
31 */ 31 */
32 - UNRESOLVED, 32 + LINKED,
33 33
34 /** 34 /**
35 - * Identifies that resolvable entity is partially resolved. 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
...@@ -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 }
......
...@@ -20,19 +20,22 @@ import java.util.Stack; ...@@ -20,19 +20,22 @@ import java.util.Stack;
20 20
21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 22
23 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.INTRA_FILE_RESOLVED;
24 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.LINKED;
25 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.RESOLVED;
26 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.UNRESOLVED;
27 +
23 /** 28 /**
24 * Represents resolution object which will be resolved by linker. 29 * Represents resolution object which will be resolved by linker.
30 + *
31 + * @param <T> type of resolution entity uses / type
25 */ 32 */
26 public class YangResolutionInfo<T> { 33 public class YangResolutionInfo<T> {
27 34
28 - // Prefix associated with the linking. 35 + /**
29 - private String prefix; 36 + * Information about the entity that needs to be resolved.
30 - 37 + */
31 - // Parsable node for which resolution is to be performed. 38 + private YangEntityToResolveInfo<T> entityToResolveInfo;
32 - private T entityToResolve;
33 -
34 - // Holder of the YANG construct for which resolution has to be carried out.
35 - private YangNode holderOfEntityToResolve;
36 39
37 // Error Line number. 40 // Error Line number.
38 private int lineNumber; 41 private int lineNumber;
...@@ -40,24 +43,20 @@ public class YangResolutionInfo<T> { ...@@ -40,24 +43,20 @@ public class YangResolutionInfo<T> {
40 // Error character position. 43 // Error character position.
41 private int charPosition; 44 private int charPosition;
42 45
43 - // Status of resolution.
44 - private boolean isResolved;
45 -
46 /* 46 /*
47 * Stack for type/uses is maintained for hierarchical references, this is 47 * Stack for type/uses is maintained for hierarchical references, this is
48 * used during resolution. 48 * used during resolution.
49 */ 49 */
50 - private Stack<T> partialResolvedStack; 50 + private Stack<YangEntityToResolveInfo<T>> partialResolvedStack;
51 -
52 - // Flag to indicate whether more references are detected.
53 - private boolean isMoreReferenceDetected;
54 51
55 // Module/Sub-module prefix. 52 // Module/Sub-module prefix.
56 private String resolutionInfoRootNodePrefix; 53 private String resolutionInfoRootNodePrefix;
57 54
58 /** 55 /**
59 - * Create a resolution information object. 56 + * It is private to ensure the overloaded method be invoked to create an
57 + * object.
60 */ 58 */
59 + @SuppressWarnings("unused")
61 private YangResolutionInfo() { 60 private YangResolutionInfo() {
62 61
63 } 62 }
...@@ -66,293 +65,268 @@ public class YangResolutionInfo<T> { ...@@ -66,293 +65,268 @@ public class YangResolutionInfo<T> {
66 * Creates a resolution information object with all the inputs. 65 * Creates a resolution information object with all the inputs.
67 * 66 *
68 * @param dataNode current parsable data node 67 * @param dataNode current parsable data node
69 - * @param resolutionType type of resolution whether grouping/typedef
70 - * @param holderNode parent YANG node
71 - * @param prefix imported module prefix
72 - * @param lineNumber error line number
73 - * @param charPositionInLine error character position in line
74 - */
75 - public YangResolutionInfo(T dataNode, ResolutionType resolutionType,
76 - YangNode holderNode, String prefix, int lineNumber,
77 - int charPositionInLine) {
78 - this.setHolderOfEntityToResolve(holderNode);
79 - this.setEntityToResolve(dataNode);
80 - this.setPrefix(prefix);
81 - this.setLineNumber(lineNumber);
82 - this.setCharPosition(charPositionInLine);
83 - setPartialResolvedStack(new Stack<T>());
84 - }
85 -
86 - /**
87 - * Creates a resolution information object with all the inputs except prefix.
88 - *
89 - * @param dataNode current parsable data node
90 - * @param resolutionType type of resolution whether grouping/typedef
91 * @param holderNode parent YANG node 68 * @param holderNode parent YANG node
92 * @param lineNumber error line number 69 * @param lineNumber error line number
93 * @param charPositionInLine error character position in line 70 * @param charPositionInLine error character position in line
94 */ 71 */
95 - public YangResolutionInfo(T dataNode, ResolutionType resolutionType, 72 + public YangResolutionInfo(T dataNode, YangNode holderNode, int lineNumber, int charPositionInLine) {
96 - YangNode holderNode, int lineNumber, 73 + setEntityToResolveInfo(new YangEntityToResolveInfo<T>());
97 - int charPositionInLine) { 74 + getEntityToResolveInfo().setEntityToResolve(dataNode);
98 - this.setHolderOfEntityToResolve(holderNode); 75 + getEntityToResolveInfo().setHolderOfEntityToResolve(holderNode);
99 - this.setEntityToResolve(dataNode);
100 this.setLineNumber(lineNumber); 76 this.setLineNumber(lineNumber);
101 this.setCharPosition(charPositionInLine); 77 this.setCharPosition(charPositionInLine);
78 + setPartialResolvedStack(new Stack<YangEntityToResolveInfo<T>>());
102 } 79 }
103 80
104 /** 81 /**
105 * Resolve linking with all the ancestors node for a resolution info. 82 * Resolve linking with all the ancestors node for a resolution info.
106 * 83 *
107 * @param resolutionInfoNodePrefix module/sub-module prefix 84 * @param resolutionInfoNodePrefix module/sub-module prefix
108 - * @throws DataModelException DataModelException a violation of data model rules 85 + * @throws DataModelException DataModelException a violation of data model
86 + * rules
109 */ 87 */
110 - public void resolveLinkingForResolutionInfo(String resolutionInfoNodePrefix) throws DataModelException { 88 + public void resolveLinkingForResolutionInfo(String resolutionInfoNodePrefix)
89 + throws DataModelException {
111 90
112 this.resolutionInfoRootNodePrefix = resolutionInfoNodePrefix; 91 this.resolutionInfoRootNodePrefix = resolutionInfoNodePrefix;
113 92
114 // Current node to resolve, it can be a YANG type or YANG uses. 93 // Current node to resolve, it can be a YANG type or YANG uses.
115 - T entityToResolve = getEntityToResolve(); 94 + T entityToResolve = getEntityToResolveInfo().getEntityToResolve();
116 95
117 // Check if linking is already done 96 // Check if linking is already done
118 if (entityToResolve instanceof Resolvable) { 97 if (entityToResolve instanceof Resolvable) {
119 Resolvable resolvable = (Resolvable) entityToResolve; 98 Resolvable resolvable = (Resolvable) entityToResolve;
120 - if (resolvable.getResolvableStatus() == ResolvableStatus.RESOLVED || 99 + if (resolvable.getResolvableStatus() == RESOLVED) {
121 - resolvable.getResolvableStatus() == ResolvableStatus.PARTIALLY_RESOLVED) { 100 + /**
101 + * entity is already resolved, so nothing to do
102 + */
122 return; 103 return;
123 } 104 }
124 } else { 105 } else {
125 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); 106 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
126 } 107 }
127 108
128 - // Push the initial YANG type to the stack. 109 + // Push the initial entity to resolve in stack.
129 - getPartialResolvedStack().push(entityToResolve); 110 + addInPartialResolvedStack(getEntityToResolveInfo());
130 -
131 - // Get holder of entity to resolve
132 - YangNode curNode = getHolderOfEntityToResolve();
133 111
134 - resolveLinkingWithAncestors(curNode); 112 + linkAndResolvePartialResolvedStack();
135 } 113 }
136 114
137 /** 115 /**
138 * Resolves linking with ancestors. 116 * Resolves linking with ancestors.
139 * 117 *
140 - * @param curNode current node for which ancestors to be checked
141 * @throws DataModelException a violation of data model rules 118 * @throws DataModelException a violation of data model rules
142 */ 119 */
143 - private void resolveLinkingWithAncestors(YangNode curNode) throws DataModelException { 120 + private void linkAndResolvePartialResolvedStack()
121 + throws DataModelException {
144 122
145 - while (curNode != null) { 123 + while (getPartialResolvedStack().size() != 0) {
146 - YangNode node = curNode.getChild(); 124 +
147 - if (resolveLinkingForNodesChildAndSibling(node, curNode)) { 125 + // Current node to resolve, it can be a YANG type or YANG uses.
148 - return; 126 + T entityToResolve = getCurrentEntityToResolveFromStack();
127 + // Check if linking is already done
128 + if (entityToResolve instanceof Resolvable) {
129 +
130 + Resolvable resolvable = (Resolvable) entityToResolve;
131 + switch (resolvable.getResolvableStatus()) {
132 + case RESOLVED: {
133 + /*
134 + * If the entity is already resolved in the stack, then
135 + * pop it and continue with the remaining stack elements
136 + * to resolve
137 + */
138 + getPartialResolvedStack().pop();
139 + break;
149 } 140 }
150 - curNode = curNode.getParent(); 141 +
142 + case LINKED: {
143 + /*
144 + * If the top of the stack is already linked then
145 + * resolve the references and pop the entity and
146 + * continue with remaining stack elements to resolve
147 + */
148 + resolveTopOfStack();
149 + getPartialResolvedStack().pop();
150 + break;
151 } 151 }
152 152
153 - // If curNode is null, it indicates an error condition in YANG file. 153 + case INTRA_FILE_RESOLVED: {
154 - DataModelException dataModelException = new DataModelException("YANG file error: Unable to find base " + 154 + /*
155 - "typedef/grouping for given type/uses"); 155 + * TODO: this needs to be deleted, when inter-file
156 + * resolution is implmeneted
157 + */
158 + getPartialResolvedStack().pop();
159 + break;
160 + }
161 +
162 + case UNRESOLVED: {
163 + linkTopOfStackReferenceUpdateStack();
164 +
165 + if (resolvable.getResolvableStatus() == UNRESOLVED) {
166 + // If current entity is still not resolved, then linking/resolution has failed.
167 + DataModelException dataModelException =
168 + new DataModelException("YANG file error: Unable to find base "
169 + + "typedef/grouping for given type/uses");
156 dataModelException.setLine(getLineNumber()); 170 dataModelException.setLine(getLineNumber());
157 dataModelException.setCharPosition(getCharPosition()); 171 dataModelException.setCharPosition(getCharPosition());
158 throw dataModelException; 172 throw dataModelException;
159 } 173 }
160 - 174 + break;
161 - /**
162 - * Resolves linking for a node child and siblings.
163 - *
164 - * @param node current node
165 - * @param parentNode parent node of current node
166 - * @return flag to indicate whether resolution is done
167 - * @throws DataModelException
168 - */
169 - private boolean resolveLinkingForNodesChildAndSibling(YangNode node, YangNode parentNode)
170 - throws DataModelException {
171 - while ((node != null)) {
172 - isMoreReferenceDetected = false;
173 - // Check if node is of type, typedef or grouping
174 - if (isNodeOfResolveType(node)) {
175 - if (resolveLinkingForNode(node, parentNode)) {
176 - return true;
177 } 175 }
176 + default: {
177 + throw new DataModelException("Data Model Exception: Unsupported, linker state");
178 } 178 }
179 - if (isMoreReferenceDetected) { 179 +
180 - /* 180 + }
181 - * If more reference are present, tree traversal must start from 181 +
182 - * first child again, to check the availability of
183 - * typedef/grouping.
184 - */
185 - node = parentNode.getChild();
186 } else { 182 } else {
187 - node = node.getNextSibling(); 183 + throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
188 } 184 }
185 +
189 } 186 }
190 - return false; 187 +
191 } 188 }
192 189
193 /** 190 /**
194 - * Resolves linking for a node. 191 + * Resolve the current entity in the stack.
195 - *
196 - * @param node current node
197 - * @param parentNode parent node of current node
198 - * @return flag to indicate whether resolution is done
199 - * @throws DataModelException a violation of data model rules
200 */ 192 */
201 - private boolean resolveLinkingForNode(YangNode node, YangNode parentNode) throws DataModelException { 193 + private void resolveTopOfStack() {
194 + ((Resolvable) getCurrentEntityToResolveFromStack()).resolve();
202 195
203 - /* 196 + if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus()
204 - * Check if name of node name matches with the entity name under 197 + != INTRA_FILE_RESOLVED) {
205 - * resolution. 198 + // Sets the resolution status in inside the type/uses.
206 - */ 199 + ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(RESOLVED);
207 - if (isNodeNameSameAsResolutionInfoName(node)) { 200 + }
208 - // Adds reference of entity to the node under resolution. 201 + }
209 - addReferredEntityLink(node); 202 +
210 - // Check if referred entity has further reference to uses/type. 203 + /**
211 - if (!(isMoreReferencePresent(node))) { 204 + * Resolves linking for a node child and siblings.
212 - // Resolve all the entities in stack. 205 + *
213 - resolveStackAndAddToStack(node); 206 + * @throws DataModelException data model error
214 - return true;
215 - } else {
216 - // Adds referred type/uses to the stack.
217 - addToPartialResolvedStack(node);
218 - /*
219 - * Check whether referred type is resolved, partially resolved
220 - * or unresolved.
221 */ 207 */
222 - if (isReferenceFullyResolved()) { 208 + private void linkTopOfStackReferenceUpdateStack()
223 - // Resolve the stack which is complete. 209 + throws DataModelException {
224 - resolveCompleteStack(); 210 +
225 - return true; 211 + if (!isSelfFileReference()) {
226 - } else if (isReferencePartiallyResolved()) {
227 /* 212 /*
228 - * Update the resolution type to partially resolved for all 213 + * TODO: use mojo utilities to load the referred module/sub-module
229 - * type/uses in stack 214 + * and get the reference to the corresponding referred entity
230 */ 215 */
231 - updateResolutionTypeToPartial(); 216 +
232 - return true; 217 + ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(INTRA_FILE_RESOLVED);
233 - } else { 218 + return;
234 - /* 219 + }
235 - * Check if prefix is present to find that the derived 220 +
236 - * reference is for intra file or inter file, if it's 221 + /**
237 - * inter-file return and stop further processing. 222 + * Try to resolve the top of the stack and update partial resolved stack
223 + * if there is recursive references
238 */ 224 */
239 - if (isExternalPrefixPresent(node)) { 225 + YangNode potentialAncestorWithReferredNode = getPartialResolvedStack().peek()
240 - /* 226 + .getHolderOfEntityToResolve();
241 - * Update the resolution type to partially resolved for 227 +
242 - * all type/uses in stack 228 + /**
229 + * Traverse up in the ancestor tree to check if the referred node is
230 + * defined
243 */ 231 */
244 - updateResolutionTypeToPartial(); 232 + while (potentialAncestorWithReferredNode != null) {
245 - return true; 233 +
246 - } else { 234 + /**
247 - /* 235 + * Check for the referred node defined in a ancestor scope
248 - * If prefix is not present it indicates intra-file
249 - * dependency in this case set the node back to first
250 - * child, as referred entity may appear in any order and
251 - * continue with the resolution.
252 */ 236 */
253 - isMoreReferenceDetected = true; 237 + YangNode potentialReferredNode = potentialAncestorWithReferredNode.getChild();
254 - return false; 238 + if (isReferredNodeInSiblingListProcessed(potentialReferredNode)) {
255 - } 239 + return;
256 - }
257 } 240 }
241 +
242 + potentialAncestorWithReferredNode = potentialAncestorWithReferredNode.getParent();
258 } 243 }
259 - return false;
260 } 244 }
261 245
262 /** 246 /**
263 - * Update resolution type to partial for all type/uses in stack. 247 + * Check if the reference in self file or in external file.
264 * 248 *
249 + * @return true if self file reference, false otherwise
265 * @throws DataModelException a violation of data model rules 250 * @throws DataModelException a violation of data model rules
266 */ 251 */
267 - private void updateResolutionTypeToPartial() throws DataModelException { 252 + private boolean isSelfFileReference()
268 - // For all entries in stack calls for the resolution in type/uses. 253 + throws DataModelException {
269 - for (T entity : getPartialResolvedStack()) { 254 + String prefix;
270 - if (!(entity instanceof Resolvable)) { 255 + if (getCurrentEntityToResolveFromStack() instanceof YangType) {
256 + prefix = ((YangType<?>) getCurrentEntityToResolveFromStack()).getPrefix();
257 + } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
258 + prefix = ((YangUses) getCurrentEntityToResolveFromStack()).getPrefix();
259 + } else {
271 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); 260 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
272 } 261 }
273 - if (((Resolvable) entity).getResolvableStatus() == ResolvableStatus.UNRESOLVED) {
274 - // Sets the resolution status in inside the type/uses.
275 - ((Resolvable) entity).setResolvableStatus(ResolvableStatus.PARTIALLY_RESOLVED);
276 - }
277 - }
278 - }
279 262
280 - /** 263 + if (prefix == null) {
281 - * Adds referred type/uses to the stack and resolve the stack. 264 + return true;
282 - *
283 - * @param node typedef/grouping node
284 - * @throws DataModelException a violation of data model rules
285 - */
286 - private void resolveStackAndAddToStack(YangNode node) throws DataModelException {
287 - if (getEntityToResolve() instanceof YangType) {
288 - // Adds to the stack only for YANG typedef.
289 - getPartialResolvedStack().push((T) ((YangTypeDef) node).getDataType());
290 } 265 }
291 - // Don't add to stack in case of YANG grouping. 266 + return prefix.contentEquals(resolutionInfoRootNodePrefix);
292 267
293 - // Resolve the complete stack.
294 - resolveCompleteStack();
295 } 268 }
296 269
297 /** 270 /**
298 - * Check if the referred type/uses is partially resolved. 271 + * Check for the referred node defined in a ancestor scope.
299 * 272 *
300 - * @return true if reference is partially resolved, otherwise false 273 + * @param potentialReferredNode potential referred node
274 + * @return status of resolution and updating the partial resolved stack with
275 + * the any recursive references
276 + * @throws DataModelException data model errors
301 */ 277 */
302 - private boolean isReferencePartiallyResolved() { 278 + private boolean isReferredNodeInSiblingListProcessed(YangNode potentialReferredNode)
303 - if (getPartialResolvedStack().peek() instanceof YangType) { 279 + throws DataModelException {
304 - /* 280 + while (potentialReferredNode != null) {
305 - * Checks if type is partially resolved. 281 +
306 - */ 282 + // Check if the potential referred node is the actual referred node
307 - if (((YangType) getPartialResolvedStack().peek()) 283 + if (isReferredNode(potentialReferredNode)) {
308 - .getResolvableStatus() == ResolvableStatus.PARTIALLY_RESOLVED) { 284 +
309 - return true; 285 + // Adds reference link of entity to the node under resolution.
310 - } 286 + addReferredEntityLink(potentialReferredNode);
311 - } else if (getPartialResolvedStack().peek() instanceof YangUses) {
312 - if (((YangUses) getPartialResolvedStack().peek())
313 - .getResolvableStatus() == ResolvableStatus.PARTIALLY_RESOLVED) {
314 - return true;
315 - }
316 - }
317 - return false;
318 - }
319 287
320 /** 288 /**
321 - * Check if the referred type/uses is resolved. 289 + * resolve the reference and update the partial resolution stack
322 - * 290 + * with any further recursive references
323 - * @return true if reference is resolved, otherwise false
324 */ 291 */
325 - private boolean isReferenceFullyResolved() { 292 + addUnresolvedRecursiveReferenceToStack(potentialReferredNode);
326 - if (getPartialResolvedStack().peek() instanceof YangType) { 293 +
327 /* 294 /*
328 - * Checks if type is partially resolved. 295 + * return true, since the reference is linked and any recursive
296 + * unresolved references is added to the stack
329 */ 297 */
330 - if (((YangType) getPartialResolvedStack().peek()).getResolvableStatus() == ResolvableStatus.RESOLVED) {
331 - return true;
332 - }
333 - } else if (getPartialResolvedStack().peek() instanceof YangUses) {
334 - if (((YangUses) getPartialResolvedStack().peek()).getResolvableStatus() == ResolvableStatus.RESOLVED) {
335 return true; 298 return true;
336 } 299 }
300 +
301 + potentialReferredNode = potentialReferredNode.getNextSibling();
337 } 302 }
338 return false; 303 return false;
339 } 304 }
340 305
341 /** 306 /**
342 - * Check if node is of resolve type i.e. of type typedef or grouping. 307 + * Check if the potential referred node is the actual referred node.
343 * 308 *
344 - * @param node typedef/grouping node 309 + * @param potentialReferredNode typedef/grouping node
345 * @return true if node is of resolve type otherwise false 310 * @return true if node is of resolve type otherwise false
346 * @throws DataModelException a violation of data model rules 311 * @throws DataModelException a violation of data model rules
347 */ 312 */
348 - private boolean isNodeOfResolveType(YangNode node) throws DataModelException { 313 + private boolean isReferredNode(YangNode potentialReferredNode)
349 - if (getPartialResolvedStack().peek() instanceof YangType && entityToResolve instanceof YangType) { 314 + throws DataModelException {
350 - if (node instanceof YangTypeDef) { 315 + if (getCurrentEntityToResolveFromStack() instanceof YangType) {
351 - return true; 316 + if (potentialReferredNode instanceof YangTypeDef) {
317 + /*
318 + * Check if name of node name matches with the entity being
319 + * resolved
320 + */
321 + return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
352 } 322 }
353 - } else if (getPartialResolvedStack().peek() instanceof YangUses && entityToResolve instanceof YangUses) { 323 + } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
354 - if (node instanceof YangGrouping) { 324 + if (potentialReferredNode instanceof YangGrouping) {
355 - return true; 325 + /*
326 + * Check if name of node name matches with the entity being
327 + * resolved
328 + */
329 + return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
356 } 330 }
357 } else { 331 } else {
358 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); 332 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
...@@ -369,13 +343,18 @@ public class YangResolutionInfo<T> { ...@@ -369,13 +343,18 @@ public class YangResolutionInfo<T> {
369 * false 343 * false
370 * @throws DataModelException a violation of data model rules 344 * @throws DataModelException a violation of data model rules
371 */ 345 */
372 - private boolean isNodeNameSameAsResolutionInfoName(YangNode node) throws DataModelException { 346 +
373 - if (getPartialResolvedStack().peek() instanceof YangType) { 347 + private boolean isNodeNameSameAsResolutionInfoName(YangNode node)
374 - if (node.getName().equals(((YangType<?>) getPartialResolvedStack().peek()).getDataTypeName())) { 348 + throws DataModelException {
349 + if (getCurrentEntityToResolveFromStack() instanceof YangType) {
350 + if (node.getName().contentEquals(
351 + ((YangType<?>) getCurrentEntityToResolveFromStack())
352 + .getDataTypeName())) {
375 return true; 353 return true;
376 } 354 }
377 - } else if (getPartialResolvedStack().peek() instanceof YangUses) { 355 + } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
378 - if (node.getName().equals(((YangUses) getPartialResolvedStack().peek()).getName())) { 356 + if (node.getName().contentEquals(
357 + ((YangUses) getCurrentEntityToResolveFromStack()).getName())) {
379 return true; 358 return true;
380 } 359 }
381 } else { 360 } else {
...@@ -387,181 +366,91 @@ public class YangResolutionInfo<T> { ...@@ -387,181 +366,91 @@ public class YangResolutionInfo<T> {
387 /** 366 /**
388 * Adds reference of grouping/typedef in uses/type. 367 * Adds reference of grouping/typedef in uses/type.
389 * 368 *
390 - * @param node grouping/typedef node 369 + * @param referredNode grouping/typedef node being referred
391 * @throws DataModelException a violation of data model rules 370 * @throws DataModelException a violation of data model rules
392 */ 371 */
393 - private void addReferredEntityLink(YangNode node) throws DataModelException { 372 + private void addReferredEntityLink(YangNode referredNode)
394 - if (getPartialResolvedStack().peek() instanceof YangType) { 373 + throws DataModelException {
395 - YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) ((YangType<?>) getPartialResolvedStack().peek()) 374 + if (getCurrentEntityToResolveFromStack() instanceof YangType) {
396 - .getDataTypeExtendedInfo(); 375 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>)
397 - derivedInfo.setReferredTypeDef((YangTypeDef) node); 376 + ((YangType<?>) getCurrentEntityToResolveFromStack()).getDataTypeExtendedInfo();
398 - } else if (getPartialResolvedStack().peek() instanceof YangUses) { 377 + derivedInfo.setReferredTypeDef((YangTypeDef) referredNode);
399 - ((YangUses) getPartialResolvedStack().peek()).setRefGroup((YangGrouping) node); 378 + } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
379 + ((YangUses) getCurrentEntityToResolveFromStack())
380 + .setRefGroup((YangGrouping) referredNode);
400 } else { 381 } else {
401 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); 382 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
402 } 383 }
384 +
385 + // Sets the resolution status in inside the type/uses.
386 + ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(LINKED);
403 } 387 }
404 388
405 /** 389 /**
406 - * Checks if typedef/grouping has further reference to type/typedef. 390 + * Checks if type/grouping has further reference to typedef/ unresolved
391 + * uses. Add it to the partial resolve stack and return the status of
392 + * addition to stack.
407 * 393 *
408 - * @param node grouping/typedef node 394 + * @param referredNode grouping/typedef node
409 - * @return true if referred entity is resolved, otherwise false
410 * @throws DataModelException a violation of data model rules 395 * @throws DataModelException a violation of data model rules
411 */ 396 */
412 - private boolean isMoreReferencePresent(YangNode node) throws DataModelException { 397 + private void addUnresolvedRecursiveReferenceToStack(YangNode referredNode)
413 - if (getEntityToResolve() instanceof YangType) { 398 + throws DataModelException {
414 - /* 399 + if (getCurrentEntityToResolveFromStack() instanceof YangType) {
415 - * Checks if typedef type is built-in type
416 - */
417 - if ((((YangTypeDef) node).getDataType().getDataType() != YangDataTypes.DERIVED)) {
418 - return false;
419 - }
420 - } else if (getEntityToResolve() instanceof YangUses) {
421 /* 400 /*
422 - * Search if the grouping has any uses child, if so return false, 401 + * Checks if typedef type is derived
423 - * else return true.
424 */ 402 */
425 - if (getUsesInGrouping(node) == null) { 403 + if (((YangTypeDef) referredNode).getTypeDefBaseType().getDataType()
426 - return false; 404 + == YangDataTypes.DERIVED) {
427 - }
428 - } else {
429 - throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
430 - }
431 - return true;
432 - }
433 405
434 - /** 406 + YangEntityToResolveInfo<YangType<?>> unResolvedEntityInfo = new YangEntityToResolveInfo<YangType<?>>();
435 - * Return if there is any uses in grouping. 407 + unResolvedEntityInfo.setEntityToResolve(((YangTypeDef) referredNode)
436 - * 408 + .getTypeDefBaseType());
437 - * @param node grouping/typedef node 409 + unResolvedEntityInfo.setHolderOfEntityToResolve(referredNode);
438 - * @return if there is any uses in grouping, otherwise return null 410 + addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo);
439 - */
440 - private YangUses getUsesInGrouping(YangNode node) {
441 - YangNode curNode = ((YangGrouping) node).getChild();
442 - while (curNode != null) {
443 - if (curNode instanceof YangUses) {
444 - break;
445 - }
446 - curNode = curNode.getNextSibling();
447 - }
448 - return (YangUses) curNode;
449 } 411 }
450 412
451 - /** 413 + } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
452 - * Resolve the complete stack.
453 - *
454 - * @throws DataModelException a violation of data model rules
455 - */
456 - private void resolveCompleteStack() throws DataModelException {
457 - // For all entries in stack calls for the resolution in type/uses.
458 - for (T entity : getPartialResolvedStack()) {
459 - if (!(entity instanceof Resolvable)) {
460 - throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
461 - }
462 - ((Resolvable) entity).resolve();
463 - // Sets the resolution status in inside the type/uses.
464 - ((Resolvable) entity).setResolvableStatus(ResolvableStatus.RESOLVED);
465 - }
466 /* 414 /*
467 - * Sets the resolution status in resolution info present in resolution 415 + * Search if the grouping has any un resolved uses child, if so
468 - * list. 416 + * return true, else return false.
469 - */
470 - setIsResolved(true);
471 - }
472 -
473 - /**
474 - * Adds to partial resolved stack.
475 - *
476 - * @param node grouping/typedef node
477 - * @throws DataModelException a violation of data model rules
478 */ 417 */
479 - private void addToPartialResolvedStack(YangNode node) throws DataModelException { 418 + addUnResolvedUsesToStack(referredNode);
480 - if (getPartialResolvedStack().peek() instanceof YangType) {
481 - // Adds to the stack only for YANG typedef.
482 - getPartialResolvedStack().push((T) ((YangTypeDef) node).getDataType());
483 - } else if (getPartialResolvedStack().peek() instanceof YangUses) {
484 - getPartialResolvedStack().push((T) getUsesInGrouping(node));
485 } else { 419 } else {
486 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); 420 throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
487 } 421 }
488 } 422 }
489 423
490 /** 424 /**
491 - * Check if prefix is associated with type/uses. 425 + * Return if there is any unresolved uses in grouping.
492 * 426 *
493 - * @param node typedef/grouping node 427 + * @param node grouping/typedef node
494 - * @return true if prefix is present, otherwise false
495 - * @throws DataModelException a violation of data model rules
496 */ 428 */
497 - private boolean isExternalPrefixPresent(YangNode node) throws DataModelException { 429 + private void addUnResolvedUsesToStack(YangNode node) {
498 - if (getEntityToResolve() instanceof YangType) {
499 - if (((YangTypeDef) node).getDataType().getPrefix() != null &&
500 - (!((YangTypeDef) node).getDataType().getPrefix().equals(resolutionInfoRootNodePrefix))) {
501 - return true;
502 - }
503 - } else if (getEntityToResolve() instanceof YangUses) {
504 - if (getUsesInGrouping(node).getPrefix() != null) {
505 - return true;
506 - }
507 - } else {
508 - throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
509 - }
510 - return false;
511 - }
512 430
513 /** 431 /**
514 - * Returns prefix of imported module. 432 + * Search the grouping node's children for presence of uses node.
515 - *
516 - * @return prefix of imported module
517 */ 433 */
518 - public String getPrefix() { 434 + YangNode curNode = node.getChild();
519 - return prefix; 435 + while (curNode != null) {
520 - } 436 + if (curNode instanceof YangUses) {
521 - 437 + ResolvableStatus curResolveStatus = ((Resolvable) curNode).getResolvableStatus();
438 + if (curResolveStatus == UNRESOLVED) {
522 /** 439 /**
523 - * Sets prefix of imported module. 440 + * The current uses is not resolved, add it to partial
524 - * 441 + * resolved stack
525 - * @param prefix of imported module
526 */ 442 */
527 - public void setPrefix(String prefix) { 443 + YangEntityToResolveInfo<YangUses> unResolvedEntityInfo = new YangEntityToResolveInfo<YangUses>();
528 - this.prefix = prefix; 444 + unResolvedEntityInfo.setEntityToResolve((YangUses) curNode);
529 - } 445 + unResolvedEntityInfo.setHolderOfEntityToResolve(node);
446 + addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo);
530 447
531 - /**
532 - * Returns parsable entity which is to be resolved.
533 - *
534 - * @return parsable entity which is to be resolved
535 - */
536 - public T getEntityToResolve() {
537 - return entityToResolve;
538 } 448 }
539 -
540 - /**
541 - * Sets parsable entity to be resolved.
542 - *
543 - * @param entityToResolve YANG entity to be resolved
544 - */
545 - public void setEntityToResolve(T entityToResolve) {
546 - this.entityToResolve = entityToResolve;
547 } 449 }
548 - 450 + curNode = curNode.getNextSibling();
549 - /**
550 - * Returns parent YANG node holder for the entity to be resolved.
551 - *
552 - * @return parent YANG node holder
553 - */
554 - public YangNode getHolderOfEntityToResolve() {
555 - return holderOfEntityToResolve;
556 } 451 }
557 452
558 - /** 453 + return;
559 - * Sets parent YANG node holder for the entity to be resolved.
560 - *
561 - * @param holderOfEntityToResolve parent YANG node holder
562 - */
563 - public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) {
564 - this.holderOfEntityToResolve = holderOfEntityToResolve;
565 } 454 }
566 455
567 /** 456 /**
...@@ -601,38 +490,59 @@ public class YangResolutionInfo<T> { ...@@ -601,38 +490,59 @@ public class YangResolutionInfo<T> {
601 } 490 }
602 491
603 /** 492 /**
604 - * Returns status of resolution. 493 + * Returns stack of YANG type with partially resolved YANG construct
494 + * hierarchy.
605 * 495 *
606 - * @return resolution status 496 + * @return partial resolved YANG construct stack
607 */ 497 */
608 - public boolean isResolved() { 498 + private Stack<YangEntityToResolveInfo<T>> getPartialResolvedStack() {
609 - return isResolved; 499 + return partialResolvedStack;
610 } 500 }
611 501
612 /** 502 /**
613 - * Sets status of resolution. 503 + * Sets stack of YANG type with partially resolved YANG construct hierarchy.
614 * 504 *
615 - * @param isResolved resolution status 505 + * @param partialResolvedStack partial resolved YANG construct stack
616 */ 506 */
617 - public void setIsResolved(boolean isResolved) { 507 + private void setPartialResolvedStack(Stack<YangEntityToResolveInfo<T>> partialResolvedStack) {
618 - this.isResolved = isResolved; 508 + this.partialResolvedStack = partialResolvedStack;
619 } 509 }
620 510
621 /** 511 /**
622 - * Returns stack of YANG type with partially resolved YANG construct hierarchy. 512 + * Sets stack of YANG type with partially resolved YANG construct hierarchy.
623 * 513 *
624 - * @return partial resolved YANG construct stack 514 + * @param partialResolvedInfo partial resolved YANG construct stack
625 */ 515 */
626 - public Stack<T> getPartialResolvedStack() { 516 + private void addInPartialResolvedStack(YangEntityToResolveInfo<T> partialResolvedInfo) {
627 - return partialResolvedStack; 517 + getPartialResolvedStack().push(partialResolvedInfo);
628 } 518 }
629 519
630 /** 520 /**
631 - * Sets stack of YANG type with partially resolved YANG construct hierarchy. 521 + * Retrieves the next entity in the stack that needs to be resolved. It is
522 + * assumed that the caller ensures that the stack is not empty.
632 * 523 *
633 - * @param partialResolvedStack partial resolved YANG construct stack 524 + * @return next entity in the stack that needs to be resolved
634 */ 525 */
635 - public void setPartialResolvedStack(Stack<T> partialResolvedStack) { 526 + private T getCurrentEntityToResolveFromStack() {
636 - this.partialResolvedStack = partialResolvedStack; 527 + return getPartialResolvedStack().peek().getEntityToResolve();
528 + }
529 +
530 + /**
531 + * Retrieves information about the entity that needs to be resolved.
532 + *
533 + * @return information about the entity that needs to be resolved
534 + */
535 + public YangEntityToResolveInfo<T> getEntityToResolveInfo() {
536 + return entityToResolveInfo;
537 + }
538 +
539 + /**
540 + * Sets information about the entity that needs to be resolved.
541 + *
542 + * @param entityToResolveInfo information about the entity that needs to be
543 + * resolved
544 + */
545 + public void setEntityToResolveInfo(YangEntityToResolveInfo<T> entityToResolveInfo) {
546 + this.entityToResolveInfo = entityToResolveInfo;
637 } 547 }
638 } 548 }
......
...@@ -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 */
...@@ -117,10 +119,14 @@ public final class DataModelUtils { ...@@ -117,10 +119,14 @@ public final class DataModelUtils {
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,9 +53,8 @@ public final class DescriptionListener { ...@@ -52,9 +53,8 @@ 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
......
...@@ -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,9 +57,8 @@ public final class KeyListener { ...@@ -57,9 +57,8 @@ 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
......
...@@ -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();
......
...@@ -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,8 +165,8 @@ public final class TypeListener { ...@@ -165,8 +165,8 @@ 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 }
...@@ -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;
......
...@@ -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();
......
...@@ -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 } 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();
......
...@@ -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;
......