Committed by
Gerrit Code Review
[ONOS-4063 to 68] Intra YANG file Linking Implementation and Intra YANG file Linking Framework
Change-Id: I06e602c351ab54178bf90b8676af71a70e42371f
Showing
58 changed files
with
1138 additions
and
421 deletions
| 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 | + | ||
| 17 | +package org.onosproject.yangutils.datamodel; | ||
| 18 | + | ||
| 19 | +import java.util.List; | ||
| 20 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Abstraction of YANG dependency resolution information. Abstracted to obtain the | ||
| 24 | + * resolution information. | ||
| 25 | + */ | ||
| 26 | +public interface HasResolutionInfo { | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * Returns unresolved resolution list. | ||
| 30 | + * | ||
| 31 | + * @return unresolved resolution list | ||
| 32 | + */ | ||
| 33 | + List<YangResolutionInfo> getUnresolvedResolutionList(); | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Add to the resolution list. | ||
| 37 | + * | ||
| 38 | + * @param resolutionInfo resolution information | ||
| 39 | + */ | ||
| 40 | + void addToResolutionList(YangResolutionInfo resolutionInfo); | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * Creates resolution list. | ||
| 44 | + * | ||
| 45 | + * @param resolutionList resolution list | ||
| 46 | + */ | ||
| 47 | + void setResolutionList(List<YangResolutionInfo> resolutionList); | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Returns unresolved imported list. | ||
| 51 | + * | ||
| 52 | + * @return unresolved imported list | ||
| 53 | + */ | ||
| 54 | + List<YangImport> getImportList(); | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * Add to the import list. | ||
| 58 | + * | ||
| 59 | + * @param yangImport import to be added | ||
| 60 | + */ | ||
| 61 | + void addToImportList(YangImport yangImport); | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * Create import list. | ||
| 65 | + * | ||
| 66 | + * @param importList import list | ||
| 67 | + */ | ||
| 68 | + void setImportList(List<YangImport> importList); | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * Returns unresolved include list. | ||
| 72 | + * | ||
| 73 | + * @return unresolved include list | ||
| 74 | + */ | ||
| 75 | + List<YangInclude> getIncludeList(); | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * Add to the include list. | ||
| 79 | + * | ||
| 80 | + * @param yangInclude include to be added | ||
| 81 | + */ | ||
| 82 | + void addToIncludeList(YangInclude yangInclude); | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * Create include list. | ||
| 86 | + * | ||
| 87 | + * @param includeList include list | ||
| 88 | + */ | ||
| 89 | + void setIncludeList(List<YangInclude> includeList); | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * Returns prefix of resolution root node. | ||
| 93 | + * | ||
| 94 | + * @return prefix resolution root node prefix | ||
| 95 | + */ | ||
| 96 | + String getPrefix(); | ||
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * Set prefix of resolution list root node. | ||
| 100 | + * | ||
| 101 | + * @param prefix resolution root node prefix | ||
| 102 | + */ | ||
| 103 | + void setPrefix(String prefix); | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * Resolve self file linking. | ||
| 107 | + * | ||
| 108 | + * @throws DataModelException a violation in data model rule | ||
| 109 | + */ | ||
| 110 | + void resolveSelfFileLinking() throws DataModelException; | ||
| 111 | +} |
| 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 | + | ||
| 17 | +package org.onosproject.yangutils.datamodel; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * ENUM to identify the YANG resolution type. | ||
| 21 | + */ | ||
| 22 | +public enum ResolutionType { | ||
| 23 | + /** | ||
| 24 | + * Identifies that resolution is for typedef. | ||
| 25 | + */ | ||
| 26 | + TYPEDEF_RESOLUTION, | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * Identifies that resolution is for grouping. | ||
| 30 | + */ | ||
| 31 | + GROUPING_RESOLUTION; | ||
| 32 | +} |
| 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 | + | ||
| 17 | +package org.onosproject.yangutils.datamodel; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Abstraction of YANG resolvable information. Abstracted to obtain the | ||
| 21 | + * information required for linking resolution. | ||
| 22 | + */ | ||
| 23 | +public interface Resolvable { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * Returns the status of resolution. If completely resolved returns enum | ||
| 27 | + * value "RESOLVED", if not returns "UNRESOLVED", in case reference of | ||
| 28 | + * grouping/typedef is added to uses/type but it's not resolved | ||
| 29 | + * "PARTIALLY_RESOLVED" is returned. | ||
| 30 | + * | ||
| 31 | + * @return status of resolution | ||
| 32 | + */ | ||
| 33 | + ResolvableStatus getResolvableStatus(); | ||
| 34 | + | ||
| 35 | + /** | ||
| 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 | ||
| 38 | + * grouping/typedef is added to uses/type but it's not resolved | ||
| 39 | + * "PARTIALLY_RESOLVED" should be set. | ||
| 40 | + * | ||
| 41 | + * @param resolvableStatus status of resolution | ||
| 42 | + */ | ||
| 43 | + void setResolvableStatus(ResolvableStatus resolvableStatus); | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * Resolves the linking. | ||
| 47 | + */ | ||
| 48 | + void resolve(); | ||
| 49 | +} |
| 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 | + | ||
| 17 | +package org.onosproject.yangutils.datamodel; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Represents the status of resolvable entity. | ||
| 21 | + */ | ||
| 22 | +public enum ResolvableStatus { | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * Identifies that resolvable entity is resolved. | ||
| 26 | + */ | ||
| 27 | + RESOLVED, | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Identifies that resolvable entity is unresolved. | ||
| 31 | + */ | ||
| 32 | + UNRESOLVED, | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Identifies that resolvable entity is partially resolved. | ||
| 36 | + */ | ||
| 37 | + PARTIALLY_RESOLVED; | ||
| 38 | +} |
| ... | @@ -16,112 +16,83 @@ | ... | @@ -16,112 +16,83 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.yangutils.datamodel; | 17 | package org.onosproject.yangutils.datamodel; |
| 18 | 18 | ||
| 19 | -import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
| 20 | -import org.onosproject.yangutils.parser.Parsable; | ||
| 21 | -import org.onosproject.yangutils.utils.YangConstructType; | ||
| 22 | - | ||
| 23 | -/*- | ||
| 24 | - * Reference RFC 6020. | ||
| 25 | - * | ||
| 26 | - * The typedef Statement | ||
| 27 | - * | ||
| 28 | - * The "typedef" statement defines a new type that may be used locally | ||
| 29 | - * in the module, in modules or submodules which include it, and by | ||
| 30 | - * other modules that import from it. The new type is called the | ||
| 31 | - * "derived type", and the type from which it was derived is called | ||
| 32 | - * the "base type". All derived types can be traced back to a YANG | ||
| 33 | - * built-in type. | ||
| 34 | - * | ||
| 35 | - * The "typedef" statement's argument is an identifier that is the name | ||
| 36 | - * of the type to be defined, and MUST be followed by a block of | ||
| 37 | - * sub-statements that holds detailed typedef information. | ||
| 38 | - * | ||
| 39 | - * The name of the type MUST NOT be one of the YANG built-in types. If | ||
| 40 | - * the typedef is defined at the top level of a YANG module or | ||
| 41 | - * submodule, the name of the type to be defined MUST be unique within | ||
| 42 | - * the module. | ||
| 43 | - */ | ||
| 44 | /** | 19 | /** |
| 45 | - * Derived type information. | 20 | + * Maintains the derived information. |
| 21 | + * | ||
| 22 | + * @param <T> extended information. | ||
| 46 | */ | 23 | */ |
| 47 | -public class YangDerivedType implements Parsable { | 24 | +public class YangDerivedInfo<T> { |
| 48 | 25 | ||
| 49 | /** | 26 | /** |
| 50 | - * All derived types can be traced back to a YANG built-in type. | 27 | + * YANG typedef reference. |
| 51 | */ | 28 | */ |
| 52 | - private YangDataTypes effectiveYangBuiltInType; | 29 | + private YangTypeDef referredTypeDef; |
| 53 | 30 | ||
| 54 | /** | 31 | /** |
| 55 | - * Base type from which the current type is derived. | 32 | + * Resolved additional information about data type after linking, example |
| 33 | + * restriction info, named values, etc. The extra information is based | ||
| 34 | + * on the data type. Based on the data type, the extended info can vary. | ||
| 56 | */ | 35 | */ |
| 57 | - private YangType<?> baseType; | 36 | + private T resolvedExtendedInfo; |
| 58 | 37 | ||
| 59 | /** | 38 | /** |
| 60 | - * Default constructor. | 39 | + * Additional information about data type, example restriction info, named |
| 40 | + * values, etc. The extra information is based on the data type. Based on | ||
| 41 | + * the data type, the extended info can vary. | ||
| 61 | */ | 42 | */ |
| 62 | - public YangDerivedType() { | 43 | + private T extendedInfo; |
| 63 | - } | ||
| 64 | 44 | ||
| 65 | /** | 45 | /** |
| 66 | - * Get the effective YANG built-in type of the derived data type. | 46 | + * Returns the referred typedef reference. |
| 67 | * | 47 | * |
| 68 | - * @return effective YANG built-in type of the derived data type | 48 | + * @return referred typedef reference |
| 69 | */ | 49 | */ |
| 70 | - public YangDataTypes getEffectiveYangBuiltInType() { | 50 | + public YangTypeDef getReferredTypeDef() { |
| 71 | - return effectiveYangBuiltInType; | 51 | + return referredTypeDef; |
| 72 | } | 52 | } |
| 73 | 53 | ||
| 74 | /** | 54 | /** |
| 75 | - * Set the effective YANG built-in type of the derived data type. | 55 | + * Set the referred typedef reference. |
| 76 | * | 56 | * |
| 77 | - * @param builtInType effective YANG built-in type of the derived data type | 57 | + * @param referredTypeDef referred typedef reference |
| 78 | */ | 58 | */ |
| 79 | - public void setEffectiveYangBuiltInType(YangDataTypes builtInType) { | 59 | + public void setReferredTypeDef(YangTypeDef referredTypeDef) { |
| 80 | - effectiveYangBuiltInType = builtInType; | 60 | + this.referredTypeDef = referredTypeDef; |
| 81 | } | 61 | } |
| 82 | 62 | ||
| 83 | /** | 63 | /** |
| 84 | - * Get the base type information. | 64 | + * Returns resolved extended information after successful linking. |
| 85 | * | 65 | * |
| 86 | - * @return base type information | 66 | + * @return resolved extended information |
| 87 | */ | 67 | */ |
| 88 | - public YangType<?> getBaseType() { | 68 | + public T getResolvedExtendedInfo() { |
| 89 | - return baseType; | 69 | + return resolvedExtendedInfo; |
| 90 | } | 70 | } |
| 91 | 71 | ||
| 92 | /** | 72 | /** |
| 93 | - * Get the base type information. | 73 | + * Set resolved extended information after successful linking. |
| 94 | * | 74 | * |
| 95 | - * @param baseType base type information | 75 | + * @param resolvedExtendedInfo resolved extended information |
| 96 | */ | 76 | */ |
| 97 | - public void setBaseType(YangType<?> baseType) { | 77 | + public void setResolvedExtendedInfo(T resolvedExtendedInfo) { |
| 98 | - this.baseType = baseType; | 78 | + this.resolvedExtendedInfo = resolvedExtendedInfo; |
| 99 | } | 79 | } |
| 100 | 80 | ||
| 101 | /** | 81 | /** |
| 102 | - * Get the parsable type. | 82 | + * Returns extended information. |
| 103 | - */ | 83 | + * |
| 104 | - @Override | 84 | + * @return extended information |
| 105 | - public YangConstructType getYangConstructType() { | ||
| 106 | - return YangConstructType.DERIVED; | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - /** | ||
| 110 | - * TODO. | ||
| 111 | */ | 85 | */ |
| 112 | - @Override | 86 | + public T getExtendedInfo() { |
| 113 | - public void validateDataOnEntry() throws DataModelException { | 87 | + return extendedInfo; |
| 114 | - // TODO Auto-generated method stub | ||
| 115 | - | ||
| 116 | } | 88 | } |
| 117 | 89 | ||
| 118 | /** | 90 | /** |
| 119 | - * TODO. | 91 | + * Set extended information. |
| 92 | + * | ||
| 93 | + * @param extendedInfo extended information | ||
| 120 | */ | 94 | */ |
| 121 | - @Override | 95 | + public void setExtendedInfo(T extendedInfo) { |
| 122 | - public void validateDataOnExit() throws DataModelException { | 96 | + this.extendedInfo = extendedInfo; |
| 123 | - // TODO Auto-generated method stub | ||
| 124 | - | ||
| 125 | } | 97 | } |
| 126 | - | ||
| 127 | } | 98 | } | ... | ... |
| ... | @@ -75,6 +75,11 @@ public class YangImport implements Parsable { | ... | @@ -75,6 +75,11 @@ public class YangImport implements Parsable { |
| 75 | private String prefixId; | 75 | private String prefixId; |
| 76 | 76 | ||
| 77 | /** | 77 | /** |
| 78 | + * Resolution information root node which is also the data model root node. | ||
| 79 | + */ | ||
| 80 | + private HasResolutionInfo resolutionInfoNode; | ||
| 81 | + | ||
| 82 | + /** | ||
| 78 | * Reference:RFC 6020. | 83 | * Reference:RFC 6020. |
| 79 | * | 84 | * |
| 80 | * The import's "revision-date" statement is used to specify the exact | 85 | * The import's "revision-date" statement is used to specify the exact |
| ... | @@ -177,4 +182,22 @@ public class YangImport implements Parsable { | ... | @@ -177,4 +182,22 @@ public class YangImport implements Parsable { |
| 177 | // TODO auto-generated method stub, to be implemented by parser | 182 | // TODO auto-generated method stub, to be implemented by parser |
| 178 | 183 | ||
| 179 | } | 184 | } |
| 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 | + * Set the dresolution information node. | ||
| 197 | + * | ||
| 198 | + * @param resolutionInfoNode the resolution information node | ||
| 199 | + */ | ||
| 200 | + public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) { | ||
| 201 | + this.resolutionInfoNode = resolutionInfoNode; | ||
| 202 | + } | ||
| 180 | } | 203 | } | ... | ... |
| ... | @@ -51,6 +51,11 @@ public class YangInclude implements Parsable { | ... | @@ -51,6 +51,11 @@ public class YangInclude implements Parsable { |
| 51 | private String revision; | 51 | private String revision; |
| 52 | 52 | ||
| 53 | /** | 53 | /** |
| 54 | + * Resolution information root node which is also the data model root node. | ||
| 55 | + */ | ||
| 56 | + private HasResolutionInfo resolutionInfoNode; | ||
| 57 | + | ||
| 58 | + /** | ||
| 54 | * Default constructor. | 59 | * Default constructor. |
| 55 | */ | 60 | */ |
| 56 | public YangInclude() { | 61 | public YangInclude() { |
| ... | @@ -124,4 +129,21 @@ public class YangInclude implements Parsable { | ... | @@ -124,4 +129,21 @@ public class YangInclude implements Parsable { |
| 124 | 129 | ||
| 125 | } | 130 | } |
| 126 | 131 | ||
| 132 | + /** | ||
| 133 | + * Returns the resolution information node. | ||
| 134 | + * | ||
| 135 | + * @return the resolution information node | ||
| 136 | + */ | ||
| 137 | + public HasResolutionInfo getResolutionInfoNode() { | ||
| 138 | + return resolutionInfoNode; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + /** | ||
| 142 | + * Set the dresolution information node. | ||
| 143 | + * | ||
| 144 | + * @param resolutionInfoNode the resolution information node | ||
| 145 | + */ | ||
| 146 | + public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) { | ||
| 147 | + this.resolutionInfoNode = resolutionInfoNode; | ||
| 148 | + } | ||
| 127 | } | 149 | } | ... | ... |
| ... | @@ -17,12 +17,12 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,12 +17,12 @@ package org.onosproject.yangutils.datamodel; |
| 17 | 17 | ||
| 18 | import java.util.LinkedList; | 18 | import java.util.LinkedList; |
| 19 | import java.util.List; | 19 | import java.util.List; |
| 20 | - | ||
| 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 20 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.parser.Parsable; | 21 | import org.onosproject.yangutils.parser.Parsable; |
| 23 | import org.onosproject.yangutils.utils.YangConstructType; | 22 | import org.onosproject.yangutils.utils.YangConstructType; |
| 24 | 23 | ||
| 25 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | 24 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
| 25 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList; | ||
| 26 | 26 | ||
| 27 | /*- | 27 | /*- |
| 28 | * Reference:RFC 6020. | 28 | * Reference:RFC 6020. |
| ... | @@ -68,7 +68,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -68,7 +68,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
| 68 | * Data model node to maintain information defined in YANG module. | 68 | * Data model node to maintain information defined in YANG module. |
| 69 | */ | 69 | */ |
| 70 | public class YangModule extends YangNode | 70 | public class YangModule extends YangNode |
| 71 | - implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector { | 71 | + implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo { |
| 72 | 72 | ||
| 73 | /** | 73 | /** |
| 74 | * Name of the module. | 74 | * Name of the module. |
| ... | @@ -185,16 +185,19 @@ public class YangModule extends YangNode | ... | @@ -185,16 +185,19 @@ public class YangModule extends YangNode |
| 185 | * matching "typedef" or "grouping" statement among the immediate | 185 | * matching "typedef" or "grouping" statement among the immediate |
| 186 | * sub-statements of each ancestor statement. | 186 | * sub-statements of each ancestor statement. |
| 187 | */ | 187 | */ |
| 188 | - /** | 188 | + private List<YangResolutionInfo> unresolvedResolutionList; |
| 189 | - * List of nodes which require nested reference resolution. | ||
| 190 | - */ | ||
| 191 | - private List<YangNode> nestedReferenceResoulutionList; | ||
| 192 | 189 | ||
| 193 | /** | 190 | /** |
| 194 | * Create a YANG node of module type. | 191 | * Create a YANG node of module type. |
| 195 | */ | 192 | */ |
| 196 | public YangModule() { | 193 | public YangModule() { |
| 194 | + | ||
| 197 | super(YangNodeType.MODULE_NODE); | 195 | super(YangNodeType.MODULE_NODE); |
| 196 | + unresolvedResolutionList = new LinkedList<YangResolutionInfo>(); | ||
| 197 | + importList = new LinkedList<YangImport>(); | ||
| 198 | + includeList = new LinkedList<YangInclude>(); | ||
| 199 | + listOfLeaf = new LinkedList<YangLeaf>(); | ||
| 200 | + listOfLeafList = new LinkedList<YangLeafList>(); | ||
| 198 | } | 201 | } |
| 199 | 202 | ||
| 200 | /** | 203 | /** |
| ... | @@ -265,28 +268,17 @@ public class YangModule extends YangNode | ... | @@ -265,28 +268,17 @@ public class YangModule extends YangNode |
| 265 | } | 268 | } |
| 266 | 269 | ||
| 267 | /** | 270 | /** |
| 268 | - * prevent setting the import list from outside. | ||
| 269 | - * | ||
| 270 | - * @param importList the import list to set | ||
| 271 | - */ | ||
| 272 | - private void setImportList(List<YangImport> importList) { | ||
| 273 | - this.importList = importList; | ||
| 274 | - } | ||
| 275 | - | ||
| 276 | - /** | ||
| 277 | * Add the imported module information to the import list. | 271 | * Add the imported module information to the import list. |
| 278 | * | 272 | * |
| 279 | * @param importedModule module being imported | 273 | * @param importedModule module being imported |
| 280 | */ | 274 | */ |
| 281 | - public void addImportedInfo(YangImport importedModule) { | 275 | + public void addToImportList(YangImport importedModule) { |
| 282 | - | ||
| 283 | - if (getImportList() == null) { | ||
| 284 | - setImportList(new LinkedList<YangImport>()); | ||
| 285 | - } | ||
| 286 | - | ||
| 287 | getImportList().add(importedModule); | 276 | getImportList().add(importedModule); |
| 277 | + } | ||
| 288 | 278 | ||
| 289 | - return; | 279 | + @Override |
| 280 | + public void setImportList(List<YangImport> importList) { | ||
| 281 | + this.importList = importList; | ||
| 290 | } | 282 | } |
| 291 | 283 | ||
| 292 | /** | 284 | /** |
| ... | @@ -299,27 +291,17 @@ public class YangModule extends YangNode | ... | @@ -299,27 +291,17 @@ public class YangModule extends YangNode |
| 299 | } | 291 | } |
| 300 | 292 | ||
| 301 | /** | 293 | /** |
| 302 | - * Set the list of included sub modules. | ||
| 303 | - * | ||
| 304 | - * @param includeList the included list to set | ||
| 305 | - */ | ||
| 306 | - private void setIncludeList(List<YangInclude> includeList) { | ||
| 307 | - this.includeList = includeList; | ||
| 308 | - } | ||
| 309 | - | ||
| 310 | - /** | ||
| 311 | * Add the included sub module information to the include list. | 294 | * Add the included sub module information to the include list. |
| 312 | * | 295 | * |
| 313 | * @param includeModule submodule being included | 296 | * @param includeModule submodule being included |
| 314 | */ | 297 | */ |
| 315 | - public void addIncludedInfo(YangInclude includeModule) { | 298 | + public void addToIncludeList(YangInclude includeModule) { |
| 316 | - | ||
| 317 | - if (getIncludeList() == null) { | ||
| 318 | - setIncludeList(new LinkedList<YangInclude>()); | ||
| 319 | - } | ||
| 320 | - | ||
| 321 | getIncludeList().add(includeModule); | 299 | getIncludeList().add(includeModule); |
| 322 | - return; | 300 | + } |
| 301 | + | ||
| 302 | + @Override | ||
| 303 | + public void setIncludeList(List<YangInclude> includeList) { | ||
| 304 | + this.includeList = includeList; | ||
| 323 | } | 305 | } |
| 324 | 306 | ||
| 325 | /** | 307 | /** |
| ... | @@ -333,25 +315,12 @@ public class YangModule extends YangNode | ... | @@ -333,25 +315,12 @@ public class YangModule extends YangNode |
| 333 | } | 315 | } |
| 334 | 316 | ||
| 335 | /** | 317 | /** |
| 336 | - * Set the list of leaf in module. | ||
| 337 | - * | ||
| 338 | - * @param leafsList the list of leaf to set | ||
| 339 | - */ | ||
| 340 | - private void setListOfLeaf(List<YangLeaf> leafsList) { | ||
| 341 | - listOfLeaf = leafsList; | ||
| 342 | - } | ||
| 343 | - | ||
| 344 | - /** | ||
| 345 | * Add a leaf in module. | 318 | * Add a leaf in module. |
| 346 | * | 319 | * |
| 347 | * @param leaf the leaf to be added | 320 | * @param leaf the leaf to be added |
| 348 | */ | 321 | */ |
| 349 | @Override | 322 | @Override |
| 350 | public void addLeaf(YangLeaf leaf) { | 323 | public void addLeaf(YangLeaf leaf) { |
| 351 | - if (getListOfLeaf() == null) { | ||
| 352 | - setListOfLeaf(new LinkedList<YangLeaf>()); | ||
| 353 | - } | ||
| 354 | - | ||
| 355 | getListOfLeaf().add(leaf); | 324 | getListOfLeaf().add(leaf); |
| 356 | } | 325 | } |
| 357 | 326 | ||
| ... | @@ -366,25 +335,12 @@ public class YangModule extends YangNode | ... | @@ -366,25 +335,12 @@ public class YangModule extends YangNode |
| 366 | } | 335 | } |
| 367 | 336 | ||
| 368 | /** | 337 | /** |
| 369 | - * Set the list of leaf-list in module. | ||
| 370 | - * | ||
| 371 | - * @param listOfLeafList the list of leaf-list to set | ||
| 372 | - */ | ||
| 373 | - private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | ||
| 374 | - this.listOfLeafList = listOfLeafList; | ||
| 375 | - } | ||
| 376 | - | ||
| 377 | - /** | ||
| 378 | * Add a leaf-list in module. | 338 | * Add a leaf-list in module. |
| 379 | * | 339 | * |
| 380 | * @param leafList the leaf-list to be added | 340 | * @param leafList the leaf-list to be added |
| 381 | */ | 341 | */ |
| 382 | @Override | 342 | @Override |
| 383 | public void addLeafList(YangLeafList leafList) { | 343 | public void addLeafList(YangLeafList leafList) { |
| 384 | - if (getListOfLeafList() == null) { | ||
| 385 | - setListOfLeafList(new LinkedList<YangLeafList>()); | ||
| 386 | - } | ||
| 387 | - | ||
| 388 | getListOfLeafList().add(leafList); | 344 | getListOfLeafList().add(leafList); |
| 389 | } | 345 | } |
| 390 | 346 | ||
| ... | @@ -442,6 +398,14 @@ public class YangModule extends YangNode | ... | @@ -442,6 +398,14 @@ public class YangModule extends YangNode |
| 442 | this.prefix = prefix; | 398 | this.prefix = prefix; |
| 443 | } | 399 | } |
| 444 | 400 | ||
| 401 | + @Override | ||
| 402 | + public void resolveSelfFileLinking() throws DataModelException { | ||
| 403 | + // Get the list to be resolved. | ||
| 404 | + List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(); | ||
| 405 | + // Resolve linking for a resolution list. | ||
| 406 | + resolveLinkingForResolutionList(resolutionList, this); | ||
| 407 | + } | ||
| 408 | + | ||
| 445 | /** | 409 | /** |
| 446 | * Get the textual reference. | 410 | * Get the textual reference. |
| 447 | * | 411 | * |
| ... | @@ -499,37 +463,6 @@ public class YangModule extends YangNode | ... | @@ -499,37 +463,6 @@ public class YangModule extends YangNode |
| 499 | } | 463 | } |
| 500 | 464 | ||
| 501 | /** | 465 | /** |
| 502 | - * Get the list of nested reference's which required resolution. | ||
| 503 | - * | ||
| 504 | - * @return list of nested reference's which required resolution | ||
| 505 | - */ | ||
| 506 | - public List<YangNode> getNestedReferenceResoulutionList() { | ||
| 507 | - return nestedReferenceResoulutionList; | ||
| 508 | - } | ||
| 509 | - | ||
| 510 | - /** | ||
| 511 | - * Set list of nested reference's which requires resolution. | ||
| 512 | - * | ||
| 513 | - * @param nestedReferenceResoulutionList list of nested reference's which | ||
| 514 | - * requires resolution | ||
| 515 | - */ | ||
| 516 | - private void setNestedReferenceResoulutionList(List<YangNode> nestedReferenceResoulutionList) { | ||
| 517 | - this.nestedReferenceResoulutionList = nestedReferenceResoulutionList; | ||
| 518 | - } | ||
| 519 | - | ||
| 520 | - /** | ||
| 521 | - * Set list of nested reference's which requires resolution. | ||
| 522 | - * | ||
| 523 | - * @param nestedReference nested reference which requires resolution | ||
| 524 | - */ | ||
| 525 | - public void addToNestedReferenceResoulutionList(YangNode nestedReference) { | ||
| 526 | - if (getNestedReferenceResoulutionList() == null) { | ||
| 527 | - setNestedReferenceResoulutionList(new LinkedList<YangNode>()); | ||
| 528 | - } | ||
| 529 | - getNestedReferenceResoulutionList().add(nestedReference); | ||
| 530 | - } | ||
| 531 | - | ||
| 532 | - /** | ||
| 533 | * Returns the type of the parsed data. | 466 | * Returns the type of the parsed data. |
| 534 | * | 467 | * |
| 535 | * @return returns MODULE_DATA | 468 | * @return returns MODULE_DATA |
| ... | @@ -565,31 +498,6 @@ public class YangModule extends YangNode | ... | @@ -565,31 +498,6 @@ public class YangModule extends YangNode |
| 565 | */ | 498 | */ |
| 566 | } | 499 | } |
| 567 | 500 | ||
| 568 | - /** | ||
| 569 | - * Add a type to resolve the nested references. | ||
| 570 | - * | ||
| 571 | - * @param node grouping or typedef node which needs to be resolved | ||
| 572 | - * @throws DataModelException data model exception | ||
| 573 | - */ | ||
| 574 | - public static void addToResolveList(YangNode node) throws DataModelException { | ||
| 575 | - /* get the module node to add maintain the list of nested reference */ | ||
| 576 | - YangModule module; | ||
| 577 | - YangNode curNode = node; | ||
| 578 | - while (curNode.getNodeType() != YangNodeType.MODULE_NODE) { | ||
| 579 | - curNode = curNode.getParent(); | ||
| 580 | - if (curNode == null) { | ||
| 581 | - break; | ||
| 582 | - } | ||
| 583 | - } | ||
| 584 | - if (curNode == null) { | ||
| 585 | - throw new DataModelException("Datamodel tree is not correct"); | ||
| 586 | - } | ||
| 587 | - | ||
| 588 | - module = (YangModule) curNode; | ||
| 589 | - module.addToNestedReferenceResoulutionList(node); | ||
| 590 | - return; | ||
| 591 | - } | ||
| 592 | - | ||
| 593 | @Override | 501 | @Override |
| 594 | public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { | 502 | public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { |
| 595 | // Asks helper to detect colliding child. | 503 | // Asks helper to detect colliding child. |
| ... | @@ -601,4 +509,18 @@ public class YangModule extends YangNode | ... | @@ -601,4 +509,18 @@ public class YangModule extends YangNode |
| 601 | // Not required as module doesn't have any parent. | 509 | // Not required as module doesn't have any parent. |
| 602 | } | 510 | } |
| 603 | 511 | ||
| 512 | + @Override | ||
| 513 | + public List<YangResolutionInfo> getUnresolvedResolutionList() { | ||
| 514 | + return unresolvedResolutionList; | ||
| 515 | + } | ||
| 516 | + | ||
| 517 | + @Override | ||
| 518 | + public void addToResolutionList(YangResolutionInfo resolutionInfo) { | ||
| 519 | + unresolvedResolutionList.add(resolutionInfo); | ||
| 520 | + } | ||
| 521 | + | ||
| 522 | + @Override | ||
| 523 | + public void setResolutionList(List<YangResolutionInfo> resolutionList) { | ||
| 524 | + unresolvedResolutionList = resolutionList; | ||
| 525 | + } | ||
| 604 | } | 526 | } | ... | ... |
| ... | @@ -45,7 +45,7 @@ public class YangNodeIdentifier { | ... | @@ -45,7 +45,7 @@ public class YangNodeIdentifier { |
| 45 | /** | 45 | /** |
| 46 | * Set name of the node identifier. | 46 | * Set name of the node identifier. |
| 47 | * | 47 | * |
| 48 | - * @param name node identifier name | 48 | + * @param name name of the node identifier |
| 49 | */ | 49 | */ |
| 50 | public void setName(String name) { | 50 | public void setName(String name) { |
| 51 | this.name = name; | 51 | this.name = name; |
| ... | @@ -54,7 +54,7 @@ public class YangNodeIdentifier { | ... | @@ -54,7 +54,7 @@ public class YangNodeIdentifier { |
| 54 | /** | 54 | /** |
| 55 | * Returns prefix of the node identifier. | 55 | * Returns prefix of the node identifier. |
| 56 | * | 56 | * |
| 57 | - * @return prefix of the node identifier | 57 | + * @return name of the node identifier |
| 58 | */ | 58 | */ |
| 59 | public String getPrefix() { | 59 | public String getPrefix() { |
| 60 | return prefix; | 60 | return prefix; | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangResolutionInfo.java
0 → 100644
This diff is collapsed. Click to expand it.
| ... | @@ -17,12 +17,12 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,12 +17,12 @@ package org.onosproject.yangutils.datamodel; |
| 17 | 17 | ||
| 18 | import java.util.LinkedList; | 18 | import java.util.LinkedList; |
| 19 | import java.util.List; | 19 | import java.util.List; |
| 20 | - | ||
| 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 20 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.parser.Parsable; | 21 | import org.onosproject.yangutils.parser.Parsable; |
| 23 | import org.onosproject.yangutils.utils.YangConstructType; | 22 | import org.onosproject.yangutils.utils.YangConstructType; |
| 24 | 23 | ||
| 25 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | 24 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
| 25 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList; | ||
| 26 | 26 | ||
| 27 | /* | 27 | /* |
| 28 | * Reference RFC 6020. | 28 | * Reference RFC 6020. |
| ... | @@ -75,7 +75,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol | ... | @@ -75,7 +75,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol |
| 75 | * Data model node to maintain information defined in YANG sub-module. | 75 | * Data model node to maintain information defined in YANG sub-module. |
| 76 | */ | 76 | */ |
| 77 | public class YangSubModule extends YangNode | 77 | public class YangSubModule extends YangNode |
| 78 | - implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector { | 78 | + implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo { |
| 79 | 79 | ||
| 80 | /** | 80 | /** |
| 81 | * Name of sub module. | 81 | * Name of sub module. |
| ... | @@ -124,17 +124,17 @@ public class YangSubModule extends YangNode | ... | @@ -124,17 +124,17 @@ public class YangSubModule extends YangNode |
| 124 | private List<YangLeafList> listOfLeafList; | 124 | private List<YangLeafList> listOfLeafList; |
| 125 | 125 | ||
| 126 | /** | 126 | /** |
| 127 | - * organization owner of the sub-module. | 127 | + * Organization owner of the sub-module. |
| 128 | */ | 128 | */ |
| 129 | private String organization; | 129 | private String organization; |
| 130 | 130 | ||
| 131 | /** | 131 | /** |
| 132 | - * reference of the sub-module. | 132 | + * Reference of the sub-module. |
| 133 | */ | 133 | */ |
| 134 | private String reference; | 134 | private String reference; |
| 135 | 135 | ||
| 136 | /** | 136 | /** |
| 137 | - * revision info of the sub-module. | 137 | + * Revision info of the sub-module. |
| 138 | */ | 138 | */ |
| 139 | private YangRevision revision; | 139 | private YangRevision revision; |
| 140 | 140 | ||
| ... | @@ -144,10 +144,54 @@ public class YangSubModule extends YangNode | ... | @@ -144,10 +144,54 @@ public class YangSubModule extends YangNode |
| 144 | private byte version; | 144 | private byte version; |
| 145 | 145 | ||
| 146 | /** | 146 | /** |
| 147 | + * Prefix of parent module. | ||
| 148 | + */ | ||
| 149 | + private String prefix; | ||
| 150 | + /*- | ||
| 151 | + * Reference RFC 6020. | ||
| 152 | + * | ||
| 153 | + * Nested typedefs and groupings. | ||
| 154 | + * Typedefs and groupings may appear nested under many YANG statements, | ||
| 155 | + * allowing these to be lexically scoped by the hierarchy under which | ||
| 156 | + * they appear. This allows types and groupings to be defined near | ||
| 157 | + * where they are used, rather than placing them at the top level of the | ||
| 158 | + * hierarchy. The close proximity increases readability. | ||
| 159 | + * | ||
| 160 | + * Scoping also allows types to be defined without concern for naming | ||
| 161 | + * conflicts between types in different submodules. Type names can be | ||
| 162 | + * specified without adding leading strings designed to prevent name | ||
| 163 | + * collisions within large modules. | ||
| 164 | + * | ||
| 165 | + * Finally, scoping allows the module author to keep types and groupings | ||
| 166 | + * private to their module or submodule, preventing their reuse. Since | ||
| 167 | + * only top-level types and groupings (i.e., those appearing as | ||
| 168 | + * sub-statements to a module or submodule statement) can be used outside | ||
| 169 | + * the module or submodule, the developer has more control over what | ||
| 170 | + * pieces of their module are presented to the outside world, supporting | ||
| 171 | + * the need to hide internal information and maintaining a boundary | ||
| 172 | + * between what is shared with the outside world and what is kept | ||
| 173 | + * private. | ||
| 174 | + * | ||
| 175 | + * Scoped definitions MUST NOT shadow definitions at a higher scope. A | ||
| 176 | + * type or grouping cannot be defined if a higher level in the schema | ||
| 177 | + * hierarchy has a definition with a matching identifier. | ||
| 178 | + * | ||
| 179 | + * A reference to an unprefixed type or grouping, or one which uses the | ||
| 180 | + * prefix of the current module, is resolved by locating the closest | ||
| 181 | + * matching "typedef" or "grouping" statement among the immediate | ||
| 182 | + * sub-statements of each ancestor statement. | ||
| 183 | + */ | ||
| 184 | + private List<YangResolutionInfo> unresolvedResolutionList; | ||
| 185 | + /** | ||
| 147 | * Create a sub module node. | 186 | * Create a sub module node. |
| 148 | */ | 187 | */ |
| 149 | public YangSubModule() { | 188 | public YangSubModule() { |
| 150 | super(YangNodeType.SUB_MODULE_NODE); | 189 | super(YangNodeType.SUB_MODULE_NODE); |
| 190 | + unresolvedResolutionList = new LinkedList<YangResolutionInfo>(); | ||
| 191 | + importList = new LinkedList<YangImport>(); | ||
| 192 | + includeList = new LinkedList<YangInclude>(); | ||
| 193 | + listOfLeaf = new LinkedList<YangLeaf>(); | ||
| 194 | + listOfLeafList = new LinkedList<YangLeafList>(); | ||
| 151 | } | 195 | } |
| 152 | 196 | ||
| 153 | /** | 197 | /** |
| ... | @@ -236,28 +280,17 @@ public class YangSubModule extends YangNode | ... | @@ -236,28 +280,17 @@ public class YangSubModule extends YangNode |
| 236 | } | 280 | } |
| 237 | 281 | ||
| 238 | /** | 282 | /** |
| 239 | - * prevent setting the import list from outside. | ||
| 240 | - * | ||
| 241 | - * @param importList the import list to set | ||
| 242 | - */ | ||
| 243 | - private void setImportList(List<YangImport> importList) { | ||
| 244 | - this.importList = importList; | ||
| 245 | - } | ||
| 246 | - | ||
| 247 | - /** | ||
| 248 | * Add the imported module information to the import list. | 283 | * Add the imported module information to the import list. |
| 249 | * | 284 | * |
| 250 | * @param importedModule module being imported | 285 | * @param importedModule module being imported |
| 251 | */ | 286 | */ |
| 252 | - public void addImportedInfo(YangImport importedModule) { | 287 | + public void addToImportList(YangImport importedModule) { |
| 253 | - | ||
| 254 | - if (getImportList() == null) { | ||
| 255 | - setImportList(new LinkedList<YangImport>()); | ||
| 256 | - } | ||
| 257 | - | ||
| 258 | getImportList().add(importedModule); | 288 | getImportList().add(importedModule); |
| 289 | + } | ||
| 259 | 290 | ||
| 260 | - return; | 291 | + @Override |
| 292 | + public void setImportList(List<YangImport> importList) { | ||
| 293 | + this.importList = importList; | ||
| 261 | } | 294 | } |
| 262 | 295 | ||
| 263 | /** | 296 | /** |
| ... | @@ -270,27 +303,35 @@ public class YangSubModule extends YangNode | ... | @@ -270,27 +303,35 @@ public class YangSubModule extends YangNode |
| 270 | } | 303 | } |
| 271 | 304 | ||
| 272 | /** | 305 | /** |
| 273 | - * Set the list of included sub modules. | 306 | + * Add the included sub module information to the include list. |
| 274 | * | 307 | * |
| 275 | - * @param includeList the included list to set | 308 | + * @param includeModule submodule being included |
| 276 | */ | 309 | */ |
| 277 | - private void setIncludeList(List<YangInclude> includeList) { | 310 | + public void addToIncludeList(YangInclude includeModule) { |
| 311 | + getIncludeList().add(includeModule); | ||
| 312 | + } | ||
| 313 | + | ||
| 314 | + @Override | ||
| 315 | + public void setIncludeList(List<YangInclude> includeList) { | ||
| 278 | this.includeList = includeList; | 316 | this.includeList = includeList; |
| 279 | } | 317 | } |
| 280 | 318 | ||
| 281 | - /** | 319 | + @Override |
| 282 | - * Add the included sub module information to the include list. | 320 | + public String getPrefix() { |
| 283 | - * | 321 | + return prefix; |
| 284 | - * @param includeModule submodule being included | 322 | + } |
| 285 | - */ | ||
| 286 | - public void addIncludedInfo(YangInclude includeModule) { | ||
| 287 | 323 | ||
| 288 | - if (getIncludeList() == null) { | 324 | + @Override |
| 289 | - setIncludeList(new LinkedList<YangInclude>()); | 325 | + public void setPrefix(String prefix) { |
| 290 | - } | 326 | + this.prefix = prefix; |
| 327 | + } | ||
| 291 | 328 | ||
| 292 | - getIncludeList().add(includeModule); | 329 | + @Override |
| 293 | - return; | 330 | + public void resolveSelfFileLinking() throws DataModelException { |
| 331 | + // Get the list to be resolved. | ||
| 332 | + List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(); | ||
| 333 | + // Resolve linking for a resolution list. | ||
| 334 | + resolveLinkingForResolutionList(resolutionList, this); | ||
| 294 | } | 335 | } |
| 295 | 336 | ||
| 296 | /** | 337 | /** |
| ... | @@ -304,25 +345,12 @@ public class YangSubModule extends YangNode | ... | @@ -304,25 +345,12 @@ public class YangSubModule extends YangNode |
| 304 | } | 345 | } |
| 305 | 346 | ||
| 306 | /** | 347 | /** |
| 307 | - * Set the list of leaves. | ||
| 308 | - * | ||
| 309 | - * @param leafsList the list of leaf to set | ||
| 310 | - */ | ||
| 311 | - private void setListOfLeaf(List<YangLeaf> leafsList) { | ||
| 312 | - listOfLeaf = leafsList; | ||
| 313 | - } | ||
| 314 | - | ||
| 315 | - /** | ||
| 316 | * Add a leaf. | 348 | * Add a leaf. |
| 317 | * | 349 | * |
| 318 | * @param leaf the leaf to be added | 350 | * @param leaf the leaf to be added |
| 319 | */ | 351 | */ |
| 320 | @Override | 352 | @Override |
| 321 | public void addLeaf(YangLeaf leaf) { | 353 | public void addLeaf(YangLeaf leaf) { |
| 322 | - if (getListOfLeaf() == null) { | ||
| 323 | - setListOfLeaf(new LinkedList<YangLeaf>()); | ||
| 324 | - } | ||
| 325 | - | ||
| 326 | getListOfLeaf().add(leaf); | 354 | getListOfLeaf().add(leaf); |
| 327 | } | 355 | } |
| 328 | 356 | ||
| ... | @@ -337,25 +365,12 @@ public class YangSubModule extends YangNode | ... | @@ -337,25 +365,12 @@ public class YangSubModule extends YangNode |
| 337 | } | 365 | } |
| 338 | 366 | ||
| 339 | /** | 367 | /** |
| 340 | - * Set the list of leaf-list. | ||
| 341 | - * | ||
| 342 | - * @param listOfLeafList the list of leaf-list to set | ||
| 343 | - */ | ||
| 344 | - private void setListOfLeafList(List<YangLeafList> listOfLeafList) { | ||
| 345 | - this.listOfLeafList = listOfLeafList; | ||
| 346 | - } | ||
| 347 | - | ||
| 348 | - /** | ||
| 349 | * Add a leaf-list. | 368 | * Add a leaf-list. |
| 350 | * | 369 | * |
| 351 | * @param leafList the leaf-list to be added | 370 | * @param leafList the leaf-list to be added |
| 352 | */ | 371 | */ |
| 353 | @Override | 372 | @Override |
| 354 | public void addLeafList(YangLeafList leafList) { | 373 | public void addLeafList(YangLeafList leafList) { |
| 355 | - if (getListOfLeafList() == null) { | ||
| 356 | - setListOfLeafList(new LinkedList<YangLeafList>()); | ||
| 357 | - } | ||
| 358 | - | ||
| 359 | getListOfLeafList().add(leafList); | 374 | getListOfLeafList().add(leafList); |
| 360 | } | 375 | } |
| 361 | 376 | ||
| ... | @@ -473,4 +488,19 @@ public class YangSubModule extends YangNode | ... | @@ -473,4 +488,19 @@ public class YangSubModule extends YangNode |
| 473 | public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { | 488 | public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { |
| 474 | // Not required as module doesn't have any parent. | 489 | // Not required as module doesn't have any parent. |
| 475 | } | 490 | } |
| 491 | + | ||
| 492 | + @Override | ||
| 493 | + public List<YangResolutionInfo> getUnresolvedResolutionList() { | ||
| 494 | + return unresolvedResolutionList; | ||
| 495 | + } | ||
| 496 | + | ||
| 497 | + @Override | ||
| 498 | + public void addToResolutionList(YangResolutionInfo resolutionInfo) { | ||
| 499 | + this.unresolvedResolutionList.add(resolutionInfo); | ||
| 500 | + } | ||
| 501 | + | ||
| 502 | + @Override | ||
| 503 | + public void setResolutionList(List<YangResolutionInfo> resolutionList) { | ||
| 504 | + this.unresolvedResolutionList = resolutionList; | ||
| 505 | + } | ||
| 476 | } | 506 | } | ... | ... |
| ... | @@ -49,12 +49,12 @@ import org.onosproject.yangutils.utils.YangConstructType; | ... | @@ -49,12 +49,12 @@ import org.onosproject.yangutils.utils.YangConstructType; |
| 49 | * | 49 | * |
| 50 | * @param <T> YANG data type info | 50 | * @param <T> YANG data type info |
| 51 | */ | 51 | */ |
| 52 | -public class YangType<T> implements Parsable { | 52 | +public class YangType<T> implements Parsable, Resolvable { |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | - * YANG data type name. | 55 | + * YANG node identifier. |
| 56 | */ | 56 | */ |
| 57 | - private String dataTypeName; | 57 | + private YangNodeIdentifier nodeIdentifier; |
| 58 | 58 | ||
| 59 | /** | 59 | /** |
| 60 | * Java package in which the Java type is defined. | 60 | * Java package in which the Java type is defined. |
| ... | @@ -74,9 +74,50 @@ public class YangType<T> implements Parsable { | ... | @@ -74,9 +74,50 @@ public class YangType<T> implements Parsable { |
| 74 | private T dataTypeExtendedInfo; | 74 | private T dataTypeExtendedInfo; |
| 75 | 75 | ||
| 76 | /** | 76 | /** |
| 77 | + * Effective built-in type, requried in case type of typedef is again a | ||
| 78 | + * derived type. This information is to be added during linking. | ||
| 79 | + */ | ||
| 80 | + private YangDataTypes effectiveBuiltInType; | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * Effective pattern restriction, requried in case type of typedef is again | ||
| 84 | + * a derived type. This information is to be added during linking. | ||
| 85 | + */ | ||
| 86 | + private YangPatternRestriction effectivePatternRestriction; | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * Status of resolution. If completely resolved enum value is "RESOLVED", | ||
| 90 | + * 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 | ||
| 92 | + * "PARTIALLY_RESOLVED". | ||
| 93 | + */ | ||
| 94 | + private ResolvableStatus resolvableStatus; | ||
| 95 | + | ||
| 96 | + /** | ||
| 77 | * Default constructor. | 97 | * Default constructor. |
| 78 | */ | 98 | */ |
| 79 | public YangType() { | 99 | public YangType() { |
| 100 | + | ||
| 101 | + nodeIdentifier = new YangNodeIdentifier(); | ||
| 102 | + resolvableStatus = ResolvableStatus.UNRESOLVED; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * Returns prefix associated with data type name. | ||
| 107 | + * | ||
| 108 | + * @return prefix associated with data type name | ||
| 109 | + */ | ||
| 110 | + public String getPrefix() { | ||
| 111 | + return nodeIdentifier.getPrefix(); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + /** | ||
| 115 | + * Set prefix associated with data type name. | ||
| 116 | + * | ||
| 117 | + * @param prefix prefix associated with data type name | ||
| 118 | + */ | ||
| 119 | + public void setPrefix(String prefix) { | ||
| 120 | + nodeIdentifier.setPrefix(prefix); | ||
| 80 | } | 121 | } |
| 81 | 122 | ||
| 82 | /** | 123 | /** |
| ... | @@ -85,7 +126,7 @@ public class YangType<T> implements Parsable { | ... | @@ -85,7 +126,7 @@ public class YangType<T> implements Parsable { |
| 85 | * @return the name of data type | 126 | * @return the name of data type |
| 86 | */ | 127 | */ |
| 87 | public String getDataTypeName() { | 128 | public String getDataTypeName() { |
| 88 | - return dataTypeName; | 129 | + return nodeIdentifier.getName(); |
| 89 | } | 130 | } |
| 90 | 131 | ||
| 91 | /** | 132 | /** |
| ... | @@ -94,7 +135,7 @@ public class YangType<T> implements Parsable { | ... | @@ -94,7 +135,7 @@ public class YangType<T> implements Parsable { |
| 94 | * @param typeName the name to set | 135 | * @param typeName the name to set |
| 95 | */ | 136 | */ |
| 96 | public void setDataTypeName(String typeName) { | 137 | public void setDataTypeName(String typeName) { |
| 97 | - dataTypeName = typeName; | 138 | + nodeIdentifier.setName(typeName); |
| 98 | } | 139 | } |
| 99 | 140 | ||
| 100 | /** | 141 | /** |
| ... | @@ -152,6 +193,60 @@ public class YangType<T> implements Parsable { | ... | @@ -152,6 +193,60 @@ public class YangType<T> implements Parsable { |
| 152 | } | 193 | } |
| 153 | 194 | ||
| 154 | /** | 195 | /** |
| 196 | + * Returns node identifier. | ||
| 197 | + * | ||
| 198 | + * @return node identifier | ||
| 199 | + */ | ||
| 200 | + public YangNodeIdentifier getNodeIdentifier() { | ||
| 201 | + return nodeIdentifier; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + /** | ||
| 205 | + * Set node identifier. | ||
| 206 | + * | ||
| 207 | + * @param nodeIdentifier the node identifier | ||
| 208 | + */ | ||
| 209 | + public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) { | ||
| 210 | + this.nodeIdentifier = nodeIdentifier; | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + /** | ||
| 214 | + * Return effective built-in type. | ||
| 215 | + * | ||
| 216 | + * @return effective built-in type | ||
| 217 | + */ | ||
| 218 | + public YangDataTypes getEffectiveBuiltInType() { | ||
| 219 | + return effectiveBuiltInType; | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + /** | ||
| 223 | + * Set effective built-in type. | ||
| 224 | + * | ||
| 225 | + * @param effectiveBuiltInType effective built-in type | ||
| 226 | + */ | ||
| 227 | + public void setEffectiveBuiltInType(YangDataTypes effectiveBuiltInType) { | ||
| 228 | + this.effectiveBuiltInType = effectiveBuiltInType; | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + /** | ||
| 232 | + * Returns effective pattern restriction. | ||
| 233 | + * | ||
| 234 | + * @return effective pattern restriction | ||
| 235 | + */ | ||
| 236 | + public YangPatternRestriction getEffectivePatternRestriction() { | ||
| 237 | + return effectivePatternRestriction; | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + /** | ||
| 241 | + * Set effective pattern restriction. | ||
| 242 | + * | ||
| 243 | + * @param effectivePatternRestriction effective pattern restriction | ||
| 244 | + */ | ||
| 245 | + public void setEffectivePatternRestriction(YangPatternRestriction effectivePatternRestriction) { | ||
| 246 | + this.effectivePatternRestriction = effectivePatternRestriction; | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + /** | ||
| 155 | * Returns the type of the parsed data. | 250 | * Returns the type of the parsed data. |
| 156 | * | 251 | * |
| 157 | * @return returns TYPE_DATA | 252 | * @return returns TYPE_DATA |
| ... | @@ -182,4 +277,19 @@ public class YangType<T> implements Parsable { | ... | @@ -182,4 +277,19 @@ public class YangType<T> implements Parsable { |
| 182 | // TODO auto-generated method stub, to be implemented by parser | 277 | // TODO auto-generated method stub, to be implemented by parser |
| 183 | 278 | ||
| 184 | } | 279 | } |
| 280 | + | ||
| 281 | + @Override | ||
| 282 | + public ResolvableStatus getResolvableStatus() { | ||
| 283 | + return resolvableStatus; | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + @Override | ||
| 287 | + public void setResolvableStatus(ResolvableStatus resolvableStatus) { | ||
| 288 | + this.resolvableStatus = resolvableStatus; | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + @Override | ||
| 292 | + public void resolve() { | ||
| 293 | + //TODO: implement the method. | ||
| 294 | + } | ||
| 185 | } | 295 | } | ... | ... |
| ... | @@ -75,9 +75,14 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -75,9 +75,14 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 75 | private YangStatusType status; | 75 | private YangStatusType status; |
| 76 | 76 | ||
| 77 | /** | 77 | /** |
| 78 | - * Maintain the derived type information. | 78 | + * Name of the typedef. |
| 79 | */ | 79 | */ |
| 80 | - private YangType<YangDerivedType> derivedType; | 80 | + private String name; |
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * Maintain the data type information. | ||
| 84 | + */ | ||
| 85 | + private YangType<?> dataType; | ||
| 81 | 86 | ||
| 82 | /** | 87 | /** |
| 83 | * Units of the data type. | 88 | * Units of the data type. |
| ... | @@ -92,7 +97,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -92,7 +97,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 92 | } | 97 | } |
| 93 | 98 | ||
| 94 | /** | 99 | /** |
| 95 | - * Get the default value. | 100 | + * Returns the default value. |
| 96 | * | 101 | * |
| 97 | * @return the default value | 102 | * @return the default value |
| 98 | */ | 103 | */ |
| ... | @@ -110,7 +115,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -110,7 +115,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 110 | } | 115 | } |
| 111 | 116 | ||
| 112 | /** | 117 | /** |
| 113 | - * Get the description. | 118 | + * Returns the description. |
| 114 | * | 119 | * |
| 115 | * @return the description | 120 | * @return the description |
| 116 | */ | 121 | */ |
| ... | @@ -130,7 +135,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -130,7 +135,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 130 | } | 135 | } |
| 131 | 136 | ||
| 132 | /** | 137 | /** |
| 133 | - * Get the textual reference. | 138 | + * Returns the textual reference. |
| 134 | * | 139 | * |
| 135 | * @return the reference | 140 | * @return the reference |
| 136 | */ | 141 | */ |
| ... | @@ -150,7 +155,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -150,7 +155,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 150 | } | 155 | } |
| 151 | 156 | ||
| 152 | /** | 157 | /** |
| 153 | - * Get the status. | 158 | + * Returns the status. |
| 154 | * | 159 | * |
| 155 | * @return the status | 160 | * @return the status |
| 156 | */ | 161 | */ |
| ... | @@ -170,25 +175,25 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -170,25 +175,25 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 170 | } | 175 | } |
| 171 | 176 | ||
| 172 | /** | 177 | /** |
| 173 | - * Get the derived type. | 178 | + * Returns the data type. |
| 174 | * | 179 | * |
| 175 | - * @return the derived type | 180 | + * @return the data type |
| 176 | */ | 181 | */ |
| 177 | - public YangType<YangDerivedType> getDerivedType() { | 182 | + public YangType<?> getDataType() { |
| 178 | - return derivedType; | 183 | + return dataType; |
| 179 | } | 184 | } |
| 180 | 185 | ||
| 181 | /** | 186 | /** |
| 182 | - * Set the derived type. | 187 | + * Set the data type. |
| 183 | * | 188 | * |
| 184 | - * @param derivedType the derived type | 189 | + * @param dataType the data type |
| 185 | */ | 190 | */ |
| 186 | - public void setDerivedType(YangType<YangDerivedType> derivedType) { | 191 | + public void setDataType(YangType<?> dataType) { |
| 187 | - this.derivedType = derivedType; | 192 | + this.dataType = dataType; |
| 188 | } | 193 | } |
| 189 | 194 | ||
| 190 | /** | 195 | /** |
| 191 | - * Get the unit. | 196 | + * Returns the unit. |
| 192 | * | 197 | * |
| 193 | * @return the units | 198 | * @return the units |
| 194 | */ | 199 | */ |
| ... | @@ -232,47 +237,17 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -232,47 +237,17 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 232 | */ | 237 | */ |
| 233 | @Override | 238 | @Override |
| 234 | public void validateDataOnExit() throws DataModelException { | 239 | public void validateDataOnExit() throws DataModelException { |
| 235 | - YangType<YangDerivedType> type = getDerivedType(); | 240 | + // TODO auto-generated method stub, to be implemented by parser |
| 236 | - if (type == null) { | ||
| 237 | - throw new DataModelException("Typedef does not have type info."); | ||
| 238 | - } | ||
| 239 | - if (type.getDataType() != YangDataTypes.DERIVED | ||
| 240 | - || type.getDataTypeName() == null) { | ||
| 241 | - throw new DataModelException("Typedef type is not derived."); | ||
| 242 | - } | ||
| 243 | - | ||
| 244 | - YangDerivedType derivedTypeInfo = type.getDataTypeExtendedInfo(); | ||
| 245 | - if (derivedTypeInfo == null) { | ||
| 246 | - throw new DataModelException("derrived type does not have derived info."); | ||
| 247 | - } | ||
| 248 | - | ||
| 249 | - YangType<?> baseType = derivedTypeInfo.getBaseType(); | ||
| 250 | - if (baseType == null) { | ||
| 251 | - throw new DataModelException("Base type of a derived type is missing."); | ||
| 252 | - } | ||
| 253 | - | ||
| 254 | - if (derivedTypeInfo.getEffectiveYangBuiltInType() == null) { | ||
| 255 | - /* resolve the effective type from the data tree. */ | ||
| 256 | - /* | ||
| 257 | - * TODO: try to resolve the nested reference, if possible in the | ||
| 258 | - * partial tree, otherwise we need to resolve finally when the | ||
| 259 | - * complete module is created. | ||
| 260 | - */ | ||
| 261 | - YangModule.addToResolveList(this); | ||
| 262 | - } | ||
| 263 | } | 241 | } |
| 264 | 242 | ||
| 265 | /** | 243 | /** |
| 266 | - * Get the YANG name of the typedef. | 244 | + * Returns the YANG name of the typedef. |
| 267 | * | 245 | * |
| 268 | * @return YANG name of the typedef | 246 | * @return YANG name of the typedef |
| 269 | */ | 247 | */ |
| 270 | @Override | 248 | @Override |
| 271 | public String getName() { | 249 | public String getName() { |
| 272 | - if (getDerivedType() != null) { | 250 | + return name; |
| 273 | - return getDerivedType().getDataTypeName(); | ||
| 274 | - } | ||
| 275 | - return null; | ||
| 276 | } | 251 | } |
| 277 | 252 | ||
| 278 | /** | 253 | /** |
| ... | @@ -282,12 +257,6 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -282,12 +257,6 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 282 | */ | 257 | */ |
| 283 | @Override | 258 | @Override |
| 284 | public void setName(String name) { | 259 | public void setName(String name) { |
| 285 | - if (getDerivedType() == null) { | 260 | + this.name = name; |
| 286 | - throw new RuntimeException( | ||
| 287 | - "Derrived Type info needs to be set in parser when the typedef listner is processed"); | ||
| 288 | - } | ||
| 289 | - getDerivedType().setDataTypeName(name); | ||
| 290 | - getDerivedType().setDataType(YangDataTypes.DERIVED); | ||
| 291 | } | 261 | } |
| 292 | - | ||
| 293 | } | 262 | } | ... | ... |
| ... | @@ -52,12 +52,12 @@ import org.onosproject.yangutils.utils.YangConstructType; | ... | @@ -52,12 +52,12 @@ import org.onosproject.yangutils.utils.YangConstructType; |
| 52 | * Data model node to maintain information defined in YANG uses. | 52 | * Data model node to maintain information defined in YANG uses. |
| 53 | * | 53 | * |
| 54 | */ | 54 | */ |
| 55 | -public class YangUses extends YangNode implements YangCommonInfo, Parsable { | 55 | +public class YangUses extends YangNode implements YangCommonInfo, Parsable, Resolvable { |
| 56 | 56 | ||
| 57 | /** | 57 | /** |
| 58 | - * Name of YANG uses. | 58 | + * YANG node identifier. |
| 59 | */ | 59 | */ |
| 60 | - private String name; | 60 | + private YangNodeIdentifier nodeIdentifier; |
| 61 | 61 | ||
| 62 | /** | 62 | /** |
| 63 | * Referred group. | 63 | * Referred group. |
| ... | @@ -80,28 +80,20 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -80,28 +80,20 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 80 | private YangStatusType status; | 80 | private YangStatusType status; |
| 81 | 81 | ||
| 82 | /** | 82 | /** |
| 83 | - * Create an YANG uses node. | 83 | + * Status of resolution. If completely resolved enum value is "RESOLVED", |
| 84 | + * if not enum value is "UNRESOLVED", in case reference of grouping/typedef | ||
| 85 | + * is added to uses/type but it's not resolved value of enum should be | ||
| 86 | + * "PARTIALLY_RESOLVED". | ||
| 84 | */ | 87 | */ |
| 85 | - public YangUses() { | 88 | + private ResolvableStatus resolvableStatus; |
| 86 | - super(YangNodeType.USES_NODE); | ||
| 87 | - } | ||
| 88 | 89 | ||
| 89 | /** | 90 | /** |
| 90 | - * Returns the name. | 91 | + * Create an YANG uses node. |
| 91 | - * | ||
| 92 | - * @return the name | ||
| 93 | - */ | ||
| 94 | - public String getRefGroupingName() { | ||
| 95 | - return name; | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - /** | ||
| 99 | - * Set the name. | ||
| 100 | - * | ||
| 101 | - * @param refGroupingName the referred grouping name to set | ||
| 102 | */ | 92 | */ |
| 103 | - public void setRefGroupingName(String refGroupingName) { | 93 | + public YangUses() { |
| 104 | - name = refGroupingName; | 94 | + super(YangNodeType.USES_NODE); |
| 95 | + nodeIdentifier = new YangNodeIdentifier(); | ||
| 96 | + resolvableStatus = ResolvableStatus.UNRESOLVED; | ||
| 105 | } | 97 | } |
| 106 | 98 | ||
| 107 | /** | 99 | /** |
| ... | @@ -214,12 +206,62 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -214,12 +206,62 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 214 | 206 | ||
| 215 | @Override | 207 | @Override |
| 216 | public String getName() { | 208 | public String getName() { |
| 217 | - return name; | 209 | + return nodeIdentifier.getName(); |
| 218 | } | 210 | } |
| 219 | 211 | ||
| 220 | @Override | 212 | @Override |
| 221 | public void setName(String name) { | 213 | public void setName(String name) { |
| 222 | - this.name = name; | 214 | + nodeIdentifier.setName(name); |
| 215 | + } | ||
| 216 | + | ||
| 217 | + /** | ||
| 218 | + * Returns node identifier. | ||
| 219 | + * | ||
| 220 | + * @return node identifier | ||
| 221 | + */ | ||
| 222 | + public YangNodeIdentifier getNodeIdentifier() { | ||
| 223 | + return nodeIdentifier; | ||
| 223 | } | 224 | } |
| 224 | 225 | ||
| 226 | + /** | ||
| 227 | + * Set node identifier. | ||
| 228 | + * | ||
| 229 | + * @param nodeIdentifier the node identifier | ||
| 230 | + */ | ||
| 231 | + public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) { | ||
| 232 | + this.nodeIdentifier = nodeIdentifier; | ||
| 233 | + } | ||
| 234 | + | ||
| 235 | + /** | ||
| 236 | + * Returns prefix associated with uses. | ||
| 237 | + * | ||
| 238 | + * @return prefix associated with uses | ||
| 239 | + */ | ||
| 240 | + public String getPrefix() { | ||
| 241 | + return nodeIdentifier.getPrefix(); | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + /** | ||
| 245 | + * Get prefix associated with uses. | ||
| 246 | + * | ||
| 247 | + * @param prefix prefix associated with uses | ||
| 248 | + */ | ||
| 249 | + public void setPrefix(String prefix) { | ||
| 250 | + nodeIdentifier.setPrefix(prefix); | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + @Override | ||
| 254 | + public void resolve() { | ||
| 255 | + //TODO: implement the method. | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + @Override | ||
| 259 | + public ResolvableStatus getResolvableStatus() { | ||
| 260 | + return resolvableStatus; | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + @Override | ||
| 264 | + public void setResolvableStatus(ResolvableStatus resolvableStatus) { | ||
| 265 | + this.resolvableStatus = resolvableStatus; | ||
| 266 | + } | ||
| 225 | } | 267 | } | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/exceptions/DataModelException.java
| ... | @@ -21,6 +21,8 @@ package org.onosproject.yangutils.datamodel.exceptions; | ... | @@ -21,6 +21,8 @@ package org.onosproject.yangutils.datamodel.exceptions; |
| 21 | public class DataModelException extends Exception { | 21 | public class DataModelException extends Exception { |
| 22 | 22 | ||
| 23 | private static final long serialVersionUID = 201601270658L; | 23 | private static final long serialVersionUID = 201601270658L; |
| 24 | + private int lineNumber; | ||
| 25 | + private int charPositionInLine; | ||
| 24 | 26 | ||
| 25 | /** | 27 | /** |
| 26 | * Constructor to create a data model exception with message. | 28 | * Constructor to create a data model exception with message. |
| ... | @@ -49,4 +51,40 @@ public class DataModelException extends Exception { | ... | @@ -49,4 +51,40 @@ public class DataModelException extends Exception { |
| 49 | public DataModelException(final Throwable cause) { | 51 | public DataModelException(final Throwable cause) { |
| 50 | super(cause); | 52 | super(cause); |
| 51 | } | 53 | } |
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Returns line number of the exception. | ||
| 57 | + * | ||
| 58 | + * @return line number of the exception | ||
| 59 | + */ | ||
| 60 | + public int getLineNumber() { | ||
| 61 | + return this.lineNumber; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * Returns position of the exception. | ||
| 66 | + * | ||
| 67 | + * @return position of the exception | ||
| 68 | + */ | ||
| 69 | + public int getCharPositionInLine() { | ||
| 70 | + return this.charPositionInLine; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * Sets line number of YANG file. | ||
| 75 | + * | ||
| 76 | + * @param line line number of YANG file | ||
| 77 | + */ | ||
| 78 | + public void setLine(int line) { | ||
| 79 | + this.lineNumber = line; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * Sets position of exception. | ||
| 84 | + * | ||
| 85 | + * @param charPosition position of exception | ||
| 86 | + */ | ||
| 87 | + public void setCharPosition(int charPosition) { | ||
| 88 | + this.charPositionInLine = charPosition; | ||
| 89 | + } | ||
| 52 | } | 90 | } | ... | ... |
| ... | @@ -16,11 +16,14 @@ | ... | @@ -16,11 +16,14 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.yangutils.datamodel.utils; | 17 | package org.onosproject.yangutils.datamodel.utils; |
| 18 | 18 | ||
| 19 | +import java.util.List; | ||
| 19 | import org.onosproject.yangutils.datamodel.CollisionDetector; | 20 | import org.onosproject.yangutils.datamodel.CollisionDetector; |
| 21 | +import org.onosproject.yangutils.datamodel.HasResolutionInfo; | ||
| 20 | import org.onosproject.yangutils.datamodel.YangLeaf; | 22 | import org.onosproject.yangutils.datamodel.YangLeaf; |
| 21 | import org.onosproject.yangutils.datamodel.YangLeafList; | 23 | import org.onosproject.yangutils.datamodel.YangLeafList; |
| 22 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; | 24 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
| 23 | import org.onosproject.yangutils.datamodel.YangNode; | 25 | import org.onosproject.yangutils.datamodel.YangNode; |
| 26 | +import org.onosproject.yangutils.datamodel.YangResolutionInfo; | ||
| 24 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 27 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 25 | import org.onosproject.yangutils.utils.YangConstructType; | 28 | import org.onosproject.yangutils.utils.YangConstructType; |
| 26 | 29 | ||
| ... | @@ -39,27 +42,23 @@ public final class DataModelUtils { | ... | @@ -39,27 +42,23 @@ public final class DataModelUtils { |
| 39 | * Detects the colliding identifier name in a given YANG node and its child. | 42 | * Detects the colliding identifier name in a given YANG node and its child. |
| 40 | * | 43 | * |
| 41 | * @param identifierName name for which collision detection is to be | 44 | * @param identifierName name for which collision detection is to be |
| 42 | - * checked. | 45 | + * checked |
| 43 | - * @param dataType type of YANG node asking for detecting collision. | 46 | + * @param dataType type of YANG node asking for detecting collision |
| 44 | - * @param node instance of calling node. | 47 | + * @param node instance of calling node |
| 45 | - * @throws DataModelException a violation of data model rules. | 48 | + * @throws DataModelException a violation of data model rules |
| 46 | */ | 49 | */ |
| 47 | public static void detectCollidingChildUtil(String identifierName, YangConstructType dataType, YangNode node) | 50 | public static void detectCollidingChildUtil(String identifierName, YangConstructType dataType, YangNode node) |
| 48 | throws DataModelException { | 51 | throws DataModelException { |
| 49 | - if (((YangLeavesHolder) node).getListOfLeaf() != null) { | 52 | + if (dataType == YangConstructType.LEAF_DATA) { |
| 50 | - for (YangLeaf leaf : ((YangLeavesHolder) node).getListOfLeaf()) { | 53 | + YangLeavesHolder leavesHolder = (YangLeavesHolder) node; |
| 51 | - if (leaf.getLeafName().equals(identifierName)) { | 54 | + if (leavesHolder.getListOfLeaf() != null) { |
| 52 | - throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \"" | 55 | + detectCollidingLeaf(leavesHolder, identifierName); |
| 53 | - + leaf.getLeafName() + "\""); | ||
| 54 | - } | ||
| 55 | } | 56 | } |
| 56 | } | 57 | } |
| 57 | - if (((YangLeavesHolder) node).getListOfLeafList() != null) { | 58 | + if (dataType == YangConstructType.LEAF_LIST_DATA) { |
| 58 | - for (YangLeafList leafList : ((YangLeavesHolder) node).getListOfLeafList()) { | 59 | + if (((YangLeavesHolder) node).getListOfLeafList() != null) { |
| 59 | - if (leafList.getLeafName().equals(identifierName)) { | 60 | + YangLeavesHolder leavesHolder = (YangLeavesHolder) node; |
| 60 | - throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " + | 61 | + detectCollidingLeafList(leavesHolder, identifierName); |
| 61 | - "list \"" + leafList.getLeafName() + "\""); | ||
| 62 | - } | ||
| 63 | } | 62 | } |
| 64 | } | 63 | } |
| 65 | node = node.getChild(); | 64 | node = node.getChild(); |
| ... | @@ -70,4 +69,78 @@ public final class DataModelUtils { | ... | @@ -70,4 +69,78 @@ public final class DataModelUtils { |
| 70 | node = node.getNextSibling(); | 69 | node = node.getNextSibling(); |
| 71 | } | 70 | } |
| 72 | } | 71 | } |
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * Detects the colliding identifier name in a given leaf node. | ||
| 75 | + * | ||
| 76 | + * @param leavesHolder leaves node against which collision to be checked | ||
| 77 | + * @param identifierName name for which collision detection is to be | ||
| 78 | + * checked | ||
| 79 | + * @throws DataModelException a violation of data model rules | ||
| 80 | + */ | ||
| 81 | + private static void detectCollidingLeaf(YangLeavesHolder leavesHolder, String identifierName) throws | ||
| 82 | + DataModelException { | ||
| 83 | + for (YangLeaf leaf : leavesHolder.getListOfLeaf()) { | ||
| 84 | + if (leaf.getLeafName().equals(identifierName)) { | ||
| 85 | + throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \"" | ||
| 86 | + + leaf.getLeafName() + "\""); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * Detects the colliding identifier name in a given leaf-list node. | ||
| 93 | + * | ||
| 94 | + * @param leavesHolder leaves node against which collision to be checked | ||
| 95 | + * @param identifierName name for which collision detection is to be | ||
| 96 | + * checked | ||
| 97 | + * @throws DataModelException a violation of data model rules | ||
| 98 | + */ | ||
| 99 | + private static void detectCollidingLeafList(YangLeavesHolder leavesHolder, String identifierName) throws | ||
| 100 | + DataModelException { | ||
| 101 | + for (YangLeafList leafList : leavesHolder.getListOfLeafList()) { | ||
| 102 | + if (leafList.getLeafName().equals(identifierName)) { | ||
| 103 | + throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " + | ||
| 104 | + "list \"" + leafList.getLeafName() + "\""); | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + /** | ||
| 110 | + * Add a resolution information. | ||
| 111 | + * | ||
| 112 | + * @param resolutionInfo information about the YANG construct which has to | ||
| 113 | + * be resolved | ||
| 114 | + * @throws DataModelException a violation of data model rules | ||
| 115 | + */ | ||
| 116 | + public static void addResolutionInfo(YangResolutionInfo resolutionInfo) throws DataModelException { | ||
| 117 | + /* get the module node to add maintain the list of nested reference */ | ||
| 118 | + YangNode curNode = resolutionInfo.getHolderOfEntityToResolve(); | ||
| 119 | + while (!(curNode instanceof HasResolutionInfo)) { | ||
| 120 | + curNode = curNode.getParent(); | ||
| 121 | + if (curNode == null) { | ||
| 122 | + throw new DataModelException("Internal datamodel error: Datamodel tree is not correct"); | ||
| 123 | + } | ||
| 124 | + } | ||
| 125 | + HasResolutionInfo resolutionNode = (HasResolutionInfo) curNode; | ||
| 126 | + resolutionNode.addToResolutionList(resolutionInfo); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * Resolve linking for a resolution list. | ||
| 131 | + * | ||
| 132 | + * @param resolutionList resolution list for which linking to be done | ||
| 133 | + * @param resolutionInfoNode module/sub-module node | ||
| 134 | + * @throws DataModelException a violation of data model rules | ||
| 135 | + */ | ||
| 136 | + public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList, | ||
| 137 | + HasResolutionInfo resolutionInfoNode) | ||
| 138 | + throws DataModelException { | ||
| 139 | + for (YangResolutionInfo resolutionInfo : resolutionList) { | ||
| 140 | + if (resolutionInfo.getPrefix() == null || | ||
| 141 | + resolutionInfo.getPrefix().equals(resolutionInfoNode.getPrefix())) { | ||
| 142 | + resolutionInfo.resolveLinkingForResolutionInfo(resolutionInfoNode.getPrefix()); | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + } | ||
| 73 | } | 146 | } | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
| 5 | + * use this file except in compliance with the License. You may obtain a copy of | ||
| 6 | + * 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, WITHOUT | ||
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| 13 | + * License for the specific language governing permissions and limitations under | ||
| 14 | + * the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | +package org.onosproject.yangutils.linker; | ||
| 18 | + | ||
| 19 | +import java.util.Map; | ||
| 20 | +import org.onosproject.yangutils.datamodel.HasResolutionInfo; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Abstraction of entity which provides linking service of YANG files. | ||
| 24 | + */ | ||
| 25 | +public interface YangLinker { | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * Resolve the import and include dependencies for a given resolution | ||
| 29 | + * information. | ||
| 30 | + * | ||
| 31 | + * @param fileMapEntry map entry for which resolution is to be done | ||
| 32 | + * @param yangFilesMap map of dependent file and resolution information*/ | ||
| 33 | + void resolveDependencies(Map.Entry<String, HasResolutionInfo> fileMapEntry, Map<String, | ||
| 34 | + HasResolutionInfo> yangFilesMap); | ||
| 35 | +} |
| 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 | + | ||
| 17 | +/** | ||
| 18 | + * Provide inter file and inter jar linking implementation. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.yangutils.linker.impl; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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 | + | ||
| 17 | +/** | ||
| 18 | + * Provide inter jar and inter file linking abstract interface. | ||
| 19 | + */ | ||
| 20 | +package org.onosproject.yangutils.linker; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
| ... | @@ -23,13 +23,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -23,13 +23,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
| 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 23 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
| 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 24 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
| 25 | 25 | ||
| 26 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; | ||
| 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 26 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
| 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
| 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
| 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
| 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
| 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
| 32 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; | ||
| 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
| 34 | import static org.onosproject.yangutils.utils.YangConstructType.BELONGS_TO_DATA; | 34 | import static org.onosproject.yangutils.utils.YangConstructType.BELONGS_TO_DATA; |
| 35 | 35 | ||
| ... | @@ -119,6 +119,7 @@ public final class BelongsToListener { | ... | @@ -119,6 +119,7 @@ public final class BelongsToListener { |
| 119 | case SUB_MODULE_DATA: { | 119 | case SUB_MODULE_DATA: { |
| 120 | YangSubModule subModule = (YangSubModule) tmpNode; | 120 | YangSubModule subModule = (YangSubModule) tmpNode; |
| 121 | subModule.setBelongsTo((YangBelongsTo) tmpBelongstoNode); | 121 | subModule.setBelongsTo((YangBelongsTo) tmpBelongstoNode); |
| 122 | + subModule.setPrefix(subModule.getBelongsTo().getPrefix()); | ||
| 122 | break; | 123 | break; |
| 123 | } | 124 | } |
| 124 | default: | 125 | default: | ... | ... |
| ... | @@ -113,12 +113,12 @@ public final class ImportListener { | ... | @@ -113,12 +113,12 @@ public final class ImportListener { |
| 113 | switch (tmpNode.getYangConstructType()) { | 113 | switch (tmpNode.getYangConstructType()) { |
| 114 | case MODULE_DATA: { | 114 | case MODULE_DATA: { |
| 115 | YangModule module = (YangModule) tmpNode; | 115 | YangModule module = (YangModule) tmpNode; |
| 116 | - module.addImportedInfo((YangImport) tmpImportNode); | 116 | + module.addToImportList((YangImport) tmpImportNode); |
| 117 | break; | 117 | break; |
| 118 | } | 118 | } |
| 119 | case SUB_MODULE_DATA: { | 119 | case SUB_MODULE_DATA: { |
| 120 | YangSubModule subModule = (YangSubModule) tmpNode; | 120 | YangSubModule subModule = (YangSubModule) tmpNode; |
| 121 | - subModule.addImportedInfo((YangImport) tmpImportNode); | 121 | + subModule.addToImportList((YangImport) tmpImportNode); |
| 122 | break; | 122 | break; |
| 123 | } | 123 | } |
| 124 | default: | 124 | default: | ... | ... |
| ... | @@ -24,13 +24,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ... | @@ -24,13 +24,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
| 24 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 24 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
| 25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
| 26 | 26 | ||
| 27 | -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; | ||
| 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | 27 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; |
| 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | 28 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; |
| 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | 29 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; |
| 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | 30 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; |
| 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | 31 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; |
| 33 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | 32 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; |
| 33 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; | ||
| 34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | 34 | import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; |
| 35 | import static org.onosproject.yangutils.utils.YangConstructType.INCLUDE_DATA; | 35 | import static org.onosproject.yangutils.utils.YangConstructType.INCLUDE_DATA; |
| 36 | 36 | ||
| ... | @@ -112,12 +112,12 @@ public final class IncludeListener { | ... | @@ -112,12 +112,12 @@ public final class IncludeListener { |
| 112 | switch (tmpNode.getYangConstructType()) { | 112 | switch (tmpNode.getYangConstructType()) { |
| 113 | case MODULE_DATA: { | 113 | case MODULE_DATA: { |
| 114 | YangModule module = (YangModule) tmpNode; | 114 | YangModule module = (YangModule) tmpNode; |
| 115 | - module.addIncludedInfo((YangInclude) tmpIncludeNode); | 115 | + module.addToIncludeList((YangInclude) tmpIncludeNode); |
| 116 | break; | 116 | break; |
| 117 | } | 117 | } |
| 118 | case SUB_MODULE_DATA: { | 118 | case SUB_MODULE_DATA: { |
| 119 | YangSubModule subModule = (YangSubModule) tmpNode; | 119 | YangSubModule subModule = (YangSubModule) tmpNode; |
| 120 | - subModule.addIncludedInfo((YangInclude) tmpIncludeNode); | 120 | + subModule.addToIncludeList((YangInclude) tmpIncludeNode); |
| 121 | break; | 121 | break; |
| 122 | } | 122 | } |
| 123 | default: | 123 | default: | ... | ... |
| ... | @@ -16,8 +16,10 @@ | ... | @@ -16,8 +16,10 @@ |
| 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.HasResolutionInfo; | ||
| 19 | import org.onosproject.yangutils.datamodel.YangModule; | 20 | import org.onosproject.yangutils.datamodel.YangModule; |
| 20 | import org.onosproject.yangutils.datamodel.YangRevision; | 21 | import org.onosproject.yangutils.datamodel.YangRevision; |
| 22 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
| 21 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 23 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
| 22 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 24 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
| 23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
| ... | @@ -113,5 +115,13 @@ public final class ModuleListener { | ... | @@ -113,5 +115,13 @@ public final class ModuleListener { |
| 113 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, MODULE_DATA, | 115 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, MODULE_DATA, |
| 114 | ctx.identifier().getText(), EXIT)); | 116 | ctx.identifier().getText(), EXIT)); |
| 115 | } | 117 | } |
| 118 | + try { | ||
| 119 | + ((HasResolutionInfo) listener.getParsedDataStack().peek()).resolveSelfFileLinking(); | ||
| 120 | + } catch (DataModelException e) { | ||
| 121 | + ParserException parserException = new ParserException(e.getMessage()); | ||
| 122 | + parserException.setLine(e.getLineNumber()); | ||
| 123 | + parserException.setCharPosition(e.getCharPositionInLine()); | ||
| 124 | + throw parserException; | ||
| 125 | + } | ||
| 116 | } | 126 | } |
| 117 | } | 127 | } | ... | ... |
utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
| ... | @@ -16,8 +16,10 @@ | ... | @@ -16,8 +16,10 @@ |
| 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.HasResolutionInfo; | ||
| 19 | import org.onosproject.yangutils.datamodel.YangRevision; | 20 | import org.onosproject.yangutils.datamodel.YangRevision; |
| 20 | import org.onosproject.yangutils.datamodel.YangSubModule; | 21 | import org.onosproject.yangutils.datamodel.YangSubModule; |
| 22 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
| 21 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 23 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
| 22 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 24 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
| 23 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; | 25 | import org.onosproject.yangutils.parser.impl.TreeWalkListener; |
| ... | @@ -118,5 +120,13 @@ public final class SubModuleListener { | ... | @@ -118,5 +120,13 @@ public final class SubModuleListener { |
| 118 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, SUB_MODULE_DATA, | 120 | throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, SUB_MODULE_DATA, |
| 119 | ctx.identifier().getText(), EXIT)); | 121 | ctx.identifier().getText(), EXIT)); |
| 120 | } | 122 | } |
| 123 | + try { | ||
| 124 | + ((HasResolutionInfo) listener.getParsedDataStack().peek()).resolveSelfFileLinking(); | ||
| 125 | + } catch (DataModelException e) { | ||
| 126 | + ParserException parserException = new ParserException(e.getMessage()); | ||
| 127 | + parserException.setLine(e.getLineNumber()); | ||
| 128 | + parserException.setCharPosition(e.getCharPositionInLine()); | ||
| 129 | + throw parserException; | ||
| 130 | + } | ||
| 121 | } | 131 | } |
| 122 | } | 132 | } | ... | ... |
| ... | @@ -17,18 +17,15 @@ | ... | @@ -17,18 +17,15 @@ |
| 17 | package org.onosproject.yangutils.parser.impl.listeners; | 17 | package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | import org.onosproject.yangutils.datamodel.YangContainer; | 19 | import org.onosproject.yangutils.datamodel.YangContainer; |
| 20 | -import org.onosproject.yangutils.datamodel.YangDataTypes; | 20 | +import org.onosproject.yangutils.datamodel.YangInput; |
| 21 | -import org.onosproject.yangutils.datamodel.YangDerivedType; | ||
| 22 | import org.onosproject.yangutils.datamodel.YangList; | 21 | import org.onosproject.yangutils.datamodel.YangList; |
| 23 | import org.onosproject.yangutils.datamodel.YangModule; | 22 | import org.onosproject.yangutils.datamodel.YangModule; |
| 24 | import org.onosproject.yangutils.datamodel.YangNode; | 23 | import org.onosproject.yangutils.datamodel.YangNode; |
| 25 | -import org.onosproject.yangutils.datamodel.YangSubModule; | ||
| 26 | -import org.onosproject.yangutils.datamodel.YangType; | ||
| 27 | -import org.onosproject.yangutils.datamodel.YangTypeDef; | ||
| 28 | -import org.onosproject.yangutils.datamodel.YangInput; | ||
| 29 | -import org.onosproject.yangutils.datamodel.YangOutput; | ||
| 30 | import org.onosproject.yangutils.datamodel.YangNotification; | 24 | import org.onosproject.yangutils.datamodel.YangNotification; |
| 25 | +import org.onosproject.yangutils.datamodel.YangOutput; | ||
| 31 | import org.onosproject.yangutils.datamodel.YangRpc; | 26 | import org.onosproject.yangutils.datamodel.YangRpc; |
| 27 | +import org.onosproject.yangutils.datamodel.YangSubModule; | ||
| 28 | +import org.onosproject.yangutils.datamodel.YangTypeDef; | ||
| 32 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 29 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 33 | import org.onosproject.yangutils.parser.Parsable; | 30 | import org.onosproject.yangutils.parser.Parsable; |
| 34 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 31 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
| ... | @@ -123,12 +120,8 @@ public final class TypeDefListener { | ... | @@ -123,12 +120,8 @@ public final class TypeDefListener { |
| 123 | * Create a derived type information, the base type must be set in type | 120 | * Create a derived type information, the base type must be set in type |
| 124 | * listener. | 121 | * listener. |
| 125 | */ | 122 | */ |
| 126 | - YangType<YangDerivedType> derivedType = new YangType<YangDerivedType>(); | ||
| 127 | - derivedType.setDataType(YangDataTypes.DERIVED); | ||
| 128 | - derivedType.setDataTypeName(identifier); | ||
| 129 | - | ||
| 130 | YangTypeDef typeDefNode = getYangTypeDefNode(JAVA_GENERATION); | 123 | YangTypeDef typeDefNode = getYangTypeDefNode(JAVA_GENERATION); |
| 131 | - typeDefNode.setDerivedType(derivedType); | 124 | + typeDefNode.setName(identifier); |
| 132 | 125 | ||
| 133 | Parsable curData = listener.getParsedDataStack().peek(); | 126 | Parsable curData = listener.getParsedDataStack().peek(); |
| 134 | 127 | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -1102,7 +1102,7 @@ public class TempJavaCodeFragmentFiles { | ... | @@ -1102,7 +1102,7 @@ public class TempJavaCodeFragmentFiles { |
| 1102 | public void addTypeDefAttributeToTempFiles(YangNode curNode) throws IOException { | 1102 | public void addTypeDefAttributeToTempFiles(YangNode curNode) throws IOException { |
| 1103 | 1103 | ||
| 1104 | JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfTypeDef(curNode, | 1104 | JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfTypeDef(curNode, |
| 1105 | - ((YangTypeDef) curNode).getDerivedType().getDataTypeExtendedInfo().getBaseType(), | 1105 | + ((YangTypeDef) curNode).getDataType(), |
| 1106 | ((YangTypeDef) curNode).getName(), false); | 1106 | ((YangTypeDef) curNode).getName(), false); |
| 1107 | addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); | 1107 | addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); |
| 1108 | } | 1108 | } | ... | ... |
utils/yangutils/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
0 → 100644
This diff is collapsed. Click to expand it.
| ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.ListIterator; | 20 | import java.util.ListIterator; |
| 21 | - | ||
| 22 | import org.junit.Rule; | 21 | import org.junit.Rule; |
| 23 | import org.junit.Test; | 22 | import org.junit.Test; |
| 24 | import org.junit.rules.ExpectedException; | 23 | import org.junit.rules.ExpectedException; |
| ... | @@ -170,7 +169,7 @@ public class ConfigListenerTest { | ... | @@ -170,7 +169,7 @@ public class ConfigListenerTest { |
| 170 | YangLeaf leafInfo = leafIterator.next(); | 169 | YangLeaf leafInfo = leafIterator.next(); |
| 171 | 170 | ||
| 172 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 171 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 173 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 172 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 174 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 173 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 175 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 174 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 176 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 175 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
| ... | @@ -206,7 +205,7 @@ public class ConfigListenerTest { | ... | @@ -206,7 +205,7 @@ public class ConfigListenerTest { |
| 206 | YangLeaf leafInfo = leafIterator.next(); | 205 | YangLeaf leafInfo = leafIterator.next(); |
| 207 | 206 | ||
| 208 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 207 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 209 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 208 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 210 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 209 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 211 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 210 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 212 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 211 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | ... | ... |
| ... | @@ -193,7 +193,7 @@ public class ContainerListenerTest { | ... | @@ -193,7 +193,7 @@ public class ContainerListenerTest { |
| 193 | YangLeaf leafInfo = leafIterator.next(); | 193 | YangLeaf leafInfo = leafIterator.next(); |
| 194 | 194 | ||
| 195 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 195 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 196 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 196 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 197 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 197 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 198 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 198 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 199 | assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT)); | 199 | assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT)); | ... | ... |
| ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.ListIterator; | 20 | import java.util.ListIterator; |
| 21 | - | ||
| 22 | import org.junit.Rule; | 21 | import org.junit.Rule; |
| 23 | import org.junit.Test; | 22 | import org.junit.Test; |
| 24 | import org.junit.rules.ExpectedException; | 23 | import org.junit.rules.ExpectedException; |
| ... | @@ -178,7 +177,7 @@ public class DescriptionListenerTest { | ... | @@ -178,7 +177,7 @@ public class DescriptionListenerTest { |
| 178 | YangLeaf leafInfo = leafIterator.next(); | 177 | YangLeaf leafInfo = leafIterator.next(); |
| 179 | 178 | ||
| 180 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 179 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 181 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 180 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 182 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 181 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 183 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 182 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 184 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 183 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
| ... | @@ -215,7 +214,7 @@ public class DescriptionListenerTest { | ... | @@ -215,7 +214,7 @@ public class DescriptionListenerTest { |
| 215 | YangLeaf leafInfo = leafIterator.next(); | 214 | YangLeaf leafInfo = leafIterator.next(); |
| 216 | 215 | ||
| 217 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 216 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 218 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 217 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 219 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 218 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 220 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 219 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 221 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 220 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | ... | ... |
| ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.ListIterator; | 20 | import java.util.ListIterator; |
| 21 | - | ||
| 22 | import org.junit.Rule; | 21 | import org.junit.Rule; |
| 23 | import org.junit.Test; | 22 | import org.junit.Test; |
| 24 | import org.junit.rules.ExpectedException; | 23 | import org.junit.rules.ExpectedException; |
| ... | @@ -68,7 +67,7 @@ public class LeafListListenerTest { | ... | @@ -68,7 +67,7 @@ public class LeafListListenerTest { |
| 68 | YangLeafList leafListInfo = leafListIterator.next(); | 67 | YangLeafList leafListInfo = leafListIterator.next(); |
| 69 | 68 | ||
| 70 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 69 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); |
| 71 | - assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 70 | + assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); |
| 72 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 71 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 73 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); | 72 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); |
| 74 | assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 73 | assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
| ... | @@ -163,7 +162,7 @@ public class LeafListListenerTest { | ... | @@ -163,7 +162,7 @@ public class LeafListListenerTest { |
| 163 | YangLeafList leafListInfo = leafListIterator.next(); | 162 | YangLeafList leafListInfo = leafListIterator.next(); |
| 164 | 163 | ||
| 165 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 164 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); |
| 166 | - assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 165 | + assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); |
| 167 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 166 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 168 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); | 167 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); |
| 169 | assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 168 | assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
| ... | @@ -200,7 +199,7 @@ public class LeafListListenerTest { | ... | @@ -200,7 +199,7 @@ public class LeafListListenerTest { |
| 200 | YangLeafList leafListInfo = leafListIterator.next(); | 199 | YangLeafList leafListInfo = leafListIterator.next(); |
| 201 | 200 | ||
| 202 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 201 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); |
| 203 | - assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 202 | + assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); |
| 204 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 203 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 205 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); | 204 | assertThat(leafListInfo.getUnits(), is("\"seconds\"")); |
| 206 | assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 205 | assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | ... | ... |
| ... | @@ -68,7 +68,7 @@ public class LeafListenerTest { | ... | @@ -68,7 +68,7 @@ public class LeafListenerTest { |
| 68 | YangLeaf leafInfo = leafIterator.next(); | 68 | YangLeaf leafInfo = leafIterator.next(); |
| 69 | 69 | ||
| 70 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 70 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 71 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 71 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 72 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 72 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 73 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 73 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 74 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 74 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
| ... | @@ -162,7 +162,7 @@ public class LeafListenerTest { | ... | @@ -162,7 +162,7 @@ public class LeafListenerTest { |
| 162 | YangLeaf leafInfo = leafIterator.next(); | 162 | YangLeaf leafInfo = leafIterator.next(); |
| 163 | 163 | ||
| 164 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 164 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 165 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 165 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 166 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 166 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 167 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 167 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 168 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 168 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
| ... | @@ -225,7 +225,7 @@ public class LeafListenerTest { | ... | @@ -225,7 +225,7 @@ public class LeafListenerTest { |
| 225 | YangLeaf leafInfo = leafIterator.next(); | 225 | YangLeaf leafInfo = leafIterator.next(); |
| 226 | 226 | ||
| 227 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 227 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 228 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 228 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 229 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 229 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 230 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 230 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 231 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 231 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | ... | ... |
| ... | @@ -162,7 +162,7 @@ public class ListListenerTest { | ... | @@ -162,7 +162,7 @@ public class ListListenerTest { |
| 162 | YangLeaf leafInfo = leafIterator.next(); | 162 | YangLeaf leafInfo = leafIterator.next(); |
| 163 | 163 | ||
| 164 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 164 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 165 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 165 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 166 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 166 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 167 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 167 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 168 | assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT)); | 168 | assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT)); | ... | ... |
| ... | @@ -16,21 +16,19 @@ | ... | @@ -16,21 +16,19 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.yangutils.parser.impl.listeners; | 17 | package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | +import java.io.IOException; | ||
| 20 | +import java.util.ListIterator; | ||
| 19 | import org.junit.Test; | 21 | import org.junit.Test; |
| 20 | -import org.onosproject.yangutils.datamodel.YangNode; | 22 | +import org.onosproject.yangutils.datamodel.YangLeaf; |
| 21 | import org.onosproject.yangutils.datamodel.YangModule; | 23 | import org.onosproject.yangutils.datamodel.YangModule; |
| 24 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
| 25 | +import org.onosproject.yangutils.datamodel.YangNodeType; | ||
| 22 | import org.onosproject.yangutils.datamodel.YangNotification; | 26 | import org.onosproject.yangutils.datamodel.YangNotification; |
| 23 | import org.onosproject.yangutils.datamodel.YangStatusType; | 27 | import org.onosproject.yangutils.datamodel.YangStatusType; |
| 24 | -import org.onosproject.yangutils.datamodel.YangNodeType; | ||
| 25 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 28 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
| 26 | -import org.onosproject.yangutils.datamodel.YangLeaf; | ||
| 27 | -import org.onosproject.yangutils.datamodel.YangDataTypes; | ||
| 28 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 29 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
| 29 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 30 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
| 30 | 31 | ||
| 31 | -import java.io.IOException; | ||
| 32 | -import java.util.ListIterator; | ||
| 33 | - | ||
| 34 | import static org.hamcrest.core.Is.is; | 32 | import static org.hamcrest.core.Is.is; |
| 35 | import static org.junit.Assert.assertThat; | 33 | import static org.junit.Assert.assertThat; |
| 36 | 34 | ||
| ... | @@ -63,8 +61,6 @@ public class NotificationListenerTest { | ... | @@ -63,8 +61,6 @@ public class NotificationListenerTest { |
| 63 | YangTypeDef typeDef = (YangTypeDef) yangNotification.getChild(); | 61 | YangTypeDef typeDef = (YangTypeDef) yangNotification.getChild(); |
| 64 | assertThat(typeDef.getName(), is("my-type")); | 62 | assertThat(typeDef.getName(), is("my-type")); |
| 65 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); | 63 | assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED)); |
| 66 | - assertThat(typeDef.getDerivedType().getDataTypeExtendedInfo() | ||
| 67 | - .getBaseType().getDataType(), is(YangDataTypes.INT32)); | ||
| 68 | 64 | ||
| 69 | ListIterator<YangLeaf> leafIterator = yangNotification.getListOfLeaf().listIterator(); | 65 | ListIterator<YangLeaf> leafIterator = yangNotification.getListOfLeaf().listIterator(); |
| 70 | YangLeaf leafInfo = leafIterator.next(); | 66 | YangLeaf leafInfo = leafIterator.next(); | ... | ... |
| ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.ListIterator; | 20 | import java.util.ListIterator; |
| 21 | - | ||
| 22 | import org.junit.Rule; | 21 | import org.junit.Rule; |
| 23 | import org.junit.Test; | 22 | import org.junit.Test; |
| 24 | import org.junit.rules.ExpectedException; | 23 | import org.junit.rules.ExpectedException; |
| ... | @@ -177,7 +176,7 @@ public class ReferenceListenerTest { | ... | @@ -177,7 +176,7 @@ public class ReferenceListenerTest { |
| 177 | YangLeaf leafInfo = leafIterator.next(); | 176 | YangLeaf leafInfo = leafIterator.next(); |
| 178 | 177 | ||
| 179 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 178 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 180 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 179 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 181 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 180 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 182 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 181 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 183 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 182 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
| ... | @@ -214,7 +213,7 @@ public class ReferenceListenerTest { | ... | @@ -214,7 +213,7 @@ public class ReferenceListenerTest { |
| 214 | YangLeaf leafInfo = leafIterator.next(); | 213 | YangLeaf leafInfo = leafIterator.next(); |
| 215 | 214 | ||
| 216 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 215 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 217 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 216 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 218 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 217 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 219 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 218 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 220 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 219 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | ... | ... |
| ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.ListIterator; | 20 | import java.util.ListIterator; |
| 21 | - | ||
| 22 | import org.junit.Rule; | 21 | import org.junit.Rule; |
| 23 | import org.junit.Test; | 22 | import org.junit.Test; |
| 24 | import org.junit.rules.ExpectedException; | 23 | import org.junit.rules.ExpectedException; |
| ... | @@ -187,7 +186,7 @@ public class StatusListenerTest { | ... | @@ -187,7 +186,7 @@ public class StatusListenerTest { |
| 187 | YangLeaf leafInfo = leafIterator.next(); | 186 | YangLeaf leafInfo = leafIterator.next(); |
| 188 | 187 | ||
| 189 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 188 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 190 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 189 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 191 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 190 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 192 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 191 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 193 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 192 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
| ... | @@ -224,7 +223,7 @@ public class StatusListenerTest { | ... | @@ -224,7 +223,7 @@ public class StatusListenerTest { |
| 224 | YangLeaf leafInfo = leafIterator.next(); | 223 | YangLeaf leafInfo = leafIterator.next(); |
| 225 | 224 | ||
| 226 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 225 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 227 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 226 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 228 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 227 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 229 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 228 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 230 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 229 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | ... | ... |
| ... | @@ -2,7 +2,6 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -2,7 +2,6 @@ package org.onosproject.yangutils.parser.impl.listeners; |
| 2 | 2 | ||
| 3 | import java.io.IOException; | 3 | import java.io.IOException; |
| 4 | import java.util.ListIterator; | 4 | import java.util.ListIterator; |
| 5 | - | ||
| 6 | import org.junit.Test; | 5 | import org.junit.Test; |
| 7 | import org.onosproject.yangutils.datamodel.YangDataTypes; | 6 | import org.onosproject.yangutils.datamodel.YangDataTypes; |
| 8 | import org.onosproject.yangutils.datamodel.YangLeaf; | 7 | import org.onosproject.yangutils.datamodel.YangLeaf; |
| ... | @@ -45,7 +44,7 @@ public class TypeListenerTest { | ... | @@ -45,7 +44,7 @@ public class TypeListenerTest { |
| 45 | YangLeaf leafInfo = leafIterator.next(); | 44 | YangLeaf leafInfo = leafIterator.next(); |
| 46 | 45 | ||
| 47 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 46 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 48 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"hello\"")); | 47 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); |
| 49 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | 48 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); |
| 50 | } | 49 | } |
| 51 | 50 | ||
| ... | @@ -71,7 +70,7 @@ public class TypeListenerTest { | ... | @@ -71,7 +70,7 @@ public class TypeListenerTest { |
| 71 | YangLeaf leafInfo = leafIterator.next(); | 70 | YangLeaf leafInfo = leafIterator.next(); |
| 72 | 71 | ||
| 73 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 72 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 74 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 73 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 75 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 74 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 76 | } | 75 | } |
| 77 | 76 | ||
| ... | @@ -97,7 +96,7 @@ public class TypeListenerTest { | ... | @@ -97,7 +96,7 @@ public class TypeListenerTest { |
| 97 | YangLeafList leafListInfo = leafListIterator.next(); | 96 | YangLeafList leafListInfo = leafListIterator.next(); |
| 98 | 97 | ||
| 99 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); | 98 | assertThat(leafListInfo.getLeafName(), is("invalid-interval")); |
| 100 | - assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 99 | + assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16")); |
| 101 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 100 | assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
| 102 | } | 101 | } |
| 103 | } | 102 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
| ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; | ... | @@ -18,7 +18,6 @@ package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.ListIterator; | 20 | import java.util.ListIterator; |
| 21 | - | ||
| 22 | import org.junit.Rule; | 21 | import org.junit.Rule; |
| 23 | import org.junit.Test; | 22 | import org.junit.Test; |
| 24 | import org.junit.rules.ExpectedException; | 23 | import org.junit.rules.ExpectedException; |
| ... | @@ -117,7 +116,7 @@ public class UnitsListenerTest { | ... | @@ -117,7 +116,7 @@ public class UnitsListenerTest { |
| 117 | 116 | ||
| 118 | // Check whether leaf properties is set correctly. | 117 | // Check whether leaf properties is set correctly. |
| 119 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); | 118 | assertThat(leafInfo.getLeafName(), is("invalid-interval")); |
| 120 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\"")); | 119 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); |
| 121 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 120 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
| 122 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); | 121 | assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\"")); |
| 123 | assertThat(leafInfo.isConfig(), is(true)); | 122 | assertThat(leafInfo.isConfig(), is(true)); | ... | ... |
| ... | @@ -3,6 +3,6 @@ module Test { | ... | @@ -3,6 +3,6 @@ module Test { |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | leaf invalid-interval { | 5 | leaf invalid-interval { |
| 6 | - type "hello"; | 6 | + type P:hello; |
| 7 | } | 7 | } |
| 8 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 8 | +} | ... | ... |
| ... | @@ -5,17 +5,17 @@ module Test { | ... | @@ -5,17 +5,17 @@ module Test { |
| 5 | list valid { | 5 | list valid { |
| 6 | key address; | 6 | key address; |
| 7 | leaf address { | 7 | leaf address { |
| 8 | - type ip; | 8 | + type P:ip; |
| 9 | } | 9 | } |
| 10 | grouping endpoint { | 10 | grouping endpoint { |
| 11 | description "grouping under test"; | 11 | description "grouping under test"; |
| 12 | status current; | 12 | status current; |
| 13 | reference "RFC 6020"; | 13 | reference "RFC 6020"; |
| 14 | leaf address { | 14 | leaf address { |
| 15 | - type ip-address; | 15 | + type P:ip-address; |
| 16 | } | 16 | } |
| 17 | leaf port { | 17 | leaf port { |
| 18 | - type port-number; | 18 | + type P:port-number; |
| 19 | } | 19 | } |
| 20 | } | 20 | } |
| 21 | } | 21 | } | ... | ... |
| ... | @@ -5,10 +5,10 @@ module Test { | ... | @@ -5,10 +5,10 @@ module Test { |
| 5 | container valid { | 5 | container valid { |
| 6 | grouping endpoint { | 6 | grouping endpoint { |
| 7 | leaf address { | 7 | leaf address { |
| 8 | - type ip-address; | 8 | + type P:ip-address; |
| 9 | } | 9 | } |
| 10 | leaf port { | 10 | leaf port { |
| 11 | - type port-number; | 11 | + type P:port-number; |
| 12 | } | 12 | } |
| 13 | } | 13 | } |
| 14 | } | 14 | } | ... | ... |
| ... | @@ -5,14 +5,14 @@ module Test { | ... | @@ -5,14 +5,14 @@ module Test { |
| 5 | list valid { | 5 | list valid { |
| 6 | key address; | 6 | key address; |
| 7 | leaf address { | 7 | leaf address { |
| 8 | - type ip; | 8 | + type P:ip; |
| 9 | } | 9 | } |
| 10 | grouping endpoint { | 10 | grouping endpoint { |
| 11 | leaf address { | 11 | leaf address { |
| 12 | - type ip-address; | 12 | + type P:ip-address; |
| 13 | } | 13 | } |
| 14 | leaf port { | 14 | leaf port { |
| 15 | - type port-number; | 15 | + type P:port-number; |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
| 18 | } | 18 | } | ... | ... |
| ... | @@ -4,10 +4,10 @@ module Test { | ... | @@ -4,10 +4,10 @@ module Test { |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | grouping endpoint { | 5 | grouping endpoint { |
| 6 | leaf address { | 6 | leaf address { |
| 7 | - type ip-address; | 7 | + type P:ip-address; |
| 8 | } | 8 | } |
| 9 | leaf port { | 9 | leaf port { |
| 10 | - type port-number; | 10 | + type P:port-number; |
| 11 | } | 11 | } |
| 12 | } | 12 | } |
| 13 | } | 13 | } | ... | ... |
utils/yangutils/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang
0 → 100644
| 1 | +module Test { | ||
| 2 | + yang-version 1; | ||
| 3 | + namespace http://huawei.com; | ||
| 4 | + prefix Ant; | ||
| 5 | + typedef Percentage { | ||
| 6 | + type INT; | ||
| 7 | + } | ||
| 8 | + container ospf { | ||
| 9 | + list valid { | ||
| 10 | + key "invalid-interval"; | ||
| 11 | + leaf invalid-interval { | ||
| 12 | + type Ant:FirstClass; | ||
| 13 | + } | ||
| 14 | + typedef FirstClass { | ||
| 15 | + type Ant:PassingClass; | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | + typedef PassingClass { | ||
| 19 | + type Percentage; | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | +} |
utils/yangutils/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
0 → 100644
| 1 | +module Test { | ||
| 2 | + yang-version 1; | ||
| 3 | + namespace http://huawei.com; | ||
| 4 | + prefix Ant; | ||
| 5 | + typedef Percentage { | ||
| 6 | + type P:Per; | ||
| 7 | + } | ||
| 8 | + container ospf { | ||
| 9 | + list valid { | ||
| 10 | + key "invalid-interval"; | ||
| 11 | + leaf invalid-interval { | ||
| 12 | + type FirstClass; | ||
| 13 | + } | ||
| 14 | + typedef FirstClass { | ||
| 15 | + type PassingClass; | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | + typedef PassingClass { | ||
| 19 | + type Percentage; | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | +} |
| 1 | +module Test { | ||
| 2 | + yang-version 1; | ||
| 3 | + namespace http://huawei.com; | ||
| 4 | + prefix Ant; | ||
| 5 | + typedef Percentage { | ||
| 6 | + type int32; | ||
| 7 | + } | ||
| 8 | + container ospf { | ||
| 9 | + list valid { | ||
| 10 | + key "invalid-interval"; | ||
| 11 | + leaf invalid-interval { | ||
| 12 | + type FirstClass; | ||
| 13 | + } | ||
| 14 | + typedef FirstClass { | ||
| 15 | + type PassingClass; | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | + typedef PassingClass { | ||
| 19 | + type Percentage; | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | +} |
utils/yangutils/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
0 → 100644
| 1 | +module Test { | ||
| 2 | + yang-version 1; | ||
| 3 | + namespace http://huawei.com; | ||
| 4 | + prefix Ant; | ||
| 5 | + typedef Percentage { | ||
| 6 | + type int32; | ||
| 7 | + } | ||
| 8 | + container ospf { | ||
| 9 | + list valid { | ||
| 10 | + key "invalid-interval"; | ||
| 11 | + leaf invalid-interval { | ||
| 12 | + type Ant:FirstClass; | ||
| 13 | + } | ||
| 14 | + typedef FirstClass { | ||
| 15 | + type P:PassingClass; | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | + typedef PassingClass { | ||
| 19 | + type Ant:Percentage; | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | +} |
| 1 | +module Test { | ||
| 2 | + yang-version 1; | ||
| 3 | + namespace http://huawei.com; | ||
| 4 | + prefix Ant; | ||
| 5 | + typedef Percentage { | ||
| 6 | + type int32; | ||
| 7 | + } | ||
| 8 | + container ospf { | ||
| 9 | + list valid { | ||
| 10 | + key "invalid-interval"; | ||
| 11 | + leaf invalid-interval { | ||
| 12 | + type Ant:FirstClass; | ||
| 13 | + } | ||
| 14 | + typedef FirstClass { | ||
| 15 | + type PassingClass; | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | + typedef PassingClass { | ||
| 19 | + type Ant:Percentage; | ||
| 20 | + } | ||
| 21 | + } | ||
| 22 | +} |
| ... | @@ -5,7 +5,7 @@ module Test { | ... | @@ -5,7 +5,7 @@ module Test { |
| 5 | list valid { | 5 | list valid { |
| 6 | key address; | 6 | key address; |
| 7 | leaf address { | 7 | leaf address { |
| 8 | - type ip; | 8 | + type P:ip; |
| 9 | } | 9 | } |
| 10 | uses endpoint { | 10 | uses endpoint { |
| 11 | description "grouping under test"; | 11 | description "grouping under test"; | ... | ... |
| ... | @@ -16,10 +16,10 @@ module rock { | ... | @@ -16,10 +16,10 @@ module rock { |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
| 18 | leaf if-admin-status { | 18 | leaf if-admin-status { |
| 19 | - type admin-status; | 19 | + type P:admin-status; |
| 20 | } | 20 | } |
| 21 | leaf if-oper-status { | 21 | leaf if-oper-status { |
| 22 | - type oper-status; | 22 | + type P:oper-status; |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| 25 | } | 25 | } | ... | ... |
-
Please register or login to post a comment