Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.yangutils.datamodel; |
| 17 | |
| 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 19 | import org.onosproject.yangutils.parser.Parsable; |
| 20 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 21 | |
| 22 | /*- |
| 23 | * The "must" statement, which is optional, takes as an argument a string that |
| 24 | * contains an XPath expression. It is used to formally declare a constraint |
| 25 | * on valid data. |
| 26 | * |
| 27 | * When a datastore is validated, all "must" constraints are conceptually |
| 28 | * evaluated once for each data node in the data tree, and for all leafs with |
| 29 | * default values in use. If a data node does not exist in the data tree, and |
| 30 | * it does not have a default value, its "must" statements are not evaluated. |
| 31 | * |
| 32 | * All such constraints MUST evaluate to true for the data to be valid. |
| 33 | * |
| 34 | * The must's sub-statements |
| 35 | * |
| 36 | * +---------------+---------+-------------+------------------+ |
| 37 | * | substatement | section | cardinality |data model mapping| |
| 38 | * +---------------+---------+-------------+------------------+ |
| 39 | * | description | 7.19.3 | 0..1 | -string | |
| 40 | * | error-app-tag | 7.5.4.2 | 0..1 | -not supported | |
| 41 | * | error-message | 7.5.4.1 | 0..1 | -not supported | |
| 42 | * | reference | 7.19.4 | 0..1 | -string | |
| 43 | * +---------------+---------+-------------+------------------+ |
| 44 | */ |
| 45 | |
| 46 | /** |
| 47 | * Maintain information defined in YANG must. |
| 48 | */ |
| 49 | public class YangMust implements YangDesc, YangReference, Parsable { |
| 50 | |
| 51 | /** |
| 52 | * Constraint info. |
| 53 | */ |
| 54 | private String constratint; |
| 55 | |
| 56 | /** |
| 57 | * Description string. |
| 58 | */ |
| 59 | private String description; |
| 60 | |
| 61 | /** |
| 62 | * reference string. |
| 63 | */ |
| 64 | private String reference; |
| 65 | |
| 66 | /** |
| 67 | * Create a YANG must restriction. |
| 68 | */ |
| 69 | public YangMust() { |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Get the constraint. |
| 74 | * |
| 75 | * @return the constraint. |
| 76 | */ |
| 77 | public String getConstratint() { |
| 78 | return constratint; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Set the constraint. |
| 83 | * |
| 84 | * @param constratint the constraint to set |
| 85 | */ |
| 86 | public void setConstratint(String constratint) { |
| 87 | this.constratint = constratint; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Get the description. |
| 92 | * |
| 93 | * @return the description. |
| 94 | */ |
| 95 | public String getDescription() { |
| 96 | return description; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Set the description. |
| 101 | * |
| 102 | * @param description set the description. |
| 103 | */ |
| 104 | public void setDescription(String description) { |
| 105 | this.description = description; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Get the textual reference. |
| 110 | * |
| 111 | * @return the reference. |
| 112 | */ |
| 113 | public String getReference() { |
| 114 | return reference; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Set the textual reference. |
| 119 | * |
| 120 | * @param reference the reference to set. |
| 121 | */ |
| 122 | public void setReference(String reference) { |
| 123 | this.reference = reference; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Returns the type of the parsed data. |
| 128 | * |
| 129 | * @return returns MUST_DATA |
| 130 | */ |
| 131 | public ParsableDataType getParsableDataType() { |
| 132 | return ParsableDataType.MUST_DATA; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Validate the data on entering the corresponding parse tree node. |
| 137 | * |
| 138 | * @throws DataModelException a violation of data model rules. |
| 139 | */ |
| 140 | public void validateDataOnEntry() throws DataModelException { |
| 141 | // TODO auto-generated method stub, to be implemented by parser |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Validate the data on exiting the corresponding parse tree node. |
| 146 | * |
| 147 | * @throws DataModelException a violation of data model rules. |
| 148 | */ |
| 149 | public void validateDataOnExit() throws DataModelException { |
| 150 | // TODO auto-generated method stub, to be implemented by parser |
| 151 | } |
| 152 | } |