Gaurav Agrawal
Committed by Gerrit Code Review

YANG: Restriction resolution implementation

Change-Id: I69503e8229def07b289a0c8c762bfe0ae5530232
Showing 33 changed files with 1194 additions and 444 deletions
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 +
17 +package org.onosproject.yangutils.datamodel;
18 +
19 +/**
20 + * Abstraction of location information, this is used during resolution is
21 + * carried out and line/character position in line is required to point
22 + * out the error location in YANG file.
23 + */
24 +public interface LocationInfo {
25 +
26 + /**
27 + * Returns the line number YANG construct in file.
28 + *
29 + * @return the line number YANG construct in file
30 + */
31 + int getLineNumber();
32 +
33 + /**
34 + * Returns the character position in line.
35 + *
36 + * @return the character position in line
37 + */
38 + int getCharPosition();
39 +
40 + /**
41 + * Sets line number of YANG construct.
42 + *
43 + * @param lineNumber the line number of YANG construct in file
44 + */
45 + void setLineNumber(int lineNumber);
46 +
47 + /**
48 + * Sets character position of YANG construct.
49 + *
50 + * @param charPositionInLine character position of YANG construct in file
51 + */
52 + void setCharPosition(int charPositionInLine);
53 +}
...@@ -228,7 +228,7 @@ public enum YangDataTypes { ...@@ -228,7 +228,7 @@ public enum YangDataTypes {
228 public static YangDataTypes getType(String name) { 228 public static YangDataTypes getType(String name) {
229 name = name.replace("\"", ""); 229 name = name.replace("\"", "");
230 for (YangDataTypes yangDataType : values()) { 230 for (YangDataTypes yangDataType : values()) {
231 - if (yangDataType.name().equalsIgnoreCase(name)) { 231 + if (yangDataType.name().toLowerCase().equals(name)) {
232 return yangDataType; 232 return yangDataType;
233 } 233 }
234 } 234 }
......
...@@ -16,12 +16,30 @@ ...@@ -16,12 +16,30 @@
16 16
17 package org.onosproject.yangutils.datamodel; 17 package org.onosproject.yangutils.datamodel;
18 18
19 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 +import com.google.common.base.Strings;
21 +
22 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.INTRA_FILE_RESOLVED;
23 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.RESOLVED;
24 +import static org.onosproject.yangutils.datamodel.YangDataTypes.BITS;
25 +import static org.onosproject.yangutils.datamodel.YangDataTypes.BOOLEAN;
26 +import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
27 +import static org.onosproject.yangutils.datamodel.YangDataTypes.EMPTY;
28 +import static org.onosproject.yangutils.datamodel.YangDataTypes.ENUMERATION;
29 +import static org.onosproject.yangutils.datamodel.YangDataTypes.IDENTITYREF;
30 +import static org.onosproject.yangutils.datamodel.YangDataTypes.LEAFREF;
31 +import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
32 +import static org.onosproject.yangutils.datamodel.YangDataTypes.UNION;
33 +import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType;
34 +import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction;
35 +import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRestriction;
36 +
19 /** 37 /**
20 * Represents the derived information. 38 * Represents the derived information.
21 * 39 *
22 * @param <T> extended information. 40 * @param <T> extended information.
23 */ 41 */
24 -public class YangDerivedInfo<T> { 42 +public class YangDerivedInfo<T> implements LocationInfo {
25 43
26 /** 44 /**
27 * YANG typedef reference. 45 * YANG typedef reference.
...@@ -36,11 +54,38 @@ public class YangDerivedInfo<T> { ...@@ -36,11 +54,38 @@ public class YangDerivedInfo<T> {
36 private T resolvedExtendedInfo; 54 private T resolvedExtendedInfo;
37 55
38 /** 56 /**
39 - * Additional information about data type, example restriction info, named 57 + * Line number of pattern restriction in YANG file.
40 - * values, etc. The extra information is based on the data type. Based on 58 + */
41 - * the data type, the extended info can vary. 59 + private int lineNumber;
60 +
61 + /**
62 + * Position of pattern restriction in line.
63 + */
64 + private int charPositionInLine;
65 +
66 + /**
67 + * Effective built-in type, requried in case type of typedef is again a
68 + * derived type. This information is to be added during linking.
42 */ 69 */
43 - private T extendedInfo; 70 + private YangDataTypes effectiveBuiltInType;
71 +
72 + /**
73 + * Length restriction string to temporary store the length restriction when the type
74 + * is derived.
75 + */
76 + private String lengthRestrictionString;
77 +
78 + /**
79 + * Range restriction string to temporary store the range restriction when the type
80 + * is derived.
81 + */
82 + private String rangeRestrictionString;
83 +
84 + /**
85 + * Pattern restriction string to temporary store the pattern restriction when the type
86 + * is derived.
87 + */
88 + private YangPatternRestriction patternRestriction;
44 89
45 /** 90 /**
46 * Returns the referred typedef reference. 91 * Returns the referred typedef reference.
...@@ -78,21 +123,503 @@ public class YangDerivedInfo<T> { ...@@ -78,21 +123,503 @@ public class YangDerivedInfo<T> {
78 this.resolvedExtendedInfo = resolvedExtendedInfo; 123 this.resolvedExtendedInfo = resolvedExtendedInfo;
79 } 124 }
80 125
126 + @Override
127 + public int getLineNumber() {
128 + return lineNumber;
129 + }
130 +
131 + @Override
132 + public int getCharPosition() {
133 + return charPositionInLine;
134 + }
135 +
136 + @Override
137 + public void setLineNumber(int lineNumber) {
138 + this.lineNumber = lineNumber;
139 + }
140 +
141 + @Override
142 + public void setCharPosition(int charPositionInLine) {
143 + this.charPositionInLine = charPositionInLine;
144 + }
145 +
146 + /**
147 + * Returns the length restriction string.
148 + *
149 + * @return the length restriction string
150 + */
151 + public String getLengthRestrictionString() {
152 + return lengthRestrictionString;
153 + }
154 +
155 + /**
156 + * Sets the length restriction string.
157 + *
158 + * @param lengthRestrictionString the length restriction string
159 + */
160 + public void setLengthRestrictionString(String lengthRestrictionString) {
161 + this.lengthRestrictionString = lengthRestrictionString;
162 + }
163 +
164 + /**
165 + * Returns the range restriction string.
166 + *
167 + * @return the range restriction string
168 + */
169 + public String getRangeRestrictionString() {
170 + return rangeRestrictionString;
171 + }
172 +
173 + /**
174 + * Sets the range restriction string.
175 + *
176 + * @param rangeRestrictionString the range restriction string
177 + */
178 + public void setRangeRestrictionString(String rangeRestrictionString) {
179 + this.rangeRestrictionString = rangeRestrictionString;
180 + }
181 +
182 + /**
183 + * Returns the pattern restriction.
184 + *
185 + * @return the pattern restriction
186 + */
187 + public YangPatternRestriction getPatternRestriction() {
188 + return patternRestriction;
189 + }
190 +
191 + /**
192 + * Sets the pattern restriction.
193 + *
194 + * @param patternRestriction the pattern restriction
195 + */
196 + public void setPatternRestriction(YangPatternRestriction patternRestriction) {
197 + this.patternRestriction = patternRestriction;
198 + }
199 +
200 + /**
201 + * Returns effective built-in type.
202 + *
203 + * @return effective built-in type
204 + */
205 + public YangDataTypes getEffectiveBuiltInType() {
206 + return effectiveBuiltInType;
207 + }
208 +
209 + /**
210 + * Sets effective built-in type.
211 + *
212 + * @param effectiveBuiltInType effective built-in type
213 + */
214 + public void setEffectiveBuiltInType(YangDataTypes effectiveBuiltInType) {
215 + this.effectiveBuiltInType = effectiveBuiltInType;
216 + }
217 +
81 /** 218 /**
82 - * Returns extended information. 219 + * Resolves the type derived info, by obtaining the effective built-in type
220 + * and resolving the restrictions.
83 * 221 *
84 - * @return extended information 222 + * @return resolution status
223 + * @throws DataModelException a violation in data mode rule
85 */ 224 */
86 - public T getExtendedInfo() { 225 + public ResolvableStatus resolve() throws DataModelException {
87 - return extendedInfo; 226 +
227 + YangType<?> baseType = getReferredTypeDef().getTypeDefBaseType();
228 +
229 + /*
230 + * Checks the data type of the referred typedef, if it's derived,
231 + * obtain effective built-in type and restrictions from it's derived
232 + * info, otherwise take from the base type of type itself.
233 + */
234 + if (baseType.getDataType() == DERIVED) {
235 + /*
236 + * Check whether the referred typedef is resolved.
237 + */
238 + if (baseType.getResolvableStatus() != INTRA_FILE_RESOLVED && baseType.getResolvableStatus() != RESOLVED) {
239 + throw new DataModelException("Linker Error: Referred typedef is not resolved.");
240 + }
241 +
242 + /*
243 + * Check if the referred typedef is intra file resolved, if yes sets
244 + * current status also to intra file resolved .
245 + */
246 + if (getReferredTypeDef().getTypeDefBaseType().getResolvableStatus() == INTRA_FILE_RESOLVED) {
247 + return INTRA_FILE_RESOLVED;
248 + }
249 + setEffectiveBuiltInType(((YangDerivedInfo<?>) baseType.getDataTypeExtendedInfo())
250 + .getEffectiveBuiltInType());
251 + YangDerivedInfo refDerivedInfo = ((YangDerivedInfo<?>) baseType.getDataTypeExtendedInfo());
252 + /*
253 + * Check whether the effective built-in type can have range
254 + * restrictions, if yes call resolution of range.
255 + */
256 + if (isOfRangeRestrictedType(getEffectiveBuiltInType())) {
257 + if (refDerivedInfo.getResolvedExtendedInfo() == null) {
258 + resolveRangeRestriction(null);
259 + /*
260 + * Return the resolution status as resolved, if it's not
261 + * resolve range/string restriction will throw exception
262 + * in previous function.
263 + */
264 + return RESOLVED;
265 + } else {
266 + if (!(refDerivedInfo.getResolvedExtendedInfo() instanceof YangRangeRestriction)) {
267 + throw new DataModelException("Linker error: Referred typedef restriction info is of invalid " +
268 + "type.");
269 + }
270 + resolveRangeRestriction((YangRangeRestriction) refDerivedInfo.getResolvedExtendedInfo());
271 + /*
272 + * Return the resolution status as resolved, if it's not
273 + * resolve range/string restriction will throw exception
274 + * in previous function.
275 + */
276 + return RESOLVED;
277 + }
278 + /*
279 + * If the effective built-in type is of type string calls
280 + * for string resolution.
281 + */
282 + } else if (getEffectiveBuiltInType() == STRING) {
283 + if (refDerivedInfo.getResolvedExtendedInfo() == null) {
284 + resolveStringRestriction(null);
285 + /*
286 + * Return the resolution status as resolved, if it's not
287 + * resolve range/string restriction will throw exception
288 + * in previous function.
289 + */
290 + return RESOLVED;
291 + } else {
292 + if (!(refDerivedInfo.getResolvedExtendedInfo() instanceof YangStringRestriction)) {
293 + throw new DataModelException("Linker error: Referred typedef restriction info is of invalid " +
294 + "type.");
295 + }
296 + resolveStringRestriction((YangStringRestriction) refDerivedInfo.getResolvedExtendedInfo());
297 + /*
298 + * Return the resolution status as resolved, if it's not
299 + * resolve range/string restriction will throw exception
300 + * in previous function.
301 + */
302 + return RESOLVED;
303 + }
304 + }
305 + } else {
306 + setEffectiveBuiltInType((baseType.getDataType()));
307 + /*
308 + * Check whether the effective built-in type can have range
309 + * restrictions, if yes call resolution of range.
310 + */
311 + if (isOfRangeRestrictedType(getEffectiveBuiltInType())) {
312 + if (baseType.getDataTypeExtendedInfo() == null) {
313 + resolveRangeRestriction(null);
314 + /*
315 + * Return the resolution status as resolved, if it's not
316 + * resolve range/string restriction will throw exception
317 + * in previous function.
318 + */
319 + return RESOLVED;
320 + } else {
321 + if (!(baseType.getDataTypeExtendedInfo() instanceof YangRangeRestriction)) {
322 + throw new DataModelException("Linker error: Referred typedef restriction info is of invalid " +
323 + "type.");
324 + }
325 + resolveRangeRestriction((YangRangeRestriction) baseType.getDataTypeExtendedInfo());
326 + /*
327 + * Return the resolution status as resolved, if it's not
328 + * resolve range/string restriction will throw exception
329 + * in previous function.
330 + */
331 + return RESOLVED;
332 + }
333 + /*
334 + * If the effective built-in type is of type string calls
335 + * for string resolution.
336 + */
337 + } else if (getEffectiveBuiltInType() == STRING) {
338 + if (baseType.getDataTypeExtendedInfo() == null) {
339 + resolveStringRestriction(null);
340 + /*
341 + * Return the resolution status as resolved, if it's not
342 + * resolve range/string restriction will throw exception
343 + * in previous function.
344 + */
345 + return RESOLVED;
346 + } else {
347 + if (!(baseType.getDataTypeExtendedInfo() instanceof YangStringRestriction)) {
348 + throw new DataModelException("Linker error: Referred typedef restriction info is of invalid " +
349 + "type.");
350 + }
351 + resolveStringRestriction((YangStringRestriction) baseType.getDataTypeExtendedInfo());
352 + /*
353 + * Return the resolution status as resolved, if it's not
354 + * resolve range/string restriction will throw exception
355 + * in previous function.
356 + */
357 + return RESOLVED;
358 + }
359 + }
360 + }
361 +
362 + /*
363 + * Check if the data type is the one which can't be restricted, in
364 + * this case check whether no self restrictions should be present.
365 + */
366 + if (isOfValidNonRestrictedType(getEffectiveBuiltInType())) {
367 + if (Strings.isNullOrEmpty(getLengthRestrictionString())
368 + && Strings.isNullOrEmpty(getRangeRestrictionString())
369 + && getPatternRestriction() == null) {
370 + return RESOLVED;
371 + } else {
372 + throw new DataModelException("YANG file error: Restrictions can't be applied to a given type");
373 + }
374 + }
375 +
376 + // Throw exception for unsupported types
377 + throw new DataModelException("Linker error: Unable to process the derived type.");
378 + }
379 +
380 + /**
381 + * Resolves the string restrictions.
382 + *
383 + * @param refStringRestriction referred string restriction of typedef
384 + * @throws DataModelException a violation in data model rule
385 + */
386 + private void resolveStringRestriction(YangStringRestriction refStringRestriction) throws DataModelException {
387 + YangStringRestriction curStringRestriction = null;
388 + YangRangeRestriction refRangeRestriction = null;
389 + YangPatternRestriction refPatternRestriction = null;
390 +
391 + /*
392 + * Check that range restriction should be null when built-in type is
393 + * string.
394 + */
395 + if (!(Strings.isNullOrEmpty(getRangeRestrictionString()))) {
396 + DataModelException dataModelException = new DataModelException("YANG file error: Range restriction " +
397 + "should't be present for string data type.");
398 + dataModelException.setLine(lineNumber);
399 + dataModelException.setCharPosition(charPositionInLine);
400 + throw dataModelException;
401 + }
402 +
403 + /*
404 + * If referred restriction and self restriction both are null, no
405 + * resolution is required.
406 + */
407 + if (refStringRestriction == null && Strings.isNullOrEmpty(getLengthRestrictionString())
408 + && getPatternRestriction() == null) {
409 + return;
410 + }
411 +
412 + /*
413 + * If referred string restriction is not null, take value of length
414 + * and pattern restriction and assign.
415 + */
416 + if (refStringRestriction != null) {
417 + refRangeRestriction = refStringRestriction.getLengthRestriction();
418 + refPatternRestriction = refStringRestriction.getPatternRestriction();
419 + }
420 +
421 + YangRangeRestriction lengthRestriction = resolveLengthRestriction(refRangeRestriction);
422 + YangPatternRestriction patternRestriction = resolvePatternRestriction(refPatternRestriction);
423 +
424 + /*
425 + * Check if either of length or pattern restriction is present, if yes
426 + * create string restriction and assign value.
427 + */
428 + if (lengthRestriction != null || patternRestriction != null) {
429 + curStringRestriction = new YangStringRestriction();
430 + curStringRestriction.setLengthRestriction(lengthRestriction);
431 + curStringRestriction.setPatternRestriction(patternRestriction);
432 + }
433 + setResolvedExtendedInfo((T) curStringRestriction);
434 + }
435 +
436 + /**
437 + * Resolves pattern restriction.
438 + *
439 + * @param refPatternRestriction referred pattern restriction of typedef
440 + * @return resolved pattern restriction
441 + */
442 + private YangPatternRestriction resolvePatternRestriction(YangPatternRestriction refPatternRestriction) {
443 + /*
444 + * If referred restriction and self restriction both are null, no
445 + * resolution is required.
446 + */
447 + if (refPatternRestriction == null && getPatternRestriction() == null) {
448 + return null;
449 + }
450 +
451 + /*
452 + * If self restriction is null, and referred restriction is present
453 + * shallow copy the referred to self.
454 + */
455 + if (getPatternRestriction() == null) {
456 + return refPatternRestriction;
457 + }
458 +
459 + /*
460 + * If referred restriction is null, and self restriction is present
461 + * carry out self resolution.
462 + */
463 + if (refPatternRestriction == null) {
464 + return getPatternRestriction();
465 + }
466 +
467 + /*
468 + * Get patterns of referred type and add it to current pattern
469 + * restrictions.
470 + */
471 + for (String pattern : refPatternRestriction.getPatternList()) {
472 + getPatternRestriction().addPattern(pattern);
473 + }
474 + return getPatternRestriction();
475 + }
476 +
477 + /**
478 + * Resolves the length restrictions.
479 + *
480 + * @param refLengthRestriction referred length restriction of typedef
481 + * @return resolved length restriction
482 + * @throws DataModelException a violation in data model rule
483 + */
484 + private YangRangeRestriction resolveLengthRestriction(YangRangeRestriction refLengthRestriction) throws
485 + DataModelException {
486 +
487 + /*
488 + * If referred restriction and self restriction both are null, no
489 + * resolution is required.
490 + */
491 + if (refLengthRestriction == null && Strings.isNullOrEmpty(getLengthRestrictionString())) {
492 + return null;
493 + }
494 +
495 + /*
496 + * If self restriction is null, and referred restriction is present
497 + * shallow copy the referred to self.
498 + */
499 + if (Strings.isNullOrEmpty(getLengthRestrictionString())) {
500 + return refLengthRestriction;
501 + }
502 +
503 + /*
504 + * If referred restriction is null, and self restriction is present
505 + * carry out self resolution.
506 + */
507 + if (refLengthRestriction == null) {
508 + YangRangeRestriction curLengthRestriction = processLengthRestriction(null, lineNumber,
509 + charPositionInLine, false, getLengthRestrictionString());
510 + return curLengthRestriction;
511 + }
512 +
513 + /*
514 + * Carry out self resolution based with obtained effective built-in
515 + * type and MIN/MAX values as per the referred typedef's values.
516 + */
517 + YangRangeRestriction curLengthRestriction = processLengthRestriction(refLengthRestriction, lineNumber,
518 + charPositionInLine, true, getLengthRestrictionString());
519 +
520 + // Resolve the range with referred typedef's restriction.
521 + resolveLengthAndRangeRestriction(refLengthRestriction, curLengthRestriction);
522 + return curLengthRestriction;
523 + }
524 +
525 + /**
526 + * Resolves the length/range self and referred restriction, to check whether
527 + * the all the range interval in self restriction is stricter than the
528 + * referred typedef's restriction.
529 + *
530 + * @param refRestriction referred restriction
531 + * @param curRestriction self restriction
532 + */
533 + private void resolveLengthAndRangeRestriction(YangRangeRestriction refRestriction,
534 + YangRangeRestriction curRestriction) throws DataModelException {
535 + for (Object curInterval : curRestriction.getAscendingRangeIntervals()) {
536 + if (!(curInterval instanceof YangRangeInterval)) {
537 + throw new DataModelException("Linker error: Current range intervals not processed correctly.");
538 + }
539 + try {
540 + refRestriction.isValidInterval((YangRangeInterval) curInterval);
541 + } catch (DataModelException e) {
542 + DataModelException dataModelException = new DataModelException(e);
543 + dataModelException.setLine(lineNumber);
544 + dataModelException.setCharPosition(charPositionInLine);
545 + throw dataModelException;
546 + }
547 + }
548 + }
549 +
550 + /**
551 + * Resolves the range restrictions.
552 + *
553 + * @param refRangeRestriction referred range restriction of typedef
554 + * @throws DataModelException a violation in data model rule
555 + */
556 + private void resolveRangeRestriction(YangRangeRestriction refRangeRestriction) throws DataModelException {
557 +
558 + /*
559 + * Check that string restriction should be null when built-in type is
560 + * of range type.
561 + */
562 + if (!(Strings.isNullOrEmpty(getLengthRestrictionString())) || getPatternRestriction() != null) {
563 + DataModelException dataModelException = new DataModelException("YANG file error: Length/Pattern " +
564 + "restriction should't be present for int/uint/decimal data type.");
565 + dataModelException.setLine(lineNumber);
566 + dataModelException.setCharPosition(charPositionInLine);
567 + throw dataModelException;
568 + }
569 +
570 + /*
571 + * If referred restriction and self restriction both are null, no
572 + * resolution is required.
573 + */
574 + if (refRangeRestriction == null && Strings.isNullOrEmpty(getRangeRestrictionString())) {
575 + return;
576 + }
577 +
578 + /*
579 + * If self restriction is null, and referred restriction is present
580 + * shallow copy the referred to self.
581 + */
582 + if (Strings.isNullOrEmpty(getRangeRestrictionString())) {
583 + setResolvedExtendedInfo((T) refRangeRestriction);
584 + return;
585 + }
586 +
587 + /*
588 + * If referred restriction is null, and self restriction is present
589 + * carry out self resolution.
590 + */
591 + if (refRangeRestriction == null) {
592 + YangRangeRestriction curRangeRestriction = processRangeRestriction(null, lineNumber,
593 + charPositionInLine, false, getRangeRestrictionString(), getEffectiveBuiltInType());
594 + setResolvedExtendedInfo((T) curRangeRestriction);
595 + return;
596 + }
597 +
598 + /*
599 + * Carry out self resolution based with obtained effective built-in
600 + * type and MIN/MAX values as per the referred typedef's values.
601 + */
602 + YangRangeRestriction curRangeRestriction = processRangeRestriction(refRangeRestriction, lineNumber,
603 + charPositionInLine, true, getRangeRestrictionString(), getEffectiveBuiltInType());
604 +
605 + // Resolve the range with referred typedef's restriction.
606 + resolveLengthAndRangeRestriction(refRangeRestriction, curRangeRestriction);
607 + setResolvedExtendedInfo((T) curRangeRestriction);
88 } 608 }
89 609
90 /** 610 /**
91 - * Sets extended information. 611 + * Returns whether the data type is of non restricted type.
92 * 612 *
93 - * @param extendedInfo extended information 613 + * @param dataType data type to be checked
614 + * @return true, if data type can't be restricted, false otherwise
94 */ 615 */
95 - public void setExtendedInfo(T extendedInfo) { 616 + private boolean isOfValidNonRestrictedType(YangDataTypes dataType) {
96 - this.extendedInfo = extendedInfo; 617 + return (dataType == BOOLEAN
618 + || dataType == ENUMERATION
619 + || dataType == BITS
620 + || dataType == EMPTY
621 + || dataType == UNION
622 + || dataType == IDENTITYREF
623 + || dataType == LEAFREF);
97 } 624 }
98 } 625 }
......
...@@ -46,6 +46,7 @@ import java.util.List; ...@@ -46,6 +46,7 @@ import java.util.List;
46 * | reference | 7.19.4 | 0..1 | 46 * | reference | 7.19.4 | 0..1 |
47 * +---------------+---------+-------------+ 47 * +---------------+---------+-------------+
48 */ 48 */
49 +
49 /** 50 /**
50 * Represents pattern restriction information. The regular expression restriction on string 51 * Represents pattern restriction information. The regular expression restriction on string
51 * data type. 52 * data type.
...@@ -58,11 +59,6 @@ public class YangPatternRestriction { ...@@ -58,11 +59,6 @@ public class YangPatternRestriction {
58 private List<String> patternList; 59 private List<String> patternList;
59 60
60 /** 61 /**
61 - * Effective pattern restriction that needs inherited from base type.
62 - */
63 - private List<String> basePattern;
64 -
65 - /**
66 * Creates a YANG pattern restriction object. 62 * Creates a YANG pattern restriction object.
67 */ 63 */
68 public YangPatternRestriction() { 64 public YangPatternRestriction() {
...@@ -95,22 +91,4 @@ public class YangPatternRestriction { ...@@ -95,22 +91,4 @@ public class YangPatternRestriction {
95 public void addPattern(String newPattern) { 91 public void addPattern(String newPattern) {
96 getPatternList().add(newPattern); 92 getPatternList().add(newPattern);
97 } 93 }
98 -
99 - /**
100 - * Returns the pattern restriction defined in base type.
101 - *
102 - * @return pattern restriction defined in base type.
103 - */
104 - public List<String> getBasePattern() {
105 - return basePattern;
106 - }
107 -
108 - /**
109 - * Sets the pattern restriction defined in base type.
110 - *
111 - * @param basePattern pattern restriction defined in base type.
112 - */
113 - public void setBasePattern(List<String> basePattern) {
114 - this.basePattern = basePattern;
115 - }
116 } 94 }
......
...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel; ...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.datamodel;
18 18
19 import java.util.LinkedList; 19 import java.util.LinkedList;
20 import java.util.List; 20 import java.util.List;
21 -
22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo; 22 import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo;
24 23
...@@ -111,8 +110,8 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>> ...@@ -111,8 +110,8 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>>
111 /** 110 /**
112 * Returns the minimum valid value as per the restriction. 111 * Returns the minimum valid value as per the restriction.
113 * 112 *
114 - * @throws DataModelException data model exception for minimum restriction
115 * @return minimum restricted value 113 * @return minimum restricted value
114 + * @throws DataModelException data model exception for minimum restriction
116 */ 115 */
117 public T getMinRestrictedvalue() throws DataModelException { 116 public T getMinRestrictedvalue() throws DataModelException {
118 if (getAscendingRangeIntervals() == null) { 117 if (getAscendingRangeIntervals() == null) {
...@@ -127,8 +126,8 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>> ...@@ -127,8 +126,8 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>>
127 /** 126 /**
128 * Returns the maximum valid value as per the restriction. 127 * Returns the maximum valid value as per the restriction.
129 * 128 *
130 - * @throws DataModelException data model exception for maximum restriction
131 * @return minimum maximum value 129 * @return minimum maximum value
130 + * @throws DataModelException data model exception for maximum restriction
132 */ 131 */
133 public T getMaxRestrictedvalue() throws DataModelException { 132 public T getMaxRestrictedvalue() throws DataModelException {
134 if (getAscendingRangeIntervals() == null) { 133 if (getAscendingRangeIntervals() == null) {
...@@ -175,7 +174,7 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>> ...@@ -175,7 +174,7 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>>
175 } 174 }
176 175
177 /** 176 /**
178 - * Check if the given value is correct as per the restriction. 177 + * Validates if the given value is correct as per the restriction.
179 * 178 *
180 * @param valueInString value 179 * @param valueInString value
181 * @return true, if the value is confirming to restriction, false otherwise 180 * @return true, if the value is confirming to restriction, false otherwise
...@@ -206,6 +205,32 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>> ...@@ -206,6 +205,32 @@ public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>>
206 } 205 }
207 206
208 /** 207 /**
208 + * Validates if the given interval is correct as per the restriction.
209 + *
210 + * @param rangeInterval range interval
211 + * @return true, if the interval is confirming to restriction, false otherwise
212 + * @throws DataModelException data model error
213 + */
214 + public boolean isValidInterval(YangRangeInterval rangeInterval) throws DataModelException {
215 +
216 + if (getAscendingRangeIntervals() == null
217 + || getAscendingRangeIntervals().isEmpty()) {
218 + // Throw exception, At least one default range needs to be set in constructor or in linker.
219 + throw new DataModelException("Range interval missing in range restriction.");
220 + }
221 +
222 + for (YangRangeInterval<T> interval : getAscendingRangeIntervals()) {
223 + int rangeStartCompareRes = interval.getStartValue().compareTo((T) rangeInterval.getStartValue());
224 + int rangeEndCompareRes = interval.getEndValue().compareTo((T) rangeInterval.getEndValue());
225 +
226 + if (rangeStartCompareRes <= 0 && rangeEndCompareRes >= 0) {
227 + return true;
228 + }
229 + }
230 + throw new DataModelException("Range interval doesn't fall within the referred restriction ranges");
231 + }
232 +
233 + /**
209 * Returns the textual reference of the length restriction. 234 * Returns the textual reference of the length restriction.
210 * 235 *
211 * @return textual reference of the length restriction 236 * @return textual reference of the length restriction
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
17 package org.onosproject.yangutils.datamodel; 17 package org.onosproject.yangutils.datamodel;
18 18
19 import java.util.Stack; 19 import java.util.Stack;
20 -
21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 20 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 21
23 import static org.onosproject.yangutils.datamodel.ResolvableStatus.INTRA_FILE_RESOLVED; 22 import static org.onosproject.yangutils.datamodel.ResolvableStatus.INTRA_FILE_RESOLVED;
...@@ -30,7 +29,7 @@ import static org.onosproject.yangutils.datamodel.ResolvableStatus.UNRESOLVED; ...@@ -30,7 +29,7 @@ import static org.onosproject.yangutils.datamodel.ResolvableStatus.UNRESOLVED;
30 * 29 *
31 * @param <T> type of resolution entity uses / type 30 * @param <T> type of resolution entity uses / type
32 */ 31 */
33 -public class YangResolutionInfo<T> { 32 +public class YangResolutionInfo<T> implements LocationInfo {
34 33
35 /** 34 /**
36 * Information about the entity that needs to be resolved. 35 * Information about the entity that needs to be resolved.
...@@ -64,9 +63,9 @@ public class YangResolutionInfo<T> { ...@@ -64,9 +63,9 @@ public class YangResolutionInfo<T> {
64 /** 63 /**
65 * Creates a resolution information object with all the inputs. 64 * Creates a resolution information object with all the inputs.
66 * 65 *
67 - * @param dataNode current parsable data node 66 + * @param dataNode current parsable data node
68 - * @param holderNode parent YANG node 67 + * @param holderNode parent YANG node
69 - * @param lineNumber error line number 68 + * @param lineNumber error line number
70 * @param charPositionInLine error character position in line 69 * @param charPositionInLine error character position in line
71 */ 70 */
72 public YangResolutionInfo(T dataNode, YangNode holderNode, int lineNumber, int charPositionInLine) { 71 public YangResolutionInfo(T dataNode, YangNode holderNode, int lineNumber, int charPositionInLine) {
...@@ -193,7 +192,6 @@ public class YangResolutionInfo<T> { ...@@ -193,7 +192,6 @@ public class YangResolutionInfo<T> {
193 private void resolveTopOfStack() 192 private void resolveTopOfStack()
194 throws DataModelException { 193 throws DataModelException {
195 ((Resolvable) getCurrentEntityToResolveFromStack()).resolve(); 194 ((Resolvable) getCurrentEntityToResolveFromStack()).resolve();
196 -
197 if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus() 195 if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus()
198 != INTRA_FILE_RESOLVED) { 196 != INTRA_FILE_RESOLVED) {
199 // Sets the resolution status in inside the type/uses. 197 // Sets the resolution status in inside the type/uses.
...@@ -453,42 +451,6 @@ public class YangResolutionInfo<T> { ...@@ -453,42 +451,6 @@ public class YangResolutionInfo<T> {
453 } 451 }
454 452
455 /** 453 /**
456 - * Returns error position.
457 - *
458 - * @return error position
459 - */
460 - public int getCharPosition() {
461 - return charPosition;
462 - }
463 -
464 - /**
465 - * Sets error position.
466 - *
467 - * @param charPosition position of error
468 - */
469 - public void setCharPosition(int charPosition) {
470 - this.charPosition = charPosition;
471 - }
472 -
473 - /**
474 - * Returns error character position in line.
475 - *
476 - * @return error character position in line
477 - */
478 - public int getLineNumber() {
479 - return lineNumber;
480 - }
481 -
482 - /**
483 - * Sets error character position in line.
484 - *
485 - * @param lineNumber error character position in line
486 - */
487 - public void setLineNumber(int lineNumber) {
488 - this.lineNumber = lineNumber;
489 - }
490 -
491 - /**
492 * Returns stack of YANG type with partially resolved YANG construct 454 * Returns stack of YANG type with partially resolved YANG construct
493 * hierarchy. 455 * hierarchy.
494 * 456 *
...@@ -539,9 +501,29 @@ public class YangResolutionInfo<T> { ...@@ -539,9 +501,29 @@ public class YangResolutionInfo<T> {
539 * Sets information about the entity that needs to be resolved. 501 * Sets information about the entity that needs to be resolved.
540 * 502 *
541 * @param entityToResolveInfo information about the entity that needs to be 503 * @param entityToResolveInfo information about the entity that needs to be
542 - * resolved 504 + * resolved
543 */ 505 */
544 public void setEntityToResolveInfo(YangEntityToResolveInfo<T> entityToResolveInfo) { 506 public void setEntityToResolveInfo(YangEntityToResolveInfo<T> entityToResolveInfo) {
545 this.entityToResolveInfo = entityToResolveInfo; 507 this.entityToResolveInfo = entityToResolveInfo;
546 } 508 }
509 +
510 + @Override
511 + public int getLineNumber() {
512 + return lineNumber;
513 + }
514 +
515 + @Override
516 + public int getCharPosition() {
517 + return charPosition;
518 + }
519 +
520 + @Override
521 + public void setLineNumber(int lineNumber) {
522 + this.lineNumber = lineNumber;
523 + }
524 +
525 + @Override
526 + public void setCharPosition(int charPositionInLine) {
527 + this.charPosition = charPositionInLine;
528 + }
547 } 529 }
......
...@@ -24,6 +24,7 @@ import org.onosproject.yangutils.utils.builtindatatype.YangUint64; ...@@ -24,6 +24,7 @@ import org.onosproject.yangutils.utils.builtindatatype.YangUint64;
24 * A string can be restricted with the "length" and "pattern" statements. 24 * A string can be restricted with the "length" and "pattern" statements.
25 * 25 *
26 */ 26 */
27 +
27 /** 28 /**
28 * Represents the restriction for string data type. 29 * Represents the restriction for string data type.
29 */ 30 */
...@@ -113,7 +114,7 @@ public class YangStringRestriction { ...@@ -113,7 +114,7 @@ public class YangStringRestriction {
113 * 114 *
114 * @param patternRestriction pattern restriction for the type 115 * @param patternRestriction pattern restriction for the type
115 */ 116 */
116 - private void setPatternRestriction(YangPatternRestriction patternRestriction) { 117 + public void setPatternRestriction(YangPatternRestriction patternRestriction) {
117 this.patternRestriction = patternRestriction; 118 this.patternRestriction = patternRestriction;
118 } 119 }
119 120
......
...@@ -20,7 +20,6 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; ...@@ -20,7 +20,6 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 import org.onosproject.yangutils.parser.Parsable; 20 import org.onosproject.yangutils.parser.Parsable;
21 import org.onosproject.yangutils.utils.YangConstructType; 21 import org.onosproject.yangutils.utils.YangConstructType;
22 22
23 -import static org.onosproject.yangutils.datamodel.ResolvableStatus.INTRA_FILE_RESOLVED;
24 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 23 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
25 24
26 /* 25 /*
...@@ -78,18 +77,6 @@ public class YangType<T> ...@@ -78,18 +77,6 @@ public class YangType<T>
78 private T dataTypeExtendedInfo; 77 private T dataTypeExtendedInfo;
79 78
80 /** 79 /**
81 - * Effective built-in type, requried in case type of typedef is again a
82 - * derived type. This information is to be added during linking.
83 - */
84 - private YangDataTypes effectiveBuiltInType;
85 -
86 - /**
87 - * Effective pattern restriction, requried in case type of typedef is again
88 - * a derived type. This information is to be added during linking.
89 - */
90 - private YangPatternRestriction effectivePatternRestriction;
91 -
92 - /**
93 * Status of resolution. If completely resolved enum value is "RESOLVED", 80 * Status of resolution. If completely resolved enum value is "RESOLVED",
94 * if not enum value is "UNRESOLVED", in case reference of grouping/typedef 81 * if not enum value is "UNRESOLVED", in case reference of grouping/typedef
95 * is added to uses/type but it's not resolved value of enum should be 82 * is added to uses/type but it's not resolved value of enum should be
...@@ -215,42 +202,6 @@ public class YangType<T> ...@@ -215,42 +202,6 @@ public class YangType<T>
215 } 202 }
216 203
217 /** 204 /**
218 - * Return effective built-in type.
219 - *
220 - * @return effective built-in type
221 - */
222 - public YangDataTypes getEffectiveBuiltInType() {
223 - return effectiveBuiltInType;
224 - }
225 -
226 - /**
227 - * Sets effective built-in type.
228 - *
229 - * @param effectiveBuiltInType effective built-in type
230 - */
231 - public void setEffectiveBuiltInType(YangDataTypes effectiveBuiltInType) {
232 - this.effectiveBuiltInType = effectiveBuiltInType;
233 - }
234 -
235 - /**
236 - * Returns effective pattern restriction.
237 - *
238 - * @return effective pattern restriction
239 - */
240 - public YangPatternRestriction getEffectivePatternRestriction() {
241 - return effectivePatternRestriction;
242 - }
243 -
244 - /**
245 - * Sets effective pattern restriction.
246 - *
247 - * @param effectivePatternRestriction effective pattern restriction
248 - */
249 - public void setEffectivePatternRestriction(YangPatternRestriction effectivePatternRestriction) {
250 - this.effectivePatternRestriction = effectivePatternRestriction;
251 - }
252 -
253 - /**
254 * Returns the type of the parsed data. 205 * Returns the type of the parsed data.
255 * 206 *
256 * @return returns TYPE_DATA 207 * @return returns TYPE_DATA
...@@ -269,7 +220,6 @@ public class YangType<T> ...@@ -269,7 +220,6 @@ public class YangType<T>
269 public void validateDataOnEntry() 220 public void validateDataOnEntry()
270 throws DataModelException { 221 throws DataModelException {
271 // TODO auto-generated method stub, to be implemented by parser 222 // TODO auto-generated method stub, to be implemented by parser
272 -
273 } 223 }
274 224
275 /** 225 /**
...@@ -281,7 +231,6 @@ public class YangType<T> ...@@ -281,7 +231,6 @@ public class YangType<T>
281 public void validateDataOnExit() 231 public void validateDataOnExit()
282 throws DataModelException { 232 throws DataModelException {
283 // TODO auto-generated method stub, to be implemented by parser 233 // TODO auto-generated method stub, to be implemented by parser
284 -
285 } 234 }
286 235
287 @Override 236 @Override
...@@ -297,17 +246,19 @@ public class YangType<T> ...@@ -297,17 +246,19 @@ public class YangType<T>
297 @Override 246 @Override
298 public void resolve() throws DataModelException { 247 public void resolve() throws DataModelException {
299 /* 248 /*
300 - Inherit the Restriction from the referred typedef definition. 249 + * Check whether the data type is derived.
301 */ 250 */
302 if (getDataType() != DERIVED) { 251 if (getDataType() != DERIVED) {
303 - throw new DataModelException("Resolve should only be called for derived data types"); 252 + throw new DataModelException("Linker Error: Resolve should only be called for derived data types.");
304 } 253 }
305 254
306 - YangDerivedInfo<?> derrivedInfo = (YangDerivedInfo<?>) getDataTypeExtendedInfo(); 255 + // Check if the derived info is present.
307 - YangType<?> baseType = derrivedInfo.getReferredTypeDef().getTypeDefBaseType(); 256 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) getDataTypeExtendedInfo();
308 - if (DERIVED == baseType.getDataType() && baseType.getResolvableStatus() == INTRA_FILE_RESOLVED) { 257 + if (derivedInfo == null) {
309 - setResolvableStatus(INTRA_FILE_RESOLVED); 258 + throw new DataModelException("Linker Error: Derived information is missing.");
310 } 259 }
311 - //TODO: 260 +
261 + // Initiate the resolution
262 + setResolvableStatus(derivedInfo.resolve());
312 } 263 }
313 } 264 }
......
...@@ -83,11 +83,6 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, Y ...@@ -83,11 +83,6 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, Y
83 private String name; 83 private String name;
84 84
85 /** 85 /**
86 - * Maintain the data type information.
87 - */
88 - private YangType<?> dataType;
89 -
90 - /**
91 * Units of the data type. 86 * Units of the data type.
92 */ 87 */
93 private String units; 88 private String units;
......
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -16,34 +16,26 @@ ...@@ -16,34 +16,26 @@
16 16
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 -import java.util.regex.Pattern; 19 +import org.onosproject.yangutils.datamodel.YangDataTypes;
20 - 20 +import org.onosproject.yangutils.datamodel.YangDerivedInfo;
21 import org.onosproject.yangutils.datamodel.YangRangeRestriction; 21 import org.onosproject.yangutils.datamodel.YangRangeRestriction;
22 -import org.onosproject.yangutils.datamodel.YangRangeInterval;
23 import org.onosproject.yangutils.datamodel.YangStringRestriction; 22 import org.onosproject.yangutils.datamodel.YangStringRestriction;
24 import org.onosproject.yangutils.datamodel.YangType; 23 import org.onosproject.yangutils.datamodel.YangType;
25 -import org.onosproject.yangutils.datamodel.YangDataTypes;
26 -import org.onosproject.yangutils.datamodel.YangDerivedInfo;
27 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
28 import org.onosproject.yangutils.parser.Parsable; 24 import org.onosproject.yangutils.parser.Parsable;
29 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 25 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
30 import org.onosproject.yangutils.parser.exceptions.ParserException; 26 import org.onosproject.yangutils.parser.exceptions.ParserException;
31 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 27 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
32 import org.onosproject.yangutils.utils.YangConstructType; 28 import org.onosproject.yangutils.utils.YangConstructType;
33 -import org.onosproject.yangutils.utils.builtindatatype.DataTypeException;
34 -import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo;
35 29
36 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat; 30 +import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
37 -import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA;
38 -import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
40 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
41 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
42 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
43 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
44 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
45 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
46 -import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString; 36 +import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction;
37 +import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA;
38 +import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
47 39
48 /* 40 /*
49 * Reference: RFC6020 and YANG ANTLR Grammar 41 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -71,11 +63,6 @@ import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectF ...@@ -71,11 +63,6 @@ import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectF
71 */ 63 */
72 public final class LengthRestrictionListener { 64 public final class LengthRestrictionListener {
73 65
74 - private static final String PIPE = "|";
75 - private static final String LENGTH_INTERVAL = "..";
76 - private static final int MAX_RANGE_BOUNDARY = 2;
77 - private static final int MIN_RANGE_BOUNDARY = 1;
78 -
79 /** 66 /**
80 * Creates a new length restriction listener. 67 * Creates a new length restriction listener.
81 */ 68 */
...@@ -88,10 +75,10 @@ public final class LengthRestrictionListener { ...@@ -88,10 +75,10 @@ public final class LengthRestrictionListener {
88 * tree. 75 * tree.
89 * 76 *
90 * @param listener listener's object 77 * @param listener listener's object
91 - * @param ctx context object of the grammar rule 78 + * @param ctx context object of the grammar rule
92 */ 79 */
93 public static void processLengthRestrictionEntry(TreeWalkListener listener, 80 public static void processLengthRestrictionEntry(TreeWalkListener listener,
94 - GeneratedYangParser.LengthStatementContext ctx) { 81 + GeneratedYangParser.LengthStatementContext ctx) {
95 82
96 // Check for stack to be non empty. 83 // Check for stack to be non empty.
97 checkStackIsNotEmpty(listener, MISSING_HOLDER, LENGTH_DATA, ctx.length().getText(), ENTRY); 84 checkStackIsNotEmpty(listener, MISSING_HOLDER, LENGTH_DATA, ctx.length().getText(), ENTRY);
...@@ -110,18 +97,22 @@ public final class LengthRestrictionListener { ...@@ -110,18 +97,22 @@ public final class LengthRestrictionListener {
110 * Sets the length restriction to type. 97 * Sets the length restriction to type.
111 * 98 *
112 * @param type Yang type for which length restriction to be set 99 * @param type Yang type for which length restriction to be set
113 - * @param ctx context object of the grammar rule 100 + * @param ctx context object of the grammar rule
114 */ 101 */
115 private static void setLengthRestriction(YangType type, 102 private static void setLengthRestriction(YangType type,
116 - GeneratedYangParser.LengthStatementContext ctx) { 103 + GeneratedYangParser.LengthStatementContext ctx) {
117 - 104 +
118 - YangStringRestriction stringRestriction; 105 + if (type.getDataType() == DERIVED) {
119 - YangBuiltInDataTypeInfo<?> startValue; 106 + ((YangDerivedInfo<YangRangeRestriction>) type.getDataTypeExtendedInfo())
120 - YangBuiltInDataTypeInfo<?> endValue; 107 + .setLengthRestrictionString(ctx.length().getText());
121 - YangRangeRestriction lengthRestriction = new YangRangeRestriction<>(); 108 + ((YangDerivedInfo<YangRangeRestriction>) type.getDataTypeExtendedInfo())
122 - 109 + .setLineNumber(ctx.getStart().getLine());
123 - if (type.getDataType() != YangDataTypes.STRING && type.getDataType() != YangDataTypes.DERIVED) { 110 + ((YangDerivedInfo<YangRangeRestriction>) type.getDataTypeExtendedInfo())
111 + .setCharPosition(ctx.getStart().getCharPositionInLine());
112 + return;
113 + }
124 114
115 + if (type.getDataType() != YangDataTypes.STRING) {
125 ParserException parserException = new ParserException("YANG file error : " + 116 ParserException parserException = new ParserException("YANG file error : " +
126 YangConstructType.getYangConstructType(LENGTH_DATA) + " name " + ctx.length().getText() + 117 YangConstructType.getYangConstructType(LENGTH_DATA) + " name " + ctx.length().getText() +
127 " can be used to restrict the built-in type string or types derived from string."); 118 " can be used to restrict the built-in type string or types derived from string.");
...@@ -130,71 +121,14 @@ public final class LengthRestrictionListener { ...@@ -130,71 +121,14 @@ public final class LengthRestrictionListener {
130 throw parserException; 121 throw parserException;
131 } 122 }
132 123
133 - if (type.getDataType() == YangDataTypes.STRING) { 124 + YangRangeRestriction lengthRestriction = processLengthRestriction(null, ctx.getStart().getLine(),
134 - stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo(); 125 + ctx.getStart().getCharPositionInLine(), false, ctx.length().getText());
135 - } else { 126 +
136 - stringRestriction = (YangStringRestriction) ((YangDerivedInfo<?>) type 127 + YangStringRestriction stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo();
137 - .getDataTypeExtendedInfo()).getExtendedInfo();
138 - }
139 128
140 if (stringRestriction == null) { 129 if (stringRestriction == null) {
141 stringRestriction = new YangStringRestriction(); 130 stringRestriction = new YangStringRestriction();
142 - if (type.getDataType() == YangDataTypes.STRING) { 131 + type.setDataTypeExtendedInfo(stringRestriction);
143 - type.setDataTypeExtendedInfo(stringRestriction);
144 - } else {
145 - ((YangDerivedInfo<YangStringRestriction>) type.getDataTypeExtendedInfo())
146 - .setExtendedInfo(stringRestriction);
147 - }
148 - }
149 -
150 - String rangeArgument = removeQuotesAndHandleConcat(ctx.length().getText());
151 - String[] rangeArguments = rangeArgument.trim().split(Pattern.quote(PIPE));
152 -
153 - for (String rangePart : rangeArguments) {
154 - String startInterval;
155 - String endInterval;
156 - YangRangeInterval rangeInterval = new YangRangeInterval<>();
157 - String[] rangeBoundary = rangePart.trim().split(Pattern.quote(LENGTH_INTERVAL));
158 -
159 - if (rangeBoundary.length > MAX_RANGE_BOUNDARY) {
160 - ParserException parserException = new ParserException("YANG file error : " +
161 - YangConstructType.getYangConstructType(LENGTH_DATA) + " " + rangeArgument +
162 - " is not valid.");
163 - parserException.setLine(ctx.getStart().getLine());
164 - parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
165 - throw parserException;
166 - }
167 -
168 - if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
169 - startInterval = rangeBoundary[0];
170 - endInterval = rangeBoundary[0];
171 - } else {
172 - startInterval = rangeBoundary[0];
173 - endInterval = rangeBoundary[1];
174 - }
175 -
176 - try {
177 - startValue = getDataObjectFromString(startInterval, YangDataTypes.UINT64);
178 - endValue = getDataObjectFromString(endInterval, YangDataTypes.UINT64);
179 - } catch (DataTypeException e) {
180 - ParserException parserException = new ParserException(e.getMessage());
181 - parserException.setLine(ctx.getStart().getLine());
182 - parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
183 - throw parserException;
184 - }
185 -
186 - rangeInterval.setStartValue(startValue);
187 - rangeInterval.setEndValue(endValue);
188 -
189 - try {
190 - lengthRestriction.addRangeRestrictionInterval(rangeInterval);
191 - } catch (DataModelException e) {
192 - ParserException parserException = new ParserException(constructExtendedListenerErrorMessage(
193 - UNHANDLED_PARSED_DATA, LENGTH_DATA, rangeArgument, ENTRY, e.getMessage()));
194 - parserException.setLine(ctx.getStart().getLine());
195 - parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
196 - throw parserException;
197 - }
198 } 132 }
199 133
200 stringRestriction.setLengthRestriction(lengthRestriction); 134 stringRestriction.setLengthRestriction(lengthRestriction);
......
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -16,23 +16,24 @@ ...@@ -16,23 +16,24 @@
16 16
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 +import org.onosproject.yangutils.datamodel.YangDataTypes;
19 import org.onosproject.yangutils.datamodel.YangDerivedInfo; 20 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
20 -import org.onosproject.yangutils.datamodel.YangType; 21 +import org.onosproject.yangutils.datamodel.YangPatternRestriction;
21 import org.onosproject.yangutils.datamodel.YangStringRestriction; 22 import org.onosproject.yangutils.datamodel.YangStringRestriction;
22 -import org.onosproject.yangutils.datamodel.YangDataTypes; 23 +import org.onosproject.yangutils.datamodel.YangType;
23 import org.onosproject.yangutils.parser.Parsable; 24 import org.onosproject.yangutils.parser.Parsable;
24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 25 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
25 import org.onosproject.yangutils.parser.exceptions.ParserException; 26 import org.onosproject.yangutils.parser.exceptions.ParserException;
26 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 27 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
27 import org.onosproject.yangutils.utils.YangConstructType; 28 import org.onosproject.yangutils.utils.YangConstructType;
28 29
29 -import static org.onosproject.yangutils.utils.YangConstructType.PATTERN_DATA;
30 -import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
35 +import static org.onosproject.yangutils.utils.YangConstructType.PATTERN_DATA;
36 +import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
36 37
37 /* 38 /*
38 * Reference: RFC6020 and YANG ANTLR Grammar 39 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -72,10 +73,10 @@ public final class PatternRestrictionListener { ...@@ -72,10 +73,10 @@ public final class PatternRestrictionListener {
72 * tree. 73 * tree.
73 * 74 *
74 * @param listener listener's object 75 * @param listener listener's object
75 - * @param ctx context object of the grammar rule 76 + * @param ctx context object of the grammar rule
76 */ 77 */
77 public static void processPatternRestrictionEntry(TreeWalkListener listener, 78 public static void processPatternRestrictionEntry(TreeWalkListener listener,
78 - GeneratedYangParser.PatternStatementContext ctx) { 79 + GeneratedYangParser.PatternStatementContext ctx) {
79 80
80 // Check for stack to be non empty. 81 // Check for stack to be non empty.
81 checkStackIsNotEmpty(listener, MISSING_HOLDER, PATTERN_DATA, ctx.string().getText(), ENTRY); 82 checkStackIsNotEmpty(listener, MISSING_HOLDER, PATTERN_DATA, ctx.string().getText(), ENTRY);
...@@ -94,13 +95,11 @@ public final class PatternRestrictionListener { ...@@ -94,13 +95,11 @@ public final class PatternRestrictionListener {
94 * Sets the pattern restriction to type. 95 * Sets the pattern restriction to type.
95 * 96 *
96 * @param type Yang type for which pattern restriction to be set 97 * @param type Yang type for which pattern restriction to be set
97 - * @param ctx context object of the grammar rule 98 + * @param ctx context object of the grammar rule
98 */ 99 */
99 private static void setPatternRestriction(YangType type, 100 private static void setPatternRestriction(YangType type,
100 GeneratedYangParser.PatternStatementContext ctx) { 101 GeneratedYangParser.PatternStatementContext ctx) {
101 102
102 - YangStringRestriction stringRestriction;
103 -
104 if (type.getDataType() != YangDataTypes.STRING && type.getDataType() != YangDataTypes.DERIVED) { 103 if (type.getDataType() != YangDataTypes.STRING && type.getDataType() != YangDataTypes.DERIVED) {
105 104
106 ParserException parserException = new ParserException("YANG file error : " + 105 ParserException parserException = new ParserException("YANG file error : " +
...@@ -111,24 +110,28 @@ public final class PatternRestrictionListener { ...@@ -111,24 +110,28 @@ public final class PatternRestrictionListener {
111 throw parserException; 110 throw parserException;
112 } 111 }
113 112
114 - if (type.getDataType() == YangDataTypes.STRING) { 113 + String patternArgument = ctx.string().getText().replace("\"", EMPTY_STRING);
115 - stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo();
116 - } else {
117 - stringRestriction = (YangStringRestriction) ((YangDerivedInfo<?>) type
118 - .getDataTypeExtendedInfo()).getExtendedInfo();
119 - }
120 114
121 - if (stringRestriction == null) { 115 + if (type.getDataType() == YangDataTypes.STRING) {
122 - stringRestriction = new YangStringRestriction(); 116 + YangStringRestriction stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo();
123 - if (type.getDataType() == YangDataTypes.STRING) { 117 + if (stringRestriction == null) {
118 + stringRestriction = new YangStringRestriction();
124 type.setDataTypeExtendedInfo(stringRestriction); 119 type.setDataTypeExtendedInfo(stringRestriction);
120 + stringRestriction.addPattern(patternArgument);
125 } else { 121 } else {
126 - ((YangDerivedInfo<YangStringRestriction>) type.getDataTypeExtendedInfo()) 122 + stringRestriction.addPattern(patternArgument);
127 - .setExtendedInfo(stringRestriction); 123 + }
124 + } else {
125 + YangPatternRestriction patternRestriction = (YangPatternRestriction) ((YangDerivedInfo<?>) type
126 + .getDataTypeExtendedInfo()).getPatternRestriction();
127 + if (patternRestriction == null) {
128 + patternRestriction = new YangPatternRestriction();
129 + ((YangDerivedInfo<?>) type.getDataTypeExtendedInfo()).setPatternRestriction(patternRestriction);
130 + patternRestriction.addPattern(patternArgument);
131 + } else {
132 + ((YangDerivedInfo<?>) type.getDataTypeExtendedInfo()).setPatternRestriction(patternRestriction);
133 + patternRestriction.addPattern(patternArgument);
128 } 134 }
129 } 135 }
130 -
131 - String patternArgument = ctx.string().getText().replace("\"", EMPTY_STRING);
132 - stringRestriction.addPattern(patternArgument);
133 } 136 }
134 } 137 }
......
...@@ -16,33 +16,24 @@ ...@@ -16,33 +16,24 @@
16 16
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 -import java.util.regex.Pattern; 19 +import org.onosproject.yangutils.datamodel.YangDerivedInfo;
20 -
21 -import org.onosproject.yangutils.datamodel.YangRangeInterval;
22 import org.onosproject.yangutils.datamodel.YangRangeRestriction; 20 import org.onosproject.yangutils.datamodel.YangRangeRestriction;
23 import org.onosproject.yangutils.datamodel.YangType; 21 import org.onosproject.yangutils.datamodel.YangType;
24 -import org.onosproject.yangutils.datamodel.YangDerivedInfo;
25 -import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
26 -import org.onosproject.yangutils.datamodel.YangDataTypes;
27 import org.onosproject.yangutils.parser.Parsable; 22 import org.onosproject.yangutils.parser.Parsable;
28 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
29 import org.onosproject.yangutils.parser.exceptions.ParserException; 24 import org.onosproject.yangutils.parser.exceptions.ParserException;
30 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 25 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
31 -import org.onosproject.yangutils.utils.YangConstructType;
32 -import org.onosproject.yangutils.utils.builtindatatype.DataTypeException;
33 -import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo;
34 26
27 +import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 28 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
36 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
37 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 29 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
38 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
40 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
41 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
42 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
43 -import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA; 33 +import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType;
34 +import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRestriction;
44 import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA; 35 import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA;
45 -import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString; 36 +import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
46 37
47 /* 38 /*
48 * Reference: RFC6020 and YANG ANTLR Grammar 39 * Reference: RFC6020 and YANG ANTLR Grammar
...@@ -68,11 +59,6 @@ import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectF ...@@ -68,11 +59,6 @@ import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectF
68 */ 59 */
69 public final class RangeRestrictionListener { 60 public final class RangeRestrictionListener {
70 61
71 - private static final String PIPE = "|";
72 - private static final String RANGE_INTERVAL = "..";
73 - private static final int MAX_RANGE_BOUNDARY = 2;
74 - private static final int MIN_RANGE_BOUNDARY = 1;
75 -
76 /** 62 /**
77 * Creates a new range restriction listener. 63 * Creates a new range restriction listener.
78 */ 64 */
...@@ -85,10 +71,10 @@ public final class RangeRestrictionListener { ...@@ -85,10 +71,10 @@ public final class RangeRestrictionListener {
85 * tree. 71 * tree.
86 * 72 *
87 * @param listener listener's object 73 * @param listener listener's object
88 - * @param ctx context object of the grammar rule 74 + * @param ctx context object of the grammar rule
89 */ 75 */
90 public static void processRangeRestrictionEntry(TreeWalkListener listener, 76 public static void processRangeRestrictionEntry(TreeWalkListener listener,
91 - GeneratedYangParser.RangeStatementContext ctx) { 77 + GeneratedYangParser.RangeStatementContext ctx) {
92 78
93 // Check for stack to be non empty. 79 // Check for stack to be non empty.
94 checkStackIsNotEmpty(listener, MISSING_HOLDER, RANGE_DATA, ctx.range().getText(), ENTRY); 80 checkStackIsNotEmpty(listener, MISSING_HOLDER, RANGE_DATA, ctx.range().getText(), ENTRY);
...@@ -107,73 +93,34 @@ public final class RangeRestrictionListener { ...@@ -107,73 +93,34 @@ public final class RangeRestrictionListener {
107 * Sets the range restriction to type. 93 * Sets the range restriction to type.
108 * 94 *
109 * @param type YANG type for which range restriction to be added 95 * @param type YANG type for which range restriction to be added
110 - * @param ctx context object of the grammar rule 96 + * @param ctx context object of the grammar rule
111 */ 97 */
112 private static void setRangeRestriction(YangType type, 98 private static void setRangeRestriction(YangType type,
113 - GeneratedYangParser.RangeStatementContext ctx) { 99 + GeneratedYangParser.RangeStatementContext ctx) {
114 - 100 +
115 - YangBuiltInDataTypeInfo<?> startValue; 101 + if (type.getDataType() == DERIVED) {
116 - YangBuiltInDataTypeInfo<?> endValue; 102 + ((YangDerivedInfo<YangRangeRestriction>) type.getDataTypeExtendedInfo())
117 - YangRangeRestriction rangeRestriction = new YangRangeRestriction(); 103 + .setRangeRestrictionString(ctx.range().getText());
118 - 104 + ((YangDerivedInfo<YangRangeRestriction>) type.getDataTypeExtendedInfo())
119 - String rangeArgument = removeQuotesAndHandleConcat(ctx.range().getText()); 105 + .setLineNumber(ctx.getStart().getLine());
120 - String[] rangeArguments = rangeArgument.trim().split(Pattern.quote(PIPE)); 106 + ((YangDerivedInfo<YangRangeRestriction>) type.getDataTypeExtendedInfo())
121 - 107 + .setCharPosition(ctx.getStart().getCharPositionInLine());
122 - for (String rangePart : rangeArguments) { 108 + return;
123 - String startInterval; 109 + }
124 - String endInterval;
125 - YangRangeInterval rangeInterval = new YangRangeInterval();
126 - String[] rangeBoundary = rangePart.trim().split(Pattern.quote(RANGE_INTERVAL));
127 -
128 - if (rangeBoundary.length > MAX_RANGE_BOUNDARY) {
129 - ParserException parserException = new ParserException("YANG file error : " +
130 - YangConstructType.getYangConstructType(RANGE_DATA) + " " + rangeArgument +
131 - " is not valid.");
132 - parserException.setLine(ctx.getStart().getLine());
133 - parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
134 - throw parserException;
135 - }
136 -
137 - if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
138 - startInterval = rangeBoundary[0];
139 - endInterval = rangeBoundary[0];
140 - } else {
141 - startInterval = rangeBoundary[0];
142 - endInterval = rangeBoundary[1];
143 - }
144 -
145 - try {
146 - startValue = getDataObjectFromString(startInterval, type.getDataType());
147 - endValue = getDataObjectFromString(endInterval, type.getDataType());
148 - } catch (DataTypeException e) {
149 - ParserException parserException = new ParserException(e.getMessage());
150 - parserException.setLine(ctx.getStart().getLine());
151 - parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
152 - throw parserException;
153 - }
154 -
155 - rangeInterval.setStartValue(startValue);
156 - rangeInterval.setEndValue(endValue);
157 110
158 - try { 111 + if (!(isOfRangeRestrictedType(type.getDataType()))) {
159 - rangeRestriction.addRangeRestrictionInterval(rangeInterval); 112 + ParserException parserException = new ParserException("YANG file error: Range restriction can't be " +
160 - } catch (DataModelException e) { 113 + "applied to a given type");
161 - ParserException parserException = new ParserException(constructExtendedListenerErrorMessage( 114 + parserException.setLine(ctx.getStart().getLine());
162 - UNHANDLED_PARSED_DATA, RANGE_DATA, rangeArgument, ENTRY, e.getMessage())); 115 + parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
163 - parserException.setLine(ctx.getStart().getLine()); 116 + throw parserException;
164 - parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
165 - throw parserException;
166 - }
167 } 117 }
168 118
119 + YangRangeRestriction rangeRestriction = processRangeRestriction(null, ctx.getStart().getLine(),
120 + ctx.getStart().getCharPositionInLine(), false, ctx.range().getText(), type.getDataType());
121 +
169 if (rangeRestriction != null) { 122 if (rangeRestriction != null) {
170 - if (type.getDataType() == YangDataTypes.DERIVED) { 123 + type.setDataTypeExtendedInfo(rangeRestriction);
171 - ((YangDerivedInfo<YangRangeRestriction>) type.getDataTypeExtendedInfo())
172 - .setExtendedInfo(rangeRestriction);
173 - } else {
174 - type.setDataTypeExtendedInfo(rangeRestriction);
175 - }
176 } 124 }
177 -
178 } 125 }
179 } 126 }
...\ No newline at end of file ...\ No newline at end of file
......
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 +
17 +package org.onosproject.yangutils.utils;
18 +
19 +import java.util.regex.Pattern;
20 +import org.onosproject.yangutils.datamodel.YangDataTypes;
21 +import org.onosproject.yangutils.datamodel.YangRangeInterval;
22 +import org.onosproject.yangutils.datamodel.YangRangeRestriction;
23 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 +import org.onosproject.yangutils.parser.exceptions.ParserException;
25 +import org.onosproject.yangutils.utils.builtindatatype.DataTypeException;
26 +import org.onosproject.yangutils.utils.builtindatatype.YangBuiltInDataTypeInfo;
27 +
28 +import static org.onosproject.yangutils.datamodel.YangDataTypes.DECIMAL64;
29 +import static org.onosproject.yangutils.datamodel.YangDataTypes.INT16;
30 +import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
31 +import static org.onosproject.yangutils.datamodel.YangDataTypes.INT64;
32 +import static org.onosproject.yangutils.datamodel.YangDataTypes.INT8;
33 +import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT16;
34 +import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT32;
35 +import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT64;
36 +import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT8;
37 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
38 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
39 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
40 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
41 +import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA;
42 +import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA;
43 +import static org.onosproject.yangutils.utils.builtindatatype.BuiltInTypeObjectFactory.getDataObjectFromString;
44 +
45 +/**
46 + * Represents restriction resolver which provide common utility used by parser
47 + * and during linking for restriction resolution.
48 + */
49 +public final class RestrictionResolver {
50 +
51 + private static final String PIPE = "|";
52 + private static final String INTERVAL = "..";
53 + private static final int MAX_RANGE_BOUNDARY = 2;
54 + private static final int MIN_RANGE_BOUNDARY = 1;
55 + private static final String MIN_KEYWORD = "min";
56 + private static final String MAX_KEYWORD = "max";
57 +
58 + /**
59 + * Creates a restriction resolver.
60 + */
61 + private RestrictionResolver() {
62 + }
63 +
64 + /**
65 + * Processes the range restriction for parser and linker.
66 + *
67 + * @param refRangeRestriction range restriction of referred typedef
68 + * @param lineNumber error line number
69 + * @param charPositionInLine error character position in line
70 + * @param hasReferredRestriction whether has referred restriction
71 + * @param curRangeString caller type's range string
72 + * @param effectiveType effective type, when called from linker
73 + * @return YANG range restriction
74 + */
75 + public static YangRangeRestriction processRangeRestriction(YangRangeRestriction refRangeRestriction,
76 + int lineNumber, int charPositionInLine,
77 + boolean hasReferredRestriction,
78 + String curRangeString, YangDataTypes effectiveType) {
79 + YangBuiltInDataTypeInfo<?> startValue;
80 + YangBuiltInDataTypeInfo<?> endValue;
81 + YangRangeRestriction rangeRestriction = new YangRangeRestriction();
82 +
83 + String rangeArgument = removeQuotesAndHandleConcat(curRangeString);
84 + String[] rangeArguments = rangeArgument.trim().split(Pattern.quote(PIPE));
85 +
86 + for (String rangePart : rangeArguments) {
87 + String startInterval;
88 + String endInterval;
89 + YangRangeInterval rangeInterval = new YangRangeInterval();
90 + String[] rangeBoundary = rangePart.trim().split(Pattern.quote(INTERVAL));
91 +
92 + if (rangeBoundary.length > MAX_RANGE_BOUNDARY) {
93 + ParserException parserException = new ParserException("YANG file error : " +
94 + YangConstructType.getYangConstructType(RANGE_DATA) + " " + rangeArgument +
95 + " is not valid.");
96 + parserException.setLine(lineNumber);
97 + parserException.setCharPosition(charPositionInLine);
98 + throw parserException;
99 + }
100 +
101 + if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
102 + startInterval = rangeBoundary[0];
103 + endInterval = rangeBoundary[0];
104 + } else {
105 + startInterval = rangeBoundary[0];
106 + endInterval = rangeBoundary[1];
107 + }
108 +
109 + try {
110 + if (hasReferredRestriction && startInterval.equals(MIN_KEYWORD)
111 + && refRangeRestriction.getMinRestrictedvalue() != null) {
112 + startValue = refRangeRestriction.getMinRestrictedvalue();
113 + } else if (hasReferredRestriction && startInterval.equals(MAX_KEYWORD)
114 + && refRangeRestriction.getMaxRestrictedvalue() != null) {
115 + startValue = refRangeRestriction.getMaxRestrictedvalue();
116 + } else {
117 + startValue = getDataObjectFromString(startInterval, effectiveType);
118 + }
119 + if (hasReferredRestriction && endInterval.equals(MIN_KEYWORD)
120 + && refRangeRestriction.getMinRestrictedvalue() != null) {
121 + endValue = refRangeRestriction.getMinRestrictedvalue();
122 + } else if (hasReferredRestriction && endInterval.equals(MAX_KEYWORD)
123 + && refRangeRestriction.getMaxRestrictedvalue() != null) {
124 + endValue = refRangeRestriction.getMaxRestrictedvalue();
125 + } else {
126 + endValue = getDataObjectFromString(endInterval, effectiveType);
127 + }
128 + } catch (DataTypeException | DataModelException e) {
129 + ParserException parserException = new ParserException(e.getMessage());
130 + parserException.setLine(lineNumber);
131 + parserException.setCharPosition(charPositionInLine);
132 + throw parserException;
133 + }
134 +
135 + rangeInterval.setStartValue(startValue);
136 + rangeInterval.setEndValue(endValue);
137 +
138 + try {
139 + rangeRestriction.addRangeRestrictionInterval(rangeInterval);
140 + } catch (DataModelException e) {
141 + ParserException parserException = new ParserException(constructExtendedListenerErrorMessage(
142 + UNHANDLED_PARSED_DATA, RANGE_DATA, rangeArgument, ENTRY, e.getMessage()));
143 + parserException.setLine(lineNumber);
144 + parserException.setCharPosition(charPositionInLine);
145 + throw parserException;
146 + }
147 + }
148 + return rangeRestriction;
149 + }
150 +
151 + /**
152 + * Processes the length restriction for parser and linker.
153 + *
154 + * @param refLengthRestriction length restriction of referred typedef
155 + * @param lineNumber error line number
156 + * @param charPositionInLine error character position in line
157 + * @param hasReferredRestriction whether has referred restriction
158 + * @param curLengthString caller type's length string
159 + * @return YANG range restriction
160 + */
161 + public static YangRangeRestriction processLengthRestriction(YangRangeRestriction refLengthRestriction,
162 + int lineNumber, int charPositionInLine,
163 + boolean hasReferredRestriction,
164 + String curLengthString) {
165 +
166 + YangBuiltInDataTypeInfo<?> startValue;
167 + YangBuiltInDataTypeInfo<?> endValue;
168 + YangRangeRestriction lengthRestriction = new YangRangeRestriction<>();
169 +
170 + String rangeArgument = removeQuotesAndHandleConcat(curLengthString);
171 + String[] rangeArguments = rangeArgument.trim().split(Pattern.quote(PIPE));
172 +
173 + for (String rangePart : rangeArguments) {
174 + String startInterval;
175 + String endInterval;
176 + YangRangeInterval rangeInterval = new YangRangeInterval<>();
177 + String[] rangeBoundary = rangePart.trim().split(Pattern.quote(INTERVAL));
178 +
179 + if (rangeBoundary.length > MAX_RANGE_BOUNDARY) {
180 + ParserException parserException = new ParserException("YANG file error : " +
181 + YangConstructType.getYangConstructType(LENGTH_DATA) + " " + rangeArgument +
182 + " is not valid.");
183 + parserException.setLine(lineNumber);
184 + parserException.setCharPosition(charPositionInLine);
185 + throw parserException;
186 + }
187 +
188 + if (rangeBoundary.length == MIN_RANGE_BOUNDARY) {
189 + startInterval = rangeBoundary[0];
190 + endInterval = rangeBoundary[0];
191 + } else {
192 + startInterval = rangeBoundary[0];
193 + endInterval = rangeBoundary[1];
194 + }
195 +
196 + try {
197 + if (hasReferredRestriction && startInterval.equals(MIN_KEYWORD)
198 + && refLengthRestriction.getMinRestrictedvalue() != null) {
199 + startValue = refLengthRestriction.getMinRestrictedvalue();
200 + } else if (hasReferredRestriction && startInterval.equals(MAX_KEYWORD)
201 + && refLengthRestriction.getMaxRestrictedvalue() != null) {
202 + startValue = refLengthRestriction.getMaxRestrictedvalue();
203 + } else {
204 + startValue = getDataObjectFromString(startInterval, YangDataTypes.UINT64);
205 + }
206 + if (hasReferredRestriction && endInterval.equals(MIN_KEYWORD)
207 + && refLengthRestriction.getMinRestrictedvalue() != null) {
208 + endValue = refLengthRestriction.getMinRestrictedvalue();
209 + } else if (hasReferredRestriction && endInterval.equals(MAX_KEYWORD)
210 + && refLengthRestriction.getMaxRestrictedvalue() != null) {
211 + endValue = refLengthRestriction.getMaxRestrictedvalue();
212 + } else {
213 + endValue = getDataObjectFromString(endInterval, YangDataTypes.UINT64);
214 + }
215 + } catch (DataTypeException | DataModelException e) {
216 + ParserException parserException = new ParserException(e.getMessage());
217 + parserException.setLine(lineNumber);
218 + parserException.setCharPosition(charPositionInLine);
219 + throw parserException;
220 + }
221 +
222 + rangeInterval.setStartValue(startValue);
223 + rangeInterval.setEndValue(endValue);
224 +
225 + try {
226 + lengthRestriction.addRangeRestrictionInterval(rangeInterval);
227 + } catch (DataModelException e) {
228 + ParserException parserException = new ParserException(constructExtendedListenerErrorMessage(
229 + UNHANDLED_PARSED_DATA, LENGTH_DATA, rangeArgument, ENTRY, e.getMessage()));
230 + parserException.setLine(lineNumber);
231 + parserException.setCharPosition(charPositionInLine);
232 + throw parserException;
233 + }
234 + }
235 + return lengthRestriction;
236 + }
237 +
238 + /**
239 + * Returns whether the data type is of range restricted type.
240 + *
241 + * @param dataType data type to be checked
242 + * @return true, if data type can have range restrictions, false otherwise
243 + */
244 + public static boolean isOfRangeRestrictedType(YangDataTypes dataType) {
245 + return (dataType == INT8
246 + || dataType == INT16
247 + || dataType == INT32
248 + || dataType == INT64
249 + || dataType == UINT8
250 + || dataType == UINT16
251 + || dataType == UINT32
252 + || dataType == UINT64
253 + || dataType == DECIMAL64);
254 + }
255 +}
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 +
16 package org.onosproject.yangutils.utils.builtindatatype; 17 package org.onosproject.yangutils.utils.builtindatatype;
17 18
18 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
...@@ -66,7 +67,8 @@ public class YangInt16 implements YangBuiltInDataTypeInfo<YangInt16> { ...@@ -66,7 +67,8 @@ public class YangInt16 implements YangBuiltInDataTypeInfo<YangInt16> {
66 try { 67 try {
67 value = Short.parseShort(valueInString); 68 value = Short.parseShort(valueInString);
68 } catch (Exception e) { 69 } catch (Exception e) {
69 - throw new DataTypeException("YANG file error : " + valueInString + " is not valid."); 70 + throw new DataTypeException("YANG file error : Input value \"" + valueInString + "\" is not a valid " +
71 + "int16.");
70 } 72 }
71 } 73 }
72 } 74 }
......
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 +
16 package org.onosproject.yangutils.utils.builtindatatype; 17 package org.onosproject.yangutils.utils.builtindatatype;
17 18
18 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
...@@ -65,7 +66,8 @@ public class YangInt32 implements YangBuiltInDataTypeInfo<YangInt32> { ...@@ -65,7 +66,8 @@ public class YangInt32 implements YangBuiltInDataTypeInfo<YangInt32> {
65 try { 66 try {
66 value = Integer.parseInt(valueInString); 67 value = Integer.parseInt(valueInString);
67 } catch (Exception e) { 68 } catch (Exception e) {
68 - throw new DataTypeException("YANG file error : " + valueInString + " is not valid."); 69 + throw new DataTypeException("YANG file error : Input value \"" + valueInString + "\" is not a valid " +
70 + "int32.");
69 } 71 }
70 } 72 }
71 } 73 }
......
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 +
16 package org.onosproject.yangutils.utils.builtindatatype; 17 package org.onosproject.yangutils.utils.builtindatatype;
17 18
18 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
...@@ -65,7 +66,8 @@ public class YangInt64 implements YangBuiltInDataTypeInfo<YangInt64> { ...@@ -65,7 +66,8 @@ public class YangInt64 implements YangBuiltInDataTypeInfo<YangInt64> {
65 try { 66 try {
66 value = Long.parseLong(valueInString); 67 value = Long.parseLong(valueInString);
67 } catch (Exception e) { 68 } catch (Exception e) {
68 - throw new DataTypeException("YANG file error : " + valueInString + " is not valid."); 69 + throw new DataTypeException("YANG file error : Input value \"" + valueInString + "\" is not a valid " +
70 + "int64.");
69 } 71 }
70 } 72 }
71 } 73 }
......
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 +
16 package org.onosproject.yangutils.utils.builtindatatype; 17 package org.onosproject.yangutils.utils.builtindatatype;
17 18
18 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
...@@ -65,7 +66,8 @@ public class YangInt8 implements YangBuiltInDataTypeInfo<YangInt8> { ...@@ -65,7 +66,8 @@ public class YangInt8 implements YangBuiltInDataTypeInfo<YangInt8> {
65 try { 66 try {
66 value = Byte.parseByte(valueInString); 67 value = Byte.parseByte(valueInString);
67 } catch (Exception e) { 68 } catch (Exception e) {
68 - throw new DataTypeException("YANG file error : " + valueInString + " is not valid."); 69 + throw new DataTypeException("YANG file error : Input value \"" + valueInString + "\" is not a valid " +
70 + "int8.");
69 } 71 }
70 } 72 }
71 } 73 }
......
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 +
16 package org.onosproject.yangutils.utils.builtindatatype; 17 package org.onosproject.yangutils.utils.builtindatatype;
17 18
18 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
...@@ -65,7 +66,8 @@ public class YangUint16 implements YangBuiltInDataTypeInfo<YangUint16> { ...@@ -65,7 +66,8 @@ public class YangUint16 implements YangBuiltInDataTypeInfo<YangUint16> {
65 try { 66 try {
66 value = Integer.parseInt(valueInString); 67 value = Integer.parseInt(valueInString);
67 } catch (Exception e) { 68 } catch (Exception e) {
68 - throw new DataTypeException("YANG file error : " + valueInString + " is not valid."); 69 + throw new DataTypeException("YANG file error : Input value \"" + valueInString + "\" is not a valid " +
70 + "uint16.");
69 } 71 }
70 } 72 }
71 73
......
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 +
16 package org.onosproject.yangutils.utils.builtindatatype; 17 package org.onosproject.yangutils.utils.builtindatatype;
17 18
18 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
...@@ -58,7 +59,8 @@ public class YangUint32 implements YangBuiltInDataTypeInfo<YangUint32> { ...@@ -58,7 +59,8 @@ public class YangUint32 implements YangBuiltInDataTypeInfo<YangUint32> {
58 try { 59 try {
59 value = Long.parseLong(valueInString); 60 value = Long.parseLong(valueInString);
60 } catch (Exception e) { 61 } catch (Exception e) {
61 - throw new DataTypeException("YANG file error : " + valueInString + " is not valid."); 62 + throw new DataTypeException("YANG file error : Input value \"" + valueInString + "\" is not a valid " +
63 + "uint32.");
62 } 64 }
63 } 65 }
64 66
......
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 +
16 package org.onosproject.yangutils.utils.builtindatatype; 17 package org.onosproject.yangutils.utils.builtindatatype;
17 18
18 import java.math.BigInteger; 19 import java.math.BigInteger;
...@@ -71,7 +72,8 @@ public class YangUint64 implements YangBuiltInDataTypeInfo<YangUint64> { ...@@ -71,7 +72,8 @@ public class YangUint64 implements YangBuiltInDataTypeInfo<YangUint64> {
71 } else if (NON_NEGATIVE_INTEGER_PATTERN.matcher(valueInString).matches()) { 72 } else if (NON_NEGATIVE_INTEGER_PATTERN.matcher(valueInString).matches()) {
72 value = new BigInteger(valueInString); 73 value = new BigInteger(valueInString);
73 } else { 74 } else {
74 - throw new DataTypeException("YANG file error : " + valueInString + " is not valid."); 75 + throw new DataTypeException("YANG file error : Input value \"" + valueInString + "\" is not a valid " +
76 + "uint64.");
75 } 77 }
76 78
77 if (value.compareTo(MIN_VALUE) < 0) { 79 if (value.compareTo(MIN_VALUE) < 0) {
......
1 /* 1 /*
2 - * Copyright 2016 Open Networking Laboratory 2 + * Copyright 2016-present Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 +
16 package org.onosproject.yangutils.utils.builtindatatype; 17 package org.onosproject.yangutils.utils.builtindatatype;
17 18
18 import org.onosproject.yangutils.datamodel.YangDataTypes; 19 import org.onosproject.yangutils.datamodel.YangDataTypes;
...@@ -65,7 +66,8 @@ public class YangUint8 implements YangBuiltInDataTypeInfo<YangUint8> { ...@@ -65,7 +66,8 @@ public class YangUint8 implements YangBuiltInDataTypeInfo<YangUint8> {
65 try { 66 try {
66 value = Short.parseShort(valueInString); 67 value = Short.parseShort(valueInString);
67 } catch (Exception e) { 68 } catch (Exception e) {
68 - throw new DataTypeException("YANG file error : " + valueInString + " is not valid."); 69 + throw new DataTypeException("YANG file error : Input value \"" + valueInString + "\" is not a valid " +
70 + "uint8.");
69 } 71 }
70 } 72 }
71 73
......
...@@ -18,23 +18,26 @@ package org.onosproject.yangutils.linker; ...@@ -18,23 +18,26 @@ package org.onosproject.yangutils.linker;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.ListIterator; 20 import java.util.ListIterator;
21 -
22 import org.junit.Test; 21 import org.junit.Test;
23 -import org.onosproject.yangutils.datamodel.ResolvableStatus;
24 import org.onosproject.yangutils.datamodel.YangContainer; 22 import org.onosproject.yangutils.datamodel.YangContainer;
25 -import org.onosproject.yangutils.datamodel.YangDataTypes;
26 import org.onosproject.yangutils.datamodel.YangDerivedInfo; 23 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
27 import org.onosproject.yangutils.datamodel.YangLeaf; 24 import org.onosproject.yangutils.datamodel.YangLeaf;
28 import org.onosproject.yangutils.datamodel.YangList; 25 import org.onosproject.yangutils.datamodel.YangList;
29 import org.onosproject.yangutils.datamodel.YangModule; 26 import org.onosproject.yangutils.datamodel.YangModule;
30 import org.onosproject.yangutils.datamodel.YangNode; 27 import org.onosproject.yangutils.datamodel.YangNode;
31 -import org.onosproject.yangutils.datamodel.YangNodeType;
32 import org.onosproject.yangutils.datamodel.YangTypeDef; 28 import org.onosproject.yangutils.datamodel.YangTypeDef;
33 import org.onosproject.yangutils.parser.exceptions.ParserException; 29 import org.onosproject.yangutils.parser.exceptions.ParserException;
34 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 30 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
35 31
32 +import static org.hamcrest.CoreMatchers.nullValue;
36 import static org.hamcrest.MatcherAssert.assertThat; 33 import static org.hamcrest.MatcherAssert.assertThat;
37 import static org.hamcrest.core.Is.is; 34 import static org.hamcrest.core.Is.is;
35 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.INTRA_FILE_RESOLVED;
36 +import static org.onosproject.yangutils.datamodel.ResolvableStatus.RESOLVED;
37 +import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
38 +import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
39 +import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
40 +import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
38 41
39 /** 42 /**
40 * Test cases for testing "type" intra file linking. 43 * Test cases for testing "type" intra file linking.
...@@ -56,7 +59,7 @@ public class IntraFileTypeLinkingTest { ...@@ -56,7 +59,7 @@ public class IntraFileTypeLinkingTest {
56 assertThat(node instanceof YangModule, is(true)); 59 assertThat(node instanceof YangModule, is(true));
57 60
58 // Check whether the node type is set properly to module. 61 // Check whether the node type is set properly to module.
59 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); 62 + assertThat(node.getNodeType(), is(MODULE_NODE));
60 63
61 // Check whether the module name is set correctly. 64 // Check whether the module name is set correctly.
62 YangModule yangNode = (YangModule) node; 65 YangModule yangNode = (YangModule) node;
...@@ -67,13 +70,23 @@ public class IntraFileTypeLinkingTest { ...@@ -67,13 +70,23 @@ public class IntraFileTypeLinkingTest {
67 70
68 assertThat(leafInfo.getName(), is("invalid-interval")); 71 assertThat(leafInfo.getName(), is("invalid-interval"));
69 assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); 72 assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
70 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); 73 + assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
71 74
72 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 75 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
73 is((YangTypeDef) node.getChild())); 76 is((YangTypeDef) node.getChild()));
74 77
75 - assertThat(leafInfo.getDataType().getResolvableStatus(), 78 + assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
76 - is(ResolvableStatus.RESOLVED)); 79 +
80 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
81 +
82 + // Check for the effective built-in type.
83 + assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
84 +
85 + // Check for the restriction.
86 + assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
87 + assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
88 + assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
89 + assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
77 } 90 }
78 91
79 /** 92 /**
...@@ -91,7 +104,7 @@ public class IntraFileTypeLinkingTest { ...@@ -91,7 +104,7 @@ public class IntraFileTypeLinkingTest {
91 assertThat((node instanceof YangModule), is(true)); 104 assertThat((node instanceof YangModule), is(true));
92 105
93 // Check whether the node type is set properly to module. 106 // Check whether the node type is set properly to module.
94 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); 107 + assertThat(node.getNodeType(), is(MODULE_NODE));
95 108
96 // Check whether the module name is set correctly. 109 // Check whether the module name is set correctly.
97 YangModule yangNode = (YangModule) node; 110 YangModule yangNode = (YangModule) node;
...@@ -106,13 +119,23 @@ public class IntraFileTypeLinkingTest { ...@@ -106,13 +119,23 @@ public class IntraFileTypeLinkingTest {
106 119
107 assertThat(leafInfo.getName(), is("invalid-interval")); 120 assertThat(leafInfo.getName(), is("invalid-interval"));
108 assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); 121 assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
109 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); 122 + assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
110 123
111 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 124 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
112 is((YangTypeDef) node.getChild())); 125 is((YangTypeDef) node.getChild()));
113 126
114 - assertThat(leafInfo.getDataType().getResolvableStatus(), 127 + assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
115 - is(ResolvableStatus.RESOLVED)); 128 +
129 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
130 +
131 + // Check for the effective built-in type.
132 + assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
133 +
134 + // Check for the restriction.
135 + assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
136 + assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
137 + assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
138 + assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
116 } 139 }
117 140
118 /** 141 /**
...@@ -131,7 +154,7 @@ public class IntraFileTypeLinkingTest { ...@@ -131,7 +154,7 @@ public class IntraFileTypeLinkingTest {
131 assertThat((node instanceof YangModule), is(true)); 154 assertThat((node instanceof YangModule), is(true));
132 155
133 // Check whether the node type is set properly to module. 156 // Check whether the node type is set properly to module.
134 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); 157 + assertThat(node.getNodeType(), is(MODULE_NODE));
135 158
136 // Check whether the module name is set correctly. 159 // Check whether the module name is set correctly.
137 YangModule yangNode = (YangModule) node; 160 YangModule yangNode = (YangModule) node;
...@@ -146,13 +169,23 @@ public class IntraFileTypeLinkingTest { ...@@ -146,13 +169,23 @@ public class IntraFileTypeLinkingTest {
146 169
147 assertThat(leafInfo.getName(), is("invalid-interval")); 170 assertThat(leafInfo.getName(), is("invalid-interval"));
148 assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); 171 assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
149 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); 172 + assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
150 173
151 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 174 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
152 is((YangTypeDef) node.getChild().getNextSibling())); 175 is((YangTypeDef) node.getChild().getNextSibling()));
153 176
154 - assertThat(leafInfo.getDataType().getResolvableStatus(), 177 + assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
155 - is(ResolvableStatus.RESOLVED)); 178 +
179 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
180 +
181 + // Check for the effective built-in type.
182 + assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
183 +
184 + // Check for the restriction.
185 + assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
186 + assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
187 + assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
188 + assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
156 } 189 }
157 190
158 /** 191 /**
...@@ -171,7 +204,7 @@ public class IntraFileTypeLinkingTest { ...@@ -171,7 +204,7 @@ public class IntraFileTypeLinkingTest {
171 assertThat((node instanceof YangModule), is(true)); 204 assertThat((node instanceof YangModule), is(true));
172 205
173 // Check whether the node type is set properly to module. 206 // Check whether the node type is set properly to module.
174 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); 207 + assertThat(node.getNodeType(), is(MODULE_NODE));
175 208
176 // Check whether the module name is set correctly. 209 // Check whether the module name is set correctly.
177 YangModule yangNode = (YangModule) node; 210 YangModule yangNode = (YangModule) node;
...@@ -186,13 +219,23 @@ public class IntraFileTypeLinkingTest { ...@@ -186,13 +219,23 @@ public class IntraFileTypeLinkingTest {
186 219
187 assertThat(leafInfo.getName(), is("invalid-interval")); 220 assertThat(leafInfo.getName(), is("invalid-interval"));
188 assertThat(leafInfo.getDataType().getDataTypeName(), is("hello")); 221 assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
189 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); 222 + assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
190 223
191 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 224 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
192 is((YangTypeDef) yangContainer.getChild().getNextSibling())); 225 is((YangTypeDef) yangContainer.getChild().getNextSibling()));
193 226
194 - assertThat(leafInfo.getDataType().getResolvableStatus(), 227 + assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
195 - is(ResolvableStatus.RESOLVED)); 228 +
229 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
230 +
231 + // Check for the effective built-in type.
232 + assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
233 +
234 + // Check for the restriction.
235 + assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
236 + assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
237 + assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
238 + assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
196 } 239 }
197 240
198 /** 241 /**
...@@ -209,7 +252,7 @@ public class IntraFileTypeLinkingTest { ...@@ -209,7 +252,7 @@ public class IntraFileTypeLinkingTest {
209 assertThat((node instanceof YangModule), is(true)); 252 assertThat((node instanceof YangModule), is(true));
210 253
211 // Check whether the node type is set properly to module. 254 // Check whether the node type is set properly to module.
212 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); 255 + assertThat(node.getNodeType(), is(MODULE_NODE));
213 256
214 // Check whether the module name is set correctly. 257 // Check whether the module name is set correctly.
215 YangModule yangNode = (YangModule) node; 258 YangModule yangNode = (YangModule) node;
...@@ -224,26 +267,37 @@ public class IntraFileTypeLinkingTest { ...@@ -224,26 +267,37 @@ public class IntraFileTypeLinkingTest {
224 267
225 assertThat(leafInfo.getName(), is("invalid-interval")); 268 assertThat(leafInfo.getName(), is("invalid-interval"));
226 assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); 269 assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
227 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); 270 + assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
228 271
229 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 272 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
230 is((YangTypeDef) yangList.getChild())); 273 is((YangTypeDef) yangList.getChild()));
231 assertThat(leafInfo.getDataType().getResolvableStatus(), 274 assertThat(leafInfo.getDataType().getResolvableStatus(),
232 - is(ResolvableStatus.RESOLVED)); 275 + is(RESOLVED));
233 276
234 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); 277 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
235 278
236 assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), 279 assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
237 is((YangTypeDef) yangContainer.getChild().getNextSibling())); 280 is((YangTypeDef) yangContainer.getChild().getNextSibling()));
238 assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(), 281 assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
239 - is(ResolvableStatus.RESOLVED)); 282 + is(RESOLVED));
240 283
241 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); 284 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
242 285
243 assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), 286 assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
244 is((YangTypeDef) node.getChild())); 287 is((YangTypeDef) node.getChild()));
245 assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(), 288 assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
246 - is(ResolvableStatus.RESOLVED)); 289 + is(RESOLVED));
290 +
291 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
292 +
293 + // Check for the effective built-in type.
294 + assertThat(derivedInfo.getEffectiveBuiltInType(), is(INT32));
295 +
296 + // Check for the restriction.
297 + assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
298 + assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
299 + assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
300 + assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
247 } 301 }
248 302
249 /** 303 /**
...@@ -261,7 +315,7 @@ public class IntraFileTypeLinkingTest { ...@@ -261,7 +315,7 @@ public class IntraFileTypeLinkingTest {
261 assertThat((node instanceof YangModule), is(true)); 315 assertThat((node instanceof YangModule), is(true));
262 316
263 // Check whether the node type is set properly to module. 317 // Check whether the node type is set properly to module.
264 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); 318 + assertThat(node.getNodeType(), is(MODULE_NODE));
265 319
266 // Check whether the module name is set correctly. 320 // Check whether the module name is set correctly.
267 YangModule yangNode = (YangModule) node; 321 YangModule yangNode = (YangModule) node;
...@@ -276,26 +330,37 @@ public class IntraFileTypeLinkingTest { ...@@ -276,26 +330,37 @@ public class IntraFileTypeLinkingTest {
276 330
277 assertThat(leafInfo.getName(), is("invalid-interval")); 331 assertThat(leafInfo.getName(), is("invalid-interval"));
278 assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); 332 assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
279 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); 333 + assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
280 334
281 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 335 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
282 is((YangTypeDef) yangList.getChild())); 336 is((YangTypeDef) yangList.getChild()));
283 assertThat(leafInfo.getDataType().getResolvableStatus(), 337 assertThat(leafInfo.getDataType().getResolvableStatus(),
284 - is(ResolvableStatus.INTRA_FILE_RESOLVED)); 338 + is(INTRA_FILE_RESOLVED));
285 339
286 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); 340 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
287 341
288 assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), 342 assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
289 is((YangTypeDef) yangContainer.getChild().getNextSibling())); 343 is((YangTypeDef) yangContainer.getChild().getNextSibling()));
290 assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(), 344 assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
291 - is(ResolvableStatus.INTRA_FILE_RESOLVED)); 345 + is(INTRA_FILE_RESOLVED));
292 346
293 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); 347 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
294 348
295 assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), 349 assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
296 is((YangTypeDef) node.getChild())); 350 is((YangTypeDef) node.getChild()));
297 assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(), 351 assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
298 - is(ResolvableStatus.INTRA_FILE_RESOLVED)); 352 + is(INTRA_FILE_RESOLVED));
353 +
354 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
355 +
356 + // Check for the effective built-in type.
357 + assertThat(derivedInfo.getEffectiveBuiltInType(), is(nullValue()));
358 +
359 + // Check for the restriction.
360 + assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
361 + assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
362 + assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
363 + assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
299 } 364 }
300 365
301 /** 366 /**
...@@ -312,7 +377,7 @@ public class IntraFileTypeLinkingTest { ...@@ -312,7 +377,7 @@ public class IntraFileTypeLinkingTest {
312 assertThat((node instanceof YangModule), is(true)); 377 assertThat((node instanceof YangModule), is(true));
313 378
314 // Check whether the node type is set properly to module. 379 // Check whether the node type is set properly to module.
315 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); 380 + assertThat(node.getNodeType(), is(MODULE_NODE));
316 381
317 // Check whether the module name is set correctly. 382 // Check whether the module name is set correctly.
318 YangModule yangNode = (YangModule) node; 383 YangModule yangNode = (YangModule) node;
...@@ -327,26 +392,37 @@ public class IntraFileTypeLinkingTest { ...@@ -327,26 +392,37 @@ public class IntraFileTypeLinkingTest {
327 392
328 assertThat(leafInfo.getName(), is("invalid-interval")); 393 assertThat(leafInfo.getName(), is("invalid-interval"));
329 assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); 394 assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
330 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); 395 + assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
331 396
332 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 397 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
333 is((YangTypeDef) yangList.getChild())); 398 is((YangTypeDef) yangList.getChild()));
334 assertThat(leafInfo.getDataType().getResolvableStatus(), 399 assertThat(leafInfo.getDataType().getResolvableStatus(),
335 - is(ResolvableStatus.RESOLVED)); 400 + is(RESOLVED));
336 401
337 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); 402 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
338 403
339 assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), 404 assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
340 is((YangTypeDef) yangContainer.getChild().getNextSibling())); 405 is((YangTypeDef) yangContainer.getChild().getNextSibling()));
341 assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(), 406 assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
342 - is(ResolvableStatus.RESOLVED)); 407 + is(RESOLVED));
343 408
344 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling(); 409 YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
345 410
346 assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), 411 assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
347 is((YangTypeDef) node.getChild())); 412 is((YangTypeDef) node.getChild()));
348 assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(), 413 assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
349 - is(ResolvableStatus.RESOLVED)); 414 + is(RESOLVED));
415 +
416 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
417 +
418 + // Check for the effective built-in type.
419 + assertThat(derivedInfo.getEffectiveBuiltInType(), is(INT32));
420 +
421 + // Check for the restriction.
422 + assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
423 + assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
424 + assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
425 + assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
350 } 426 }
351 427
352 /** 428 /**
...@@ -364,7 +440,7 @@ public class IntraFileTypeLinkingTest { ...@@ -364,7 +440,7 @@ public class IntraFileTypeLinkingTest {
364 assertThat((node instanceof YangModule), is(true)); 440 assertThat((node instanceof YangModule), is(true));
365 441
366 // Check whether the node type is set properly to module. 442 // Check whether the node type is set properly to module.
367 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE)); 443 + assertThat(node.getNodeType(), is(MODULE_NODE));
368 444
369 // Check whether the module name is set correctly. 445 // Check whether the module name is set correctly.
370 YangModule yangNode = (YangModule) node; 446 YangModule yangNode = (YangModule) node;
...@@ -379,12 +455,12 @@ public class IntraFileTypeLinkingTest { ...@@ -379,12 +455,12 @@ public class IntraFileTypeLinkingTest {
379 455
380 assertThat(leafInfo.getName(), is("invalid-interval")); 456 assertThat(leafInfo.getName(), is("invalid-interval"));
381 assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass")); 457 assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
382 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED)); 458 + assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
383 459
384 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(), 460 assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
385 is((YangTypeDef) yangList.getChild())); 461 is((YangTypeDef) yangList.getChild()));
386 assertThat(leafInfo.getDataType().getResolvableStatus(), 462 assertThat(leafInfo.getDataType().getResolvableStatus(),
387 - is(ResolvableStatus.INTRA_FILE_RESOLVED)); 463 + is(INTRA_FILE_RESOLVED));
388 464
389 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild(); 465 YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
390 466
...@@ -393,7 +469,18 @@ public class IntraFileTypeLinkingTest { ...@@ -393,7 +469,18 @@ public class IntraFileTypeLinkingTest {
393 assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(), 469 assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
394 is((YangTypeDef) node.getChild())); 470 is((YangTypeDef) node.getChild()));
395 assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(), 471 assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
396 - is(ResolvableStatus.RESOLVED)); 472 + is(RESOLVED));
473 +
474 + YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
475 +
476 + // Check for the effective built-in type.
477 + assertThat(derivedInfo.getEffectiveBuiltInType(), is(nullValue()));
478 +
479 + // Check for the restriction.
480 + assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
481 + assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
482 + assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
483 + assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
397 } 484 }
398 485
399 /** 486 /**
......
...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.linker; ...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.linker;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.ListIterator; 20 import java.util.ListIterator;
21 -
22 import org.junit.Rule; 21 import org.junit.Rule;
23 import org.junit.Test; 22 import org.junit.Test;
24 import org.junit.rules.ExpectedException; 23 import org.junit.rules.ExpectedException;
...@@ -81,7 +80,7 @@ public class IntraFileUsesLinkingTest { ...@@ -81,7 +80,7 @@ public class IntraFileUsesLinkingTest {
81 80
82 // Check whether the information in the leaf is correct under grouping. 81 // Check whether the information in the leaf is correct under grouping.
83 assertThat(leafInfo.getName(), is("hello")); 82 assertThat(leafInfo.getName(), is("hello"));
84 - assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); 83 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
85 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 84 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
86 85
87 // Check whether uses is module's child. 86 // Check whether uses is module's child.
...@@ -97,7 +96,7 @@ public class IntraFileUsesLinkingTest { ...@@ -97,7 +96,7 @@ public class IntraFileUsesLinkingTest {
97 96
98 // Check whether the information in the leaf is correct under module. 97 // Check whether the information in the leaf is correct under module.
99 assertThat(leafInfo.getName(), is("hello")); 98 assertThat(leafInfo.getName(), is("hello"));
100 - assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); 99 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
101 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 100 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
102 101
103 } 102 }
...@@ -135,7 +134,7 @@ public class IntraFileUsesLinkingTest { ...@@ -135,7 +134,7 @@ public class IntraFileUsesLinkingTest {
135 134
136 // Check whether the information in the leaf is correct under grouping. 135 // Check whether the information in the leaf is correct under grouping.
137 assertThat(leafInfo.getName(), is("treat")); 136 assertThat(leafInfo.getName(), is("treat"));
138 - assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); 137 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
139 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 138 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
140 139
141 // Check whether container is the child of grouping. 140 // Check whether container is the child of grouping.
...@@ -150,7 +149,7 @@ public class IntraFileUsesLinkingTest { ...@@ -150,7 +149,7 @@ public class IntraFileUsesLinkingTest {
150 149
151 // Check whether the information in the leaf is correct under container which is under grouping. 150 // Check whether the information in the leaf is correct under container which is under grouping.
152 assertThat(leafInfo.getName(), is("leaf2")); 151 assertThat(leafInfo.getName(), is("leaf2"));
153 - assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); 152 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
154 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 153 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
155 154
156 // Check whether uses is module's child. 155 // Check whether uses is module's child.
...@@ -166,7 +165,7 @@ public class IntraFileUsesLinkingTest { ...@@ -166,7 +165,7 @@ public class IntraFileUsesLinkingTest {
166 165
167 // Check whether the information in the leaf is correct under module. 166 // Check whether the information in the leaf is correct under module.
168 assertThat(leafInfo.getName(), is("treat")); 167 assertThat(leafInfo.getName(), is("treat"));
169 - assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); 168 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
170 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 169 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
171 170
172 // Check whether container is the child of module. 171 // Check whether container is the child of module.
...@@ -181,7 +180,7 @@ public class IntraFileUsesLinkingTest { ...@@ -181,7 +180,7 @@ public class IntraFileUsesLinkingTest {
181 180
182 // Check whether the information in the leaf is correct under container which is under module. 181 // Check whether the information in the leaf is correct under container which is under module.
183 assertThat(leafInfo.getName(), is("leaf2")); 182 assertThat(leafInfo.getName(), is("leaf2"));
184 - assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); 183 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
185 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 184 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
186 } 185 }
187 186
...@@ -688,7 +687,7 @@ public class IntraFileUsesLinkingTest { ...@@ -688,7 +687,7 @@ public class IntraFileUsesLinkingTest {
688 687
689 // Check whether the information in the leaf is correct under grouping. 688 // Check whether the information in the leaf is correct under grouping.
690 assertThat(leafInfo.getName(), is("hello")); 689 assertThat(leafInfo.getName(), is("hello"));
691 - assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); 690 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
692 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 691 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
693 692
694 } 693 }
...@@ -762,7 +761,7 @@ public class IntraFileUsesLinkingTest { ...@@ -762,7 +761,7 @@ public class IntraFileUsesLinkingTest {
762 761
763 // Check whether the information in the leaf is correct under grouping. 762 // Check whether the information in the leaf is correct under grouping.
764 assertThat(leafInfo.getName(), is("hello")); 763 assertThat(leafInfo.getName(), is("hello"));
765 - assertThat(leafInfo.getDataType().getDataTypeName(), is("String")); 764 + assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
766 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 765 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
767 } 766 }
768 767
......
...@@ -19,20 +19,18 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -19,20 +19,18 @@ package org.onosproject.yangutils.parser.impl.listeners;
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.math.BigInteger; 20 import java.math.BigInteger;
21 import java.util.ListIterator; 21 import java.util.ListIterator;
22 -
23 import org.junit.Rule; 22 import org.junit.Rule;
24 import org.junit.Test; 23 import org.junit.Test;
25 -
26 import org.junit.rules.ExpectedException; 24 import org.junit.rules.ExpectedException;
27 -import org.onosproject.yangutils.datamodel.YangNode; 25 +import org.onosproject.yangutils.datamodel.YangDataTypes;
28 -import org.onosproject.yangutils.datamodel.YangModule;
29 -import org.onosproject.yangutils.datamodel.YangNodeType;
30 import org.onosproject.yangutils.datamodel.YangLeaf; 26 import org.onosproject.yangutils.datamodel.YangLeaf;
31 import org.onosproject.yangutils.datamodel.YangLeafList; 27 import org.onosproject.yangutils.datamodel.YangLeafList;
32 -import org.onosproject.yangutils.datamodel.YangDataTypes; 28 +import org.onosproject.yangutils.datamodel.YangModule;
33 -import org.onosproject.yangutils.datamodel.YangStringRestriction; 29 +import org.onosproject.yangutils.datamodel.YangNode;
30 +import org.onosproject.yangutils.datamodel.YangNodeType;
34 import org.onosproject.yangutils.datamodel.YangRangeInterval; 31 import org.onosproject.yangutils.datamodel.YangRangeInterval;
35 import org.onosproject.yangutils.datamodel.YangRangeRestriction; 32 import org.onosproject.yangutils.datamodel.YangRangeRestriction;
33 +import org.onosproject.yangutils.datamodel.YangStringRestriction;
36 import org.onosproject.yangutils.datamodel.YangTypeDef; 34 import org.onosproject.yangutils.datamodel.YangTypeDef;
37 import org.onosproject.yangutils.parser.exceptions.ParserException; 35 import org.onosproject.yangutils.parser.exceptions.ParserException;
38 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 36 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
...@@ -71,11 +69,11 @@ public class LengthRestrictionListenerTest { ...@@ -71,11 +69,11 @@ public class LengthRestrictionListenerTest {
71 assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); 69 assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
72 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 70 assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
73 YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo 71 YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
74 - .getDataType().getDataTypeExtendedInfo(); 72 + .getDataType().getDataTypeExtendedInfo();
75 YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction(); 73 YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
76 74
77 ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals() 75 ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
78 - .listIterator(); 76 + .listIterator();
79 77
80 YangRangeInterval rangeInterval = lengthListIterator.next(); 78 YangRangeInterval rangeInterval = lengthListIterator.next();
81 79
...@@ -220,7 +218,7 @@ public class LengthRestrictionListenerTest { ...@@ -220,7 +218,7 @@ public class LengthRestrictionListenerTest {
220 @Test 218 @Test
221 public void processLengthWithInvalidIntegerPattern() throws IOException, ParserException { 219 public void processLengthWithInvalidIntegerPattern() throws IOException, ParserException {
222 thrown.expect(ParserException.class); 220 thrown.expect(ParserException.class);
223 - thrown.expectMessage("YANG file error : a is not valid."); 221 + thrown.expectMessage("YANG file error : Input value \"a\" is not a valid uint64.");
224 YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidIntegerPattern.yang"); 222 YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidIntegerPattern.yang");
225 } 223 }
226 224
......
...@@ -18,18 +18,17 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -18,18 +18,17 @@ package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.ListIterator; 20 import java.util.ListIterator;
21 -
22 import org.junit.Rule; 21 import org.junit.Rule;
23 import org.junit.Test; 22 import org.junit.Test;
24 import org.junit.rules.ExpectedException; 23 import org.junit.rules.ExpectedException;
25 -import org.onosproject.yangutils.datamodel.YangNode; 24 +import org.onosproject.yangutils.datamodel.YangDataTypes;
26 import org.onosproject.yangutils.datamodel.YangLeaf; 25 import org.onosproject.yangutils.datamodel.YangLeaf;
27 import org.onosproject.yangutils.datamodel.YangLeafList; 26 import org.onosproject.yangutils.datamodel.YangLeafList;
28 -import org.onosproject.yangutils.datamodel.YangRangeRestriction;
29 -import org.onosproject.yangutils.datamodel.YangRangeInterval;
30 import org.onosproject.yangutils.datamodel.YangModule; 27 import org.onosproject.yangutils.datamodel.YangModule;
28 +import org.onosproject.yangutils.datamodel.YangNode;
31 import org.onosproject.yangutils.datamodel.YangNodeType; 29 import org.onosproject.yangutils.datamodel.YangNodeType;
32 -import org.onosproject.yangutils.datamodel.YangDataTypes; 30 +import org.onosproject.yangutils.datamodel.YangRangeInterval;
31 +import org.onosproject.yangutils.datamodel.YangRangeRestriction;
33 import org.onosproject.yangutils.parser.exceptions.ParserException; 32 import org.onosproject.yangutils.parser.exceptions.ParserException;
34 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 33 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
35 import org.onosproject.yangutils.utils.builtindatatype.YangInt32; 34 import org.onosproject.yangutils.utils.builtindatatype.YangInt32;
...@@ -70,7 +69,7 @@ public class RangeRestrictionListenerTest { ...@@ -70,7 +69,7 @@ public class RangeRestrictionListenerTest {
70 .getDataType().getDataTypeExtendedInfo(); 69 .getDataType().getDataTypeExtendedInfo();
71 70
72 ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals() 71 ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
73 - .listIterator(); 72 + .listIterator();
74 YangRangeInterval rangeInterval = rangeListIterator.next(); 73 YangRangeInterval rangeInterval = rangeListIterator.next();
75 assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1)); 74 assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
76 assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4)); 75 assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
...@@ -172,7 +171,7 @@ public class RangeRestrictionListenerTest { ...@@ -172,7 +171,7 @@ public class RangeRestrictionListenerTest {
172 @Test 171 @Test
173 public void processRangeWithInvalidIntegerPattern() throws IOException, ParserException { 172 public void processRangeWithInvalidIntegerPattern() throws IOException, ParserException {
174 thrown.expect(ParserException.class); 173 thrown.expect(ParserException.class);
175 - thrown.expectMessage("YANG file error : a is not valid."); 174 + thrown.expectMessage("YANG file error : Input value \"a\" is not a valid int32.");
176 YangNode node = manager.getDataModel("src/test/resources/RangeWithInvalidIntegerPattern.yang"); 175 YangNode node = manager.getDataModel("src/test/resources/RangeWithInvalidIntegerPattern.yang");
177 } 176 }
178 } 177 }
......
...@@ -10,7 +10,7 @@ module Test { ...@@ -10,7 +10,7 @@ module Test {
10 } 10 }
11 } 11 }
12 typedef hello { 12 typedef hello {
13 - type String; 13 + type string;
14 } 14 }
15 } 15 }
16 } 16 }
......
...@@ -11,6 +11,6 @@ module Test { ...@@ -11,6 +11,6 @@ module Test {
11 } 11 }
12 } 12 }
13 typedef hello { 13 typedef hello {
14 - type String; 14 + type string;
15 } 15 }
16 } 16 }
......
...@@ -3,7 +3,7 @@ module Test { ...@@ -3,7 +3,7 @@ module Test {
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 typedef hello { 5 typedef hello {
6 - type String; 6 + type string;
7 } 7 }
8 container ospf { 8 container ospf {
9 list valid { 9 list valid {
......
...@@ -7,14 +7,14 @@ module Test { ...@@ -7,14 +7,14 @@ module Test {
7 } 7 }
8 grouping Percentage { 8 grouping Percentage {
9 leaf hello{ 9 leaf hello{
10 - type String; 10 + type string;
11 } 11 }
12 } 12 }
13 container ospf { 13 container ospf {
14 list valid { 14 list valid {
15 key "invalid"; 15 key "invalid";
16 - leaf invalid{ 16 + leaf invalid{
17 - type String; 17 + type string;
18 } 18 }
19 uses Ant:FirstClass; 19 uses Ant:FirstClass;
20 grouping FirstClass { 20 grouping FirstClass {
......
...@@ -3,15 +3,15 @@ module Test { ...@@ -3,15 +3,15 @@ module Test {
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 grouping Percentage { 5 grouping Percentage {
6 - leaf hello{ 6 + leaf hello{
7 - type String; 7 + type string;
8 } 8 }
9 } 9 }
10 container ospf { 10 container ospf {
11 list valid { 11 list valid {
12 key "invalid"; 12 key "invalid";
13 - leaf invalid{ 13 + leaf invalid{
14 - type String; 14 + type string;
15 } 15 }
16 uses Ant:FirstClass; 16 uses Ant:FirstClass;
17 grouping FirstClass { 17 grouping FirstClass {
......
...@@ -6,6 +6,6 @@ module Test { ...@@ -6,6 +6,6 @@ module Test {
6 type hello; 6 type hello;
7 } 7 }
8 typedef hello { 8 typedef hello {
9 - type String; 9 + type string;
10 } 10 }
11 } 11 }
......
...@@ -4,8 +4,8 @@ module Test { ...@@ -4,8 +4,8 @@ module Test {
4 prefix Ant; 4 prefix Ant;
5 uses hello; 5 uses hello;
6 grouping hello { 6 grouping hello {
7 - leaf hello{ 7 + leaf hello{
8 - type String; 8 + type string;
9 } 9 }
10 } 10 }
11 } 11 }
......
...@@ -4,12 +4,12 @@ module Test { ...@@ -4,12 +4,12 @@ module Test {
4 prefix Ant; 4 prefix Ant;
5 uses treat; 5 uses treat;
6 grouping treat { 6 grouping treat {
7 - leaf treat{ 7 + leaf treat{
8 - type String; 8 + type string;
9 } 9 }
10 container test{ 10 container test{
11 leaf leaf2{ 11 leaf leaf2{
12 - type String; 12 + type string;
13 } 13 }
14 } 14 }
15 } 15 }
......