Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 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 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 19 | import java.io.Serializable; |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 20 | |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
| 23 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; |
| 24 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
Gaurav Agrawal | 72cd1b7 | 2016-06-30 13:28:14 +0530 | [diff] [blame] | 25 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 26 | |
Gaurav Agrawal | 72cd1b7 | 2016-06-30 13:28:14 +0530 | [diff] [blame] | 27 | import static org.onosproject.yangutils.datamodel.BuiltInTypeObjectFactory.getDataObjectFromString; |
| 28 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypeUtils.isOfRangeRestrictedType; |
| 29 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED; |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 30 | |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 31 | /* |
| 32 | * Reference:RFC 6020. |
| 33 | * The "type" statement takes as an argument a string that is the name |
| 34 | * of a YANG built-in type or a derived type, followed by an optional |
| 35 | * block of sub-statements that are used to put further restrictions |
| 36 | * on the type. |
| 37 | * |
| 38 | * The restrictions that can be applied depend on the type being restricted. |
| 39 | * The type's sub-statements |
| 40 | * |
| 41 | * +------------------+---------+-------------+------------------------------------+ |
| 42 | * | substatement | section | cardinality | mapped data type | |
| 43 | * +------------------+---------+-------------+------------------------------------+ |
| 44 | * | bit | 9.7.4 | 0..n | - YangBit used in YangBits | |
| 45 | * | enum | 9.6.4 | 0..n | - YangEnum used in YangEnumeration | |
| 46 | * | length | 9.4.4 | 0..1 | - used for string | |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 47 | * | path | 9.9.2 | 0..1 | - path for referred leaf/leaf-list | |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 48 | * | pattern | 9.4.6 | 0..n | - used for string | |
| 49 | * | range | 9.2.4 | 0..1 | - used for integer data type | |
| 50 | * | require-instance | 9.13.2 | 0..1 | - TODO instance-identifier | |
| 51 | * | type | 7.4 | 0..n | - TODO union | |
| 52 | * +------------------+---------+-------------+------------------------------------+ |
| 53 | */ |
| 54 | |
| 55 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 56 | * Represents the data type information. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 57 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 58 | * @param <T> YANG data type info |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 59 | */ |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 60 | public class YangType<T> |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 61 | implements Parsable, Resolvable, Serializable { |
| 62 | |
| 63 | private static final long serialVersionUID = 8062016054L; |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 64 | |
| 65 | /** |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 66 | * YANG node identifier. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 67 | */ |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 68 | private YangNodeIdentifier nodeIdentifier; |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * YANG data type. |
| 72 | */ |
| 73 | private YangDataTypes dataType; |
| 74 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 75 | /** |
| 76 | * Additional information about data type, example restriction info, named |
| 77 | * values, etc. The extra information is based on the data type. Based on |
| 78 | * the data type, the extended info can vary. |
| 79 | */ |
| 80 | private T dataTypeExtendedInfo; |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 81 | |
| 82 | /** |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 83 | * Status of resolution. If completely resolved enum value is "RESOLVED", |
| 84 | * if not enum value is "UNRESOLVED", in case reference of grouping/typedef |
| 85 | * is added to uses/type but it's not resolved value of enum should be |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 86 | * "INTRA_FILE_RESOLVED". |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 87 | */ |
| 88 | private ResolvableStatus resolvableStatus; |
| 89 | |
| 90 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 91 | * Creates a YANG type object. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 92 | */ |
| 93 | public YangType() { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 94 | |
| 95 | nodeIdentifier = new YangNodeIdentifier(); |
| 96 | resolvableStatus = ResolvableStatus.UNRESOLVED; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Returns prefix associated with data type name. |
| 101 | * |
| 102 | * @return prefix associated with data type name |
| 103 | */ |
| 104 | public String getPrefix() { |
| 105 | return nodeIdentifier.getPrefix(); |
| 106 | } |
| 107 | |
| 108 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 109 | * Sets prefix associated with data type name. |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 110 | * |
| 111 | * @param prefix prefix associated with data type name |
| 112 | */ |
| 113 | public void setPrefix(String prefix) { |
| 114 | nodeIdentifier.setPrefix(prefix); |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 118 | * Returns the name of data type. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 119 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 120 | * @return the name of data type |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 121 | */ |
| 122 | public String getDataTypeName() { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 123 | return nodeIdentifier.getName(); |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 127 | * Sets the name of the data type. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 128 | * |
| 129 | * @param typeName the name to set |
| 130 | */ |
| 131 | public void setDataTypeName(String typeName) { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 132 | nodeIdentifier.setName(typeName); |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 136 | * Returns the type of data. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 137 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 138 | * @return the data type |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 139 | */ |
| 140 | public YangDataTypes getDataType() { |
| 141 | return dataType; |
| 142 | } |
| 143 | |
| 144 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 145 | * Sets the type of data. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 146 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 147 | * @param dataType data type |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 148 | */ |
| 149 | public void setDataType(YangDataTypes dataType) { |
| 150 | this.dataType = dataType; |
| 151 | } |
| 152 | |
| 153 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 154 | * Returns the data type meta data. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 155 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 156 | * @return the data type meta data |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 157 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 158 | public T getDataTypeExtendedInfo() { |
| 159 | return dataTypeExtendedInfo; |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 163 | * Sets the data type meta data. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 164 | * |
| 165 | * @param dataTypeInfo the meta data to set |
| 166 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 167 | public void setDataTypeExtendedInfo(T dataTypeInfo) { |
| 168 | this.dataTypeExtendedInfo = dataTypeInfo; |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /** |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 172 | * Returns node identifier. |
| 173 | * |
| 174 | * @return node identifier |
| 175 | */ |
| 176 | public YangNodeIdentifier getNodeIdentifier() { |
| 177 | return nodeIdentifier; |
| 178 | } |
| 179 | |
| 180 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 181 | * Sets node identifier. |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 182 | * |
| 183 | * @param nodeIdentifier the node identifier |
| 184 | */ |
| 185 | public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) { |
| 186 | this.nodeIdentifier = nodeIdentifier; |
| 187 | } |
| 188 | |
| 189 | /** |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 190 | * Resets the class attributes to its default value. |
| 191 | */ |
| 192 | public void resetYangType() { |
| 193 | nodeIdentifier = new YangNodeIdentifier(); |
| 194 | resolvableStatus = ResolvableStatus.UNRESOLVED; |
| 195 | dataType = null; |
| 196 | dataTypeExtendedInfo = null; |
| 197 | } |
| 198 | |
| 199 | /** |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 200 | * Returns the type of the parsed data. |
| 201 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 202 | * @return returns TYPE_DATA |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 203 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 204 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 205 | public YangConstructType getYangConstructType() { |
| 206 | return YangConstructType.TYPE_DATA; |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 210 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 211 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 212 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 213 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 214 | @Override |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 215 | public void validateDataOnEntry() |
| 216 | throws DataModelException { |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 217 | // TODO auto-generated method stub, to be implemented by parser |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 221 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 222 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 223 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 224 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 225 | @Override |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 226 | public void validateDataOnExit() |
| 227 | throws DataModelException { |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 228 | // TODO auto-generated method stub, to be implemented by parser |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 229 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 230 | |
| 231 | @Override |
| 232 | public ResolvableStatus getResolvableStatus() { |
| 233 | return resolvableStatus; |
| 234 | } |
| 235 | |
| 236 | @Override |
| 237 | public void setResolvableStatus(ResolvableStatus resolvableStatus) { |
| 238 | this.resolvableStatus = resolvableStatus; |
| 239 | } |
| 240 | |
| 241 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 242 | public void resolve() |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 243 | throws DataModelException { |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 244 | /* |
| 245 | * Check whether the data type is derived. |
| 246 | */ |
Vidyashree Rama | 7142d9c | 2016-04-26 15:06:06 +0530 | [diff] [blame] | 247 | if (getDataType() != DERIVED) { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 248 | throw new DataModelException("Linker Error: Resolve should only be called for derived data types."); |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 249 | } |
| 250 | |
Gaurav Agrawal | cfa1c41 | 2016-05-03 00:41:48 +0530 | [diff] [blame] | 251 | // Check if the derived info is present. |
| 252 | YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) getDataTypeExtendedInfo(); |
| 253 | if (derivedInfo == null) { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 254 | throw new DataModelException("Linker Error: Derived information is missing."); |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 255 | } |
Gaurav Agrawal | cfa1c41 | 2016-05-03 00:41:48 +0530 | [diff] [blame] | 256 | |
| 257 | // Initiate the resolution |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 258 | try { |
| 259 | setResolvableStatus(derivedInfo.resolve()); |
| 260 | } catch (DataModelException e) { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 261 | throw new DataModelException(e.getMessage()); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 262 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 263 | } |
Gaurav Agrawal | 72cd1b7 | 2016-06-30 13:28:14 +0530 | [diff] [blame] | 264 | |
| 265 | /** |
| 266 | * Validates the input data value against the permissible value for the |
| 267 | * type as per the YANG file. |
| 268 | * |
| 269 | * @param value input data value |
| 270 | * @return status of validation |
| 271 | */ |
| 272 | public boolean isValidValue(String value) { |
| 273 | switch (getDataType()) { |
| 274 | case INT8: |
| 275 | case INT16: |
| 276 | case INT32: |
| 277 | case INT64: |
| 278 | case UINT8: |
| 279 | case UINT16: |
| 280 | case UINT32: |
| 281 | case UINT64: { |
| 282 | isValidValueForRangeRestrictedType(value); |
| 283 | } |
| 284 | case DECIMAL64: { |
| 285 | // TODO |
| 286 | } |
| 287 | case STRING: { |
| 288 | // TODO implement in string restriction similar to range restriction |
| 289 | } |
| 290 | case ENUMERATION: { |
| 291 | // TODO validate using list of YANG enum of enumeration class in extended info. |
| 292 | } |
| 293 | case BINARY: { |
| 294 | // TODO validate based on extended info |
| 295 | } |
| 296 | case BITS: { |
| 297 | // TODO validate based on extended info |
| 298 | } |
| 299 | case BOOLEAN: { |
| 300 | // TODO true or false |
| 301 | } |
| 302 | case LEAFREF: { |
| 303 | // TODO validate based on extended info |
| 304 | } |
| 305 | case IDENTITYREF: { |
| 306 | // TODO TBD |
| 307 | } |
| 308 | case EMPTY: { |
| 309 | // TODO true or false |
| 310 | } |
| 311 | case UNION: { |
| 312 | // TODO validate based on extended info |
| 313 | } |
| 314 | case INSTANCE_IDENTIFIER: { |
| 315 | // TODO TBD |
| 316 | } |
| 317 | case DERIVED: { |
| 318 | if (isOfRangeRestrictedType(((YangDerivedInfo) getDataTypeExtendedInfo()).getEffectiveBuiltInType())) { |
| 319 | try { |
| 320 | if (((YangDerivedInfo) getDataTypeExtendedInfo()).getResolvedExtendedInfo() == null) { |
| 321 | getDataObjectFromString(value, |
| 322 | ((YangDerivedInfo) getDataTypeExtendedInfo()).getEffectiveBuiltInType()); |
| 323 | return true; |
| 324 | } else { |
| 325 | return ((YangRangeRestriction) ((YangDerivedInfo) getDataTypeExtendedInfo()) |
| 326 | .getResolvedExtendedInfo()).isValidValueString(value); |
| 327 | } |
| 328 | } catch (Exception e) { |
| 329 | return false; |
| 330 | } |
| 331 | } else { |
| 332 | // TODO |
| 333 | } |
| 334 | } |
| 335 | default: { |
| 336 | // TODO |
| 337 | } |
| 338 | } |
| 339 | return true; |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Validates the input data value for range restricted types against the |
| 344 | * permissible value for the type as per the YANG file. |
| 345 | * |
| 346 | * @param value input data value |
| 347 | * @return status of validation |
| 348 | */ |
| 349 | private boolean isValidValueForRangeRestrictedType(String value) { |
| 350 | try { |
| 351 | if (getDataTypeExtendedInfo() == null) { |
| 352 | getDataObjectFromString(value, getDataType()); |
| 353 | return true; |
| 354 | } else { |
| 355 | return ((YangRangeRestriction) getDataTypeExtendedInfo()).isValidValueString(value); |
| 356 | } |
| 357 | } catch (Exception e) { |
| 358 | return false; |
| 359 | } |
| 360 | } |
Vinod Kumar S | cf04442 | 2016-02-09 19:53:45 +0530 | [diff] [blame] | 361 | } |