blob: cf18a62f73732658e292d534add1388962d7cb21 [file] [log] [blame]
Vinod Kumar S19f39c72016-02-09 20:12:31 +05301/*
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 */
16package org.onosproject.yangutils.datamodel;
17
18import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
19import org.onosproject.yangutils.parser.Parsable;
20import org.onosproject.yangutils.parser.ParsableDataType;
21
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 */
62/**
63 * Maintains the information about the imported modules.
64 */
65public class YangImport implements Parsable {
66
67 /**
68 * Name of the module that is being imported.
69 */
70 private String name;
71
72 /**
73 * Prefix used to identify the entities from the imported module.
74 */
75 private String prefixId;
76
77 /**
78 * Reference:RFC 6020.
79 * The import's "revision-date" statement is used to specify the exact
80 * version of the module to import. The "revision-date" statement MUST match
81 * the most recent "revision" statement in the imported module. organization
82 * which defined the YANG module.
83 */
84 private String revision;
85
86 /**
87 * Default constructor.
88 */
89 public YangImport() {
90
91 }
92
93 /**
94 * Get the imported module name.
95 *
96 * @return the module name.
97 */
98 public String getModuleName() {
99 return name;
100 }
101
102 /**
103 * Set module name.
104 *
105 * @param moduleName the module name to set
106 */
107 public void setModuleName(String moduleName) {
108 name = moduleName;
109 }
110
111 /**
112 * Get the prefix used to identify the entities from the imported module.
113 *
114 * @return the prefix used to identify the entities from the imported
115 * module.
116 */
117 public String getPrefixId() {
118 return prefixId;
119 }
120
121 /**
122 * Set prefix identifier.
123 *
124 * @param prefixId set the prefix identifier of the imported module.
125 */
126 public void setPrefixId(String prefixId) {
127 this.prefixId = prefixId;
128 }
129
130 /**
131 * Get the revision of the imported module.
132 *
133 * @return the revision of the imported module.
134 */
135 public String getRevision() {
136 return revision;
137 }
138
139 /**
140 * Set the revision of the imported module.
141 *
142 * @param rev set the revision of the imported module.
143 */
144 public void setRevision(String rev) {
145 revision = rev;
146 }
147
148 /**
149 * Returns the type of the parsed data.
150 *
151 * @return returns IMPORT_DATA
152 */
153 public ParsableDataType getParsableDataType() {
154 return ParsableDataType.IMPORT_DATA;
155 }
156
157 /**
158 * Validate the data on entering the corresponding parse tree node.
159 *
160 * @throws DataModelException a violation of data model rules
161 */
162 public void validateDataOnEntry() throws DataModelException {
163 // TODO auto-generated method stub, to be implemented by parser
164
165 }
166
167 /**
168 * Validate the data on exiting the corresponding parse tree node.
169 *
170 * @throws DataModelException a violation of data model rules
171 */
172 public void validateDataOnExit() throws DataModelException {
173 // TODO auto-generated method stub, to be implemented by parser
174
175 }
176}