blob: 9cccaee61916b42bb043a1a72fcd0e4c46434fc9 [file] [log] [blame]
Vinod Kumar S0c330cd2016-02-23 22:36:57 +05301/*Copyright 2016.year Open Networking Laboratory
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.*/
14package org.onosproject.yangutils.datamodel;
15
16import java.math.BigInteger;
17
18/*-
19 * Reference RFC 6020.
20 *
21 * A string can be restricted with the "length" and "pattern" statements.
22 *
23 */
24/**
25 * The restriction for string data type.
26 */
27public class YangStringRestriction {
28
29 /*-
30 * Reference RFC 6020.
31 * The length Statement
32 *
33 * The "length" statement, which is an optional sub-statement to the
34 * "type" statement, takes as an argument a length expression string.
35 * It is used to restrict the built-in type "string", or types derived
36 * from "string".
37 * A "length" statement restricts the number of unicode characters in
38 * the string.
39 * A length range consists of an explicit value, or a lower bound, two
40 * consecutive dots "..", and an upper bound. Multiple values or ranges
41 * can be given, separated by "|". Length-restricting values MUST NOT
42 * be negative. If multiple values or ranges are given, they all MUST
43 * be disjoint and MUST be in ascending order. If a length restriction
44 * is applied to an already length-restricted type, the new restriction
45 * MUST be equal or more limiting, that is, raising the lower bounds,
46 * reducing the upper bounds, removing explicit length values or ranges,
47 * or splitting ranges into multiple ranges with intermediate gaps. A
48 * length value is a non-negative integer, or one of the special values
49 * "min" or "max". "min" and "max" mean the minimum and maximum length
50 * accepted for the type being restricted, respectively. An
51 * implementation is not required to support a length value larger than
52 * 18446744073709551615.
53 * The length's sub-statements
54 *
55 * +---------------+---------+-------------+-----------------+
56 * | substatement | section | cardinality | mapped data type|
57 * +---------------+---------+-------------+-----------------+
58 * | description | 7.19.3 | 0..1 | string |
59 * | error-app-tag | 7.5.4.2 | 0..1 | string |
60 * | error-message | 7.5.4.1 | 0..1 | string |
61 * | reference | 7.19.4 | 0..1 | string |
62 * +---------------+---------+-------------+-----------------+
63 */
64 /**
65 * Length restriction information.
66 */
67 private YangRangeRestriction<BigInteger> lengthRestriction;
68
69 /**
70 * Effective pattern restriction for the type.
71 */
72 private YangPatternRestriction patternRestriction;
73
74 /**
75 * Default constructor.
76 */
77 public YangStringRestriction() {
78 }
79
80 /**
81 * Get the length restriction on the string data.
82 *
83 * @return length restriction on the string data.
84 */
85 public YangRangeRestriction<BigInteger> getLengthRestriction() {
86 return lengthRestriction;
87 }
88
89 /**
90 * Set the length restriction on the string data.
91 *
92 * @param lengthRestriction length restriction on the string data.
93 */
94 public void setLengthRestriction(YangRangeRestriction<BigInteger> lengthRestriction) {
95 this.lengthRestriction = lengthRestriction;
96 }
97
98 /**
99 * Get the pattern restriction for the type.
100 *
101 * @return pattern restriction for the type.
102 */
103 public YangPatternRestriction getPatternRestriction() {
104 return patternRestriction;
105 }
106
107 /**
108 * Set the pattern restriction for the type.
109 *
110 * @param patternRestriction pattern restriction for the type.
111 */
112 public void setPatternRestriction(YangPatternRestriction patternRestriction) {
113 this.patternRestriction = patternRestriction;
114 }
115}