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; |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 20 | import org.onosproject.yangutils.utils.YangConstructType; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 21 | |
| 22 | /*- |
| 23 | * Reference RFC 6020. |
| 24 | * |
| 25 | * The "uses" statement is used to reference a "grouping" definition. It takes |
| 26 | * one argument, which is the name of the grouping. |
| 27 | * |
| 28 | * The effect of a "uses" reference to a grouping is that the nodes defined by |
| 29 | * the grouping are copied into the current schema tree, and then updated |
| 30 | * according to the "refine" and "augment" statements. |
| 31 | * |
| 32 | * The identifiers defined in the grouping are not bound to a namespace until |
| 33 | * the contents of the grouping are added to the schema tree via a "uses" |
| 34 | * statement that does not appear inside a "grouping" statement, at which point |
| 35 | * they are bound to the namespace of the current module. |
| 36 | * |
| 37 | * The uses's sub-statements |
| 38 | * |
| 39 | * +--------------+---------+-------------+------------------+ |
| 40 | * | substatement | section | cardinality |data model mapping| |
| 41 | * +--------------+---------+-------------+------------------+ |
| 42 | * | augment | 7.15 | 0..1 | -child nodes | |
| 43 | * | description | 7.19.3 | 0..1 | -string | |
| 44 | * | if-feature | 7.18.2 | 0..n | -TODO | |
| 45 | * | refine | 7.12.2 | 0..1 | -TODO | |
| 46 | * | reference | 7.19.4 | 0..1 | -string | |
| 47 | * | status | 7.19.2 | 0..1 | -YangStatus | |
| 48 | * | when | 7.19.5 | 0..1 | -TODO | |
| 49 | * +--------------+---------+-------------+------------------+ |
| 50 | */ |
| 51 | /** |
| 52 | * Data model node to maintain information defined in YANG uses. |
| 53 | * |
| 54 | */ |
| 55 | public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 56 | |
| 57 | /** |
| 58 | * Name. |
| 59 | */ |
| 60 | private String name; |
| 61 | |
| 62 | /** |
| 63 | * referred group. |
| 64 | */ |
| 65 | private YangGrouping refGroup; |
| 66 | |
| 67 | /** |
| 68 | * description. |
| 69 | */ |
| 70 | private String description; |
| 71 | |
| 72 | /** |
| 73 | * YANG reference. |
| 74 | */ |
| 75 | private String reference; |
| 76 | |
| 77 | /** |
| 78 | * Status. |
| 79 | */ |
| 80 | private YangStatusType status; |
| 81 | |
| 82 | /** |
| 83 | * Create an YANG uses node. |
| 84 | */ |
| 85 | public YangUses() { |
| 86 | super(YangNodeType.USES_NODE); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Get the name. |
| 91 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 92 | * @return the name |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 93 | */ |
| 94 | public String getRefGroupingName() { |
| 95 | return name; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Set the name. |
| 100 | * |
| 101 | * @param refGroupingName the referred grouping name to set |
| 102 | */ |
| 103 | public void setRefGroupingName(String refGroupingName) { |
| 104 | name = refGroupingName; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Get the referred group. |
| 109 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 110 | * @return the referred group |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 111 | */ |
| 112 | public YangGrouping getRefGroup() { |
| 113 | return refGroup; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Set the referred group. |
| 118 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 119 | * @param refGroup the referred group |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 120 | */ |
| 121 | public void setRefGroup(YangGrouping refGroup) { |
| 122 | this.refGroup = refGroup; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Get the description. |
| 127 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 128 | * @return the description |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 129 | */ |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 130 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 131 | public String getDescription() { |
| 132 | return description; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Set the description. |
| 137 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 138 | * @param description set the description |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 139 | */ |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 140 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 141 | public void setDescription(String description) { |
| 142 | this.description = description; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Get the textual reference. |
| 147 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 148 | * @return the reference |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 149 | */ |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 150 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 151 | public String getReference() { |
| 152 | return reference; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Set the textual reference. |
| 157 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 158 | * @param reference the reference to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 159 | */ |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 160 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 161 | public void setReference(String reference) { |
| 162 | this.reference = reference; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Get the status. |
| 167 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 168 | * @return the status |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 169 | */ |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 170 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 171 | public YangStatusType getStatus() { |
| 172 | return status; |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Set the status. |
| 177 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 178 | * @param status the status to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 179 | */ |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 180 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 181 | public void setStatus(YangStatusType status) { |
| 182 | this.status = status; |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * Returns the type of the data. |
| 187 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 188 | * @return returns USES_DATA |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 189 | */ |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 190 | @Override |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 191 | public YangConstructType getYangConstructType() { |
| 192 | return YangConstructType.USES_DATA; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Validate the data on entering the corresponding parse tree node. |
| 197 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 198 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 199 | */ |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 200 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 201 | public void validateDataOnEntry() throws DataModelException { |
| 202 | // TODO auto-generated method stub, to be implemented by parser |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Validate the data on exiting the corresponding parse tree node. |
| 207 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 208 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 209 | */ |
Bharat saraswal | 5e3c45c | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 210 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 211 | public void validateDataOnExit() throws DataModelException { |
| 212 | // TODO auto-generated method stub, to be implemented by parser |
| 213 | } |
| 214 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 215 | /** |
| 216 | * Get uses name. |
| 217 | * |
| 218 | * @return uses name |
| 219 | */ |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 220 | @Override |
| 221 | public String getName() { |
| 222 | // TODO Auto-generated method stub |
| 223 | return null; |
| 224 | } |
| 225 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 226 | /** |
| 227 | * Set uses name. |
| 228 | * |
| 229 | * @param name uses name |
| 230 | */ |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 231 | @Override |
| 232 | public void setName(String name) { |
| 233 | // TODO Auto-generated method stub |
| 234 | |
| 235 | } |
| 236 | |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 237 | } |