blob: 4ab3f2a10b375869cfffc70209506da2e5454fc7 [file] [log] [blame]
Vinod Kumar S19f39c72016-02-09 20:12:31 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S19f39c72016-02-09 20:12:31 +05303 *
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 */
16package org.onosproject.yangutils.datamodel;
17
18import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
19import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053020import org.onosproject.yangutils.utils.YangConstructType;
Vinod Kumar S19f39c72016-02-09 20:12:31 +053021
22/*
23 * Reference:RFC 6020.
24 * The "import" statement makes definitions from one module available
25 * inside another module or submodule. The argument is the name of the
26 * module to import, and the statement is followed by a block of
27 * sub statements that holds detailed import information.
28 * When a module is imported, the importing module may:
29 * o use any grouping and typedef defined at the top level in the
30 * imported module or its submodules.
31 *
32 * o use any extension, feature, and identity defined in the imported
33 * module or its submodules.
34 *
35 * o use any node in the imported module's schema tree in "must",
36 * "path", and "when" statements, or as the target node in "augment"
37 * and "deviation" statements.
38 *
39 * The mandatory "prefix" sub statement assigns a prefix for the imported
40 * module that is scoped to the importing module or submodule. Multiple
41 * "import" statements may be specified to import from different
42 * modules.
43 * When the optional "revision-date" sub-statement is present, any
44 * typedef, grouping, extension, feature, and identity referenced by
45 * definitions in the local module are taken from the specified revision
46 * of the imported module. It is an error if the specified revision of
47 * the imported module does not exist. If no "revision-date"
48 * sub-statement is present, it is undefined from which revision of the
49 * module they are taken.
50 *
51 * Multiple revisions of the same module MUST NOT be imported.
52 *
53 * The import's Substatements
54 *
55 * +---------------+---------+-------------+------------------+
56 * | substatement | section | cardinality |data model mapping|
57 * +---------------+---------+-------------+------------------+
58 * | prefix | 7.1.4 | 1 | string |
59 * | revision-date | 7.1.5.1 | 0..1 | string |
60 * +---------------+---------+-------------+------------------+
61 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053062
Vinod Kumar S19f39c72016-02-09 20:12:31 +053063/**
Bharat saraswald9822e92016-04-05 15:13:44 +053064 * Represents the information about the imported modules.
Vinod Kumar S19f39c72016-02-09 20:12:31 +053065 */
Vinod Kumar Sd4deb062016-04-15 18:08:57 +053066public class YangImport
67 implements Parsable {
Vinod Kumar S19f39c72016-02-09 20:12:31 +053068
69 /**
70 * Name of the module that is being imported.
71 */
72 private String name;
73
74 /**
75 * Prefix used to identify the entities from the imported module.
76 */
77 private String prefixId;
78
79 /**
80 * Reference:RFC 6020.
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053081 *
Vinod Kumar S19f39c72016-02-09 20:12:31 +053082 * The import's "revision-date" statement is used to specify the exact
83 * version of the module to import. The "revision-date" statement MUST match
84 * the most recent "revision" statement in the imported module. organization
85 * which defined the YANG module.
86 */
87 private String revision;
88
89 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053090 * Creates a YANG import.
Vinod Kumar S19f39c72016-02-09 20:12:31 +053091 */
92 public YangImport() {
93
94 }
95
96 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053097 * Returns the imported module name.
Vinod Kumar S19f39c72016-02-09 20:12:31 +053098 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053099 * @return the module name
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530100 */
101 public String getModuleName() {
102 return name;
103 }
104
105 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530106 * Sets module name.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530107 *
108 * @param moduleName the module name to set
109 */
110 public void setModuleName(String moduleName) {
111 name = moduleName;
112 }
113
114 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530115 * Returns the prefix used to identify the entities from the imported module.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530116 *
117 * @return the prefix used to identify the entities from the imported
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530118 * module
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530119 */
120 public String getPrefixId() {
121 return prefixId;
122 }
123
124 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530125 * Sets prefix identifier.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530126 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530127 * @param prefixId set the prefix identifier of the imported module
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530128 */
129 public void setPrefixId(String prefixId) {
130 this.prefixId = prefixId;
131 }
132
133 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530134 * Returns the revision of the imported module.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530135 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530136 * @return the revision of the imported module
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530137 */
138 public String getRevision() {
139 return revision;
140 }
141
142 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530143 * Sets the revision of the imported module.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530144 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530145 * @param rev set the revision of the imported module
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530146 */
147 public void setRevision(String rev) {
148 revision = rev;
149 }
150
151 /**
152 * Returns the type of the parsed data.
153 *
154 * @return returns IMPORT_DATA
155 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530156 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530157 public YangConstructType getYangConstructType() {
158 return YangConstructType.IMPORT_DATA;
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530159 }
160
161 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530162 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530163 *
164 * @throws DataModelException a violation of data model rules
165 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530166 @Override
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530167 public void validateDataOnEntry()
168 throws DataModelException {
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530169 // TODO auto-generated method stub, to be implemented by parser
170
171 }
172
173 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530174 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530175 *
176 * @throws DataModelException a violation of data model rules
177 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530178 @Override
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530179 public void validateDataOnExit()
180 throws DataModelException {
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530181 // TODO auto-generated method stub, to be implemented by parser
182
183 }
Vinod Kumar S19f39c72016-02-09 20:12:31 +0530184}