Vidyashree Rama | 36f2fab | 2016-07-15 14:06:56 +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 | |
| 17 | package org.onosproject.yangutils.datamodel; |
| 18 | |
| 19 | import java.io.Serializable; |
| 20 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 21 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
| 22 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
| 23 | |
| 24 | /*- |
| 25 | * Reference RFC 6020. |
| 26 | * |
| 27 | * The "extension" statement allows the definition of new statements |
| 28 | * within the YANG language. This new statement definition can be |
| 29 | * imported and used by other modules. |
| 30 | * |
| 31 | * The statement's argument is an identifier that is the new keyword for |
| 32 | * the extension and must be followed by a block of sub-statements that |
| 33 | * holds detailed extension information. The purpose of the "extension" |
| 34 | * statement is to define a keyword, so that it can be imported and used |
| 35 | * by other modules. |
| 36 | * |
| 37 | * The extension can be used like a normal YANG statement, with the |
| 38 | * statement name followed by an argument if one is defined by the |
| 39 | * extension, and an optional block of sub-statements. The statement's |
| 40 | * name is created by combining the prefix of the module in which the |
| 41 | * extension was defined, a colon (":"), and the extension's keyword, |
| 42 | * with no interleaving whitespace. The sub-statements of an extension |
| 43 | * are defined by the extension, using some mechanism outside the scope |
| 44 | * of this specification. Syntactically, the sub-statements MUST be YANG |
| 45 | * statements, or also defined using "extension" statements. |
| 46 | * |
| 47 | * The extension's Sub-statements |
| 48 | * |
| 49 | * +--------------+---------+-------------+------------------+ |
| 50 | * | substatement | section | cardinality |data model mapping| |
| 51 | * +--------------+---------+-------------+------------------+ |
| 52 | * | description | 7.19.3 | 0..1 | -string | |
| 53 | * | reference | 7.19.4 | 0..1 | -string | |
| 54 | * | status | 7.19.2 | 0..1 | -YangStatus | |
| 55 | * | argument | 7.17.2 | 0..1 | -string | |
| 56 | * +--------------+---------+-------------+------------------+ |
| 57 | */ |
| 58 | |
| 59 | /** |
| 60 | * Represents data model node to maintain information defined in YANG extension. |
| 61 | */ |
| 62 | public class YangExtension |
| 63 | implements YangCommonInfo, Serializable, Parsable { |
| 64 | |
| 65 | private static final long serialVersionUID = 806201605L; |
| 66 | |
| 67 | /** |
| 68 | * Name of the extension. |
| 69 | */ |
| 70 | private String name; |
| 71 | |
| 72 | /** |
| 73 | * Name of the argument. |
| 74 | */ |
| 75 | private String argumentName; |
| 76 | |
| 77 | /** |
| 78 | * Description of extension. |
| 79 | */ |
| 80 | private String description; |
| 81 | |
| 82 | /** |
| 83 | * Reference of the extension. |
| 84 | */ |
| 85 | private String reference; |
| 86 | |
| 87 | /** |
| 88 | * Status of the extension. |
| 89 | */ |
| 90 | private YangStatusType status = YangStatusType.CURRENT; |
| 91 | |
| 92 | /** |
| 93 | * Returns the YANG name of extension. |
| 94 | * |
| 95 | * @return the name of extension as defined in YANG file |
| 96 | */ |
| 97 | public String getName() { |
| 98 | return name; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Sets the YANG name of extension. |
| 103 | * |
| 104 | * @param name the name of extension as defined in YANG file |
| 105 | */ |
| 106 | public void setName(String name) { |
| 107 | this.name = name; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Returns the YANG argument name of extension. |
| 112 | * |
| 113 | * @return the name of argument as defined in YANG file |
| 114 | */ |
| 115 | public String getArgumentName() { |
| 116 | return argumentName; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Sets the YANG argument name of extension. |
| 121 | * |
| 122 | * @param argumentName the name of argument as defined in YANG file |
| 123 | */ |
| 124 | public void setArgumentName(String argumentName) { |
| 125 | this.argumentName = argumentName; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Returns the description. |
| 130 | * |
| 131 | * @return the description |
| 132 | */ |
| 133 | @Override |
| 134 | public String getDescription() { |
| 135 | return description; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Sets the description. |
| 140 | * |
| 141 | * @param description set the description |
| 142 | */ |
| 143 | @Override |
| 144 | public void setDescription(String description) { |
| 145 | this.description = description; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Returns the textual reference. |
| 150 | * |
| 151 | * @return the reference |
| 152 | */ |
| 153 | @Override |
| 154 | public String getReference() { |
| 155 | return reference; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Sets the textual reference. |
| 160 | * |
| 161 | * @param reference the reference to set |
| 162 | */ |
| 163 | @Override |
| 164 | public void setReference(String reference) { |
| 165 | this.reference = reference; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * Returns the status. |
| 170 | * |
| 171 | * @return the status |
| 172 | */ |
| 173 | @Override |
| 174 | public YangStatusType getStatus() { |
| 175 | return status; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Sets the status. |
| 180 | * |
| 181 | * @param status the status to set |
| 182 | */ |
| 183 | @Override |
| 184 | public void setStatus(YangStatusType status) { |
| 185 | this.status = status; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Returns the type of the data. |
| 190 | * |
| 191 | * @return returns EXTENSION_DATA |
| 192 | */ |
| 193 | @Override |
| 194 | public YangConstructType getYangConstructType() { |
| 195 | return YangConstructType.EXTENSION_DATA; |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * Validates the data on entering the corresponding parse tree node. |
| 200 | * |
| 201 | * @throws DataModelException a violation of data model rules |
| 202 | */ |
| 203 | @Override |
| 204 | public void validateDataOnEntry() |
| 205 | throws DataModelException { |
| 206 | // TODO auto-generated method stub, to be implemented by parser |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Validates the data on exiting the corresponding parse tree node. |
| 211 | * |
| 212 | * @throws DataModelException a violation of data model rules |
| 213 | */ |
| 214 | @Override |
| 215 | public void validateDataOnExit() |
| 216 | throws DataModelException { |
| 217 | // TODO : to be implemented |
| 218 | } |
| 219 | } |