Committed by
Gerrit Code Review
[ONOS-4753] Identity/identityref implementation and UT
Change-Id: I40148fa228465555be3bdf410cc294ffc0f34c18
Showing
56 changed files
with
1613 additions
and
76 deletions
... | @@ -39,5 +39,15 @@ public enum ResolvableType { | ... | @@ -39,5 +39,15 @@ public enum ResolvableType { |
39 | /** | 39 | /** |
40 | * Identifies the leafref. | 40 | * Identifies the leafref. |
41 | */ | 41 | */ |
42 | - YANG_LEAFREF | 42 | + YANG_LEAFREF, |
43 | + | ||
44 | + /** | ||
45 | + * Identifies the base. | ||
46 | + */ | ||
47 | + YANG_BASE, | ||
48 | + | ||
49 | + /** | ||
50 | + * Identifies the identityref. | ||
51 | + */ | ||
52 | + YANG_IDENTITYREF | ||
43 | } | 53 | } | ... | ... |
utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangBase.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
19 | +import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; | ||
20 | + | ||
21 | +import java.io.Serializable; | ||
22 | + | ||
23 | +/** | ||
24 | + * Reference RFC 6020. | ||
25 | + * | ||
26 | + * Represents data model node to maintain information defined in YANG base. | ||
27 | + * The "base" statement, which is optional, takes as an argument a | ||
28 | + * string that is the name of an existing identity, from which the new | ||
29 | + * identity is derived. If no "base" statement is present, the identity | ||
30 | + * is defined from scratch. | ||
31 | + * | ||
32 | + * If a prefix is present on the base name, it refers to an identity | ||
33 | + * defined in the module that was imported with that prefix, or the | ||
34 | + * local module if the prefix matches the local module's prefix. | ||
35 | + * Otherwise, an identity with the matching name MUST be defined in the | ||
36 | + * current module or an included submodule. | ||
37 | + */ | ||
38 | + | ||
39 | +/** | ||
40 | + * Represents data model node to maintain information defined in YANG base. | ||
41 | + */ | ||
42 | + public class YangBase implements Resolvable, Serializable { | ||
43 | + | ||
44 | + private static final long serialVersionUID = 806201693L; | ||
45 | + | ||
46 | + // YANG node identifier. | ||
47 | + private YangNodeIdentifier baseIdentifier; | ||
48 | + | ||
49 | + // Referred identity parent information. | ||
50 | + private YangIdentity referredIdentity; | ||
51 | + | ||
52 | + /** | ||
53 | + * Status of resolution. If completely resolved enum value is "RESOLVED", | ||
54 | + * if not enum value is "UNRESOLVED", in case reference of grouping/typedef/base/identityref | ||
55 | + * is added to uses/type/base/identityref but it's not resolved value of enum should be | ||
56 | + * "INTRA_FILE_RESOLVED". | ||
57 | + */ | ||
58 | + private ResolvableStatus resolvableStatus; | ||
59 | + | ||
60 | + // Creates a base type of node. | ||
61 | + public YangBase() { | ||
62 | + resolvableStatus = ResolvableStatus.UNRESOLVED; | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * Returns the YANG node identifier. | ||
67 | + * | ||
68 | + * @return the YANG node identifier | ||
69 | + */ | ||
70 | + public YangNodeIdentifier getBaseIdentifier() { | ||
71 | + return baseIdentifier; | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Sets the YANG node identifier. | ||
76 | + * | ||
77 | + * @param baseIdentifier the YANG node identifier to set | ||
78 | + */ | ||
79 | + public void setBaseIdentifier(YangNodeIdentifier baseIdentifier) { | ||
80 | + this.baseIdentifier = baseIdentifier; | ||
81 | + } | ||
82 | + | ||
83 | + /** | ||
84 | + * Returns the parent identity node. | ||
85 | + * | ||
86 | + * @return the parent identity node | ||
87 | + */ | ||
88 | + public YangIdentity getReferredIdentity() { | ||
89 | + return referredIdentity; | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * Sets the parent identity node. | ||
94 | + * | ||
95 | + * @param referredIdentity the parent identity node to set | ||
96 | + */ | ||
97 | + public void setReferredIdentity(YangIdentity referredIdentity) { | ||
98 | + this.referredIdentity = referredIdentity; | ||
99 | + } | ||
100 | + | ||
101 | + @Override | ||
102 | + public ResolvableStatus getResolvableStatus() { | ||
103 | + return resolvableStatus; | ||
104 | + } | ||
105 | + | ||
106 | + @Override | ||
107 | + public void setResolvableStatus(ResolvableStatus resolvableStatus) { | ||
108 | + this.resolvableStatus = resolvableStatus; | ||
109 | + } | ||
110 | + | ||
111 | + @Override | ||
112 | + public void resolve() throws DataModelException { | ||
113 | + } | ||
114 | +} |
... | @@ -334,7 +334,7 @@ public class YangDerivedInfo<T> | ... | @@ -334,7 +334,7 @@ public class YangDerivedInfo<T> |
334 | return RESOLVED; | 334 | return RESOLVED; |
335 | } | 335 | } |
336 | } | 336 | } |
337 | - } else if (baseType.getDataType() == LEAFREF) { | 337 | + } else if ((baseType.getDataType() == LEAFREF) || (baseType.getDataType() == IDENTITYREF)) { |
338 | setEffectiveBuiltInType(baseType.getDataType()); | 338 | setEffectiveBuiltInType(baseType.getDataType()); |
339 | return RESOLVED; | 339 | return RESOLVED; |
340 | } else { | 340 | } else { | ... | ... |
utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentity.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
19 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
20 | +import org.onosproject.yangutils.datamodel.utils.YangConstructType; | ||
21 | + | ||
22 | +import java.io.Serializable; | ||
23 | + | ||
24 | +/*- | ||
25 | + * Reference RFC 6020. | ||
26 | + * | ||
27 | + * The "identity" statement is used to define a new globally unique, | ||
28 | + * abstract, and untyped identity. Its only purpose is to denote its | ||
29 | + * name, semantics, and existence. An identity can either be defined | ||
30 | + * from scratch or derived from a base identity. The identity's | ||
31 | + * argument is an identifier that is the name of the identity. It is | ||
32 | + * followed by a block of substatements that holds detailed identity | ||
33 | + * information. | ||
34 | + * | ||
35 | + * The identity's Substatements | ||
36 | + * | ||
37 | + * +--------------+---------+-------------+-----------------------+ | ||
38 | + * | substatement | section | cardinality | data model mapping | | ||
39 | + * +--------------+---------+-------------+-----------------------+ | ||
40 | + * | base | 7.16.2 | 0..1 | -YangNodeIdentifier | | ||
41 | + * | description | 7.19.3 | 0..1 | -string | | ||
42 | + * | reference | 7.19.4 | 0..1 | -string | | ||
43 | + * | status | 7.19.2 | 0..1 | -YangStatus | | ||
44 | + * +--------------+---------+-------------+-----------------------+ | ||
45 | + */ | ||
46 | + | ||
47 | +/** | ||
48 | + * Represents data model node to maintain information defined in YANG identity. | ||
49 | + */ | ||
50 | +public class YangIdentity extends YangNode implements YangCommonInfo, Parsable, Serializable { | ||
51 | + | ||
52 | + private static final long serialVersionUID = 806201691L; | ||
53 | + | ||
54 | + //Name of the identity. | ||
55 | + private String name; | ||
56 | + | ||
57 | + //Base node of identity. | ||
58 | + private YangBase baseNode; | ||
59 | + | ||
60 | + //Status of YANG identity. | ||
61 | + private YangStatusType status; | ||
62 | + | ||
63 | + //Description of YANG identity. | ||
64 | + private String description; | ||
65 | + | ||
66 | + //YANG reference of the identity. | ||
67 | + private String reference; | ||
68 | + | ||
69 | + //Creates a identity type of node. | ||
70 | + public YangIdentity() { | ||
71 | + super(YangNodeType.IDENTITY_NODE); | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Returns the name of identity. | ||
76 | + * | ||
77 | + * @return the identity name | ||
78 | + */ | ||
79 | + public String getName() { | ||
80 | + return name; | ||
81 | + } | ||
82 | + | ||
83 | + /** | ||
84 | + * Sets the name of identity. | ||
85 | + * | ||
86 | + * @param name the identity name to set | ||
87 | + */ | ||
88 | + public void setName(String name) { | ||
89 | + this.name = name; | ||
90 | + } | ||
91 | + | ||
92 | + @Override | ||
93 | + public YangStatusType getStatus() { | ||
94 | + return status; | ||
95 | + } | ||
96 | + | ||
97 | + @Override | ||
98 | + public void setStatus(YangStatusType status) { | ||
99 | + this.status = status; | ||
100 | + } | ||
101 | + | ||
102 | + @Override | ||
103 | + public String getDescription() { | ||
104 | + return description; | ||
105 | + } | ||
106 | + | ||
107 | + @Override | ||
108 | + public void setDescription(String description) { | ||
109 | + this.description = description; | ||
110 | + } | ||
111 | + | ||
112 | + @Override | ||
113 | + public String getReference() { | ||
114 | + return reference; | ||
115 | + } | ||
116 | + | ||
117 | + @Override | ||
118 | + public void setReference(String reference) { | ||
119 | + this.reference = reference; | ||
120 | + } | ||
121 | + | ||
122 | + @Override | ||
123 | + public YangConstructType getYangConstructType() { | ||
124 | + return YangConstructType.IDENTITY_DATA; | ||
125 | + } | ||
126 | + | ||
127 | + @Override | ||
128 | + public void validateDataOnEntry() throws DataModelException { | ||
129 | + } | ||
130 | + | ||
131 | + @Override | ||
132 | + public void validateDataOnExit() throws DataModelException { | ||
133 | + } | ||
134 | + | ||
135 | + /** | ||
136 | + * Returns base node of identity. | ||
137 | + * | ||
138 | + * @return the base node of identity | ||
139 | + */ | ||
140 | + public YangBase getBaseNode() { | ||
141 | + return baseNode; | ||
142 | + } | ||
143 | + | ||
144 | + /** | ||
145 | + * Sets the base node. | ||
146 | + * | ||
147 | + * @param baseNode the base node to set | ||
148 | + */ | ||
149 | + public void setBaseNode(YangBase baseNode) { | ||
150 | + this.baseNode = baseNode; | ||
151 | + } | ||
152 | +} |
utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangIdentityRef.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.datamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
19 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
20 | +import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; | ||
21 | +import org.onosproject.yangutils.datamodel.utils.YangConstructType; | ||
22 | + | ||
23 | +import java.io.Serializable; | ||
24 | + | ||
25 | +/*- | ||
26 | + * Reference RFC 6020. | ||
27 | + * | ||
28 | + * The identityref type is used to reference an existing identity. | ||
29 | + * | ||
30 | + * The identityref's base Statement : | ||
31 | + * The "base" statement, which is a substatement to the "type" | ||
32 | + * statement, MUST be present if the type is "identityref". The | ||
33 | + * argument is the name of an identity, as defined by an "identity" | ||
34 | + * statement. If a prefix is present on the identity name, it refers to | ||
35 | + * an identity defined in the module that was imported with that prefix. | ||
36 | + * Otherwise, an identity with the matching name MUST be defined in the | ||
37 | + * current module or an included submodule. | ||
38 | + * Valid values for an identityref are any identities derived from the | ||
39 | + * identityref's base identity. On a particular server, the valid | ||
40 | + * values are further restricted to the set of identities defined in the | ||
41 | + * modules supported by the server. | ||
42 | + */ | ||
43 | + | ||
44 | +/** | ||
45 | + * Represents data model node to maintain information defined in YANG identityref. | ||
46 | + */ | ||
47 | +public class YangIdentityRef extends YangNode implements Parsable, Resolvable, Serializable { | ||
48 | + | ||
49 | + private static final long serialVersionUID = 806201692L; | ||
50 | + | ||
51 | + // Get referred identity parent information. | ||
52 | + private YangIdentity referredIdentity; | ||
53 | + | ||
54 | + // YANG node identifier. | ||
55 | + private YangNodeIdentifier baseIdentity; | ||
56 | + | ||
57 | + /** | ||
58 | + * Status of resolution. If completely resolved enum value is "RESOLVED", | ||
59 | + * if not enum value is "UNRESOLVED", in case reference of grouping/typedef/identityref/base | ||
60 | + * is added to uses/type/identityref/base but it's not resolved value of enum should be | ||
61 | + * "INTRA_FILE_RESOLVED". | ||
62 | + */ | ||
63 | + private ResolvableStatus resolvableStatus; | ||
64 | + | ||
65 | + // Creates a specific identityref of node. | ||
66 | + public YangIdentityRef() { | ||
67 | + super(YangNodeType.IDENTITYREF_NODE); | ||
68 | + baseIdentity = new YangNodeIdentifier(); | ||
69 | + resolvableStatus = ResolvableStatus.UNRESOLVED; | ||
70 | + } | ||
71 | + | ||
72 | + @Override | ||
73 | + public ResolvableStatus getResolvableStatus() { | ||
74 | + return resolvableStatus; | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public void setResolvableStatus(ResolvableStatus resolvableStatus) { | ||
79 | + this.resolvableStatus = resolvableStatus; | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public void resolve() throws DataModelException { | ||
84 | + | ||
85 | + // Check if the derived info is present. | ||
86 | + YangIdentity identity = getReferredIdentity(); | ||
87 | + | ||
88 | + if (identity == null) { | ||
89 | + throw new DataModelException("Linker Error: Identity information is missing."); | ||
90 | + } | ||
91 | + | ||
92 | + while (identity.getBaseNode() != null) { | ||
93 | + if (identity.getBaseNode().getResolvableStatus() != ResolvableStatus.RESOLVED) { | ||
94 | + setResolvableStatus(ResolvableStatus.INTRA_FILE_RESOLVED); | ||
95 | + return; | ||
96 | + } | ||
97 | + identity = identity.getBaseNode().getReferredIdentity(); | ||
98 | + } | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * Returns the YANG base node identifier. | ||
103 | + * | ||
104 | + * @return the YANG base node identifier | ||
105 | + */ | ||
106 | + public YangNodeIdentifier getBaseIdentity() { | ||
107 | + return baseIdentity; | ||
108 | + } | ||
109 | + | ||
110 | + /** | ||
111 | + * Sets the YANG node identifier. | ||
112 | + * | ||
113 | + * @param baseIdentity the YANG node identifier to set | ||
114 | + */ | ||
115 | + public void setBaseIdentity(YangNodeIdentifier baseIdentity) { | ||
116 | + this.baseIdentity = baseIdentity; | ||
117 | + } | ||
118 | + | ||
119 | + /** | ||
120 | + * Returns the name of identity. | ||
121 | + * | ||
122 | + * @return the identity name | ||
123 | + */ | ||
124 | + @Override | ||
125 | + public String getName() { | ||
126 | + return baseIdentity.getName(); | ||
127 | + } | ||
128 | + | ||
129 | + /** | ||
130 | + * Sets the name of identity. | ||
131 | + * | ||
132 | + * @param name the identity name to set | ||
133 | + */ | ||
134 | + @Override | ||
135 | + public void setName(String name) { | ||
136 | + baseIdentity.setName(name); | ||
137 | + } | ||
138 | + | ||
139 | + /** | ||
140 | + * Sets node identifier. | ||
141 | + * | ||
142 | + * @param nodeIdentifier the node identifier | ||
143 | + */ | ||
144 | + public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) { | ||
145 | + this.baseIdentity = nodeIdentifier; | ||
146 | + } | ||
147 | + | ||
148 | + /** | ||
149 | + * Returns prefix associated with base. | ||
150 | + * | ||
151 | + * @return prefix associated with base | ||
152 | + */ | ||
153 | + public String getPrefix() { | ||
154 | + return baseIdentity.getPrefix(); | ||
155 | + } | ||
156 | + | ||
157 | + /** | ||
158 | + * Sets prefix associated with base. | ||
159 | + * | ||
160 | + * @param prefix prefix associated with base | ||
161 | + */ | ||
162 | + public void setPrefix(String prefix) { | ||
163 | + baseIdentity.setPrefix(prefix); | ||
164 | + } | ||
165 | + | ||
166 | + @Override | ||
167 | + public YangConstructType getYangConstructType() { | ||
168 | + return YangConstructType.IDENTITYREF_DATA; | ||
169 | + } | ||
170 | + | ||
171 | + @Override | ||
172 | + public void validateDataOnEntry() throws DataModelException { | ||
173 | + } | ||
174 | + | ||
175 | + @Override | ||
176 | + public void validateDataOnExit() throws DataModelException { | ||
177 | + } | ||
178 | + | ||
179 | + /** | ||
180 | + * Returns the parent identity node. | ||
181 | + * | ||
182 | + * @return the parent identity node | ||
183 | + */ | ||
184 | + public YangIdentity getReferredIdentity() { | ||
185 | + return referredIdentity; | ||
186 | + } | ||
187 | + | ||
188 | + /** | ||
189 | + * Sets the parent identity node. | ||
190 | + * | ||
191 | + * @param referredIdentity the parent identity node to set | ||
192 | + */ | ||
193 | + public void setReferredIdentity(YangIdentity referredIdentity) { | ||
194 | + this.referredIdentity = referredIdentity; | ||
195 | + } | ||
196 | +} |
... | @@ -216,6 +216,17 @@ public class YangModule | ... | @@ -216,6 +216,17 @@ public class YangModule |
216 | private List<YangResolutionInfo> leafrefResolutionList; | 216 | private List<YangResolutionInfo> leafrefResolutionList; |
217 | 217 | ||
218 | /** | 218 | /** |
219 | + * base resolution list. | ||
220 | + */ | ||
221 | + private List<YangResolutionInfo> baseResolutionList; | ||
222 | + | ||
223 | + /** | ||
224 | + * identityref resolution list. | ||
225 | + */ | ||
226 | + private List<YangResolutionInfo> identityrefResolutionList; | ||
227 | + | ||
228 | + | ||
229 | + /** | ||
219 | * Creates a YANG node of module type. | 230 | * Creates a YANG node of module type. |
220 | */ | 231 | */ |
221 | public YangModule() { | 232 | public YangModule() { |
... | @@ -225,6 +236,8 @@ public class YangModule | ... | @@ -225,6 +236,8 @@ public class YangModule |
225 | usesResolutionList = new LinkedList<>(); | 236 | usesResolutionList = new LinkedList<>(); |
226 | ifFeatureResolutionList = new LinkedList<>(); | 237 | ifFeatureResolutionList = new LinkedList<>(); |
227 | leafrefResolutionList = new LinkedList<>(); | 238 | leafrefResolutionList = new LinkedList<>(); |
239 | + baseResolutionList = new LinkedList<>(); | ||
240 | + identityrefResolutionList = new LinkedList<>(); | ||
228 | importList = new LinkedList<YangImport>(); | 241 | importList = new LinkedList<YangImport>(); |
229 | includeList = new LinkedList<YangInclude>(); | 242 | includeList = new LinkedList<YangInclude>(); |
230 | listOfLeaf = new LinkedList<YangLeaf>(); | 243 | listOfLeaf = new LinkedList<YangLeaf>(); |
... | @@ -597,8 +610,12 @@ public class YangModule | ... | @@ -597,8 +610,12 @@ public class YangModule |
597 | return usesResolutionList; | 610 | return usesResolutionList; |
598 | } else if (type == ResolvableType.YANG_IF_FEATURE) { | 611 | } else if (type == ResolvableType.YANG_IF_FEATURE) { |
599 | return ifFeatureResolutionList; | 612 | return ifFeatureResolutionList; |
600 | - } else { | 613 | + } else if (type == ResolvableType.YANG_LEAFREF) { |
601 | return leafrefResolutionList; | 614 | return leafrefResolutionList; |
615 | + } else if (type == ResolvableType.YANG_BASE) { | ||
616 | + return baseResolutionList; | ||
617 | + } else { | ||
618 | + return identityrefResolutionList; | ||
602 | } | 619 | } |
603 | } | 620 | } |
604 | 621 | ||
... | @@ -611,8 +628,12 @@ public class YangModule | ... | @@ -611,8 +628,12 @@ public class YangModule |
611 | usesResolutionList.add(resolutionInfo); | 628 | usesResolutionList.add(resolutionInfo); |
612 | } else if (type == ResolvableType.YANG_IF_FEATURE) { | 629 | } else if (type == ResolvableType.YANG_IF_FEATURE) { |
613 | ifFeatureResolutionList.add(resolutionInfo); | 630 | ifFeatureResolutionList.add(resolutionInfo); |
614 | - } else { | 631 | + } else if (type == ResolvableType.YANG_LEAFREF) { |
615 | leafrefResolutionList.add(resolutionInfo); | 632 | leafrefResolutionList.add(resolutionInfo); |
633 | + } else if (type == ResolvableType.YANG_BASE) { | ||
634 | + baseResolutionList.add(resolutionInfo); | ||
635 | + } else if (type == ResolvableType.YANG_IDENTITYREF) { | ||
636 | + identityrefResolutionList.add(resolutionInfo); | ||
616 | } | 637 | } |
617 | } | 638 | } |
618 | 639 | ||
... | @@ -627,6 +648,10 @@ public class YangModule | ... | @@ -627,6 +648,10 @@ public class YangModule |
627 | ifFeatureResolutionList.add((YangResolutionInfo) resolutionList); | 648 | ifFeatureResolutionList.add((YangResolutionInfo) resolutionList); |
628 | } else if (type == ResolvableType.YANG_LEAFREF) { | 649 | } else if (type == ResolvableType.YANG_LEAFREF) { |
629 | leafrefResolutionList = resolutionList; | 650 | leafrefResolutionList = resolutionList; |
651 | + } else if (type == ResolvableType.YANG_BASE) { | ||
652 | + baseResolutionList = resolutionList; | ||
653 | + } else if (type == ResolvableType.YANG_IDENTITYREF) { | ||
654 | + identityrefResolutionList = resolutionList; | ||
630 | } | 655 | } |
631 | 656 | ||
632 | } | 657 | } |
... | @@ -650,11 +675,8 @@ public class YangModule | ... | @@ -650,11 +675,8 @@ public class YangModule |
650 | while (includeInfoIterator.hasNext()) { | 675 | while (includeInfoIterator.hasNext()) { |
651 | YangInclude yangInclude = includeInfoIterator.next(); | 676 | YangInclude yangInclude = includeInfoIterator.next(); |
652 | YangSubModule subModule = null; | 677 | YangSubModule subModule = null; |
653 | - try { | 678 | + subModule = yangInclude.addReferenceToInclude(yangNodeSet); |
654 | - subModule = yangInclude.addReferenceToInclude(yangNodeSet); | 679 | + |
655 | - } catch (DataModelException e) { | ||
656 | - throw e; | ||
657 | - } | ||
658 | // Check if the referred sub-modules parent is self | 680 | // Check if the referred sub-modules parent is self |
659 | if (!(subModule.getBelongsTo().getModuleNode() == this)) { | 681 | if (!(subModule.getBelongsTo().getModuleNode() == this)) { |
660 | yangInclude.reportIncludeError(); | 682 | yangInclude.reportIncludeError(); | ... | ... |
... | @@ -102,5 +102,15 @@ public enum YangNodeType { | ... | @@ -102,5 +102,15 @@ public enum YangNodeType { |
102 | /** | 102 | /** |
103 | * Node contains "YANG's list" information. | 103 | * Node contains "YANG's list" information. |
104 | */ | 104 | */ |
105 | - LIST_NODE | 105 | + LIST_NODE, |
106 | + | ||
107 | + /** | ||
108 | + * Identity node. | ||
109 | + */ | ||
110 | + IDENTITY_NODE, | ||
111 | + | ||
112 | + /** | ||
113 | + * Identityref node. | ||
114 | + */ | ||
115 | + IDENTITYREF_NODE | ||
106 | } | 116 | } | ... | ... |
... | @@ -214,6 +214,16 @@ public class YangSubModule | ... | @@ -214,6 +214,16 @@ public class YangSubModule |
214 | private List<YangResolutionInfo> leafrefResolutionList; | 214 | private List<YangResolutionInfo> leafrefResolutionList; |
215 | 215 | ||
216 | /** | 216 | /** |
217 | + * base resolution list. | ||
218 | + */ | ||
219 | + private List<YangResolutionInfo> baseResolutionList; | ||
220 | + | ||
221 | + /** | ||
222 | + * identityref resolution list. | ||
223 | + */ | ||
224 | + private List<YangResolutionInfo> identityrefResolutionList; | ||
225 | + | ||
226 | + /** | ||
217 | * Creates a sub module node. | 227 | * Creates a sub module node. |
218 | */ | 228 | */ |
219 | public YangSubModule() { | 229 | public YangSubModule() { |
... | @@ -222,6 +232,8 @@ public class YangSubModule | ... | @@ -222,6 +232,8 @@ public class YangSubModule |
222 | usesResolutionList = new LinkedList<>(); | 232 | usesResolutionList = new LinkedList<>(); |
223 | ifFeatureResolutionList = new LinkedList<>(); | 233 | ifFeatureResolutionList = new LinkedList<>(); |
224 | leafrefResolutionList = new LinkedList<>(); | 234 | leafrefResolutionList = new LinkedList<>(); |
235 | + baseResolutionList = new LinkedList<>(); | ||
236 | + identityrefResolutionList = new LinkedList<>(); | ||
225 | importList = new LinkedList<YangImport>(); | 237 | importList = new LinkedList<YangImport>(); |
226 | includeList = new LinkedList<YangInclude>(); | 238 | includeList = new LinkedList<YangInclude>(); |
227 | listOfLeaf = new LinkedList<YangLeaf>(); | 239 | listOfLeaf = new LinkedList<YangLeaf>(); |
... | @@ -559,8 +571,12 @@ public class YangSubModule | ... | @@ -559,8 +571,12 @@ public class YangSubModule |
559 | return usesResolutionList; | 571 | return usesResolutionList; |
560 | } else if (type == ResolvableType.YANG_IF_FEATURE) { | 572 | } else if (type == ResolvableType.YANG_IF_FEATURE) { |
561 | return ifFeatureResolutionList; | 573 | return ifFeatureResolutionList; |
562 | - } else { | 574 | + } else if (type == ResolvableType.YANG_LEAFREF) { |
563 | return leafrefResolutionList; | 575 | return leafrefResolutionList; |
576 | + } else if (type == ResolvableType.YANG_BASE) { | ||
577 | + return baseResolutionList; | ||
578 | + } else { | ||
579 | + return identityrefResolutionList; | ||
564 | } | 580 | } |
565 | } | 581 | } |
566 | 582 | ||
... | @@ -573,8 +589,12 @@ public class YangSubModule | ... | @@ -573,8 +589,12 @@ public class YangSubModule |
573 | usesResolutionList.add(resolutionInfo); | 589 | usesResolutionList.add(resolutionInfo); |
574 | } else if (type == ResolvableType.YANG_IF_FEATURE) { | 590 | } else if (type == ResolvableType.YANG_IF_FEATURE) { |
575 | ifFeatureResolutionList.add(resolutionInfo); | 591 | ifFeatureResolutionList.add(resolutionInfo); |
576 | - } else { | 592 | + } else if (type == ResolvableType.YANG_LEAFREF) { |
577 | leafrefResolutionList.add(resolutionInfo); | 593 | leafrefResolutionList.add(resolutionInfo); |
594 | + } else if (type == ResolvableType.YANG_BASE) { | ||
595 | + baseResolutionList.add(resolutionInfo); | ||
596 | + } else if (type == ResolvableType.YANG_IDENTITYREF) { | ||
597 | + identityrefResolutionList.add(resolutionInfo); | ||
578 | } | 598 | } |
579 | } | 599 | } |
580 | 600 | ||
... | @@ -589,6 +609,10 @@ public class YangSubModule | ... | @@ -589,6 +609,10 @@ public class YangSubModule |
589 | ifFeatureResolutionList.add((YangResolutionInfo) resolutionList); | 609 | ifFeatureResolutionList.add((YangResolutionInfo) resolutionList); |
590 | } else if (type == ResolvableType.YANG_LEAFREF) { | 610 | } else if (type == ResolvableType.YANG_LEAFREF) { |
591 | leafrefResolutionList = resolutionList; | 611 | leafrefResolutionList = resolutionList; |
612 | + } else if (type == ResolvableType.YANG_BASE) { | ||
613 | + baseResolutionList = resolutionList; | ||
614 | + } else if (type == ResolvableType.YANG_IDENTITYREF) { | ||
615 | + identityrefResolutionList = resolutionList; | ||
592 | } | 616 | } |
593 | 617 | ||
594 | } | 618 | } | ... | ... |
... | @@ -22,6 +22,8 @@ import java.util.Set; | ... | @@ -22,6 +22,8 @@ import java.util.Set; |
22 | import org.onosproject.yangutils.datamodel.CollisionDetector; | 22 | import org.onosproject.yangutils.datamodel.CollisionDetector; |
23 | import org.onosproject.yangutils.datamodel.ResolvableType; | 23 | import org.onosproject.yangutils.datamodel.ResolvableType; |
24 | import org.onosproject.yangutils.datamodel.YangIfFeature; | 24 | import org.onosproject.yangutils.datamodel.YangIfFeature; |
25 | +import org.onosproject.yangutils.datamodel.YangBase; | ||
26 | +import org.onosproject.yangutils.datamodel.YangIdentityRef; | ||
25 | import org.onosproject.yangutils.datamodel.YangLeaf; | 27 | import org.onosproject.yangutils.datamodel.YangLeaf; |
26 | import org.onosproject.yangutils.datamodel.YangLeafList; | 28 | import org.onosproject.yangutils.datamodel.YangLeafList; |
27 | import org.onosproject.yangutils.datamodel.YangLeafRef; | 29 | import org.onosproject.yangutils.datamodel.YangLeafRef; |
... | @@ -176,6 +178,10 @@ public final class DataModelUtils { | ... | @@ -176,6 +178,10 @@ public final class DataModelUtils { |
176 | .getEntityToResolve() instanceof YangLeafRef) { | 178 | .getEntityToResolve() instanceof YangLeafRef) { |
177 | resolutionNode.addToResolutionList(resolutionInfo, | 179 | resolutionNode.addToResolutionList(resolutionInfo, |
178 | ResolvableType.YANG_LEAFREF); | 180 | ResolvableType.YANG_LEAFREF); |
181 | + } else if (resolutionInfo.getEntityToResolveInfo().getEntityToResolve() instanceof YangBase) { | ||
182 | + resolutionNode.addToResolutionList(resolutionInfo, ResolvableType.YANG_BASE); | ||
183 | + } else if (resolutionInfo.getEntityToResolveInfo().getEntityToResolve() instanceof YangIdentityRef) { | ||
184 | + resolutionNode.addToResolutionList(resolutionInfo, ResolvableType.YANG_IDENTITYREF); | ||
179 | } | 185 | } |
180 | } | 186 | } |
181 | 187 | ... | ... |
... | @@ -19,6 +19,8 @@ import java.io.Serializable; | ... | @@ -19,6 +19,8 @@ import java.io.Serializable; |
19 | 19 | ||
20 | import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo; | 20 | import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo; |
21 | import org.onosproject.yangutils.datamodel.YangIfFeature; | 21 | import org.onosproject.yangutils.datamodel.YangIfFeature; |
22 | +import org.onosproject.yangutils.datamodel.YangBase; | ||
23 | +import org.onosproject.yangutils.datamodel.YangIdentityRef; | ||
22 | import org.onosproject.yangutils.datamodel.YangNode; | 24 | import org.onosproject.yangutils.datamodel.YangNode; |
23 | import org.onosproject.yangutils.datamodel.YangType; | 25 | import org.onosproject.yangutils.datamodel.YangType; |
24 | import org.onosproject.yangutils.datamodel.YangUses; | 26 | import org.onosproject.yangutils.datamodel.YangUses; |
... | @@ -79,6 +81,10 @@ public class YangEntityToResolveInfoImpl<T> implements YangEntityToResolveInfo<T | ... | @@ -79,6 +81,10 @@ public class YangEntityToResolveInfoImpl<T> implements YangEntityToResolveInfo<T |
79 | prefix = ((YangUses) entityToBeResolved).getPrefix(); | 81 | prefix = ((YangUses) entityToBeResolved).getPrefix(); |
80 | } else if (entityToBeResolved instanceof YangIfFeature) { | 82 | } else if (entityToBeResolved instanceof YangIfFeature) { |
81 | prefix = ((YangIfFeature) entityToBeResolved).getPrefix(); | 83 | prefix = ((YangIfFeature) entityToBeResolved).getPrefix(); |
84 | + } else if (entityToBeResolved instanceof YangBase) { | ||
85 | + prefix = ((YangBase) entityToBeResolved).getBaseIdentifier().getPrefix(); | ||
86 | + } else if (entityToBeResolved instanceof YangIdentityRef) { | ||
87 | + prefix = ((YangIdentityRef) entityToBeResolved).getBaseIdentity().getPrefix(); | ||
82 | } else { | 88 | } else { |
83 | throw new LinkerException("Linker Exception: Entity to resolved is other than type/uses"); | 89 | throw new LinkerException("Linker Exception: Entity to resolved is other than type/uses"); |
84 | } | 90 | } | ... | ... |
... | @@ -158,11 +158,16 @@ public class YangLinkerManager | ... | @@ -158,11 +158,16 @@ public class YangLinkerManager |
158 | try { | 158 | try { |
159 | ((YangReferenceResolver) yangNode) | 159 | ((YangReferenceResolver) yangNode) |
160 | .resolveInterFileLinking(ResolvableType.YANG_IF_FEATURE); | 160 | .resolveInterFileLinking(ResolvableType.YANG_IF_FEATURE); |
161 | - ((YangReferenceResolver) yangNode).resolveInterFileLinking(ResolvableType.YANG_USES); | 161 | + ((YangReferenceResolver) yangNode) |
162 | + .resolveInterFileLinking(ResolvableType.YANG_USES); | ||
162 | ((YangReferenceResolver) yangNode) | 163 | ((YangReferenceResolver) yangNode) |
163 | .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); | 164 | .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); |
164 | ((YangReferenceResolver) yangNode) | 165 | ((YangReferenceResolver) yangNode) |
165 | .resolveInterFileLinking(ResolvableType.YANG_LEAFREF); | 166 | .resolveInterFileLinking(ResolvableType.YANG_LEAFREF); |
167 | + ((YangReferenceResolver) yangNode) | ||
168 | + .resolveInterFileLinking(ResolvableType.YANG_BASE); | ||
169 | + ((YangReferenceResolver) yangNode) | ||
170 | + .resolveInterFileLinking(ResolvableType.YANG_IDENTITYREF); | ||
166 | } catch (DataModelException e) { | 171 | } catch (DataModelException e) { |
167 | String errorInfo = "Error in file: " + yangNode.getName() + " at line: " | 172 | String errorInfo = "Error in file: " + yangNode.getName() + " at line: " |
168 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE + e.getMessage(); | 173 | + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE + e.getMessage(); | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -28,6 +28,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangListener; | ... | @@ -28,6 +28,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangListener; |
28 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 28 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
29 | import org.onosproject.yangutils.parser.impl.listeners.AugmentListener; | 29 | import org.onosproject.yangutils.parser.impl.listeners.AugmentListener; |
30 | import org.onosproject.yangutils.parser.impl.listeners.BaseFileListener; | 30 | import org.onosproject.yangutils.parser.impl.listeners.BaseFileListener; |
31 | +import org.onosproject.yangutils.parser.impl.listeners.BaseListener; | ||
31 | import org.onosproject.yangutils.parser.impl.listeners.BelongsToListener; | 32 | import org.onosproject.yangutils.parser.impl.listeners.BelongsToListener; |
32 | import org.onosproject.yangutils.parser.impl.listeners.BitListener; | 33 | import org.onosproject.yangutils.parser.impl.listeners.BitListener; |
33 | import org.onosproject.yangutils.parser.impl.listeners.BitsListener; | 34 | import org.onosproject.yangutils.parser.impl.listeners.BitsListener; |
... | @@ -42,7 +43,9 @@ import org.onosproject.yangutils.parser.impl.listeners.EnumListener; | ... | @@ -42,7 +43,9 @@ import org.onosproject.yangutils.parser.impl.listeners.EnumListener; |
42 | import org.onosproject.yangutils.parser.impl.listeners.EnumerationListener; | 43 | import org.onosproject.yangutils.parser.impl.listeners.EnumerationListener; |
43 | import org.onosproject.yangutils.parser.impl.listeners.FeatureListener; | 44 | import org.onosproject.yangutils.parser.impl.listeners.FeatureListener; |
44 | import org.onosproject.yangutils.parser.impl.listeners.GroupingListener; | 45 | import org.onosproject.yangutils.parser.impl.listeners.GroupingListener; |
46 | +import org.onosproject.yangutils.parser.impl.listeners.IdentityrefListener; | ||
45 | import org.onosproject.yangutils.parser.impl.listeners.IfFeatureListener; | 47 | import org.onosproject.yangutils.parser.impl.listeners.IfFeatureListener; |
48 | +import org.onosproject.yangutils.parser.impl.listeners.IdentityListener; | ||
46 | import org.onosproject.yangutils.parser.impl.listeners.ImportListener; | 49 | import org.onosproject.yangutils.parser.impl.listeners.ImportListener; |
47 | import org.onosproject.yangutils.parser.impl.listeners.IncludeListener; | 50 | import org.onosproject.yangutils.parser.impl.listeners.IncludeListener; |
48 | import org.onosproject.yangutils.parser.impl.listeners.InputListener; | 51 | import org.onosproject.yangutils.parser.impl.listeners.InputListener; |
... | @@ -450,12 +453,12 @@ public class TreeWalkListener implements GeneratedYangListener { | ... | @@ -450,12 +453,12 @@ public class TreeWalkListener implements GeneratedYangListener { |
450 | 453 | ||
451 | @Override | 454 | @Override |
452 | public void enterIdentityStatement(GeneratedYangParser.IdentityStatementContext ctx) { | 455 | public void enterIdentityStatement(GeneratedYangParser.IdentityStatementContext ctx) { |
453 | - handleUnsupportedYangConstruct(YangConstructType.IDENTITY_DATA, ctx, CURRENTLY_UNSUPPORTED); | 456 | + IdentityListener.processIdentityEntry(this, ctx); |
454 | } | 457 | } |
455 | 458 | ||
456 | @Override | 459 | @Override |
457 | public void exitIdentityStatement(GeneratedYangParser.IdentityStatementContext ctx) { | 460 | public void exitIdentityStatement(GeneratedYangParser.IdentityStatementContext ctx) { |
458 | - // do nothing. | 461 | + IdentityListener.processIdentityExit(this, ctx); |
459 | } | 462 | } |
460 | 463 | ||
461 | @Override | 464 | @Override |
... | @@ -470,7 +473,7 @@ public class TreeWalkListener implements GeneratedYangListener { | ... | @@ -470,7 +473,7 @@ public class TreeWalkListener implements GeneratedYangListener { |
470 | 473 | ||
471 | @Override | 474 | @Override |
472 | public void enterBaseStatement(GeneratedYangParser.BaseStatementContext ctx) { | 475 | public void enterBaseStatement(GeneratedYangParser.BaseStatementContext ctx) { |
473 | - handleUnsupportedYangConstruct(YangConstructType.BASE_DATA, ctx, CURRENTLY_UNSUPPORTED); | 476 | + BaseListener.processBaseEntry(this, ctx); |
474 | } | 477 | } |
475 | 478 | ||
476 | @Override | 479 | @Override |
... | @@ -710,12 +713,12 @@ public class TreeWalkListener implements GeneratedYangListener { | ... | @@ -710,12 +713,12 @@ public class TreeWalkListener implements GeneratedYangListener { |
710 | 713 | ||
711 | @Override | 714 | @Override |
712 | public void enterIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) { | 715 | public void enterIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) { |
713 | - // do nothing. | 716 | + IdentityrefListener.processIdentityrefEntry(this, ctx); |
714 | } | 717 | } |
715 | 718 | ||
716 | @Override | 719 | @Override |
717 | public void exitIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) { | 720 | public void exitIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) { |
718 | - // do nothing. | 721 | + IdentityrefListener.processIdentityrefExit(this, ctx); |
719 | } | 722 | } |
720 | 723 | ||
721 | @Override | 724 | @Override | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.YangBase; | ||
19 | +import org.onosproject.yangutils.datamodel.YangIdentity; | ||
20 | +import org.onosproject.yangutils.datamodel.YangIdentityRef; | ||
21 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
22 | +import org.onosproject.yangutils.datamodel.YangNodeIdentifier; | ||
23 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
24 | +import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl; | ||
25 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
26 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
27 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
28 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
29 | + | ||
30 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo; | ||
31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | ||
32 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | ||
33 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | ||
34 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ||
35 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*; | ||
36 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidNodeIdentifier; | ||
37 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | ||
38 | +import static org.onosproject.yangutils.datamodel.utils.YangConstructType.BASE_DATA; | ||
39 | + | ||
40 | +/** | ||
41 | + * base-stmt = base-keyword sep identifier-ref-arg-str | ||
42 | + * optsep stmtend* | ||
43 | + * identifier-ref-arg = [prefix ":"] identifier | ||
44 | + */ | ||
45 | + | ||
46 | +/** | ||
47 | + * Represents listener based call back function corresponding to the "base" | ||
48 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
49 | + */ | ||
50 | +public final class BaseListener { | ||
51 | + | ||
52 | + //Creates a new base listener. | ||
53 | + private BaseListener() { | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Performs validation and updates the data model tree when parser receives an | ||
58 | + * input matching the grammar rule (base). | ||
59 | + * | ||
60 | + * @param listener listener's object | ||
61 | + * @param ctx context object of the grammar rule | ||
62 | + */ | ||
63 | + public static void processBaseEntry(TreeWalkListener listener, | ||
64 | + GeneratedYangParser.BaseStatementContext ctx) { | ||
65 | + | ||
66 | + // Check for stack to be non empty. | ||
67 | + checkStackIsNotEmpty(listener, MISSING_HOLDER, BASE_DATA, ctx.string().getText(), ENTRY); | ||
68 | + | ||
69 | + YangNodeIdentifier nodeIdentifier = getValidNodeIdentifier(ctx.string().getText(), BASE_DATA, ctx); | ||
70 | + | ||
71 | + Parsable tmpData = listener.getParsedDataStack().peek(); | ||
72 | + | ||
73 | + /** | ||
74 | + * For identityref base node identifier is copied in identity listener itself, so no need to process | ||
75 | + * base statement for indentityref | ||
76 | + */ | ||
77 | + if (tmpData instanceof YangIdentityRef) { | ||
78 | + return; | ||
79 | + } | ||
80 | + | ||
81 | + if (!(tmpData instanceof YangIdentity)) { | ||
82 | + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, BASE_DATA, | ||
83 | + ctx.string().getText(), ENTRY)); | ||
84 | + } | ||
85 | + | ||
86 | + YangBase yangBase = new YangBase(); | ||
87 | + yangBase.setBaseIdentifier(nodeIdentifier); | ||
88 | + ((YangIdentity) tmpData).setBaseNode(yangBase); | ||
89 | + | ||
90 | + int errorLine = ctx.getStart().getLine(); | ||
91 | + int errorPosition = ctx.getStart().getCharPositionInLine(); | ||
92 | + | ||
93 | + // Add resolution information to the list | ||
94 | + YangResolutionInfoImpl resolutionInfo = | ||
95 | + new YangResolutionInfoImpl<YangBase>(yangBase, (YangNode) tmpData, errorLine, errorPosition); | ||
96 | + addToResolutionList(resolutionInfo, ctx); | ||
97 | + } | ||
98 | + | ||
99 | + /** | ||
100 | + * Add to resolution list. | ||
101 | + * | ||
102 | + * @param resolutionInfo resolution information | ||
103 | + * @param ctx context object of the grammar rule | ||
104 | + */ | ||
105 | + private static void addToResolutionList(YangResolutionInfoImpl<YangBase> resolutionInfo, | ||
106 | + GeneratedYangParser.BaseStatementContext ctx) { | ||
107 | + | ||
108 | + try { | ||
109 | + addResolutionInfo(resolutionInfo); | ||
110 | + } catch (DataModelException e) { | ||
111 | + throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, | ||
112 | + BASE_DATA, ctx.string().getText(), EXIT, e.getMessage())); | ||
113 | + } | ||
114 | + } | ||
115 | + | ||
116 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.parser.impl.listeners; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.YangIdentity; | ||
19 | +import org.onosproject.yangutils.datamodel.YangModule; | ||
20 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
21 | +import org.onosproject.yangutils.datamodel.YangSubModule; | ||
22 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
23 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
24 | +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | ||
25 | +import org.onosproject.yangutils.parser.exceptions.ParserException; | ||
26 | +import org.onosproject.yangutils.parser.impl.TreeWalkListener; | ||
27 | + | ||
28 | +import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION; | ||
29 | +import static org.onosproject.yangutils.translator.tojava.YangDataModelFactory.getYangIdentityNode; | ||
30 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; | ||
31 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; | ||
32 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; | ||
33 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; | ||
34 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; | ||
35 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; | ||
36 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; | ||
37 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; | ||
38 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; | ||
39 | +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; | ||
40 | +import static org.onosproject.yangutils.datamodel.utils.YangConstructType.IDENTITY_DATA; | ||
41 | + | ||
42 | +/** | ||
43 | + * Reference: RFC6020 and YANG ANTLR Grammar. | ||
44 | + * | ||
45 | + * ABNF grammar as per RFC6020 | ||
46 | + * identity-stmt = identity-keyword sep identifier-arg-str optsep | ||
47 | + * (";" / | ||
48 | + * "{" stmtsep | ||
49 | + * ;; these stmts can appear in any order | ||
50 | + * [base-stmt stmtsep] | ||
51 | + * [status-stmt stmtsep] | ||
52 | + * [description-stmt stmtsep] | ||
53 | + * [reference-stmt stmtsep] | ||
54 | + * "}") | ||
55 | + */ | ||
56 | + | ||
57 | +/** | ||
58 | + * Represents listener based call back function corresponding to the "identity" | ||
59 | + * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020. | ||
60 | + */ | ||
61 | +public final class IdentityListener { | ||
62 | + | ||
63 | + //Creates a identity listener. | ||
64 | + private IdentityListener() { | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Performs validations and update the data model tree when parser receives an input | ||
69 | + * matching the grammar rule (identity). | ||
70 | + * | ||
71 | + * @param listener Listener's object | ||
72 | + * @param ctx context object of the grammar rule | ||
73 | + */ | ||
74 | + public static void processIdentityEntry(TreeWalkListener listener, | ||
75 | + GeneratedYangParser.IdentityStatementContext ctx) { | ||
76 | + | ||
77 | + // Check for stack to be non empty. | ||
78 | + checkStackIsNotEmpty(listener, MISSING_HOLDER, IDENTITY_DATA, ctx.identifier().getText(), ENTRY); | ||
79 | + | ||
80 | + String identifier = getValidIdentifier(ctx.identifier().getText(), IDENTITY_DATA, ctx); | ||
81 | + | ||
82 | + YangIdentity identity = getYangIdentityNode(JAVA_GENERATION); | ||
83 | + identity.setName(identifier); | ||
84 | + | ||
85 | + Parsable curData = listener.getParsedDataStack().peek(); | ||
86 | + if (curData instanceof YangModule || curData instanceof YangSubModule) { | ||
87 | + YangNode curNode = (YangNode) curData; | ||
88 | + try { | ||
89 | + curNode.addChild(identity); | ||
90 | + } catch (DataModelException e) { | ||
91 | + throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, | ||
92 | + IDENTITY_DATA, ctx.identifier().getText(), ENTRY, e.getMessage())); | ||
93 | + } | ||
94 | + // Push identity node to the stack. | ||
95 | + listener.getParsedDataStack().push(identity); | ||
96 | + } else { | ||
97 | + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, IDENTITY_DATA, | ||
98 | + ctx.identifier().getText(), ENTRY)); | ||
99 | + } | ||
100 | + | ||
101 | + } | ||
102 | + | ||
103 | + /** | ||
104 | + * Performs validations and update the data model tree when parser exits from grammar | ||
105 | + * rule (identity). | ||
106 | + * | ||
107 | + * @param listener Listener's object | ||
108 | + * @param ctx context object of the grammar rule | ||
109 | + */ | ||
110 | + public static void processIdentityExit(TreeWalkListener listener, | ||
111 | + GeneratedYangParser.IdentityStatementContext ctx) { | ||
112 | + | ||
113 | + // Check for stack to be non empty. | ||
114 | + checkStackIsNotEmpty(listener, MISSING_CURRENT_HOLDER, IDENTITY_DATA, ctx.identifier().getText(), EXIT); | ||
115 | + | ||
116 | + Parsable parsableType = listener.getParsedDataStack().pop(); | ||
117 | + if (!(parsableType instanceof YangIdentity)) { | ||
118 | + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, IDENTITY_DATA, | ||
119 | + ctx.identifier().getText(), EXIT)); | ||
120 | + } | ||
121 | + } | ||
122 | + | ||
123 | +} |
This diff is collapsed. Click to expand it.
... | @@ -130,6 +130,10 @@ public final class ModuleListener { | ... | @@ -130,6 +130,10 @@ public final class ModuleListener { |
130 | .peek()).resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); | 130 | .peek()).resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); |
131 | ((YangReferenceResolver) listener.getParsedDataStack() | 131 | ((YangReferenceResolver) listener.getParsedDataStack() |
132 | .peek()).resolveSelfFileLinking(ResolvableType.YANG_LEAFREF); | 132 | .peek()).resolveSelfFileLinking(ResolvableType.YANG_LEAFREF); |
133 | + ((YangReferenceResolver) listener.getParsedDataStack() | ||
134 | + .peek()).resolveSelfFileLinking(ResolvableType.YANG_BASE); | ||
135 | + ((YangReferenceResolver) listener.getParsedDataStack() | ||
136 | + .peek()).resolveSelfFileLinking(ResolvableType.YANG_IDENTITYREF); | ||
133 | } catch (DataModelException e) { | 137 | } catch (DataModelException e) { |
134 | LinkerException linkerException = new LinkerException(e.getMessage()); | 138 | LinkerException linkerException = new LinkerException(e.getMessage()); |
135 | linkerException.setLine(e.getLineNumber()); | 139 | linkerException.setLine(e.getLineNumber()); | ... | ... |
... | @@ -135,6 +135,10 @@ public final class SubModuleListener { | ... | @@ -135,6 +135,10 @@ public final class SubModuleListener { |
135 | .resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); | 135 | .resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); |
136 | ((YangReferenceResolver) listener.getParsedDataStack().peek()) | 136 | ((YangReferenceResolver) listener.getParsedDataStack().peek()) |
137 | .resolveSelfFileLinking(ResolvableType.YANG_LEAFREF); | 137 | .resolveSelfFileLinking(ResolvableType.YANG_LEAFREF); |
138 | + ((YangReferenceResolver) listener.getParsedDataStack().peek()) | ||
139 | + .resolveSelfFileLinking(ResolvableType.YANG_BASE); | ||
140 | + ((YangReferenceResolver) listener.getParsedDataStack().peek()) | ||
141 | + .resolveSelfFileLinking(ResolvableType.YANG_IDENTITYREF); | ||
138 | } catch (DataModelException e) { | 142 | } catch (DataModelException e) { |
139 | LinkerException linkerException = new LinkerException(e.getMessage()); | 143 | LinkerException linkerException = new LinkerException(e.getMessage()); |
140 | linkerException.setLine(e.getLineNumber()); | 144 | linkerException.setLine(e.getLineNumber()); | ... | ... |
... | @@ -310,7 +310,11 @@ public final class TypeListener { | ... | @@ -310,7 +310,11 @@ public final class TypeListener { |
310 | parserException = new ParserException("YANG file error : a type leafref" + | 310 | parserException = new ParserException("YANG file error : a type leafref" + |
311 | " must have one path statement."); | 311 | " must have one path statement."); |
312 | break; | 312 | break; |
313 | - // TODO : decimal64, identity ref | 313 | + case IDENTITYREF: |
314 | + parserException = new ParserException("YANG file error : a type identityref" + | ||
315 | + " must have base statement."); | ||
316 | + break; | ||
317 | + // TODO : decimal64, | ||
314 | default: | 318 | default: |
315 | return; | 319 | return; |
316 | } | 320 | } | ... | ... |
... | @@ -48,10 +48,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.CHAR_OF_SLASH; | ... | @@ -48,10 +48,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.CHAR_OF_SLASH; |
48 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | 48 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; |
49 | import static org.onosproject.yangutils.utils.UtilConstants.COLON; | 49 | import static org.onosproject.yangutils.utils.UtilConstants.COLON; |
50 | import static org.onosproject.yangutils.utils.UtilConstants.CURRENT; | 50 | import static org.onosproject.yangutils.utils.UtilConstants.CURRENT; |
51 | -import static org.onosproject.yangutils.utils.UtilConstants.CURRENTLY_UNSUPPORTED; | ||
52 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | 51 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
53 | import static org.onosproject.yangutils.utils.UtilConstants.FALSE; | 52 | import static org.onosproject.yangutils.utils.UtilConstants.FALSE; |
54 | -import static org.onosproject.yangutils.utils.UtilConstants.IDENTITYREF; | ||
55 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_SQUARE_BRACKET; | 53 | import static org.onosproject.yangutils.utils.UtilConstants.OPEN_SQUARE_BRACKET; |
56 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; | 54 | import static org.onosproject.yangutils.utils.UtilConstants.QUOTES; |
57 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 55 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
... | @@ -341,7 +339,6 @@ public final class ListenerUtil { | ... | @@ -341,7 +339,6 @@ public final class ListenerUtil { |
341 | String[] tmpData = tmpIdentifierString.split(Pattern.quote(COLON)); | 339 | String[] tmpData = tmpIdentifierString.split(Pattern.quote(COLON)); |
342 | if (tmpData.length == 1) { | 340 | if (tmpData.length == 1) { |
343 | YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier(); | 341 | YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier(); |
344 | - checkForUnsupportedTypes(tmpData[0], yangConstruct, ctx); | ||
345 | nodeIdentifier.setName(getValidIdentifier(tmpData[0], yangConstruct, ctx)); | 342 | nodeIdentifier.setName(getValidIdentifier(tmpData[0], yangConstruct, ctx)); |
346 | return nodeIdentifier; | 343 | return nodeIdentifier; |
347 | } else if (tmpData.length == 2) { | 344 | } else if (tmpData.length == 2) { |
... | @@ -375,7 +372,6 @@ public final class ListenerUtil { | ... | @@ -375,7 +372,6 @@ public final class ListenerUtil { |
375 | String[] tmpData = tmpIdentifierString.split(Pattern.quote(COLON)); | 372 | String[] tmpData = tmpIdentifierString.split(Pattern.quote(COLON)); |
376 | if (tmpData.length == 1) { | 373 | if (tmpData.length == 1) { |
377 | YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier(); | 374 | YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier(); |
378 | - checkForUnsupportedTypes(tmpData[0], yangConstruct, ctx); | ||
379 | nodeIdentifier.setName(getValidIdentifierForLeafref(tmpData[0], yangConstruct, ctx, yangLeafRef)); | 375 | nodeIdentifier.setName(getValidIdentifierForLeafref(tmpData[0], yangConstruct, ctx, yangLeafRef)); |
380 | return nodeIdentifier; | 376 | return nodeIdentifier; |
381 | } else if (tmpData.length == 2) { | 377 | } else if (tmpData.length == 2) { |
... | @@ -706,24 +702,6 @@ public final class ListenerUtil { | ... | @@ -706,24 +702,6 @@ public final class ListenerUtil { |
706 | } | 702 | } |
707 | 703 | ||
708 | /** | 704 | /** |
709 | - * Checks whether the type is an unsupported type. | ||
710 | - * | ||
711 | - * @param typeName name of the type | ||
712 | - * @param yangConstruct yang construct to check if it is type | ||
713 | - * @param ctx yang construct's context to get the line number and character position | ||
714 | - */ | ||
715 | - private static void checkForUnsupportedTypes(String typeName, | ||
716 | - YangConstructType yangConstruct, ParserRuleContext ctx) { | ||
717 | - | ||
718 | - if (yangConstruct == YangConstructType.TYPE_DATA) { | ||
719 | - if (typeName.equalsIgnoreCase(IDENTITYREF)) { | ||
720 | - handleUnsupportedYangConstruct(YangConstructType.IDENTITYREF_DATA, | ||
721 | - ctx, CURRENTLY_UNSUPPORTED); | ||
722 | - } | ||
723 | - } | ||
724 | - } | ||
725 | - | ||
726 | - /** | ||
727 | * Checks and return valid absolute schema node id. | 705 | * Checks and return valid absolute schema node id. |
728 | * | 706 | * |
729 | * @param argumentString string from yang file | 707 | * @param argumentString string from yang file | ... | ... |
... | @@ -89,6 +89,11 @@ public final class GeneratedJavaFileType { | ... | @@ -89,6 +89,11 @@ public final class GeneratedJavaFileType { |
89 | public static final int GENERATE_EVENT_SUBJECT_CLASS = 1024; | 89 | public static final int GENERATE_EVENT_SUBJECT_CLASS = 1024; |
90 | 90 | ||
91 | /** | 91 | /** |
92 | + * Identity listener class. | ||
93 | + */ | ||
94 | + public static final int GENERATE_IDENTITY_CLASS = 2048; | ||
95 | + | ||
96 | + /** | ||
92 | * Creates an instance of generate java file type. | 97 | * Creates an instance of generate java file type. |
93 | */ | 98 | */ |
94 | private GeneratedJavaFileType() { | 99 | private GeneratedJavaFileType() { | ... | ... |
... | @@ -20,6 +20,7 @@ import org.onosproject.yangutils.datamodel.YangCase; | ... | @@ -20,6 +20,7 @@ import org.onosproject.yangutils.datamodel.YangCase; |
20 | import org.onosproject.yangutils.datamodel.YangChoice; | 20 | import org.onosproject.yangutils.datamodel.YangChoice; |
21 | import org.onosproject.yangutils.datamodel.YangContainer; | 21 | import org.onosproject.yangutils.datamodel.YangContainer; |
22 | import org.onosproject.yangutils.datamodel.YangGrouping; | 22 | import org.onosproject.yangutils.datamodel.YangGrouping; |
23 | +import org.onosproject.yangutils.datamodel.YangIdentity; | ||
23 | import org.onosproject.yangutils.datamodel.YangInput; | 24 | import org.onosproject.yangutils.datamodel.YangInput; |
24 | import org.onosproject.yangutils.datamodel.YangLeaf; | 25 | import org.onosproject.yangutils.datamodel.YangLeaf; |
25 | import org.onosproject.yangutils.datamodel.YangLeafList; | 26 | import org.onosproject.yangutils.datamodel.YangLeafList; |
... | @@ -41,6 +42,7 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice; | ... | @@ -41,6 +42,7 @@ import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice; |
41 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer; | 42 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer; |
42 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration; | 43 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration; |
43 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; | 44 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping; |
45 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaIdentity; | ||
44 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput; | 46 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput; |
45 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeaf; | 47 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeaf; |
46 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeafList; | 48 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeafList; |
... | @@ -163,6 +165,24 @@ public final class YangDataModelFactory { | ... | @@ -163,6 +165,24 @@ public final class YangDataModelFactory { |
163 | * generated | 165 | * generated |
164 | * @return the corresponding inherited node based on the target language | 166 | * @return the corresponding inherited node based on the target language |
165 | */ | 167 | */ |
168 | + public static YangIdentity getYangIdentityNode(GeneratedLanguage targetLanguage) { | ||
169 | + switch (targetLanguage) { | ||
170 | + case JAVA_GENERATION: { | ||
171 | + return new YangJavaIdentity(); | ||
172 | + } | ||
173 | + default: { | ||
174 | + throw new TranslatorException("Only YANG to Java is supported."); | ||
175 | + } | ||
176 | + } | ||
177 | + } | ||
178 | + | ||
179 | + /** | ||
180 | + * Returns based on the target language generate the inherited data model node. | ||
181 | + * | ||
182 | + * @param targetLanguage target language in which YANG mapping needs to be | ||
183 | + * generated | ||
184 | + * @return the corresponding inherited node based on the target language | ||
185 | + */ | ||
166 | public static YangGrouping getYangGroupingNode(GeneratedLanguage targetLanguage) { | 186 | public static YangGrouping getYangGroupingNode(GeneratedLanguage targetLanguage) { |
167 | switch (targetLanguage) { | 187 | switch (targetLanguage) { |
168 | case JAVA_GENERATION: { | 188 | case JAVA_GENERATION: { | ... | ... |
... | @@ -20,7 +20,9 @@ import java.util.Stack; | ... | @@ -20,7 +20,9 @@ import java.util.Stack; |
20 | 20 | ||
21 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; | 21 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; |
22 | import org.onosproject.yangutils.datamodel.YangEnumeration; | 22 | import org.onosproject.yangutils.datamodel.YangEnumeration; |
23 | +import org.onosproject.yangutils.datamodel.YangIdentity; | ||
23 | import org.onosproject.yangutils.datamodel.YangLeafRef; | 24 | import org.onosproject.yangutils.datamodel.YangLeafRef; |
25 | +import org.onosproject.yangutils.datamodel.YangIdentityRef; | ||
24 | import org.onosproject.yangutils.datamodel.YangNode; | 26 | import org.onosproject.yangutils.datamodel.YangNode; |
25 | import org.onosproject.yangutils.datamodel.YangType; | 27 | import org.onosproject.yangutils.datamodel.YangType; |
26 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 28 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
... | @@ -161,8 +163,10 @@ public final class AttributesJavaDataType { | ... | @@ -161,8 +163,10 @@ public final class AttributesJavaDataType { |
161 | YangType<?> referredType = getReferredTypeFromLeafref(yangType); | 163 | YangType<?> referredType = getReferredTypeFromLeafref(yangType); |
162 | return getJavaImportClass(referredType, isListAttr, pluginConfig); | 164 | return getJavaImportClass(referredType, isListAttr, pluginConfig); |
163 | case IDENTITYREF: | 165 | case IDENTITYREF: |
164 | - //TODO:IDENTITYREF | 166 | + YangIdentityRef identityRef = (YangIdentityRef) yangType.getDataTypeExtendedInfo(); |
165 | - break; | 167 | + YangIdentity identity = identityRef.getReferredIdentity(); |
168 | + return getCapitalCase(getCamelCase(((YangJavaIdentity) identity). | ||
169 | + getName(), pluginConfig)); | ||
166 | case EMPTY: | 170 | case EMPTY: |
167 | return BOOLEAN_WRAPPER; | 171 | return BOOLEAN_WRAPPER; |
168 | case UNION: | 172 | case UNION: |
... | @@ -196,8 +200,9 @@ public final class AttributesJavaDataType { | ... | @@ -196,8 +200,9 @@ public final class AttributesJavaDataType { |
196 | YangType<?> referredType = getReferredTypeFromLeafref(yangType); | 200 | YangType<?> referredType = getReferredTypeFromLeafref(yangType); |
197 | return getJavaImportClass(referredType, isListAttr, pluginConfig); | 201 | return getJavaImportClass(referredType, isListAttr, pluginConfig); |
198 | case IDENTITYREF: | 202 | case IDENTITYREF: |
199 | - //TODO:IDENTITYREF | 203 | + YangIdentityRef identityRef = (YangIdentityRef) yangType.getDataTypeExtendedInfo(); |
200 | - break; | 204 | + YangIdentity identity = identityRef.getReferredIdentity(); |
205 | + return getCapitalCase(getCamelCase(((YangJavaIdentity) identity).getName(), pluginConfig)); | ||
201 | case EMPTY: | 206 | case EMPTY: |
202 | return BOOLEAN_DATA_TYPE; | 207 | return BOOLEAN_DATA_TYPE; |
203 | case UNION: | 208 | case UNION: |
... | @@ -212,7 +217,6 @@ public final class AttributesJavaDataType { | ... | @@ -212,7 +217,6 @@ public final class AttributesJavaDataType { |
212 | return null; | 217 | return null; |
213 | } | 218 | } |
214 | } | 219 | } |
215 | - return null; | ||
216 | } | 220 | } |
217 | 221 | ||
218 | /** | 222 | /** |
... | @@ -253,8 +257,7 @@ public final class AttributesJavaDataType { | ... | @@ -253,8 +257,7 @@ public final class AttributesJavaDataType { |
253 | YangType<?> referredType = getReferredTypeFromLeafref(yangType); | 257 | YangType<?> referredType = getReferredTypeFromLeafref(yangType); |
254 | return getJavaImportPackage(referredType, isListAttr, conflictResolver); | 258 | return getJavaImportPackage(referredType, isListAttr, conflictResolver); |
255 | case IDENTITYREF: | 259 | case IDENTITYREF: |
256 | - //TODO:IDENTITYREF | 260 | + return getIdentityRefPackage(yangType, conflictResolver); |
257 | - break; | ||
258 | case UNION: | 261 | case UNION: |
259 | return getUnionPackage(yangType, conflictResolver); | 262 | return getUnionPackage(yangType, conflictResolver); |
260 | case INSTANCE_IDENTIFIER: | 263 | case INSTANCE_IDENTIFIER: |
... | @@ -280,8 +283,7 @@ public final class AttributesJavaDataType { | ... | @@ -280,8 +283,7 @@ public final class AttributesJavaDataType { |
280 | YangType<?> referredType = getReferredTypeFromLeafref(yangType); | 283 | YangType<?> referredType = getReferredTypeFromLeafref(yangType); |
281 | return getJavaImportPackage(referredType, isListAttr, conflictResolver); | 284 | return getJavaImportPackage(referredType, isListAttr, conflictResolver); |
282 | case IDENTITYREF: | 285 | case IDENTITYREF: |
283 | - //TODO:IDENTITYREF | 286 | + return getIdentityRefPackage(yangType, conflictResolver); |
284 | - break; | ||
285 | case EMPTY: | 287 | case EMPTY: |
286 | return JAVA_LANG; | 288 | return JAVA_LANG; |
287 | case UNION: | 289 | case UNION: |
... | @@ -294,7 +296,6 @@ public final class AttributesJavaDataType { | ... | @@ -294,7 +296,6 @@ public final class AttributesJavaDataType { |
294 | return null; | 296 | return null; |
295 | } | 297 | } |
296 | } | 298 | } |
297 | - return null; | ||
298 | } | 299 | } |
299 | 300 | ||
300 | /** | 301 | /** |
... | @@ -361,6 +362,25 @@ public final class AttributesJavaDataType { | ... | @@ -361,6 +362,25 @@ public final class AttributesJavaDataType { |
361 | } | 362 | } |
362 | 363 | ||
363 | /** | 364 | /** |
365 | + * Returns YANG identity's java package. | ||
366 | + * | ||
367 | + * @param type YANG type | ||
368 | + * @param conflictResolver object of YANG to java naming conflict util | ||
369 | + * @return YANG identity's java package | ||
370 | + */ | ||
371 | + private static String getIdentityRefPackage(YangType<?> type, YangToJavaNamingConflictUtil conflictResolver) { | ||
372 | + | ||
373 | + if (!(type.getDataTypeExtendedInfo() instanceof YangIdentityRef)) { | ||
374 | + throw new TranslatorException("type should have been identityref."); | ||
375 | + } | ||
376 | + YangIdentityRef identityRef = (YangIdentityRef) type.getDataTypeExtendedInfo(); | ||
377 | + YangJavaIdentity identity = (YangJavaIdentity) (identityRef.getReferredIdentity()); | ||
378 | + if (identity.getJavaFileInfo().getPackage() == null) { | ||
379 | + return getPackageFromParent(identity.getParent(), conflictResolver); | ||
380 | + } | ||
381 | + return identity.getJavaFileInfo().getPackage(); | ||
382 | + } | ||
383 | + /** | ||
364 | * Returns package from parent node. | 384 | * Returns package from parent node. |
365 | * | 385 | * |
366 | * @param parent parent YANG node | 386 | * @param parent parent YANG node | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.yangutils.translator.tojava.javamodel; | ||
17 | + | ||
18 | +import org.onosproject.yangutils.datamodel.YangIdentity; | ||
19 | +import org.onosproject.yangutils.translator.exception.TranslatorException; | ||
20 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | ||
21 | +import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | ||
22 | +import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ||
23 | +import org.onosproject.yangutils.translator.tojava.JavaImportData; | ||
24 | +import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | ||
25 | +import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | ||
26 | +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | ||
27 | + | ||
28 | +import java.io.File; | ||
29 | +import java.io.IOException; | ||
30 | +import java.util.List; | ||
31 | + | ||
32 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; | ||
33 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS; | ||
34 | +import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo; | ||
35 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; | ||
36 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; | ||
37 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; | ||
38 | +import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; | ||
39 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
40 | + | ||
41 | +/** | ||
42 | + * Represents input information extended to support java code generation. | ||
43 | + */ | ||
44 | +public class YangJavaIdentity extends YangIdentity | ||
45 | + implements JavaCodeGeneratorInfo, JavaCodeGenerator { | ||
46 | + | ||
47 | + //File type extension for java classes. | ||
48 | + private static final String JAVA_FILE_EXTENSION = ".java"; | ||
49 | + | ||
50 | + | ||
51 | + //Contains the information of the java file being generated. | ||
52 | + private JavaFileInfo javaFileInfo; | ||
53 | + | ||
54 | + //Contains the information of the importd. | ||
55 | + private transient JavaImportData importData; | ||
56 | + | ||
57 | + /** | ||
58 | + * File handle to maintain temporary java code fragments as per the code | ||
59 | + * snippet types. | ||
60 | + */ | ||
61 | + private TempJavaCodeFragmentFiles tempFileHandle; | ||
62 | + | ||
63 | + /** | ||
64 | + * Creates YANG java container object. | ||
65 | + */ | ||
66 | + public YangJavaIdentity() { | ||
67 | + setJavaFileInfo(new JavaFileInfo()); | ||
68 | + getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); | ||
69 | + importData = new JavaImportData(); | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * Returns the generated java file information. | ||
74 | + * | ||
75 | + * @return generated java file information | ||
76 | + */ | ||
77 | + @Override | ||
78 | + public JavaFileInfo getJavaFileInfo() { | ||
79 | + if (javaFileInfo == null) { | ||
80 | + throw new TranslatorException("Missing java info in java datamodel node"); | ||
81 | + } | ||
82 | + return javaFileInfo; | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Sets the java file info object. | ||
87 | + * | ||
88 | + * @param javaInfo java file info object | ||
89 | + */ | ||
90 | + @Override | ||
91 | + public void setJavaFileInfo(JavaFileInfo javaInfo) { | ||
92 | + javaFileInfo = javaInfo; | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Returns the temporary file handle. | ||
97 | + * | ||
98 | + * @return temporary file handle | ||
99 | + */ | ||
100 | + @Override | ||
101 | + public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() { | ||
102 | + return tempFileHandle; | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * Sets temporary file handle. | ||
107 | + * | ||
108 | + * @param fileHandle temporary file handle | ||
109 | + */ | ||
110 | + @Override | ||
111 | + public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) { | ||
112 | + tempFileHandle = fileHandle; | ||
113 | + } | ||
114 | + | ||
115 | + /** | ||
116 | + * Prepare the information for java code generation corresponding to YANG | ||
117 | + * container info. | ||
118 | + * | ||
119 | + * @param yangPlugin YANG plugin config | ||
120 | + * @throws TranslatorException translator operation fail | ||
121 | + */ | ||
122 | + @Override | ||
123 | + public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { | ||
124 | + try { | ||
125 | + updatePackageInfo(this, yangPlugin); | ||
126 | + JavaQualifiedTypeInfo basePkgInfo = new JavaQualifiedTypeInfo(); | ||
127 | + String className = getCapitalCase(getJavaFileInfo().getJavaName()); | ||
128 | + String path = getJavaFileInfo().getPackageFilePath(); | ||
129 | + createPackage(this); | ||
130 | + List<String> imports = null; | ||
131 | + boolean isQualified = false; | ||
132 | + | ||
133 | + if (getBaseNode() != null && getBaseNode().getReferredIdentity() != null) { | ||
134 | + if (!(getBaseNode().getReferredIdentity() instanceof YangJavaIdentity)) { | ||
135 | + throw new TranslatorException("Failed to prepare generate code entry for base node"); | ||
136 | + } | ||
137 | + YangJavaIdentity baseIdentity = (YangJavaIdentity) getBaseNode().getReferredIdentity(); | ||
138 | + String baseClassName = getCapitalCase(baseIdentity.getJavaFileInfo().getJavaName()); | ||
139 | + String basePkg = baseIdentity.getJavaFileInfo().getPackage(); | ||
140 | + basePkgInfo.setClassInfo(baseClassName); | ||
141 | + basePkgInfo.setPkgInfo(basePkg); | ||
142 | + isQualified = importData.addImportInfo(basePkgInfo, className, getJavaFileInfo().getPackage()); | ||
143 | + if (!isQualified) { | ||
144 | + imports = importData.getImports(); | ||
145 | + } | ||
146 | + } | ||
147 | + | ||
148 | + File file = getFileObject(path, className, JAVA_FILE_EXTENSION, getJavaFileInfo()); | ||
149 | + | ||
150 | + initiateJavaFileGeneration(file, GENERATE_IDENTITY_CLASS, imports, this, className); | ||
151 | + closeFile(file, false); | ||
152 | + } catch (IOException e) { | ||
153 | + throw new TranslatorException( | ||
154 | + "Failed to prepare generate code entry for identity node " + this.getName()); | ||
155 | + } | ||
156 | + } | ||
157 | + | ||
158 | + /** | ||
159 | + * Create a java file using the YANG container info. | ||
160 | + * | ||
161 | + * @throws TranslatorException translator operation fail | ||
162 | + */ | ||
163 | + @Override | ||
164 | + public void generateCodeExit() throws TranslatorException { | ||
165 | + /* Do nothing, file is already generated in entry*/ | ||
166 | + } | ||
167 | +} | ||
168 | + |
... | @@ -16,10 +16,13 @@ | ... | @@ -16,10 +16,13 @@ |
16 | 16 | ||
17 | package org.onosproject.yangutils.translator.tojava.utils; | 17 | package org.onosproject.yangutils.translator.tojava.utils; |
18 | 18 | ||
19 | +import org.onosproject.yangutils.datamodel.YangIdentity; | ||
19 | import org.onosproject.yangutils.datamodel.YangNode; | 20 | import org.onosproject.yangutils.datamodel.YangNode; |
20 | import org.onosproject.yangutils.datamodel.YangNotification; | 21 | import org.onosproject.yangutils.datamodel.YangNotification; |
22 | +import org.onosproject.yangutils.translator.exception.TranslatorException; | ||
21 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; | 23 | import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; |
22 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; |
25 | +import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaIdentity; | ||
23 | 26 | ||
24 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; | 27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
25 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; | 28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; |
... | @@ -27,6 +30,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -27,6 +30,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
27 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; | 30 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; |
28 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; | 31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; |
29 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; | 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
33 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS; | ||
30 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; | 35 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; |
32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; | 36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; |
... | @@ -57,6 +61,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING | ... | @@ -57,6 +61,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_ANY_STRING |
57 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; | 61 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; |
58 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; | 62 | import static org.onosproject.yangutils.utils.UtilConstants.SPACE; |
59 | import static org.onosproject.yangutils.utils.UtilConstants.SUBJECT; | 63 | import static org.onosproject.yangutils.utils.UtilConstants.SUBJECT; |
64 | +import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT; | ||
65 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
60 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | 66 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; |
61 | 67 | ||
62 | /** | 68 | /** |
... | @@ -128,6 +134,8 @@ public final class ClassDefinitionGenerator { | ... | @@ -128,6 +134,8 @@ public final class ClassDefinitionGenerator { |
128 | return getEventListenerDefinition(yangName); | 134 | return getEventListenerDefinition(yangName); |
129 | case GENERATE_EVENT_SUBJECT_CLASS: | 135 | case GENERATE_EVENT_SUBJECT_CLASS: |
130 | return getClassDefinition(yangName); | 136 | return getClassDefinition(yangName); |
137 | + case GENERATE_IDENTITY_CLASS: | ||
138 | + return getIdentityClassDefinition(yangName, curNode); | ||
131 | default: | 139 | default: |
132 | return null; | 140 | return null; |
133 | } | 141 | } |
... | @@ -214,6 +222,32 @@ public final class ClassDefinitionGenerator { | ... | @@ -214,6 +222,32 @@ public final class ClassDefinitionGenerator { |
214 | } | 222 | } |
215 | 223 | ||
216 | /** | 224 | /** |
225 | + * Returns implementation file identity class definition. | ||
226 | + * | ||
227 | + * @param yangName file name | ||
228 | + * @return identity class definition | ||
229 | + */ | ||
230 | + private static String getIdentityClassDefinition(String yangName, YangNode curNode) { | ||
231 | + if (!(curNode instanceof YangJavaIdentity)) { | ||
232 | + throw new TranslatorException("Expected java identity instance node"); | ||
233 | + } | ||
234 | + YangJavaIdentity identity = (YangJavaIdentity) curNode; | ||
235 | + if (identity.getBaseNode() != null) { | ||
236 | + YangIdentity baseIdentity = identity.getBaseNode().getReferredIdentity(); | ||
237 | + if (!(baseIdentity instanceof YangJavaIdentity)) { | ||
238 | + throw new TranslatorException("Expected java identity instance node"); | ||
239 | + } | ||
240 | + | ||
241 | + YangJavaIdentity baseJavaIdentity = (YangJavaIdentity) baseIdentity; | ||
242 | + return PUBLIC + SPACE + ABSTRACT + SPACE + CLASS + SPACE + yangName + SPACE + EXTEND + SPACE | ||
243 | + + getCapitalCase(baseJavaIdentity.getJavaFileInfo().getJavaName()) + SPACE + | ||
244 | + OPEN_CURLY_BRACKET + NEW_LINE; | ||
245 | + } | ||
246 | + | ||
247 | + return PUBLIC + SPACE + ABSTRACT + SPACE + CLASS + SPACE + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE; | ||
248 | + } | ||
249 | + | ||
250 | + /** | ||
217 | * Returns type file class definition. | 251 | * Returns type file class definition. |
218 | * | 252 | * |
219 | * @param yangName file name | 253 | * @param yangName file name | ... | ... |
... | @@ -42,6 +42,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. | ... | @@ -42,6 +42,7 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. |
42 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; | 42 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
43 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; | 43 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; |
44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; | 44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; |
45 | +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS; | ||
45 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; | 46 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; |
46 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; | 47 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
47 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; | 48 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; |
... | @@ -68,6 +69,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionG | ... | @@ -68,6 +69,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionG |
68 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; | 69 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; |
69 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | 70 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; |
70 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; | 71 | import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS; |
72 | +import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; | ||
71 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION; | 73 | import static org.onosproject.yangutils.utils.UtilConstants.COMPONENT_ANNOTATION; |
72 | import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; | 74 | import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; |
73 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; | 75 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
... | @@ -294,6 +296,7 @@ public final class JavaFileGeneratorUtils { | ... | @@ -294,6 +296,7 @@ public final class JavaFileGeneratorUtils { |
294 | } | 296 | } |
295 | 297 | ||
296 | file.createNewFile(); | 298 | file.createNewFile(); |
299 | + | ||
297 | appendContents(file, genType, imports, curNode, className); | 300 | appendContents(file, genType, imports, curNode, className); |
298 | } catch (IOException e) { | 301 | } catch (IOException e) { |
299 | throw new IOException("Failed to create " + file.getName() + " class file."); | 302 | throw new IOException("Failed to create " + file.getName() + " class file."); |
... | @@ -348,6 +351,11 @@ public final class JavaFileGeneratorUtils { | ... | @@ -348,6 +351,11 @@ public final class JavaFileGeneratorUtils { |
348 | appendHeaderContents(file, pkgString, importsList); | 351 | appendHeaderContents(file, pkgString, importsList); |
349 | write(file, genType, EVENT_SUBJECT_CLASS, curNode, className); | 352 | write(file, genType, EVENT_SUBJECT_CLASS, curNode, className); |
350 | break; | 353 | break; |
354 | + case GENERATE_IDENTITY_CLASS: | ||
355 | + appendHeaderContents(file, pkgString, importsList); | ||
356 | + write(file, genType, EVENT_SUBJECT_CLASS, curNode, className); | ||
357 | + insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET); | ||
358 | + break; | ||
351 | default: | 359 | default: |
352 | break; | 360 | break; |
353 | } | 361 | } | ... | ... |
... | @@ -647,6 +647,11 @@ public final class UtilConstants { | ... | @@ -647,6 +647,11 @@ public final class UtilConstants { |
647 | public static final String PUBLIC = "public"; | 647 | public static final String PUBLIC = "public"; |
648 | 648 | ||
649 | /** | 649 | /** |
650 | + * Static attribute for abstract modifier. | ||
651 | + */ | ||
652 | + public static final String ABSTRACT = "abstract"; | ||
653 | + | ||
654 | + /** | ||
650 | * Static attribute for protected modifier. | 655 | * Static attribute for protected modifier. |
651 | */ | 656 | */ |
652 | public static final String PROTECTED = "protected"; | 657 | public static final String PROTECTED = "protected"; |
... | @@ -1196,6 +1201,18 @@ public final class UtilConstants { | ... | @@ -1196,6 +1201,18 @@ public final class UtilConstants { |
1196 | + "leaf/leaf-list for given leafref"; | 1201 | + "leaf/leaf-list for given leafref"; |
1197 | 1202 | ||
1198 | /** | 1203 | /** |
1204 | + * Static attribute for base linker error information. | ||
1205 | + */ | ||
1206 | + public static final String BASE_LINKER_ERROR = "YANG file error: Unable to find base " | ||
1207 | + + "identity for given base"; | ||
1208 | + | ||
1209 | + /** | ||
1210 | + * Static attribute for identityref linker error information. | ||
1211 | + */ | ||
1212 | + public static final String IDENTITYREF_LINKER_ERROR = "YANG file error: Unable to find base " | ||
1213 | + + "identity for given base"; | ||
1214 | + | ||
1215 | + /** | ||
1199 | * Static attribute for reference. | 1216 | * Static attribute for reference. |
1200 | */ | 1217 | */ |
1201 | public static final String REFERENCE = "Reference"; | 1218 | public static final String REFERENCE = "Reference"; | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -122,20 +122,6 @@ public class TypeListenerTest { | ... | @@ -122,20 +122,6 @@ public class TypeListenerTest { |
122 | } | 122 | } |
123 | 123 | ||
124 | /** | 124 | /** |
125 | - * Checks for unsupported type identityref. | ||
126 | - */ | ||
127 | - @Test | ||
128 | - public void processIdentityrefType() throws IOException, ParserException { | ||
129 | - | ||
130 | - thrown.expect(ParserException.class); | ||
131 | - thrown.expectMessage("YANG file error : \"identityref\" is not supported in current version," | ||
132 | - + " please check wiki for YANG utils road map."); | ||
133 | - | ||
134 | - YangNode node = manager | ||
135 | - .getDataModel("src/test/resources/IdentityrefInvalidIdentifier.yang"); | ||
136 | - } | ||
137 | - | ||
138 | - /** | ||
139 | * Checks for type instance-identifier. | 125 | * Checks for type instance-identifier. |
140 | */ | 126 | */ |
141 | @Test | 127 | @Test | ... | ... |
This diff is collapsed. Click to expand it.
1 | +module IdentityInModule{ | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix IdentityInModule; | ||
5 | + | ||
6 | + identity tunnel-type { | ||
7 | + description | ||
8 | + "Base identity from which specific tunnel types are derived."; | ||
9 | + } | ||
10 | + | ||
11 | + identity ref-address-family { | ||
12 | + reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2"; | ||
13 | + } | ||
14 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +module IdentityIntraFile { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix IdentityIntraFile; | ||
5 | + | ||
6 | + import "IdentityInModule" { | ||
7 | + prefix "IdentityInModule"; | ||
8 | + } | ||
9 | + | ||
10 | + identity ipv4-address-family { | ||
11 | + base IdentityInModule:ref-address-family; | ||
12 | + } | ||
13 | + | ||
14 | + identity ipv6-address-family { | ||
15 | + base IdentityInModule:ref-address-family; | ||
16 | + } | ||
17 | + | ||
18 | + leaf tunnel { | ||
19 | + type identityref { | ||
20 | + base IdentityInModule:ref-address-family; | ||
21 | + } | ||
22 | + } | ||
23 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +module IdentityListener{ | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix IdentityListener; | ||
5 | + | ||
6 | + identity tunnel { | ||
7 | + description | ||
8 | + "Base identity from which specific tunnel types are derived."; | ||
9 | + } | ||
10 | + | ||
11 | + identity tunnel-type { | ||
12 | + description | ||
13 | + "Base identity from which specific tunnel types are derived."; | ||
14 | + } | ||
15 | + | ||
16 | + identity ref-address-family { | ||
17 | + reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2"; | ||
18 | + } | ||
19 | + | ||
20 | + identity ipv4-address-family { | ||
21 | + base ref-address-family; | ||
22 | + } | ||
23 | + | ||
24 | + identity ipv6-address-family { | ||
25 | + base ref-address-family; | ||
26 | + } | ||
27 | + | ||
28 | + leaf tunnel { | ||
29 | + type identityref { | ||
30 | + base ref-address-family; | ||
31 | + } | ||
32 | + } | ||
33 | + | ||
34 | + leaf-list network-ref { | ||
35 | + type identityref { | ||
36 | + base ref-address-family; | ||
37 | + } | ||
38 | + } | ||
39 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +module Test { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix Ant; | ||
5 | + | ||
6 | + identity tunnel { | ||
7 | + description | ||
8 | + "Base identity from which specific tunnel types are derived."; | ||
9 | + } | ||
10 | + | ||
11 | + leaf tunnel-value { | ||
12 | + type type15; | ||
13 | + } | ||
14 | + | ||
15 | + typedef type15 { | ||
16 | + type identityref { | ||
17 | + base tunnel; | ||
18 | + } | ||
19 | + } | ||
20 | +} |
... | @@ -2,10 +2,15 @@ module Test { | ... | @@ -2,10 +2,15 @@ module Test { |
2 | yang-version 1; | 2 | yang-version 1; |
3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
4 | prefix Ant; | 4 | prefix Ant; |
5 | - grouping currentcheck { | 5 | + |
6 | - leaf invalid-interval { | 6 | + identity tunnel { |
7 | - type identityref { | 7 | + description |
8 | - } | 8 | + "Base identity from which specific tunnel types are derived."; |
9 | - } | 9 | + } |
10 | + | ||
11 | + typedef type15 { | ||
12 | + type identityref { | ||
13 | + base tunnel; | ||
14 | + } | ||
10 | } | 15 | } |
11 | } | 16 | } | ... | ... |
1 | +module IdentityTest{ | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix IdentityTest; | ||
5 | + | ||
6 | + identity ref-address-family { | ||
7 | + description "ref-address-family"; | ||
8 | + } | ||
9 | + | ||
10 | + identity ipv4-address-family { | ||
11 | + base ref-address-family; | ||
12 | + } | ||
13 | + | ||
14 | + leaf tunnel { | ||
15 | + type identityref { | ||
16 | + base ref-address-family; | ||
17 | + } | ||
18 | + } | ||
19 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | + | ||
2 | +module IdentityInModule{ | ||
3 | + yang-version 1; | ||
4 | + namespace http://huawei.com; | ||
5 | + prefix IdentityInModule; | ||
6 | + | ||
7 | + identity tunnel-type { | ||
8 | + description | ||
9 | + "Base identity from which specific tunnel types are derived."; | ||
10 | + } | ||
11 | + | ||
12 | + identity ref-address-family { | ||
13 | + reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2"; | ||
14 | + } | ||
15 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +module IdentityIntraFile { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix IdentityIntraFile; | ||
5 | + | ||
6 | + import "IdentityInModule" { | ||
7 | + prefix "IdentityInModule"; | ||
8 | + } | ||
9 | + | ||
10 | + identity ipv4-address-family { | ||
11 | + base IdentityInModule:ref-address-family; | ||
12 | + } | ||
13 | + | ||
14 | + identity ipv6-address-family { | ||
15 | + base IdentityInModule:ref-address-family; | ||
16 | + } | ||
17 | + | ||
18 | + leaf tunnel { | ||
19 | + type identityref { | ||
20 | + base IdentityInModule:ref-address-family; | ||
21 | + } | ||
22 | + } | ||
23 | + | ||
24 | + leaf-list network-ref { | ||
25 | + type identityref { | ||
26 | + base IdentityInModule:ref-address-family; | ||
27 | + } | ||
28 | + } | ||
29 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/plugin/src/test/resources/interfileidentityimportdependency/featurefile1.yang
0 → 100644
1 | +module syslog1 { | ||
2 | + yang-version 1; | ||
3 | + namespace "http://huawei1.com"; | ||
4 | + prefix "sys1"; | ||
5 | + | ||
6 | + import "syslog2" { | ||
7 | + prefix "sys2"; | ||
8 | + } | ||
9 | + | ||
10 | + identity ipv4-address-family { | ||
11 | + base sys2:ref-address-family; | ||
12 | + } | ||
13 | + | ||
14 | + identity ipv6-address-family { | ||
15 | + base sys2:ref-address-family; | ||
16 | + } | ||
17 | + | ||
18 | + leaf tunnel { | ||
19 | + type identityref { | ||
20 | + base sys2:ref-address-family; | ||
21 | + } | ||
22 | + } | ||
23 | + | ||
24 | + leaf-list network-ref { | ||
25 | + type identityref { | ||
26 | + base sys2:ref-address-family; | ||
27 | + } | ||
28 | + } | ||
29 | + | ||
30 | +} |
utils/yangutils/plugin/src/test/resources/interfileidentityimportdependency/featurefile2.yang
0 → 100644
1 | +module syslog2 { | ||
2 | + yang-version 1; | ||
3 | + namespace "http://huawei2.com"; | ||
4 | + prefix "sys2"; | ||
5 | + | ||
6 | + import "syslog3" { | ||
7 | + prefix "sys3"; | ||
8 | + } | ||
9 | + | ||
10 | + identity tunnel-type { | ||
11 | + base sys3:final-address-family; | ||
12 | + } | ||
13 | + | ||
14 | + identity ref-address-family { | ||
15 | + base sys3:final-address-family; | ||
16 | + } | ||
17 | +} |
1 | +module syslog1 { | ||
2 | + yang-version 1; | ||
3 | + namespace "http://huawei1.com"; | ||
4 | + prefix "sys1"; | ||
5 | + | ||
6 | + import "syslog2" { | ||
7 | + prefix "sys2"; | ||
8 | + } | ||
9 | + | ||
10 | + identity ipv4-address-family { | ||
11 | + base sys2:ref-address-family; | ||
12 | + } | ||
13 | + | ||
14 | + identity ipv6-address-family { | ||
15 | + base sys2:ref-address-family; | ||
16 | + } | ||
17 | + | ||
18 | + leaf tunnel { | ||
19 | + type identityref { | ||
20 | + base sys2:ref-address-family; | ||
21 | + } | ||
22 | + } | ||
23 | + | ||
24 | + leaf-list network-ref { | ||
25 | + type identityref { | ||
26 | + base sys2:ref-address-family; | ||
27 | + } | ||
28 | + } | ||
29 | +} |
1 | +module syslog2 { | ||
2 | + yang-version 1; | ||
3 | + namespace "http://huawei2.com"; | ||
4 | + prefix "sys2"; | ||
5 | + | ||
6 | + import "syslog3" { | ||
7 | + prefix "sys3"; | ||
8 | + } | ||
9 | + | ||
10 | + identity tunnel-type { | ||
11 | + base sys3:final-address-family; | ||
12 | + } | ||
13 | + | ||
14 | + identity ref-address-family { | ||
15 | + base sys3:final-address-family; | ||
16 | + } | ||
17 | +} | ||
18 | + |
utils/yangutils/plugin/src/test/resources/interfileidentityincludedependency/featurefile1.yang
0 → 100644
1 | +module syslog1 { | ||
2 | + yang-version 1; | ||
3 | + namespace "http://huawei3.com"; | ||
4 | + prefix "sys1"; | ||
5 | + | ||
6 | + include "syslog2"; | ||
7 | + | ||
8 | + identity ipv4-address-family { | ||
9 | + base ref-address-family; | ||
10 | + } | ||
11 | + | ||
12 | + identity ipv6-address-family { | ||
13 | + base ref-address-family; | ||
14 | + } | ||
15 | + | ||
16 | + leaf tunnel { | ||
17 | + type identityref { | ||
18 | + base ref-address-family; | ||
19 | + } | ||
20 | + } | ||
21 | + | ||
22 | + leaf-list network-ref { | ||
23 | + type identityref { | ||
24 | + base ref-address-family; | ||
25 | + } | ||
26 | + } | ||
27 | +} |
utils/yangutils/plugin/src/test/resources/interfileidentityincludedependency/featurefile2.yang
0 → 100644
1 | +submodule syslog2 { | ||
2 | + yang-version 1; | ||
3 | + belongs-to "syslog1" { | ||
4 | + prefix "sys1"; | ||
5 | + } | ||
6 | + | ||
7 | + import "syslog3" { | ||
8 | + prefix "sys3"; | ||
9 | + } | ||
10 | + | ||
11 | + identity tunnel-type { | ||
12 | + base sys3:final-address-family; | ||
13 | + } | ||
14 | + | ||
15 | + identity ref-address-family { | ||
16 | + base sys3:final-address-family; | ||
17 | + } | ||
18 | +} | ||
19 | + |
1 | +module syslog1 { | ||
2 | + yang-version 1; | ||
3 | + namespace "http://huawei3.com"; | ||
4 | + prefix "sys1"; | ||
5 | + | ||
6 | + include "syslog2"; | ||
7 | + | ||
8 | + identity ipv4-address-family { | ||
9 | + base sys2:ref-address-family; | ||
10 | + } | ||
11 | + | ||
12 | + identity ipv6-address-family { | ||
13 | + base sys2:ref-address-family; | ||
14 | + } | ||
15 | + | ||
16 | + leaf tunnel { | ||
17 | + type identityref { | ||
18 | + base sys2:ref-address-family; | ||
19 | + } | ||
20 | + } | ||
21 | + | ||
22 | + leaf-list network-ref { | ||
23 | + type identityref { | ||
24 | + base sys2:ref-address-family; | ||
25 | + } | ||
26 | + } | ||
27 | +} |
1 | +submodule syslog2 { | ||
2 | + yang-version 1; | ||
3 | + belongs-to "syslog1" { | ||
4 | + prefix "sys1"; | ||
5 | + } | ||
6 | + | ||
7 | + import "syslog3" { | ||
8 | + prefix "sys3"; | ||
9 | + } | ||
10 | + | ||
11 | + identity tunnel-type { | ||
12 | + base sys3:final-address-family; | ||
13 | + } | ||
14 | + | ||
15 | + identity ref-address-family { | ||
16 | + base sys3:final-address-family; | ||
17 | + } | ||
18 | +} | ||
19 | + |
1 | +module syslog3 { | ||
2 | + yang-version 1; | ||
3 | + namespace "http://huawei3.com"; | ||
4 | + prefix "sys3"; | ||
5 | + | ||
6 | + include "syslog4"; | ||
7 | + | ||
8 | + identity ipv4-address-family { | ||
9 | + base ref-address-family; | ||
10 | + } | ||
11 | + | ||
12 | + identity ipv6-address-family { | ||
13 | + base ref-address-family; | ||
14 | + } | ||
15 | + | ||
16 | + leaf tunnel { | ||
17 | + type identityref { | ||
18 | + base ref-address-family; | ||
19 | + } | ||
20 | + } | ||
21 | + | ||
22 | + leaf-list network-ref { | ||
23 | + type identityref { | ||
24 | + base ref-address-family; | ||
25 | + } | ||
26 | + } | ||
27 | +} |
1 | +submodule syslog4 { | ||
2 | + yang-version 1; | ||
3 | + belongs-to "syslog3" { | ||
4 | + prefix "sys3"; | ||
5 | + } | ||
6 | + | ||
7 | + identity tunnel-type { | ||
8 | + description | ||
9 | + "Base identity from which specific tunnel types are derived."; | ||
10 | + } | ||
11 | + | ||
12 | + identity ref-address-family { | ||
13 | + reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2"; | ||
14 | + } | ||
15 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +module IdentityInModule{ | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix IdentityInModule; | ||
5 | + | ||
6 | + identity tunnel-type { | ||
7 | + description | ||
8 | + "Base identity from which specific tunnel types are derived."; | ||
9 | + } | ||
10 | + | ||
11 | + identity ref-address-family { | ||
12 | + reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2"; | ||
13 | + } | ||
14 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
utils/yangutils/plugin/src/test/resources/interfileidentitytypedef/IdentityIntraFile.yang
0 → 100644
1 | +module IdentityIntraFile { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix IdentityIntraFile; | ||
5 | + | ||
6 | + import "IdentityInModule" { | ||
7 | + prefix "IdentityInModule"; | ||
8 | + } | ||
9 | + | ||
10 | + identity ipv4-address-family { | ||
11 | + base IdentityInModule:ref-address-family; | ||
12 | + } | ||
13 | + | ||
14 | + identity ipv6-address-family { | ||
15 | + base IdentityInModule:ref-address-family; | ||
16 | + } | ||
17 | + | ||
18 | + leaf tunnel { | ||
19 | + type identityref { | ||
20 | + base IdentityInModule:ref-address-family; | ||
21 | + } | ||
22 | + } | ||
23 | + | ||
24 | + leaf-list network-ref { | ||
25 | + type identityref { | ||
26 | + base IdentityInModule:ref-address-family; | ||
27 | + } | ||
28 | + } | ||
29 | + | ||
30 | + typedef type15 { | ||
31 | + type identityref { | ||
32 | + base IdentityInModule:ref-address-family; | ||
33 | + } | ||
34 | + } | ||
35 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +module IdentityTypedef { | ||
2 | + yang-version 1; | ||
3 | + namespace http://huawei.com; | ||
4 | + prefix IdentityTypedef; | ||
5 | + | ||
6 | + import "IdentityInModule" { | ||
7 | + prefix "IdentityInModule"; | ||
8 | + } | ||
9 | + | ||
10 | + identity ipv4-address-family { | ||
11 | + base IdentityInModule:ref-address-family; | ||
12 | + } | ||
13 | + | ||
14 | + identity ipv6-address-family { | ||
15 | + base IdentityInModule:ref-address-family; | ||
16 | + } | ||
17 | + | ||
18 | + leaf tunnel { | ||
19 | + type type15; | ||
20 | + } | ||
21 | + | ||
22 | + leaf-list network-ref { | ||
23 | + type type15; | ||
24 | + } | ||
25 | + | ||
26 | + typedef type15 { | ||
27 | + type identityref { | ||
28 | + base IdentityInModule:ref-address-family; | ||
29 | + } | ||
30 | + } | ||
31 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -56,7 +56,7 @@ | ... | @@ -56,7 +56,7 @@ |
56 | reference "RFC3209"; | 56 | reference "RFC3209"; |
57 | } | 57 | } |
58 | 58 | ||
59 | - /*identity tunnel-type { | 59 | + identity tunnel-type { |
60 | description | 60 | description |
61 | "Base identity from which specific tunnel types are | 61 | "Base identity from which specific tunnel types are |
62 | derived."; | 62 | derived."; |
... | @@ -254,7 +254,7 @@ | ... | @@ -254,7 +254,7 @@ |
254 | base lsp-encoding-types; | 254 | base lsp-encoding-types; |
255 | description | 255 | description |
256 | "Line (e.g., 8B/10B) LSP encoding"; | 256 | "Line (e.g., 8B/10B) LSP encoding"; |
257 | - }*/ | 257 | + } |
258 | 258 | ||
259 | /* TE basic features */ | 259 | /* TE basic features */ |
260 | feature p2mp-te { | 260 | feature p2mp-te { |
... | @@ -452,7 +452,7 @@ | ... | @@ -452,7 +452,7 @@ |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | - /*identity route-usage-type { | 455 | + identity route-usage-type { |
456 | description | 456 | description |
457 | "Base identity for route usage"; | 457 | "Base identity for route usage"; |
458 | } | 458 | } |
... | @@ -576,7 +576,7 @@ | ... | @@ -576,7 +576,7 @@ |
576 | description | 576 | description |
577 | "The set of attribute filters associated with a | 577 | "The set of attribute filters associated with a |
578 | tunnel any of which renders a link unacceptable"; | 578 | tunnel any of which renders a link unacceptable"; |
579 | - }*/ | 579 | + } |
580 | 580 | ||
581 | typedef admin-group { | 581 | typedef admin-group { |
582 | type binary { | 582 | type binary { |
... | @@ -605,7 +605,7 @@ | ... | @@ -605,7 +605,7 @@ |
605 | description "SRLG type"; | 605 | description "SRLG type"; |
606 | } | 606 | } |
607 | 607 | ||
608 | - /*identity path-computation-srlg-type { | 608 | + identity path-computation-srlg-type { |
609 | description | 609 | description |
610 | "Base identity for SRLG path computation"; | 610 | "Base identity for SRLG path computation"; |
611 | } | 611 | } |
... | @@ -632,7 +632,7 @@ | ... | @@ -632,7 +632,7 @@ |
632 | base path-computation-srlg-type; | 632 | base path-computation-srlg-type; |
633 | description | 633 | description |
634 | "Include weighted SRLG check in path computation"; | 634 | "Include weighted SRLG check in path computation"; |
635 | - }*/ | 635 | + } |
636 | 636 | ||
637 | typedef te-metric { | 637 | typedef te-metric { |
638 | type uint32; | 638 | type uint32; | ... | ... |
-
Please register or login to post a comment