Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame^] | 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 | package org.onosproject.yangutils.datamodel; |
| 17 | |
| 18 | import java.io.Serializable; |
| 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 20 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
| 21 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
| 22 | |
| 23 | /* |
| 24 | * Reference RFC 6020. |
| 25 | * |
| 26 | * The "when" statement makes its parent data definition statement |
| 27 | * conditional. The node defined by the parent data definition |
| 28 | * statement is only valid when the condition specified by the "when" |
| 29 | * statement is satisfied. |
| 30 | * |
| 31 | * The statement's argument is an XPath expression, which is used to formally |
| 32 | * specify this condition. If the XPath expression conceptually evaluates to |
| 33 | * "true" for a particular instance, then the node defined by the parent data |
| 34 | * definition statement is valid; otherwise, it is not. |
| 35 | * |
| 36 | * The when's sub-statements |
| 37 | * |
| 38 | * +---------------+---------+-------------+------------------+ |
| 39 | * | substatement | section | cardinality |data model mapping| |
| 40 | * +---------------+---------+-------------+------------------+ |
| 41 | * | description | 7.19.3 | 0..1 | -string | |
| 42 | * | reference | 7.19.4 | 0..1 | -string | |
| 43 | * +---------------+---------+-------------+------------------+ |
| 44 | */ |
| 45 | |
| 46 | /** |
| 47 | * Represents information defined in YANG when. |
| 48 | */ |
| 49 | public class YangWhen implements YangDesc, YangReference, Parsable, Serializable { |
| 50 | |
| 51 | private static final long serialVersionUID = 806201646L; |
| 52 | |
| 53 | /** |
| 54 | * When condition info. |
| 55 | */ |
| 56 | private String condition; |
| 57 | |
| 58 | /** |
| 59 | * Description string. |
| 60 | */ |
| 61 | private String description; |
| 62 | |
| 63 | /** |
| 64 | * Reference string. |
| 65 | */ |
| 66 | private String reference; |
| 67 | |
| 68 | /** |
| 69 | * Creates a YANG when restriction. |
| 70 | */ |
| 71 | public YangWhen() { |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Returns the condition. |
| 76 | * |
| 77 | * @return the condition |
| 78 | */ |
| 79 | public String getCondition() { |
| 80 | return condition; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Sets the condition. |
| 85 | * |
| 86 | * @param condition the condition to set |
| 87 | */ |
| 88 | public void setCondition(String condition) { |
| 89 | this.condition = condition; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Returns the description. |
| 94 | * |
| 95 | * @return the description |
| 96 | */ |
| 97 | @Override |
| 98 | public String getDescription() { |
| 99 | return description; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Sets the description. |
| 104 | * |
| 105 | * @param description set the description |
| 106 | */ |
| 107 | @Override |
| 108 | public void setDescription(String description) { |
| 109 | this.description = description; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Returns the textual reference. |
| 114 | * |
| 115 | * @return the reference |
| 116 | */ |
| 117 | @Override |
| 118 | public String getReference() { |
| 119 | return reference; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Sets the textual reference. |
| 124 | * |
| 125 | * @param reference the reference to set |
| 126 | */ |
| 127 | @Override |
| 128 | public void setReference(String reference) { |
| 129 | this.reference = reference; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Returns the type of the parsed data. |
| 134 | * |
| 135 | * @return returns WHEN_DATA |
| 136 | */ |
| 137 | @Override |
| 138 | public YangConstructType getYangConstructType() { |
| 139 | return YangConstructType.WHEN_DATA; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Validates the data on entering the corresponding parse tree node. |
| 144 | * |
| 145 | * @throws DataModelException a violation of data model rules |
| 146 | */ |
| 147 | @Override |
| 148 | public void validateDataOnEntry() throws DataModelException { |
| 149 | // TODO auto-generated method stub, to be implemented by parser |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Validates the data on exiting the corresponding parse tree node. |
| 154 | * |
| 155 | * @throws DataModelException a violation of data model rules |
| 156 | */ |
| 157 | @Override |
| 158 | public void validateDataOnExit() throws DataModelException { |
| 159 | // TODO auto-generated method stub, to be implemented by parser |
| 160 | } |
| 161 | } |