YANG Grouping Linker Support
Change-Id: I2fec0c0bb4d1584e82ffba3228106897ccad2bf5
Showing
40 changed files
with
733 additions
and
550 deletions
| ... | @@ -26,7 +26,7 @@ public interface Resolvable { | ... | @@ -26,7 +26,7 @@ public interface Resolvable { |
| 26 | * Returns the status of resolution. If completely resolved returns enum | 26 | * Returns the status of resolution. If completely resolved returns enum |
| 27 | * value "RESOLVED", if not returns "UNRESOLVED", in case reference of | 27 | * value "RESOLVED", if not returns "UNRESOLVED", in case reference of |
| 28 | * grouping/typedef is added to uses/type but it's not resolved | 28 | * grouping/typedef is added to uses/type but it's not resolved |
| 29 | - * "PARTIALLY_RESOLVED" is returned. | 29 | + * "INTRA_FILE_RESOLVED" is returned. |
| 30 | * | 30 | * |
| 31 | * @return status of resolution | 31 | * @return status of resolution |
| 32 | */ | 32 | */ |
| ... | @@ -36,7 +36,7 @@ public interface Resolvable { | ... | @@ -36,7 +36,7 @@ public interface Resolvable { |
| 36 | * Set the status of type/uses resolution. If completely resolved set enum | 36 | * Set the status of type/uses resolution. If completely resolved set enum |
| 37 | * value "RESOLVED", if not set it to "UNRESOLVED", in case reference of | 37 | * value "RESOLVED", if not set it to "UNRESOLVED", in case reference of |
| 38 | * grouping/typedef is added to uses/type but it's not resolved | 38 | * grouping/typedef is added to uses/type but it's not resolved |
| 39 | - * "PARTIALLY_RESOLVED" should be set. | 39 | + * "INTRA_FILE_RESOLVED" should be set. |
| 40 | * | 40 | * |
| 41 | * @param resolvableStatus status of resolution | 41 | * @param resolvableStatus status of resolution |
| 42 | */ | 42 | */ | ... | ... |
| ... | @@ -22,17 +22,24 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -22,17 +22,24 @@ package org.onosproject.yangutils.datamodel; |
| 22 | public enum ResolvableStatus { | 22 | public enum ResolvableStatus { |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | - * Identifies that resolvable entity is resolved. | ||
| 26 | - */ | ||
| 27 | - RESOLVED, | ||
| 28 | - | ||
| 29 | - /** | ||
| 30 | * Identifies that resolvable entity is unresolved. | 25 | * Identifies that resolvable entity is unresolved. |
| 31 | */ | 26 | */ |
| 32 | UNRESOLVED, | 27 | UNRESOLVED, |
| 33 | 28 | ||
| 34 | /** | 29 | /** |
| 35 | - * Identifies that resolvable entity is partially resolved. | 30 | + * Identifies that resolvable entity's reference is linked. |
| 31 | + */ | ||
| 32 | + LINKED, | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Identifies that resolvable entity is IntraFile resolved (i.e. complete | ||
| 36 | + * linking with in the intra file). | ||
| 36 | */ | 37 | */ |
| 37 | - PARTIALLY_RESOLVED; | 38 | + INTRA_FILE_RESOLVED, |
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * Identifies that resolvable entity is resolved. | ||
| 42 | + */ | ||
| 43 | + RESOLVED; | ||
| 44 | + | ||
| 38 | } | 45 | } | ... | ... |
| ... | @@ -75,6 +75,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -75,6 +75,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
| 75 | * | when | 7.19.5 | 0..1 |-TODO | | 75 | * | when | 7.19.5 | 0..1 |-TODO | |
| 76 | * +--------------+---------+-------------+------------------+ | 76 | * +--------------+---------+-------------+------------------+ |
| 77 | */ | 77 | */ |
| 78 | + | ||
| 78 | /** | 79 | /** |
| 79 | * Representation of data model node to maintain information defined in YANG augment. | 80 | * Representation of data model node to maintain information defined in YANG augment. |
| 80 | */ | 81 | */ | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEntityToResolveInfo.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.yangutils.datamodel; | ||
| 17 | + | ||
| 18 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Represents information about entity being resolved. | ||
| 22 | + */ | ||
| 23 | +public class YangEntityToResolveInfo<T> { | ||
| 24 | + | ||
| 25 | + // Parsable node for which resolution is to be performed. | ||
| 26 | + private T entityToResolve; | ||
| 27 | + | ||
| 28 | + // Holder of the YANG construct for which resolution has to be carried out. | ||
| 29 | + private YangNode holderOfEntityToResolve; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * Retrieves the entity to be resolved. | ||
| 33 | + * | ||
| 34 | + * @return entity to be resolved | ||
| 35 | + */ | ||
| 36 | + public T getEntityToResolve() { | ||
| 37 | + return entityToResolve; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * Sets entity to be resolved. | ||
| 42 | + * | ||
| 43 | + * @param entityToResolve entity to be resolved | ||
| 44 | + */ | ||
| 45 | + public void setEntityToResolve(T entityToResolve) { | ||
| 46 | + this.entityToResolve = entityToResolve; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Retrieves the parent node which contains the entity to be resolved. | ||
| 51 | + * | ||
| 52 | + * @return parent node which contains the entity to be resolved | ||
| 53 | + */ | ||
| 54 | + public YangNode getHolderOfEntityToResolve() { | ||
| 55 | + return holderOfEntityToResolve; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * Sets parent node which contains the entity to be resolved. | ||
| 60 | + * | ||
| 61 | + * @param holderOfEntityToResolve parent node which contains the entity to be resolved | ||
| 62 | + */ | ||
| 63 | + public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) { | ||
| 64 | + this.holderOfEntityToResolve = holderOfEntityToResolve; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + public String getEntityPrefix() | ||
| 69 | + throws DataModelException { | ||
| 70 | + if (getEntityToResolve() == null) { | ||
| 71 | + return null; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + String prefix; | ||
| 75 | + T entityToResolve = (T) getEntityToResolve(); | ||
| 76 | + if (entityToResolve instanceof YangType) { | ||
| 77 | + prefix = ((YangType<?>) entityToResolve).getPrefix(); | ||
| 78 | + } else if (entityToResolve instanceof YangUses) { | ||
| 79 | + prefix = ((YangUses) entityToResolve).getPrefix(); | ||
| 80 | + } else { | ||
| 81 | + throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); | ||
| 82 | + } | ||
| 83 | + return prefix; | ||
| 84 | + } | ||
| 85 | +} |
| ... | @@ -59,10 +59,12 @@ import org.onosproject.yangutils.utils.YangConstructType; | ... | @@ -59,10 +59,12 @@ import org.onosproject.yangutils.utils.YangConstructType; |
| 59 | * | revision-date | 7.1.5.1 | 0..1 | string | | 59 | * | revision-date | 7.1.5.1 | 0..1 | string | |
| 60 | * +---------------+---------+-------------+------------------+ | 60 | * +---------------+---------+-------------+------------------+ |
| 61 | */ | 61 | */ |
| 62 | + | ||
| 62 | /** | 63 | /** |
| 63 | * Represents the information about the imported modules. | 64 | * Represents the information about the imported modules. |
| 64 | */ | 65 | */ |
| 65 | -public class YangImport implements Parsable { | 66 | +public class YangImport |
| 67 | + implements Parsable { | ||
| 66 | 68 | ||
| 67 | /** | 69 | /** |
| 68 | * Name of the module that is being imported. | 70 | * Name of the module that is being imported. |
| ... | @@ -75,11 +77,6 @@ public class YangImport implements Parsable { | ... | @@ -75,11 +77,6 @@ public class YangImport implements Parsable { |
| 75 | private String prefixId; | 77 | private String prefixId; |
| 76 | 78 | ||
| 77 | /** | 79 | /** |
| 78 | - * Resolution information root node which is also the data model root node. | ||
| 79 | - */ | ||
| 80 | - private HasResolutionInfo resolutionInfoNode; | ||
| 81 | - | ||
| 82 | - /** | ||
| 83 | * Reference:RFC 6020. | 80 | * Reference:RFC 6020. |
| 84 | * | 81 | * |
| 85 | * The import's "revision-date" statement is used to specify the exact | 82 | * The import's "revision-date" statement is used to specify the exact |
| ... | @@ -118,7 +115,7 @@ public class YangImport implements Parsable { | ... | @@ -118,7 +115,7 @@ public class YangImport implements Parsable { |
| 118 | * Returns the prefix used to identify the entities from the imported module. | 115 | * Returns the prefix used to identify the entities from the imported module. |
| 119 | * | 116 | * |
| 120 | * @return the prefix used to identify the entities from the imported | 117 | * @return the prefix used to identify the entities from the imported |
| 121 | - * module | 118 | + * module |
| 122 | */ | 119 | */ |
| 123 | public String getPrefixId() { | 120 | public String getPrefixId() { |
| 124 | return prefixId; | 121 | return prefixId; |
| ... | @@ -167,7 +164,8 @@ public class YangImport implements Parsable { | ... | @@ -167,7 +164,8 @@ public class YangImport implements Parsable { |
| 167 | * @throws DataModelException a violation of data model rules | 164 | * @throws DataModelException a violation of data model rules |
| 168 | */ | 165 | */ |
| 169 | @Override | 166 | @Override |
| 170 | - public void validateDataOnEntry() throws DataModelException { | 167 | + public void validateDataOnEntry() |
| 168 | + throws DataModelException { | ||
| 171 | // TODO auto-generated method stub, to be implemented by parser | 169 | // TODO auto-generated method stub, to be implemented by parser |
| 172 | 170 | ||
| 173 | } | 171 | } |
| ... | @@ -178,26 +176,9 @@ public class YangImport implements Parsable { | ... | @@ -178,26 +176,9 @@ public class YangImport implements Parsable { |
| 178 | * @throws DataModelException a violation of data model rules | 176 | * @throws DataModelException a violation of data model rules |
| 179 | */ | 177 | */ |
| 180 | @Override | 178 | @Override |
| 181 | - public void validateDataOnExit() throws DataModelException { | 179 | + public void validateDataOnExit() |
| 180 | + throws DataModelException { | ||
| 182 | // TODO auto-generated method stub, to be implemented by parser | 181 | // TODO auto-generated method stub, to be implemented by parser |
| 183 | 182 | ||
| 184 | } | 183 | } |
| 185 | - | ||
| 186 | - /** | ||
| 187 | - * Returns the resolution information node. | ||
| 188 | - * | ||
| 189 | - * @return the resolution information node | ||
| 190 | - */ | ||
| 191 | - public HasResolutionInfo getResolutionInfoNode() { | ||
| 192 | - return resolutionInfoNode; | ||
| 193 | - } | ||
| 194 | - | ||
| 195 | - /** | ||
| 196 | - * Sets the dresolution information node. | ||
| 197 | - * | ||
| 198 | - * @param resolutionInfoNode the resolution information node | ||
| 199 | - */ | ||
| 200 | - public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) { | ||
| 201 | - this.resolutionInfoNode = resolutionInfoNode; | ||
| 202 | - } | ||
| 203 | } | 184 | } | ... | ... |
| ... | @@ -33,10 +33,12 @@ import org.onosproject.yangutils.utils.YangConstructType; | ... | @@ -33,10 +33,12 @@ import org.onosproject.yangutils.utils.YangConstructType; |
| 33 | * | revision-date | 7.1.5.1 | 0..1 | string | | 33 | * | revision-date | 7.1.5.1 | 0..1 | string | |
| 34 | * +---------------+---------+-------------+------------------+ | 34 | * +---------------+---------+-------------+------------------+ |
| 35 | */ | 35 | */ |
| 36 | + | ||
| 36 | /** | 37 | /** |
| 37 | * Represents the information about the included sub-modules. | 38 | * Represents the information about the included sub-modules. |
| 38 | */ | 39 | */ |
| 39 | -public class YangInclude implements Parsable { | 40 | +public class YangInclude |
| 41 | + implements Parsable { | ||
| 40 | 42 | ||
| 41 | /** | 43 | /** |
| 42 | * Name of the sub-module that is being included. | 44 | * Name of the sub-module that is being included. |
| ... | @@ -50,11 +52,6 @@ public class YangInclude implements Parsable { | ... | @@ -50,11 +52,6 @@ public class YangInclude implements Parsable { |
| 50 | private String revision; | 52 | private String revision; |
| 51 | 53 | ||
| 52 | /** | 54 | /** |
| 53 | - * Resolution information root node which is also the data model root node. | ||
| 54 | - */ | ||
| 55 | - private HasResolutionInfo resolutionInfoNode; | ||
| 56 | - | ||
| 57 | - /** | ||
| 58 | * Creates a YANG include. | 55 | * Creates a YANG include. |
| 59 | */ | 56 | */ |
| 60 | public YangInclude() { | 57 | public YangInclude() { |
| ... | @@ -112,7 +109,8 @@ public class YangInclude implements Parsable { | ... | @@ -112,7 +109,8 @@ public class YangInclude implements Parsable { |
| 112 | * @throws DataModelException a violation of data model rules | 109 | * @throws DataModelException a violation of data model rules |
| 113 | */ | 110 | */ |
| 114 | @Override | 111 | @Override |
| 115 | - public void validateDataOnEntry() throws DataModelException { | 112 | + public void validateDataOnEntry() |
| 113 | + throws DataModelException { | ||
| 116 | // TODO auto-generated method stub, to be implemented by parser | 114 | // TODO auto-generated method stub, to be implemented by parser |
| 117 | 115 | ||
| 118 | } | 116 | } |
| ... | @@ -123,26 +121,10 @@ public class YangInclude implements Parsable { | ... | @@ -123,26 +121,10 @@ public class YangInclude implements Parsable { |
| 123 | * @throws DataModelException a violation of data model rules | 121 | * @throws DataModelException a violation of data model rules |
| 124 | */ | 122 | */ |
| 125 | @Override | 123 | @Override |
| 126 | - public void validateDataOnExit() throws DataModelException { | 124 | + public void validateDataOnExit() |
| 125 | + throws DataModelException { | ||
| 127 | // TODO auto-generated method stub, to be implemented by parser | 126 | // TODO auto-generated method stub, to be implemented by parser |
| 128 | 127 | ||
| 129 | } | 128 | } |
| 130 | 129 | ||
| 131 | - /** | ||
| 132 | - * Returns the resolution information node. | ||
| 133 | - * | ||
| 134 | - * @return the resolution information node | ||
| 135 | - */ | ||
| 136 | - public HasResolutionInfo getResolutionInfoNode() { | ||
| 137 | - return resolutionInfoNode; | ||
| 138 | - } | ||
| 139 | - | ||
| 140 | - /** | ||
| 141 | - * Sets the dresolution information node. | ||
| 142 | - * | ||
| 143 | - * @param resolutionInfoNode the resolution information node | ||
| 144 | - */ | ||
| 145 | - public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) { | ||
| 146 | - this.resolutionInfoNode = resolutionInfoNode; | ||
| 147 | - } | ||
| 148 | } | 130 | } | ... | ... |
| ... | @@ -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 | 68 | * @param holderNode parent YANG node |
| 71 | - * @param prefix imported module prefix | ||
| 72 | * @param lineNumber error line number | 69 | * @param lineNumber error line number |
| 73 | * @param charPositionInLine error character position in line | 70 | * @param charPositionInLine error character position in line |
| 74 | */ | 71 | */ |
| 75 | - public YangResolutionInfo(T dataNode, ResolutionType resolutionType, | 72 | + public YangResolutionInfo(T dataNode, YangNode holderNode, int lineNumber, int charPositionInLine) { |
| 76 | - YangNode holderNode, String prefix, int lineNumber, | 73 | + setEntityToResolveInfo(new YangEntityToResolveInfo<T>()); |
| 77 | - int charPositionInLine) { | 74 | + getEntityToResolveInfo().setEntityToResolve(dataNode); |
| 78 | - this.setHolderOfEntityToResolve(holderNode); | 75 | + getEntityToResolveInfo().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 | ||
| 92 | - * @param lineNumber error line number | ||
| 93 | - * @param charPositionInLine error character position in line | ||
| 94 | - */ | ||
| 95 | - public YangResolutionInfo(T dataNode, ResolutionType resolutionType, | ||
| 96 | - YangNode holderNode, int lineNumber, | ||
| 97 | - int charPositionInLine) { | ||
| 98 | - this.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(); | ||
| 147 | - if (resolveLinkingForNodesChildAndSibling(node, curNode)) { | ||
| 148 | - return; | ||
| 149 | - } | ||
| 150 | - curNode = curNode.getParent(); | ||
| 151 | - } | ||
| 152 | 124 | ||
| 153 | - // If curNode is null, it indicates an error condition in YANG file. | 125 | + // Current node to resolve, it can be a YANG type or YANG uses. |
| 154 | - DataModelException dataModelException = new DataModelException("YANG file error: Unable to find base " + | 126 | + T entityToResolve = getCurrentEntityToResolveFromStack(); |
| 155 | - "typedef/grouping for given type/uses"); | 127 | + // Check if linking is already done |
| 156 | - dataModelException.setLine(getLineNumber()); | 128 | + if (entityToResolve instanceof Resolvable) { |
| 157 | - dataModelException.setCharPosition(getCharPosition()); | ||
| 158 | - throw dataModelException; | ||
| 159 | - } | ||
| 160 | 129 | ||
| 161 | - /** | 130 | + Resolvable resolvable = (Resolvable) entityToResolve; |
| 162 | - * Resolves linking for a node child and siblings. | 131 | + switch (resolvable.getResolvableStatus()) { |
| 163 | - * | 132 | + case RESOLVED: { |
| 164 | - * @param node current node | 133 | + /* |
| 165 | - * @param parentNode parent node of current node | 134 | + * If the entity is already resolved in the stack, then |
| 166 | - * @return flag to indicate whether resolution is done | 135 | + * pop it and continue with the remaining stack elements |
| 167 | - * @throws DataModelException | 136 | + * to resolve |
| 168 | - */ | 137 | + */ |
| 169 | - private boolean resolveLinkingForNodesChildAndSibling(YangNode node, YangNode parentNode) | 138 | + getPartialResolvedStack().pop(); |
| 170 | - throws DataModelException { | 139 | + break; |
| 171 | - while ((node != null)) { | 140 | + } |
| 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 | - } | ||
| 178 | - } | ||
| 179 | - if (isMoreReferenceDetected) { | ||
| 180 | - /* | ||
| 181 | - * If more reference are present, tree traversal must start from | ||
| 182 | - * first child again, to check the availability of | ||
| 183 | - * typedef/grouping. | ||
| 184 | - */ | ||
| 185 | - node = parentNode.getChild(); | ||
| 186 | - } else { | ||
| 187 | - node = node.getNextSibling(); | ||
| 188 | - } | ||
| 189 | - } | ||
| 190 | - return false; | ||
| 191 | - } | ||
| 192 | - | ||
| 193 | - /** | ||
| 194 | - * Resolves linking for a node. | ||
| 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 | - */ | ||
| 201 | - private boolean resolveLinkingForNode(YangNode node, YangNode parentNode) throws DataModelException { | ||
| 202 | 141 | ||
| 203 | - /* | 142 | + case LINKED: { |
| 204 | - * Check if name of node name matches with the entity name under | ||
| 205 | - * resolution. | ||
| 206 | - */ | ||
| 207 | - if (isNodeNameSameAsResolutionInfoName(node)) { | ||
| 208 | - // Adds reference of entity to the node under resolution. | ||
| 209 | - addReferredEntityLink(node); | ||
| 210 | - // Check if referred entity has further reference to uses/type. | ||
| 211 | - if (!(isMoreReferencePresent(node))) { | ||
| 212 | - // Resolve all the entities in stack. | ||
| 213 | - resolveStackAndAddToStack(node); | ||
| 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 | - */ | ||
| 222 | - if (isReferenceFullyResolved()) { | ||
| 223 | - // Resolve the stack which is complete. | ||
| 224 | - resolveCompleteStack(); | ||
| 225 | - return true; | ||
| 226 | - } else if (isReferencePartiallyResolved()) { | ||
| 227 | - /* | ||
| 228 | - * Update the resolution type to partially resolved for all | ||
| 229 | - * type/uses in stack | ||
| 230 | - */ | ||
| 231 | - updateResolutionTypeToPartial(); | ||
| 232 | - return true; | ||
| 233 | - } else { | ||
| 234 | - /* | ||
| 235 | - * Check if prefix is present to find that the derived | ||
| 236 | - * reference is for intra file or inter file, if it's | ||
| 237 | - * inter-file return and stop further processing. | ||
| 238 | - */ | ||
| 239 | - if (isExternalPrefixPresent(node)) { | ||
| 240 | /* | 143 | /* |
| 241 | - * Update the resolution type to partially resolved for | 144 | + * If the top of the stack is already linked then |
| 242 | - * all type/uses in stack | 145 | + * resolve the references and pop the entity and |
| 146 | + * continue with remaining stack elements to resolve | ||
| 243 | */ | 147 | */ |
| 244 | - updateResolutionTypeToPartial(); | 148 | + resolveTopOfStack(); |
| 245 | - return true; | 149 | + getPartialResolvedStack().pop(); |
| 246 | - } else { | 150 | + break; |
| 151 | + } | ||
| 152 | + | ||
| 153 | + case INTRA_FILE_RESOLVED: { | ||
| 247 | /* | 154 | /* |
| 248 | - * If prefix is not present it indicates intra-file | 155 | + * TODO: this needs to be deleted, when inter-file |
| 249 | - * dependency in this case set the node back to first | 156 | + * resolution is implmeneted |
| 250 | - * child, as referred entity may appear in any order and | ||
| 251 | - * continue with the resolution. | ||
| 252 | */ | 157 | */ |
| 253 | - isMoreReferenceDetected = true; | 158 | + getPartialResolvedStack().pop(); |
| 254 | - return false; | 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"); | ||
| 170 | + dataModelException.setLine(getLineNumber()); | ||
| 171 | + dataModelException.setCharPosition(getCharPosition()); | ||
| 172 | + throw dataModelException; | ||
| 173 | + } | ||
| 174 | + break; | ||
| 255 | } | 175 | } |
| 176 | + default: { | ||
| 177 | + throw new DataModelException("Data Model Exception: Unsupported, linker state"); | ||
| 178 | + } | ||
| 179 | + | ||
| 256 | } | 180 | } |
| 181 | + | ||
| 182 | + } else { | ||
| 183 | + throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); | ||
| 257 | } | 184 | } |
| 185 | + | ||
| 258 | } | 186 | } |
| 259 | - return false; | 187 | + |
| 260 | } | 188 | } |
| 261 | 189 | ||
| 262 | /** | 190 | /** |
| 263 | - * Update resolution type to partial for all type/uses in stack. | 191 | + * Resolve the current entity in the stack. |
| 264 | - * | ||
| 265 | - * @throws DataModelException a violation of data model rules | ||
| 266 | */ | 192 | */ |
| 267 | - private void updateResolutionTypeToPartial() throws DataModelException { | 193 | + private void resolveTopOfStack() { |
| 268 | - // For all entries in stack calls for the resolution in type/uses. | 194 | + ((Resolvable) getCurrentEntityToResolveFromStack()).resolve(); |
| 269 | - for (T entity : getPartialResolvedStack()) { | 195 | + |
| 270 | - if (!(entity instanceof Resolvable)) { | 196 | + if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus() |
| 271 | - throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); | 197 | + != INTRA_FILE_RESOLVED) { |
| 272 | - } | 198 | + // Sets the resolution status in inside the type/uses. |
| 273 | - if (((Resolvable) entity).getResolvableStatus() == ResolvableStatus.UNRESOLVED) { | 199 | + ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(RESOLVED); |
| 274 | - // Sets the resolution status in inside the type/uses. | ||
| 275 | - ((Resolvable) entity).setResolvableStatus(ResolvableStatus.PARTIALLY_RESOLVED); | ||
| 276 | - } | ||
| 277 | } | 200 | } |
| 278 | } | 201 | } |
| 279 | 202 | ||
| 280 | /** | 203 | /** |
| 281 | - * Adds referred type/uses to the stack and resolve the stack. | 204 | + * Resolves linking for a node child and siblings. |
| 282 | * | 205 | * |
| 283 | - * @param node typedef/grouping node | 206 | + * @throws DataModelException data model error |
| 284 | - * @throws DataModelException a violation of data model rules | ||
| 285 | */ | 207 | */ |
| 286 | - private void resolveStackAndAddToStack(YangNode node) throws DataModelException { | 208 | + private void linkTopOfStackReferenceUpdateStack() |
| 287 | - if (getEntityToResolve() instanceof YangType) { | 209 | + throws DataModelException { |
| 288 | - // Adds to the stack only for YANG typedef. | 210 | + |
| 289 | - getPartialResolvedStack().push((T) ((YangTypeDef) node).getDataType()); | 211 | + if (!isSelfFileReference()) { |
| 212 | + /* | ||
| 213 | + * TODO: use mojo utilities to load the referred module/sub-module | ||
| 214 | + * and get the reference to the corresponding referred entity | ||
| 215 | + */ | ||
| 216 | + | ||
| 217 | + ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(INTRA_FILE_RESOLVED); | ||
| 218 | + return; | ||
| 290 | } | 219 | } |
| 291 | - // Don't add to stack in case of YANG grouping. | ||
| 292 | 220 | ||
| 293 | - // Resolve the complete stack. | 221 | + /** |
| 294 | - resolveCompleteStack(); | 222 | + * Try to resolve the top of the stack and update partial resolved stack |
| 223 | + * if there is recursive references | ||
| 224 | + */ | ||
| 225 | + YangNode potentialAncestorWithReferredNode = getPartialResolvedStack().peek() | ||
| 226 | + .getHolderOfEntityToResolve(); | ||
| 227 | + | ||
| 228 | + /** | ||
| 229 | + * Traverse up in the ancestor tree to check if the referred node is | ||
| 230 | + * defined | ||
| 231 | + */ | ||
| 232 | + while (potentialAncestorWithReferredNode != null) { | ||
| 233 | + | ||
| 234 | + /** | ||
| 235 | + * Check for the referred node defined in a ancestor scope | ||
| 236 | + */ | ||
| 237 | + YangNode potentialReferredNode = potentialAncestorWithReferredNode.getChild(); | ||
| 238 | + if (isReferredNodeInSiblingListProcessed(potentialReferredNode)) { | ||
| 239 | + return; | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + potentialAncestorWithReferredNode = potentialAncestorWithReferredNode.getParent(); | ||
| 243 | + } | ||
| 295 | } | 244 | } |
| 296 | 245 | ||
| 297 | /** | 246 | /** |
| 298 | - * Check if the referred type/uses is partially resolved. | 247 | + * Check if the reference in self file or in external file. |
| 299 | * | 248 | * |
| 300 | - * @return true if reference is partially resolved, otherwise false | 249 | + * @return true if self file reference, false otherwise |
| 250 | + * @throws DataModelException a violation of data model rules | ||
| 301 | */ | 251 | */ |
| 302 | - private boolean isReferencePartiallyResolved() { | 252 | + private boolean isSelfFileReference() |
| 303 | - if (getPartialResolvedStack().peek() instanceof YangType) { | 253 | + throws DataModelException { |
| 304 | - /* | 254 | + String prefix; |
| 305 | - * Checks if type is partially resolved. | 255 | + if (getCurrentEntityToResolveFromStack() instanceof YangType) { |
| 306 | - */ | 256 | + prefix = ((YangType<?>) getCurrentEntityToResolveFromStack()).getPrefix(); |
| 307 | - if (((YangType) getPartialResolvedStack().peek()) | 257 | + } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) { |
| 308 | - .getResolvableStatus() == ResolvableStatus.PARTIALLY_RESOLVED) { | 258 | + prefix = ((YangUses) getCurrentEntityToResolveFromStack()).getPrefix(); |
| 309 | - return true; | 259 | + } else { |
| 310 | - } | 260 | + throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); |
| 311 | - } else if (getPartialResolvedStack().peek() instanceof YangUses) { | ||
| 312 | - if (((YangUses) getPartialResolvedStack().peek()) | ||
| 313 | - .getResolvableStatus() == ResolvableStatus.PARTIALLY_RESOLVED) { | ||
| 314 | - return true; | ||
| 315 | - } | ||
| 316 | } | 261 | } |
| 317 | - return false; | 262 | + |
| 263 | + if (prefix == null) { | ||
| 264 | + return true; | ||
| 265 | + } | ||
| 266 | + return prefix.contentEquals(resolutionInfoRootNodePrefix); | ||
| 267 | + | ||
| 318 | } | 268 | } |
| 319 | 269 | ||
| 320 | /** | 270 | /** |
| 321 | - * Check if the referred type/uses is resolved. | 271 | + * Check for the referred node defined in a ancestor scope. |
| 322 | * | 272 | * |
| 323 | - * @return true if reference is 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 | ||
| 324 | */ | 277 | */ |
| 325 | - private boolean isReferenceFullyResolved() { | 278 | + private boolean isReferredNodeInSiblingListProcessed(YangNode potentialReferredNode) |
| 326 | - if (getPartialResolvedStack().peek() instanceof YangType) { | 279 | + throws DataModelException { |
| 327 | - /* | 280 | + while (potentialReferredNode != null) { |
| 328 | - * Checks if type is partially resolved. | 281 | + |
| 329 | - */ | 282 | + // Check if the potential referred node is the actual referred node |
| 330 | - if (((YangType) getPartialResolvedStack().peek()).getResolvableStatus() == ResolvableStatus.RESOLVED) { | 283 | + if (isReferredNode(potentialReferredNode)) { |
| 331 | - return true; | 284 | + |
| 332 | - } | 285 | + // Adds reference link of entity to the node under resolution. |
| 333 | - } else if (getPartialResolvedStack().peek() instanceof YangUses) { | 286 | + addReferredEntityLink(potentialReferredNode); |
| 334 | - if (((YangUses) getPartialResolvedStack().peek()).getResolvableStatus() == ResolvableStatus.RESOLVED) { | 287 | + |
| 288 | + /** | ||
| 289 | + * resolve the reference and update the partial resolution stack | ||
| 290 | + * with any further recursive references | ||
| 291 | + */ | ||
| 292 | + addUnresolvedRecursiveReferenceToStack(potentialReferredNode); | ||
| 293 | + | ||
| 294 | + /* | ||
| 295 | + * return true, since the reference is linked and any recursive | ||
| 296 | + * unresolved references is added to the stack | ||
| 297 | + */ | ||
| 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 { |
| 399 | + if (getCurrentEntityToResolveFromStack() instanceof YangType) { | ||
| 414 | /* | 400 | /* |
| 415 | - * Checks if typedef type is built-in type | 401 | + * Checks if typedef type is derived |
| 416 | */ | 402 | */ |
| 417 | - if ((((YangTypeDef) node).getDataType().getDataType() != YangDataTypes.DERIVED)) { | 403 | + if (((YangTypeDef) referredNode).getTypeDefBaseType().getDataType() |
| 418 | - return false; | 404 | + == YangDataTypes.DERIVED) { |
| 405 | + | ||
| 406 | + YangEntityToResolveInfo<YangType<?>> unResolvedEntityInfo = new YangEntityToResolveInfo<YangType<?>>(); | ||
| 407 | + unResolvedEntityInfo.setEntityToResolve(((YangTypeDef) referredNode) | ||
| 408 | + .getTypeDefBaseType()); | ||
| 409 | + unResolvedEntityInfo.setHolderOfEntityToResolve(referredNode); | ||
| 410 | + addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo); | ||
| 419 | } | 411 | } |
| 420 | - } else if (getEntityToResolve() instanceof YangUses) { | 412 | + |
| 413 | + } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) { | ||
| 421 | /* | 414 | /* |
| 422 | - * Search if the grouping has any uses child, if so return false, | 415 | + * Search if the grouping has any un resolved uses child, if so |
| 423 | - * else return true. | 416 | + * return true, else return false. |
| 424 | */ | 417 | */ |
| 425 | - if (getUsesInGrouping(node) == null) { | 418 | + addUnResolvedUsesToStack(referredNode); |
| 426 | - return false; | ||
| 427 | - } | ||
| 428 | } else { | 419 | } else { |
| 429 | 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"); |
| 430 | } | 421 | } |
| 431 | - return true; | ||
| 432 | } | 422 | } |
| 433 | 423 | ||
| 434 | /** | 424 | /** |
| 435 | - * Return if there is any uses in grouping. | 425 | + * Return if there is any unresolved uses in grouping. |
| 436 | * | 426 | * |
| 437 | * @param node grouping/typedef node | 427 | * @param node grouping/typedef node |
| 438 | - * @return if there is any uses in grouping, otherwise return null | ||
| 439 | */ | 428 | */ |
| 440 | - private YangUses getUsesInGrouping(YangNode node) { | 429 | + private void addUnResolvedUsesToStack(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 | - } | ||
| 450 | 430 | ||
| 451 | - /** | 431 | + /** |
| 452 | - * Resolve the complete stack. | 432 | + * Search the grouping node's children for presence of uses node. |
| 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 | - /* | ||
| 467 | - * Sets the resolution status in resolution info present in resolution | ||
| 468 | - * list. | ||
| 469 | */ | 433 | */ |
| 470 | - setIsResolved(true); | 434 | + YangNode curNode = node.getChild(); |
| 471 | - } | 435 | + while (curNode != null) { |
| 472 | - | 436 | + if (curNode instanceof YangUses) { |
| 473 | - /** | 437 | + ResolvableStatus curResolveStatus = ((Resolvable) curNode).getResolvableStatus(); |
| 474 | - * Adds to partial resolved stack. | 438 | + if (curResolveStatus == UNRESOLVED) { |
| 475 | - * | 439 | + /** |
| 476 | - * @param node grouping/typedef node | 440 | + * The current uses is not resolved, add it to partial |
| 477 | - * @throws DataModelException a violation of data model rules | 441 | + * resolved stack |
| 478 | - */ | 442 | + */ |
| 479 | - private void addToPartialResolvedStack(YangNode node) throws DataModelException { | 443 | + YangEntityToResolveInfo<YangUses> unResolvedEntityInfo = new YangEntityToResolveInfo<YangUses>(); |
| 480 | - if (getPartialResolvedStack().peek() instanceof YangType) { | 444 | + unResolvedEntityInfo.setEntityToResolve((YangUses) curNode); |
| 481 | - // Adds to the stack only for YANG typedef. | 445 | + unResolvedEntityInfo.setHolderOfEntityToResolve(node); |
| 482 | - getPartialResolvedStack().push((T) ((YangTypeDef) node).getDataType()); | 446 | + addInPartialResolvedStack((YangEntityToResolveInfo<T>) unResolvedEntityInfo); |
| 483 | - } else if (getPartialResolvedStack().peek() instanceof YangUses) { | ||
| 484 | - getPartialResolvedStack().push((T) getUsesInGrouping(node)); | ||
| 485 | - } else { | ||
| 486 | - throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); | ||
| 487 | - } | ||
| 488 | - } | ||
| 489 | 447 | ||
| 490 | - /** | 448 | + } |
| 491 | - * Check if prefix is associated with type/uses. | ||
| 492 | - * | ||
| 493 | - * @param node typedef/grouping node | ||
| 494 | - * @return true if prefix is present, otherwise false | ||
| 495 | - * @throws DataModelException a violation of data model rules | ||
| 496 | - */ | ||
| 497 | - private boolean isExternalPrefixPresent(YangNode node) throws DataModelException { | ||
| 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 | } | 449 | } |
| 507 | - } else { | 450 | + curNode = curNode.getNextSibling(); |
| 508 | - throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses"); | ||
| 509 | } | 451 | } |
| 510 | - return false; | ||
| 511 | - } | ||
| 512 | 452 | ||
| 513 | - /** | 453 | + return; |
| 514 | - * Returns prefix of imported module. | ||
| 515 | - * | ||
| 516 | - * @return prefix of imported module | ||
| 517 | - */ | ||
| 518 | - public String getPrefix() { | ||
| 519 | - return prefix; | ||
| 520 | - } | ||
| 521 | - | ||
| 522 | - /** | ||
| 523 | - * Sets prefix of imported module. | ||
| 524 | - * | ||
| 525 | - * @param prefix of imported module | ||
| 526 | - */ | ||
| 527 | - public void setPrefix(String prefix) { | ||
| 528 | - this.prefix = prefix; | ||
| 529 | - } | ||
| 530 | - | ||
| 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 | - } | ||
| 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 | - } | ||
| 548 | - | ||
| 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 | - } | ||
| 557 | - | ||
| 558 | - /** | ||
| 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 | */ |
| ... | @@ -43,7 +45,7 @@ public final class DataModelUtils { | ... | @@ -43,7 +45,7 @@ public final class DataModelUtils { |
| 43 | * Detects the colliding identifier name in a given YANG node and its child. | 45 | * Detects the colliding identifier name in a given YANG node and its child. |
| 44 | * | 46 | * |
| 45 | * @param identifierName name for which collision detection is to be | 47 | * @param identifierName name for which collision detection is to be |
| 46 | - * checked | 48 | + * checked |
| 47 | * @param dataType type of YANG node asking for detecting collision | 49 | * @param dataType type of YANG node asking for detecting collision |
| 48 | * @param node instance of calling node | 50 | * @param node instance of calling node |
| 49 | * @throws DataModelException a violation of data model rules | 51 | * @throws DataModelException a violation of data model rules |
| ... | @@ -77,7 +79,7 @@ public final class DataModelUtils { | ... | @@ -77,7 +79,7 @@ public final class DataModelUtils { |
| 77 | * | 79 | * |
| 78 | * @param leavesHolder leaves node against which collision to be checked | 80 | * @param leavesHolder leaves node against which collision to be checked |
| 79 | * @param identifierName name for which collision detection is to be | 81 | * @param identifierName name for which collision detection is to be |
| 80 | - * checked | 82 | + * checked |
| 81 | * @throws DataModelException a violation of data model rules | 83 | * @throws DataModelException a violation of data model rules |
| 82 | */ | 84 | */ |
| 83 | private static void detectCollidingLeaf(YangLeavesHolder leavesHolder, String identifierName) | 85 | private static void detectCollidingLeaf(YangLeavesHolder leavesHolder, String identifierName) |
| ... | @@ -96,7 +98,7 @@ public final class DataModelUtils { | ... | @@ -96,7 +98,7 @@ public final class DataModelUtils { |
| 96 | * | 98 | * |
| 97 | * @param leavesHolder leaves node against which collision to be checked | 99 | * @param leavesHolder leaves node against which collision to be checked |
| 98 | * @param identifierName name for which collision detection is to be | 100 | * @param identifierName name for which collision detection is to be |
| 99 | - * checked | 101 | + * checked |
| 100 | * @throws DataModelException a violation of data model rules | 102 | * @throws DataModelException a violation of data model rules |
| 101 | */ | 103 | */ |
| 102 | private static void detectCollidingLeafList(YangLeavesHolder leavesHolder, String identifierName) | 104 | private static void detectCollidingLeafList(YangLeavesHolder leavesHolder, String identifierName) |
| ... | @@ -114,13 +116,17 @@ public final class DataModelUtils { | ... | @@ -114,13 +116,17 @@ public final class DataModelUtils { |
| 114 | * Add a resolution information. | 116 | * Add a resolution information. |
| 115 | * | 117 | * |
| 116 | * @param resolutionInfo information about the YANG construct which has to | 118 | * @param resolutionInfo information about the YANG construct which has to |
| 117 | - * be resolved | 119 | + * be resolved |
| 118 | * @throws DataModelException a violation of data model rules | 120 | * @throws DataModelException a violation of data model rules |
| 119 | */ | 121 | */ |
| 120 | - public static void addResolutionInfo(YangResolutionInfo resolutionInfo) throws DataModelException { | 122 | + public static void addResolutionInfo(YangResolutionInfo resolutionInfo) |
| 123 | + throws DataModelException { | ||
| 124 | + | ||
| 125 | + | ||
| 121 | 126 | ||
| 122 | /* get the module node to add maintain the list of nested reference */ | 127 | /* get the module node to add maintain the list of nested reference */ |
| 123 | - YangNode curNode = resolutionInfo.getHolderOfEntityToResolve(); | 128 | + YangNode curNode = resolutionInfo.getEntityToResolveInfo() |
| 129 | + .getHolderOfEntityToResolve(); | ||
| 124 | while (!(curNode instanceof HasResolutionInfo)) { | 130 | while (!(curNode instanceof HasResolutionInfo)) { |
| 125 | curNode = curNode.getParent(); | 131 | curNode = curNode.getParent(); |
| 126 | if (curNode == null) { | 132 | if (curNode == null) { |
| ... | @@ -128,25 +134,58 @@ public final class DataModelUtils { | ... | @@ -128,25 +134,58 @@ public final class DataModelUtils { |
| 128 | } | 134 | } |
| 129 | } | 135 | } |
| 130 | HasResolutionInfo resolutionNode = (HasResolutionInfo) curNode; | 136 | HasResolutionInfo resolutionNode = (HasResolutionInfo) curNode; |
| 137 | + | ||
| 138 | + if (!isPrefixValid(resolutionInfo.getEntityToResolveInfo().getEntityPrefix(), | ||
| 139 | + resolutionNode)) { | ||
| 140 | + throw new DataModelException("The prefix used is not valid"); | ||
| 141 | + } | ||
| 131 | resolutionNode.addToResolutionList(resolutionInfo); | 142 | resolutionNode.addToResolutionList(resolutionInfo); |
| 132 | } | 143 | } |
| 133 | 144 | ||
| 145 | + private static boolean isPrefixValid(String entityPrefix, HasResolutionInfo resolutionNode) { | ||
| 146 | + if (entityPrefix == null) { | ||
| 147 | + return true; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + if (resolutionNode.getPrefix().contentEquals(entityPrefix)) { | ||
| 151 | + return true; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + if (resolutionNode.getImportList() != null) { | ||
| 155 | + for (YangImport importedInfo : resolutionNode.getImportList()) { | ||
| 156 | + if (importedInfo.getPrefixId().contentEquals(entityPrefix)) { | ||
| 157 | + return true; | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + if (resolutionNode.getIncludeList() != null) { | ||
| 163 | + /** | ||
| 164 | + * TODO: check if the prefix matches with the imported data | ||
| 165 | + | ||
| 166 | + for (YangInclude includedInfo : resolutionNode.getIncludeList()) { | ||
| 167 | + if (includedInfo.contentEquals(prefix)) { | ||
| 168 | + return true; | ||
| 169 | + } | ||
| 170 | + }*/ | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + return false; | ||
| 174 | + } | ||
| 175 | + | ||
| 134 | /** | 176 | /** |
| 135 | * Resolve linking for a resolution list. | 177 | * Resolve linking for a resolution list. |
| 136 | * | 178 | * |
| 137 | * @param resolutionList resolution list for which linking to be done | 179 | * @param resolutionList resolution list for which linking to be done |
| 138 | - * @param resolutionInfoNode module/sub-module node | 180 | + * @param dataModelRootNode module/sub-module node |
| 139 | * @throws DataModelException a violation of data model rules | 181 | * @throws DataModelException a violation of data model rules |
| 140 | */ | 182 | */ |
| 141 | public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList, | 183 | public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList, |
| 142 | - HasResolutionInfo resolutionInfoNode) | 184 | + HasResolutionInfo dataModelRootNode) |
| 143 | throws DataModelException { | 185 | throws DataModelException { |
| 144 | 186 | ||
| 145 | for (YangResolutionInfo resolutionInfo : resolutionList) { | 187 | for (YangResolutionInfo resolutionInfo : resolutionList) { |
| 146 | - if (resolutionInfo.getPrefix() == null || | 188 | + resolutionInfo.resolveLinkingForResolutionInfo(dataModelRootNode.getPrefix()); |
| 147 | - resolutionInfo.getPrefix().equals(resolutionInfoNode.getPrefix())) { | ||
| 148 | - resolutionInfo.resolveLinkingForResolutionInfo(resolutionInfoNode.getPrefix()); | ||
| 149 | - } | ||
| 150 | } | 189 | } |
| 151 | } | 190 | } |
| 152 | } | 191 | } | ... | ... |
| ... | @@ -20,6 +20,7 @@ import org.onosproject.yangutils.datamodel.YangCase; | ... | @@ -20,6 +20,7 @@ import org.onosproject.yangutils.datamodel.YangCase; |
| 20 | import org.onosproject.yangutils.datamodel.YangChoice; | 20 | import org.onosproject.yangutils.datamodel.YangChoice; |
| 21 | import org.onosproject.yangutils.datamodel.YangContainer; | 21 | import org.onosproject.yangutils.datamodel.YangContainer; |
| 22 | import org.onosproject.yangutils.datamodel.YangGrouping; | 22 | import org.onosproject.yangutils.datamodel.YangGrouping; |
| 23 | +import org.onosproject.yangutils.datamodel.YangLeaf; | ||
| 23 | import org.onosproject.yangutils.datamodel.YangList; | 24 | import org.onosproject.yangutils.datamodel.YangList; |
| 24 | import org.onosproject.yangutils.datamodel.YangModule; | 25 | import org.onosproject.yangutils.datamodel.YangModule; |
| 25 | import org.onosproject.yangutils.datamodel.YangSubModule; | 26 | import org.onosproject.yangutils.datamodel.YangSubModule; |
| ... | @@ -34,6 +35,7 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase; | ... | @@ -34,6 +35,7 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase; |
| 34 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice; | 35 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice; |
| 35 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer; | 36 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer; |
| 36 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; | 37 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; |
| 38 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeaf; | ||
| 37 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList; | 39 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList; |
| 38 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | 40 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
| 39 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; | 41 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
| ... | @@ -51,7 +53,7 @@ import org.onosproject.yangutils.translator.exception.TranslatorException; | ... | @@ -51,7 +53,7 @@ import org.onosproject.yangutils.translator.exception.TranslatorException; |
| 51 | public final class YangDataModelFactory { | 53 | public final class YangDataModelFactory { |
| 52 | 54 | ||
| 53 | /** | 55 | /** |
| 54 | - * Creates a YANG data model factory object. | 56 | + * Utility class, hence private to prevent creating objects. |
| 55 | */ | 57 | */ |
| 56 | private YangDataModelFactory() { | 58 | private YangDataModelFactory() { |
| 57 | } | 59 | } |
| ... | @@ -261,6 +263,23 @@ public final class YangDataModelFactory { | ... | @@ -261,6 +263,23 @@ public final class YangDataModelFactory { |
| 261 | * generated | 263 | * generated |
| 262 | * @return the corresponding inherited node based on the target language | 264 | * @return the corresponding inherited node based on the target language |
| 263 | */ | 265 | */ |
| 266 | + public static YangLeaf getYangLeaf(GeneratedLanguage targetLanguage) { | ||
| 267 | + switch (targetLanguage) { | ||
| 268 | + case JAVA_GENERATION: { | ||
| 269 | + return new YangJavaLeaf(); | ||
| 270 | + } | ||
| 271 | + default: { | ||
| 272 | + throw new RuntimeException("Only YANG to Java is supported."); | ||
| 273 | + } | ||
| 274 | + } | ||
| 275 | + } | ||
| 276 | + /** | ||
| 277 | + * Returns based on the target language generate the inherited data model node. | ||
| 278 | + * | ||
| 279 | + * @param targetLanguage target language in which YANG mapping needs to be | ||
| 280 | + * generated | ||
| 281 | + * @return the corresponding inherited node based on the target language | ||
| 282 | + */ | ||
| 264 | public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) { | 283 | public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) { |
| 265 | switch (targetLanguage) { | 284 | switch (targetLanguage) { |
| 266 | case JAVA_GENERATION: { | 285 | case JAVA_GENERATION: { | ... | ... |
| ... | @@ -40,8 +40,9 @@ import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA | ... | @@ -40,8 +40,9 @@ import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA |
| 40 | */ | 40 | */ |
| 41 | 41 | ||
| 42 | /** | 42 | /** |
| 43 | - * Represents listener based call back function corresponding to the "description" | 43 | + * Represents listener based call back function corresponding to the |
| 44 | - * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | 44 | + * "description" rule defined in ANTLR grammar file for corresponding ABNF rule |
| 45 | + * in RFC 6020. | ||
| 45 | */ | 46 | */ |
| 46 | public final class DescriptionListener { | 47 | public final class DescriptionListener { |
| 47 | 48 | ||
| ... | @@ -52,15 +53,14 @@ public final class DescriptionListener { | ... | @@ -52,15 +53,14 @@ public final class DescriptionListener { |
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | /** | 55 | /** |
| 55 | - * It is called when parser receives an input matching the grammar | 56 | + * It is called when parser receives an input matching the grammar rule |
| 56 | - * rule (description), perform validations and updates the data model | 57 | + * (description), perform validations and updates the data model tree. |
| 57 | - * tree. | ||
| 58 | * | 58 | * |
| 59 | * @param listener listener's object | 59 | * @param listener listener's object |
| 60 | * @param ctx context object of the grammar rule | 60 | * @param ctx context object of the grammar rule |
| 61 | */ | 61 | */ |
| 62 | public static void processDescriptionEntry(TreeWalkListener listener, | 62 | public static void processDescriptionEntry(TreeWalkListener listener, |
| 63 | - GeneratedYangParser.DescriptionStatementContext ctx) { | 63 | + GeneratedYangParser.DescriptionStatementContext ctx) { |
| 64 | 64 | ||
| 65 | // Check for stack to be non empty. | 65 | // Check for stack to be non empty. |
| 66 | checkStackIsNotEmpty(listener, MISSING_HOLDER, DESCRIPTION_DATA, ctx.string().getText(), ENTRY); | 66 | checkStackIsNotEmpty(listener, MISSING_HOLDER, DESCRIPTION_DATA, ctx.string().getText(), ENTRY); | ... | ... |
| ... | @@ -45,8 +45,8 @@ import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA; | ... | @@ -45,8 +45,8 @@ import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA; |
| 45 | */ | 45 | */ |
| 46 | 46 | ||
| 47 | /** | 47 | /** |
| 48 | - * Represesnts listener based call back function corresponding to the "key" | 48 | + * Represesnts listener based call back function corresponding to the "key" rule |
| 49 | - * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | 49 | + * defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. |
| 50 | */ | 50 | */ |
| 51 | public final class KeyListener { | 51 | public final class KeyListener { |
| 52 | 52 | ||
| ... | @@ -57,15 +57,14 @@ public final class KeyListener { | ... | @@ -57,15 +57,14 @@ public final class KeyListener { |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /** | 59 | /** |
| 60 | - * It is called when parser receives an input matching the grammar | 60 | + * It is called when parser receives an input matching the grammar rule |
| 61 | - * rule (key), perform validations and updates the data model | 61 | + * (key), perform validations and updates the data model tree. |
| 62 | - * tree. | ||
| 63 | * | 62 | * |
| 64 | * @param listener listener's object | 63 | * @param listener listener's object |
| 65 | * @param ctx context object of the grammar rule | 64 | * @param ctx context object of the grammar rule |
| 66 | */ | 65 | */ |
| 67 | public static void processKeyEntry(TreeWalkListener listener, | 66 | public static void processKeyEntry(TreeWalkListener listener, |
| 68 | - GeneratedYangParser.KeyStatementContext ctx) { | 67 | + GeneratedYangParser.KeyStatementContext ctx) { |
| 69 | 68 | ||
| 70 | // Check for stack to be non empty. | 69 | // Check for stack to be non empty. |
| 71 | checkStackIsNotEmpty(listener, MISSING_HOLDER, KEY_DATA, ctx.key().getText(), ENTRY); | 70 | checkStackIsNotEmpty(listener, MISSING_HOLDER, KEY_DATA, ctx.key().getText(), ENTRY); |
| ... | @@ -94,7 +93,7 @@ public final class KeyListener { | ... | @@ -94,7 +93,7 @@ public final class KeyListener { |
| 94 | } | 93 | } |
| 95 | } else { | 94 | } else { |
| 96 | throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, KEY_DATA, ctx.key().getText(), | 95 | throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, KEY_DATA, ctx.key().getText(), |
| 97 | - ENTRY)); | 96 | + ENTRY)); |
| 98 | } | 97 | } |
| 99 | } | 98 | } |
| 100 | } | 99 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -27,10 +27,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -27,10 +27,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
| 27 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 27 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
| 28 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 28 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
| 29 | 29 | ||
| 30 | +import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION; | ||
| 31 | +import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangLeaf; | ||
| 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; |
| 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
| 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
| 33 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 35 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction |
| 36 | + .constructListenerErrorMessage; | ||
| 34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 37 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
| 35 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
| 36 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
| ... | @@ -108,7 +111,7 @@ public final class LeafListener { | ... | @@ -108,7 +111,7 @@ public final class LeafListener { |
| 108 | int charPositionInLine = ctx.getStart().getCharPositionInLine(); | 111 | int charPositionInLine = ctx.getStart().getCharPositionInLine(); |
| 109 | detectCollidingChildUtil(listener, line, charPositionInLine, identifier, LEAF_DATA); | 112 | detectCollidingChildUtil(listener, line, charPositionInLine, identifier, LEAF_DATA); |
| 110 | 113 | ||
| 111 | - YangLeaf leaf = new YangLeaf(); | 114 | + YangLeaf leaf = getYangLeaf(JAVA_GENERATION); |
| 112 | leaf.setLeafName(identifier); | 115 | leaf.setLeafName(identifier); |
| 113 | 116 | ||
| 114 | Parsable tmpData = listener.getParsedDataStack().peek(); | 117 | Parsable tmpData = listener.getParsedDataStack().peek(); |
| ... | @@ -142,7 +145,7 @@ public final class LeafListener { | ... | @@ -142,7 +145,7 @@ public final class LeafListener { |
| 142 | listener.getParsedDataStack().pop(); | 145 | listener.getParsedDataStack().pop(); |
| 143 | } else { | 146 | } else { |
| 144 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_DATA, | 147 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LEAF_DATA, |
| 145 | - ctx.identifier().getText(), EXIT)); | 148 | + ctx.identifier().getText(), EXIT)); |
| 146 | } | 149 | } |
| 147 | } | 150 | } |
| 148 | 151 | ... | ... |
| ... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.yangutils.parser.impl.listeners; | 17 | package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | -import org.onosproject.yangutils.datamodel.ResolutionType; | ||
| 20 | import org.onosproject.yangutils.datamodel.YangDataTypes; | 19 | import org.onosproject.yangutils.datamodel.YangDataTypes; |
| 21 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; | 20 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; |
| 22 | import org.onosproject.yangutils.datamodel.YangLeaf; | 21 | import org.onosproject.yangutils.datamodel.YangLeaf; |
| ... | @@ -34,11 +33,14 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; | ... | @@ -34,11 +33,14 @@ import org.onosproject.yangutils.parser.exceptions.ParserException; |
| 34 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 33 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
| 35 | import org.onosproject.yangutils.utils.YangConstructType; | 34 | import org.onosproject.yangutils.utils.YangConstructType; |
| 36 | 35 | ||
| 36 | +import static org.onosproject.yangutils.datamodel.ResolvableStatus.UNRESOLVED; | ||
| 37 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo; | 37 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo; |
| 38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 38 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
| 39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 39 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
| 40 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | 40 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction |
| 41 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 41 | + .constructExtendedListenerErrorMessage; |
| 42 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction | ||
| 43 | + .constructListenerErrorMessage; | ||
| 42 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 44 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
| 43 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 45 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
| 44 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 46 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
| ... | @@ -123,17 +125,15 @@ public final class TypeListener { | ... | @@ -123,17 +125,15 @@ public final class TypeListener { |
| 123 | ctx.string().getText(), EXIT)); | 125 | ctx.string().getText(), EXIT)); |
| 124 | } | 126 | } |
| 125 | 127 | ||
| 126 | - // Get the prefix information | ||
| 127 | - String prefix = ((YangType<?>) type).getPrefix(); | ||
| 128 | - | ||
| 129 | // Create empty derived info and attach it to type extended info. | 128 | // Create empty derived info and attach it to type extended info. |
| 130 | YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>(); | 129 | YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>(); |
| 131 | ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); | 130 | ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); |
| 132 | 131 | ||
| 132 | + type.setResolvableStatus(UNRESOLVED); | ||
| 133 | + | ||
| 133 | // Add resolution information to the list | 134 | // Add resolution information to the list |
| 134 | YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type, | 135 | YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type, |
| 135 | - ResolutionType.TYPEDEF_RESOLUTION, (YangNode) parentNodeOfLeaf, prefix, errorLine, | 136 | + (YangNode) parentNodeOfLeaf, errorLine, errorPosition); |
| 136 | - errorPosition); | ||
| 137 | addToResolutionList(resolutionInfo, ctx); | 137 | addToResolutionList(resolutionInfo, ctx); |
| 138 | } | 138 | } |
| 139 | break; | 139 | break; |
| ... | @@ -165,9 +165,9 @@ public final class TypeListener { | ... | @@ -165,9 +165,9 @@ public final class TypeListener { |
| 165 | ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); | 165 | ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); |
| 166 | 166 | ||
| 167 | // Add resolution information to the list | 167 | // Add resolution information to the list |
| 168 | - YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type, | 168 | + YangResolutionInfo resolutionInfo = |
| 169 | - ResolutionType.TYPEDEF_RESOLUTION, (YangNode) parentNodeOfLeafList, prefix, errorLine, | 169 | + new YangResolutionInfo<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine, |
| 170 | - errorPosition); | 170 | + errorPosition); |
| 171 | addToResolutionList(resolutionInfo, ctx); | 171 | addToResolutionList(resolutionInfo, ctx); |
| 172 | } | 172 | } |
| 173 | break; | 173 | break; |
| ... | @@ -201,8 +201,8 @@ public final class TypeListener { | ... | @@ -201,8 +201,8 @@ public final class TypeListener { |
| 201 | ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); | 201 | ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo); |
| 202 | 202 | ||
| 203 | // Add resolution information to the list | 203 | // Add resolution information to the list |
| 204 | - YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type, | 204 | + YangResolutionInfo resolutionInfo = |
| 205 | - ResolutionType.TYPEDEF_RESOLUTION, (YangNode) typeDef, prefix, errorLine, errorPosition); | 205 | + new YangResolutionInfo<YangType>(type, (YangNode) typeDef, errorLine, errorPosition); |
| 206 | addToResolutionList(resolutionInfo, ctx); | 206 | addToResolutionList(resolutionInfo, ctx); |
| 207 | } | 207 | } |
| 208 | break; | 208 | break; |
| ... | @@ -244,7 +244,7 @@ public final class TypeListener { | ... | @@ -244,7 +244,7 @@ public final class TypeListener { |
| 244 | * @param ctx context object of the grammar rule | 244 | * @param ctx context object of the grammar rule |
| 245 | */ | 245 | */ |
| 246 | private static void addToResolutionList(YangResolutionInfo<YangType> resolutionInfo, | 246 | private static void addToResolutionList(YangResolutionInfo<YangType> resolutionInfo, |
| 247 | - GeneratedYangParser.TypeStatementContext ctx) { | 247 | + GeneratedYangParser.TypeStatementContext ctx) { |
| 248 | try { | 248 | try { |
| 249 | addResolutionInfo(resolutionInfo); | 249 | addResolutionInfo(resolutionInfo); |
| 250 | } catch (DataModelException e) { | 250 | } catch (DataModelException e) { | ... | ... |
| ... | @@ -205,7 +205,7 @@ public final class ListenerUtil { | ... | @@ -205,7 +205,7 @@ public final class ListenerUtil { |
| 205 | 205 | ||
| 206 | Calendar date = Calendar.getInstance(); | 206 | Calendar date = Calendar.getInstance(); |
| 207 | SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); | 207 | SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); |
| 208 | - String dateForRevision = ((dateFormat.format(date.getTime())).replaceAll(SLASH, HYPHEN)).replaceAll(SPACE, | 208 | + String dateForRevision = dateFormat.format(date.getTime()).replaceAll(SLASH, HYPHEN).replaceAll(SPACE, |
| 209 | EMPTY_STRING); | 209 | EMPTY_STRING); |
| 210 | return dateForRevision; | 210 | return dateForRevision; |
| 211 | } | 211 | } |
| ... | @@ -218,8 +218,8 @@ public final class ListenerUtil { | ... | @@ -218,8 +218,8 @@ public final class ListenerUtil { |
| 218 | * @param ctx yang construct's context to get the line number and character position | 218 | * @param ctx yang construct's context to get the line number and character position |
| 219 | * @return valid node identifier | 219 | * @return valid node identifier |
| 220 | */ | 220 | */ |
| 221 | - public static YangNodeIdentifier getValidNodeIdentifier(String nodeIdentifierString, YangConstructType | 221 | + public static YangNodeIdentifier getValidNodeIdentifier(String nodeIdentifierString, |
| 222 | - yangConstruct, ParserRuleContext ctx) { | 222 | + YangConstructType yangConstruct, ParserRuleContext ctx) { |
| 223 | String tmpIdentifierString = removeQuotesAndHandleConcat(nodeIdentifierString); | 223 | String tmpIdentifierString = removeQuotesAndHandleConcat(nodeIdentifierString); |
| 224 | String[] tmpData = tmpIdentifierString.split(Pattern.quote(COLON)); | 224 | String[] tmpData = tmpIdentifierString.split(Pattern.quote(COLON)); |
| 225 | if (tmpData.length == 1) { | 225 | if (tmpData.length == 1) { | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.yangutils.translator.tojava; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Maintain the java qualified access details for an attribute or a class. | ||
| 20 | + */ | ||
| 21 | +public interface HasJavaQualifiedTypeInfo { | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * Obtain the java qualified details. | ||
| 25 | + * | ||
| 26 | + * @return java qualified type details | ||
| 27 | + */ | ||
| 28 | + JavaQualifiedTypeInfo getJavaQualifiedInfo(); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Assign the qualified type info. | ||
| 32 | + * | ||
| 33 | + * @param typeInfo qualified type information | ||
| 34 | + */ | ||
| 35 | + void setJavaQualifiedInfo(JavaQualifiedTypeInfo typeInfo); | ||
| 36 | +} |
| ... | @@ -1055,7 +1055,7 @@ public class TempJavaCodeFragmentFiles { | ... | @@ -1055,7 +1055,7 @@ public class TempJavaCodeFragmentFiles { |
| 1055 | public void addTypeDefAttributeToTempFiles(YangNode curNode) throws IOException { | 1055 | public void addTypeDefAttributeToTempFiles(YangNode curNode) throws IOException { |
| 1056 | 1056 | ||
| 1057 | JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfTypeDef(curNode, | 1057 | JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfTypeDef(curNode, |
| 1058 | - ((YangTypeDef) curNode).getDataType(), | 1058 | + ((YangTypeDef) curNode).getTypeDefBaseType(), |
| 1059 | ((YangTypeDef) curNode).getName(), false); | 1059 | ((YangTypeDef) curNode).getName(), false); |
| 1060 | addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); | 1060 | addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); |
| 1061 | } | 1061 | } | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.yangutils.translator.tojava.javamodel; | ||
| 17 | + | ||
| 18 | +import org.onosproject.yangutils.datamodel.YangLeaf; | ||
| 19 | +import org.onosproject.yangutils.translator.tojava.HasJavaQualifiedTypeInfo; | ||
| 20 | +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Maintains java information corresponding to the YANG leaf. | ||
| 24 | + */ | ||
| 25 | +public class YangJavaLeaf extends YangLeaf | ||
| 26 | + implements HasJavaQualifiedTypeInfo { | ||
| 27 | + | ||
| 28 | + private JavaQualifiedTypeInfo javaQualifiedAccess; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Create a YANG leaf object with java qualified access details. | ||
| 32 | + */ | ||
| 33 | + public YangJavaLeaf() { | ||
| 34 | + super(); | ||
| 35 | + setJavaQualifiedInfo(new JavaQualifiedTypeInfo()); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @Override | ||
| 39 | + public JavaQualifiedTypeInfo getJavaQualifiedInfo() { | ||
| 40 | + return javaQualifiedAccess; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + @Override | ||
| 44 | + public void setJavaQualifiedInfo(JavaQualifiedTypeInfo typeInfo) { | ||
| 45 | + javaQualifiedAccess = typeInfo; | ||
| 46 | + | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | +} |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.yangutils.linker; | ... | @@ -18,6 +18,7 @@ package org.onosproject.yangutils.linker; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.ListIterator; | 20 | import java.util.ListIterator; |
| 21 | + | ||
| 21 | import org.junit.Test; | 22 | import org.junit.Test; |
| 22 | import org.onosproject.yangutils.datamodel.ResolvableStatus; | 23 | import org.onosproject.yangutils.datamodel.ResolvableStatus; |
| 23 | import org.onosproject.yangutils.datamodel.YangContainer; | 24 | import org.onosproject.yangutils.datamodel.YangContainer; |
| ... | @@ -46,7 +47,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -46,7 +47,8 @@ public class IntraFileTypeLinkingTest { |
| 46 | * Checks self resolution when typedef and leaf using type are siblings. | 47 | * Checks self resolution when typedef and leaf using type are siblings. |
| 47 | */ | 48 | */ |
| 48 | @Test | 49 | @Test |
| 49 | - public void processSelfResolutionWhenTypeAndTypedefAtRootLevel() throws IOException, ParserException { | 50 | + public void processSelfResolutionWhenTypeAndTypedefAtRootLevel() |
| 51 | + throws IOException, ParserException { | ||
| 50 | 52 | ||
| 51 | YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang"); | 53 | YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang"); |
| 52 | 54 | ||
| ... | @@ -79,7 +81,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -79,7 +81,8 @@ public class IntraFileTypeLinkingTest { |
| 79 | * level where typedef is at the root. | 81 | * level where typedef is at the root. |
| 80 | */ | 82 | */ |
| 81 | @Test | 83 | @Test |
| 82 | - public void processSelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy() throws IOException, ParserException { | 84 | + public void processSelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy() |
| 85 | + throws IOException, ParserException { | ||
| 83 | 86 | ||
| 84 | YangNode node = | 87 | YangNode node = |
| 85 | manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang"); | 88 | manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang"); |
| ... | @@ -118,7 +121,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -118,7 +121,8 @@ public class IntraFileTypeLinkingTest { |
| 118 | * of type. | 121 | * of type. |
| 119 | */ | 122 | */ |
| 120 | @Test | 123 | @Test |
| 121 | - public void processSelfFileLinkingTypedefAtRootIsAfterContainerHavingType() throws IOException, ParserException { | 124 | + public void processSelfFileLinkingTypedefAtRootIsAfterContainerHavingType() |
| 125 | + throws IOException, ParserException { | ||
| 122 | 126 | ||
| 123 | YangNode node = | 127 | YangNode node = |
| 124 | manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang"); | 128 | manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang"); |
| ... | @@ -157,7 +161,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -157,7 +161,8 @@ public class IntraFileTypeLinkingTest { |
| 157 | * holder of type. | 161 | * holder of type. |
| 158 | */ | 162 | */ |
| 159 | @Test | 163 | @Test |
| 160 | - public void processSelfFileLinkingTypedefAtMiddleLevelAfterParentHolder() throws IOException, ParserException { | 164 | + public void processSelfFileLinkingTypedefAtMiddleLevelAfterParentHolder() |
| 165 | + throws IOException, ParserException { | ||
| 161 | 166 | ||
| 162 | YangNode node = | 167 | YangNode node = |
| 163 | manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang"); | 168 | manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang"); |
| ... | @@ -194,7 +199,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -194,7 +199,8 @@ public class IntraFileTypeLinkingTest { |
| 194 | * Checks self resolution when typedef hierarchical references are present. | 199 | * Checks self resolution when typedef hierarchical references are present. |
| 195 | */ | 200 | */ |
| 196 | @Test | 201 | @Test |
| 197 | - public void processSelfFileLinkingWithTypdefHierarchicalReference() throws IOException, ParserException { | 202 | + public void processSelfFileLinkingWithTypdefHierarchicalReference() |
| 203 | + throws IOException, ParserException { | ||
| 198 | 204 | ||
| 199 | YangNode node = | 205 | YangNode node = |
| 200 | manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang"); | 206 | manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang"); |
| ... | @@ -227,16 +233,16 @@ public class IntraFileTypeLinkingTest { | ... | @@ -227,16 +233,16 @@ public class IntraFileTypeLinkingTest { |
| 227 | 233 | ||
| 228 | YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); | 234 | YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); |
| 229 | 235 | ||
| 230 | - assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), | 236 | + assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), |
| 231 | is((YangTypeDef) yangContainer.getChild().getNextSibling())); | 237 | is((YangTypeDef) yangContainer.getChild().getNextSibling())); |
| 232 | - assertThat((typeDef1.getDataType().getResolvableStatus()), | 238 | + assertThat((typeDef1.getTypeDefBaseType().getResolvableStatus()), |
| 233 | is(ResolvableStatus.RESOLVED)); | 239 | is(ResolvableStatus.RESOLVED)); |
| 234 | 240 | ||
| 235 | YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); | 241 | YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); |
| 236 | 242 | ||
| 237 | - assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), | 243 | + assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), |
| 238 | is((YangTypeDef) node.getChild())); | 244 | is((YangTypeDef) node.getChild())); |
| 239 | - assertThat((typeDef2.getDataType().getResolvableStatus()), | 245 | + assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()), |
| 240 | is(ResolvableStatus.RESOLVED)); | 246 | is(ResolvableStatus.RESOLVED)); |
| 241 | } | 247 | } |
| 242 | 248 | ||
| ... | @@ -245,7 +251,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -245,7 +251,8 @@ public class IntraFileTypeLinkingTest { |
| 245 | * with last type is unresolved. | 251 | * with last type is unresolved. |
| 246 | */ | 252 | */ |
| 247 | @Test | 253 | @Test |
| 248 | - public void processSelfFileLinkingWithTypdefHierarchicalRefUnresolved() throws IOException, ParserException { | 254 | + public void processSelfFileLinkingWithTypdefHierarchicalRefUnresolved() |
| 255 | + throws IOException, ParserException { | ||
| 249 | 256 | ||
| 250 | YangNode node = | 257 | YangNode node = |
| 251 | manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang"); | 258 | manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang"); |
| ... | @@ -274,28 +281,29 @@ public class IntraFileTypeLinkingTest { | ... | @@ -274,28 +281,29 @@ public class IntraFileTypeLinkingTest { |
| 274 | assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), | 281 | assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), |
| 275 | is((YangTypeDef) yangList.getChild())); | 282 | is((YangTypeDef) yangList.getChild())); |
| 276 | assertThat((leafInfo.getDataType().getResolvableStatus()), | 283 | assertThat((leafInfo.getDataType().getResolvableStatus()), |
| 277 | - is(ResolvableStatus.PARTIALLY_RESOLVED)); | 284 | + is(ResolvableStatus.INTRA_FILE_RESOLVED)); |
| 278 | 285 | ||
| 279 | YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); | 286 | YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); |
| 280 | 287 | ||
| 281 | - assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), | 288 | + assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), |
| 282 | is((YangTypeDef) yangContainer.getChild().getNextSibling())); | 289 | is((YangTypeDef) yangContainer.getChild().getNextSibling())); |
| 283 | - assertThat((typeDef1.getDataType().getResolvableStatus()), | 290 | + assertThat((typeDef1.getTypeDefBaseType().getResolvableStatus()), |
| 284 | - is(ResolvableStatus.PARTIALLY_RESOLVED)); | 291 | + is(ResolvableStatus.INTRA_FILE_RESOLVED)); |
| 285 | 292 | ||
| 286 | YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); | 293 | YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); |
| 287 | 294 | ||
| 288 | - assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), | 295 | + assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), |
| 289 | is((YangTypeDef) node.getChild())); | 296 | is((YangTypeDef) node.getChild())); |
| 290 | - assertThat((typeDef2.getDataType().getResolvableStatus()), | 297 | + assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()), |
| 291 | - is(ResolvableStatus.PARTIALLY_RESOLVED)); | 298 | + is(ResolvableStatus.INTRA_FILE_RESOLVED)); |
| 292 | } | 299 | } |
| 293 | 300 | ||
| 294 | /** | 301 | /** |
| 295 | * Checks self resolution when type uses prefix of self module. | 302 | * Checks self resolution when type uses prefix of self module. |
| 296 | */ | 303 | */ |
| 297 | @Test | 304 | @Test |
| 298 | - public void processSelfFileLinkingWithTypeWithSelfModulePrefix() throws IOException, ParserException { | 305 | + public void processSelfFileLinkingWithTypeWithSelfModulePrefix() |
| 306 | + throws IOException, ParserException { | ||
| 299 | 307 | ||
| 300 | YangNode node = | 308 | YangNode node = |
| 301 | manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang"); | 309 | manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang"); |
| ... | @@ -328,16 +336,16 @@ public class IntraFileTypeLinkingTest { | ... | @@ -328,16 +336,16 @@ public class IntraFileTypeLinkingTest { |
| 328 | 336 | ||
| 329 | YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); | 337 | YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); |
| 330 | 338 | ||
| 331 | - assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), | 339 | + assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), |
| 332 | is((YangTypeDef) yangContainer.getChild().getNextSibling())); | 340 | is((YangTypeDef) yangContainer.getChild().getNextSibling())); |
| 333 | - assertThat((typeDef1.getDataType().getResolvableStatus()), | 341 | + assertThat((typeDef1.getTypeDefBaseType().getResolvableStatus()), |
| 334 | is(ResolvableStatus.RESOLVED)); | 342 | is(ResolvableStatus.RESOLVED)); |
| 335 | 343 | ||
| 336 | YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); | 344 | YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); |
| 337 | 345 | ||
| 338 | - assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), | 346 | + assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), |
| 339 | is((YangTypeDef) node.getChild())); | 347 | is((YangTypeDef) node.getChild())); |
| 340 | - assertThat((typeDef2.getDataType().getResolvableStatus()), | 348 | + assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()), |
| 341 | is(ResolvableStatus.RESOLVED)); | 349 | is(ResolvableStatus.RESOLVED)); |
| 342 | } | 350 | } |
| 343 | 351 | ||
| ... | @@ -346,7 +354,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -346,7 +354,8 @@ public class IntraFileTypeLinkingTest { |
| 346 | * some uses external prefix. | 354 | * some uses external prefix. |
| 347 | */ | 355 | */ |
| 348 | @Test | 356 | @Test |
| 349 | - public void processSelfFileLinkingWithTypeWithSelfAndExternalPrefixMix() throws IOException, ParserException { | 357 | + public void processSelfFileLinkingWithTypeWithSelfAndExternalPrefixMix() |
| 358 | + throws IOException, ParserException { | ||
| 350 | 359 | ||
| 351 | YangNode node = | 360 | YangNode node = |
| 352 | manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang"); | 361 | manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang"); |
| ... | @@ -375,15 +384,15 @@ public class IntraFileTypeLinkingTest { | ... | @@ -375,15 +384,15 @@ public class IntraFileTypeLinkingTest { |
| 375 | assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), | 384 | assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), |
| 376 | is((YangTypeDef) yangList.getChild())); | 385 | is((YangTypeDef) yangList.getChild())); |
| 377 | assertThat((leafInfo.getDataType().getResolvableStatus()), | 386 | assertThat((leafInfo.getDataType().getResolvableStatus()), |
| 378 | - is(ResolvableStatus.PARTIALLY_RESOLVED)); | 387 | + is(ResolvableStatus.INTRA_FILE_RESOLVED)); |
| 379 | 388 | ||
| 380 | YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); | 389 | YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); |
| 381 | 390 | ||
| 382 | YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); | 391 | YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); |
| 383 | 392 | ||
| 384 | - assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), | 393 | + assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), |
| 385 | is((YangTypeDef) node.getChild())); | 394 | is((YangTypeDef) node.getChild())); |
| 386 | - assertThat((typeDef2.getDataType().getResolvableStatus()), | 395 | + assertThat((typeDef2.getTypeDefBaseType().getResolvableStatus()), |
| 387 | is(ResolvableStatus.RESOLVED)); | 396 | is(ResolvableStatus.RESOLVED)); |
| 388 | } | 397 | } |
| 389 | 398 | ||
| ... | @@ -392,7 +401,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -392,7 +401,8 @@ public class IntraFileTypeLinkingTest { |
| 392 | * file. | 401 | * file. |
| 393 | */ | 402 | */ |
| 394 | @Test(expected = ParserException.class) | 403 | @Test(expected = ParserException.class) |
| 395 | - public void processSelfResolutionWhenTypeReferredTypedefNotDefined() throws IOException, ParserException { | 404 | + public void processSelfResolutionWhenTypeReferredTypedefNotDefined() |
| 405 | + throws IOException, ParserException { | ||
| 396 | 406 | ||
| 397 | YangNode node = | 407 | YangNode node = |
| 398 | manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang"); | 408 | manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang"); |
| ... | @@ -403,7 +413,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -403,7 +413,8 @@ public class IntraFileTypeLinkingTest { |
| 403 | * level where typedef is is not an ancestor of type. | 413 | * level where typedef is is not an ancestor of type. |
| 404 | */ | 414 | */ |
| 405 | @Test(expected = ParserException.class) | 415 | @Test(expected = ParserException.class) |
| 406 | - public void processSelfFileLinkingTypedefNotFound() throws IOException, ParserException { | 416 | + public void processSelfFileLinkingTypedefNotFound() |
| 417 | + throws IOException, ParserException { | ||
| 407 | 418 | ||
| 408 | YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang"); | 419 | YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang"); |
| 409 | } | 420 | } |
| ... | @@ -412,7 +423,8 @@ public class IntraFileTypeLinkingTest { | ... | @@ -412,7 +423,8 @@ public class IntraFileTypeLinkingTest { |
| 412 | * Checks hierarchical self resolution with self resolution failure scenario. | 423 | * Checks hierarchical self resolution with self resolution failure scenario. |
| 413 | */ | 424 | */ |
| 414 | @Test(expected = ParserException.class) | 425 | @Test(expected = ParserException.class) |
| 415 | - public void processSelfFileLinkingWithHierarchicalTypeFailureScenario() throws IOException, ParserException { | 426 | + public void processSelfFileLinkingWithHierarchicalTypeFailureScenario() |
| 427 | + throws IOException, ParserException { | ||
| 416 | 428 | ||
| 417 | YangNode node = | 429 | YangNode node = |
| 418 | manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang"); | 430 | manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang"); | ... | ... |
utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
| ... | @@ -106,6 +106,6 @@ public class InputListenerTest { | ... | @@ -106,6 +106,6 @@ public class InputListenerTest { |
| 106 | YangTypeDef typeDef = (YangTypeDef) yangInput.getChild(); | 106 | YangTypeDef typeDef = (YangTypeDef) yangInput.getChild(); |
| 107 | assertThat(typeDef.getName(), is("my-type")); | 107 | assertThat(typeDef.getName(), is("my-type")); |
| 108 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); | 108 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); |
| 109 | - assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32)); | 109 | + assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32)); |
| 110 | } | 110 | } |
| 111 | } | 111 | } | ... | ... |
| ... | @@ -128,7 +128,7 @@ public class LengthRestrictionListenerTest { | ... | @@ -128,7 +128,7 @@ public class LengthRestrictionListenerTest { |
| 128 | assertThat(yangNode.getName(), is("Test")); | 128 | assertThat(yangNode.getName(), is("Test")); |
| 129 | 129 | ||
| 130 | YangTypeDef typedef = (YangTypeDef) yangNode.getChild(); | 130 | YangTypeDef typedef = (YangTypeDef) yangNode.getChild(); |
| 131 | - YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getDataType() | 131 | + YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getTypeDefBaseType() |
| 132 | .getDataTypeExtendedInfo(); | 132 | .getDataTypeExtendedInfo(); |
| 133 | 133 | ||
| 134 | YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction(); | 134 | YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction(); |
| ... | @@ -234,4 +234,4 @@ public class LengthRestrictionListenerTest { | ... | @@ -234,4 +234,4 @@ public class LengthRestrictionListenerTest { |
| 234 | " 18446744073709551615."); | 234 | " 18446744073709551615."); |
| 235 | YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidInterval.yang"); | 235 | YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidInterval.yang"); |
| 236 | } | 236 | } |
| 237 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 237 | +} | ... | ... |
| ... | @@ -108,6 +108,6 @@ public class OutputListenerTest { | ... | @@ -108,6 +108,6 @@ public class OutputListenerTest { |
| 108 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); | 108 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); |
| 109 | assertThat(typeDef.getName(), is("my-type")); | 109 | assertThat(typeDef.getName(), is("my-type")); |
| 110 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); | 110 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); |
| 111 | - assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32)); | 111 | + assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32)); |
| 112 | } | 112 | } |
| 113 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 113 | +} | ... | ... |
| ... | @@ -108,7 +108,7 @@ public class PatternRestrictionListenerTest { | ... | @@ -108,7 +108,7 @@ public class PatternRestrictionListenerTest { |
| 108 | assertThat(yangNode.getName(), is("Test")); | 108 | assertThat(yangNode.getName(), is("Test")); |
| 109 | 109 | ||
| 110 | YangTypeDef typedef = (YangTypeDef) yangNode.getChild(); | 110 | YangTypeDef typedef = (YangTypeDef) yangNode.getChild(); |
| 111 | - YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getDataType() | 111 | + YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getTypeDefBaseType() |
| 112 | .getDataTypeExtendedInfo(); | 112 | .getDataTypeExtendedInfo(); |
| 113 | 113 | ||
| 114 | YangPatternRestriction yangPatternRestriction = stringRestriction.getPatternRestriction(); | 114 | YangPatternRestriction yangPatternRestriction = stringRestriction.getPatternRestriction(); |
| ... | @@ -166,4 +166,4 @@ public class PatternRestrictionListenerTest { | ... | @@ -166,4 +166,4 @@ public class PatternRestrictionListenerTest { |
| 166 | .getPatternList().listIterator(); | 166 | .getPatternList().listIterator(); |
| 167 | assertThat(patternListIterator.next(), is("-[0-9]+|[0-9]+")); | 167 | assertThat(patternListIterator.next(), is("-[0-9]+|[0-9]+")); |
| 168 | } | 168 | } |
| 169 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 169 | +} | ... | ... |
| ... | @@ -61,6 +61,6 @@ public class RpcListenerTest { | ... | @@ -61,6 +61,6 @@ public class RpcListenerTest { |
| 61 | YangTypeDef typeDef = (YangTypeDef) yangRpc.getChild(); | 61 | YangTypeDef typeDef = (YangTypeDef) yangRpc.getChild(); |
| 62 | assertThat(typeDef.getName(), is("my-type")); | 62 | assertThat(typeDef.getName(), is("my-type")); |
| 63 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); | 63 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); |
| 64 | - assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32)); | 64 | + assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32)); |
| 65 | } | 65 | } |
| 66 | } | 66 | } | ... | ... |
| ... | @@ -2,6 +2,9 @@ module Test { | ... | @@ -2,6 +2,9 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | leaf invalid-interval { | 8 | leaf invalid-interval { |
| 6 | type P:hello; | 9 | type P:hello; |
| 7 | } | 10 | } | ... | ... |
| ... | @@ -2,6 +2,9 @@ module Test { | ... | @@ -2,6 +2,9 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | list valid { | 8 | list valid { |
| 6 | key address; | 9 | key address; |
| 7 | grouping endpoint { | 10 | grouping endpoint { | ... | ... |
| ... | @@ -2,20 +2,23 @@ module Test { | ... | @@ -2,20 +2,23 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | grouping endpoint { | 8 | grouping endpoint { |
| 6 | leaf address { | 9 | leaf address { |
| 7 | - type ip-address; | 10 | + type P:ip-address; |
| 8 | } | 11 | } |
| 9 | leaf port { | 12 | leaf port { |
| 10 | - type port-number; | 13 | + type P:port-number; |
| 11 | } | 14 | } |
| 12 | } | 15 | } |
| 13 | grouping endpoint { | 16 | grouping endpoint { |
| 14 | leaf address { | 17 | leaf address { |
| 15 | - type ip-address; | 18 | + type P:pip-address; |
| 16 | } | 19 | } |
| 17 | leaf port { | 20 | leaf port { |
| 18 | - type port-number; | 21 | + type P:port-number; |
| 19 | } | 22 | } |
| 20 | } | 23 | } |
| 21 | } | 24 | } | ... | ... |
| ... | @@ -2,6 +2,9 @@ module Test { | ... | @@ -2,6 +2,9 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | list valid { | 8 | list valid { |
| 6 | key address; | 9 | key address; |
| 7 | leaf address { | 10 | leaf address { | ... | ... |
| ... | @@ -2,6 +2,9 @@ module Test { | ... | @@ -2,6 +2,9 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | container valid { | 8 | container valid { |
| 6 | grouping endpoint { | 9 | grouping endpoint { |
| 7 | leaf address { | 10 | leaf address { | ... | ... |
| ... | @@ -2,6 +2,9 @@ module Test { | ... | @@ -2,6 +2,9 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | list valid { | 8 | list valid { |
| 6 | key address; | 9 | key address; |
| 7 | leaf address { | 10 | leaf address { | ... | ... |
| ... | @@ -2,6 +2,9 @@ module Test { | ... | @@ -2,6 +2,9 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | grouping endpoint { | 8 | grouping endpoint { |
| 6 | leaf address { | 9 | leaf address { |
| 7 | type P:ip-address; | 10 | type P:ip-address; | ... | ... |
| ... | @@ -2,6 +2,9 @@ module Test { | ... | @@ -2,6 +2,9 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | typedef Percentage { | 8 | typedef Percentage { |
| 6 | type P:Per; | 9 | type P:Per; |
| 7 | } | 10 | } | ... | ... |
| ... | @@ -2,6 +2,9 @@ module Test { | ... | @@ -2,6 +2,9 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | typedef Percentage { | 8 | typedef Percentage { |
| 6 | type int32; | 9 | type int32; |
| 7 | } | 10 | } | ... | ... |
| ... | @@ -2,6 +2,9 @@ module Test { | ... | @@ -2,6 +2,9 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | list valid { | 8 | list valid { |
| 6 | key address; | 9 | key address; |
| 7 | leaf address { | 10 | leaf address { | ... | ... |
| ... | @@ -6,6 +6,9 @@ module Test { | ... | @@ -6,6 +6,9 @@ module Test { |
| 6 | import interface-module { | 6 | import interface-module { |
| 7 | prefix "if"; | 7 | prefix "if"; |
| 8 | } | 8 | } |
| 9 | + import ietf-yang-types { | ||
| 10 | + prefix "P"; | ||
| 11 | + } | ||
| 9 | augment "/if:interfaces/if:ifEntry" { | 12 | augment "/if:interfaces/if:ifEntry" { |
| 10 | when "if:ifType='ds0'"; | 13 | when "if:ifType='ds0'"; |
| 11 | leaf ds0ChannelNumber { | 14 | leaf ds0ChannelNumber { | ... | ... |
| ... | @@ -2,6 +2,9 @@ module rock { | ... | @@ -2,6 +2,9 @@ module rock { |
| 2 | namespace "http://example.net/rock"; | 2 | namespace "http://example.net/rock"; |
| 3 | prefix "rock"; | 3 | prefix "rock"; |
| 4 | 4 | ||
| 5 | + import ietf-yang-types { | ||
| 6 | + prefix "P"; | ||
| 7 | + } | ||
| 5 | notification link-failure { | 8 | notification link-failure { |
| 6 | description "A link failure has been detected"; | 9 | description "A link failure has been detected"; |
| 7 | status deprecated; | 10 | status deprecated; | ... | ... |
-
Please register or login to post a comment