blob: 8556445a166c10e8807ff4d041c0dc6bab339a8b [file] [log] [blame]
Gaurav Agrawal0d43bb52016-05-17 18:06:38 +05301/*
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
17package org.onosproject.yangutils.datamodel;
18
19/*-
20 * Reference RFC 6020.
21 *
22 * Binary can be restricted with "length" statements alone.
23 *
24 */
25
26import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
27import org.onosproject.yangutils.parser.Parsable;
28import org.onosproject.yangutils.utils.YangConstructType;
29import org.onosproject.yangutils.utils.builtindatatype.YangUint64;
30
31/**
32 * Represents the restriction for length data type.
33 */
34public class YangLengthRestriction implements YangDesc, YangReference, YangAppErrorInfo, Parsable {
35
36 /*-
37 * Reference RFC 6020.
38 * The length Statement
39 *
40 * The "length" statement, which is an optional sub-statement to the
41 * "type" statement, takes as an argument a length expression string.
42 * It is used to restrict the built-in type "string", or types derived
43 * from "string".
44 * A "length" statement restricts the number of unicode characters in
45 * the string.
46 * A length range consists of an explicit value, or a lower bound, two
47 * consecutive dots "..", and an upper bound. Multiple values or ranges
48 * can be given, separated by "|". Length-restricting values MUST NOT
49 * be negative. If multiple values or ranges are given, they all MUST
50 * be disjoint and MUST be in ascending order. If a length restriction
51 * is applied to an already length-restricted type, the new restriction
52 * MUST be equal or more limiting, that is, raising the lower bounds,
53 * reducing the upper bounds, removing explicit length values or ranges,
54 * or splitting ranges into multiple ranges with intermediate gaps. A
55 * length value is a non-negative integer, or one of the special values
56 * "min" or "max". "min" and "max" mean the minimum and maximum length
57 * accepted for the type being restricted, respectively. An
58 * implementation is not required to support a length value larger than
59 * 18446744073709551615.
60 * The length's sub-statements
61 *
62 * +---------------+---------+-------------+-----------------+
63 * | substatement | section | cardinality | mapped data type|
64 * +---------------+---------+-------------+-----------------+
65 * | description | 7.19.3 | 0..1 | string |
66 * | error-app-tag | 7.5.4.2 | 0..1 | string |
67 * | error-message | 7.5.4.1 | 0..1 | string |
68 * | reference | 7.19.4 | 0..1 | string |
69 * +---------------+---------+-------------+-----------------+
70 */
71
72 /**
73 * Length restriction information.
74 */
75 private YangRangeRestriction<YangUint64> lengthRestriction;
76
77 /**
78 * Textual reference.
79 */
80 private String reference;
81
82 /**
83 * Application's error message, to be used for data error.
84 */
85 private String errorMessage;
86
87 /**
88 * Application's error tag, to be filled in data validation error response.
89 */
90 private String errorAppTag;
91
92 /**
93 * Textual description.
94 */
95 private String description;
96
97 /**
98 * Creates a YANG length restriction object.
99 */
100 public YangLengthRestriction() {
101 }
102
103 /**
104 * Returns the length restriction on the string data.
105 *
106 * @return length restriction on the string data
107 */
108 public YangRangeRestriction<YangUint64> getLengthRestriction() {
109 return lengthRestriction;
110 }
111
112 /**
113 * Sets the length restriction on the string data.
114 *
115 * @param lengthRestriction length restriction on the string data
116 */
117 public void setLengthRestriction(YangRangeRestriction<YangUint64> lengthRestriction) {
118 this.lengthRestriction = lengthRestriction;
119 }
120
121 /**
122 * Returns the textual reference of the length restriction.
123 *
124 * @return textual reference of the length restriction
125 */
126 @Override
127 public String getReference() {
128 return reference;
129 }
130
131 /**
132 * Sets the textual reference of the length restriction.
133 *
134 * @param ref textual reference of the length restriction
135 */
136 @Override
137 public void setReference(String ref) {
138 reference = ref;
139 }
140
141 /**
142 * Returns the description of the length restriction.
143 *
144 * @return description of the length restriction
145 */
146 @Override
147 public String getDescription() {
148 return description;
149 }
150
151 /**
152 * Sets the description of the length restriction.
153 *
154 * @param desc description of the length restriction
155 */
156 @Override
157 public void setDescription(String desc) {
158 description = desc;
159
160 }
161
162 /**
163 * Returns application's error message, to be used for data error.
164 *
165 * @return Application's error message, to be used for data error
166 */
167 @Override
168 public String getGetErrorMessage() {
169 return errorMessage;
170 }
171
172 /**
173 * Sets Application's error message, to be used for data error.
174 *
175 * @param errMsg Application's error message, to be used for data error
176 */
177 @Override
178 public void setErrorMessage(String errMsg) {
179 errorMessage = errMsg;
180
181 }
182
183 /**
184 * Returns application's error tag, to be used for data error.
185 *
186 * @return application's error tag, to be used for data error
187 */
188 @Override
189 public String getGetErrorAppTag() {
190 return errorAppTag;
191 }
192
193 /**
194 * Sets application's error tag, to be used for data error.
195 *
196 * @param errTag application's error tag, to be used for data error.
197 */
198 @Override
199 public void setErrorAppTag(String errTag) {
200 errorAppTag = errTag;
201 }
202
203 @Override
204 public YangConstructType getYangConstructType() {
205 return YangConstructType.PATTERN_DATA;
206 }
207
208 @Override
209 public void validateDataOnEntry() throws DataModelException {
210 //TODO: implement the method.
211 }
212
213 @Override
214 public void validateDataOnExit() throws DataModelException {
215 //TODO: implement the method.
216 }
217}