Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +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 | 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 | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * Reference:RFC 6020. |
| 24 | * The "include" statement is used to make content from a submodule |
| 25 | * available to that submodule's parent module, or to another submodule |
| 26 | * of that parent module. The argument is an identifier that is the |
| 27 | * name of the submodule to include. |
| 28 | * The includes's Substatements |
| 29 | * |
| 30 | * +---------------+---------+-------------+------------------+ |
| 31 | * | substatement | section | cardinality |data model mapping| |
| 32 | * +---------------+---------+-------------+------------------+ |
| 33 | * | revision-date | 7.1.5.1 | 0..1 | string | |
| 34 | * +---------------+---------+-------------+------------------+ |
| 35 | */ |
| 36 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 37 | * Represents the information about the included sub-modules. |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 38 | */ |
| 39 | public class YangInclude implements Parsable { |
| 40 | |
| 41 | /** |
| 42 | * Name of the sub-module that is being included. |
| 43 | */ |
| 44 | private String subModuleName; |
| 45 | |
| 46 | /** |
| 47 | * The include's "revision-date" statement is used to specify the exact |
| 48 | * version of the submodule to import. |
| 49 | */ |
| 50 | private String revision; |
| 51 | |
| 52 | /** |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 53 | * Resolution information root node which is also the data model root node. |
| 54 | */ |
| 55 | private HasResolutionInfo resolutionInfoNode; |
| 56 | |
| 57 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 58 | * Creates a YANG include. |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 59 | */ |
| 60 | public YangInclude() { |
| 61 | } |
| 62 | |
| 63 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 64 | * Returns the name of included sub-module. |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 65 | * |
| 66 | * @return the sub-module name |
| 67 | */ |
| 68 | public String getSubModuleName() { |
| 69 | return subModuleName; |
| 70 | } |
| 71 | |
| 72 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 73 | * Sets the name of included sub-modules. |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 74 | * |
| 75 | * @param subModuleName the sub-module name to set |
| 76 | */ |
| 77 | public void setSubModuleName(String subModuleName) { |
| 78 | this.subModuleName = subModuleName; |
| 79 | } |
| 80 | |
| 81 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 82 | * Returns the revision. |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 83 | * |
| 84 | * @return the revision |
| 85 | */ |
| 86 | public String getRevision() { |
| 87 | return revision; |
| 88 | } |
| 89 | |
| 90 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 91 | * Sets the revision. |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 92 | * |
| 93 | * @param revision the revision to set |
| 94 | */ |
| 95 | public void setRevision(String revision) { |
| 96 | this.revision = revision; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Returns the type of parsed data. |
| 101 | * |
| 102 | * @return returns INCLUDE_DATA |
| 103 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 104 | @Override |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 105 | public YangConstructType getYangConstructType() { |
| 106 | return YangConstructType.INCLUDE_DATA; |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 110 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 111 | * |
| 112 | * @throws DataModelException a violation of data model rules |
| 113 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 114 | @Override |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 115 | public void validateDataOnEntry() throws DataModelException { |
| 116 | // TODO auto-generated method stub, to be implemented by parser |
| 117 | |
| 118 | } |
| 119 | |
| 120 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 121 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 122 | * |
| 123 | * @throws DataModelException a violation of data model rules |
| 124 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 125 | @Override |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 126 | public void validateDataOnExit() throws DataModelException { |
| 127 | // TODO auto-generated method stub, to be implemented by parser |
| 128 | |
| 129 | } |
| 130 | |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 131 | /** |
| 132 | * Returns the resolution information node. |
| 133 | * |
| 134 | * @return the resolution information node |
| 135 | */ |
| 136 | public HasResolutionInfo getResolutionInfoNode() { |
| 137 | return resolutionInfoNode; |
| 138 | } |
| 139 | |
| 140 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 141 | * Sets the dresolution information node. |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 142 | * |
| 143 | * @param resolutionInfoNode the resolution information node |
| 144 | */ |
| 145 | public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) { |
| 146 | this.resolutionInfoNode = resolutionInfoNode; |
| 147 | } |
Vinod Kumar S | 6a33667 | 2016-02-09 20:12:31 +0530 | [diff] [blame] | 148 | } |