Vinod Kumar S | 2ff139c | 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 | |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 18 | import java.io.IOException; |
| 19 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 20 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 21 | import org.onosproject.yangutils.parser.Parsable; |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.translator.CachedFileHandle; |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.translator.GeneratedFileType; |
| 24 | import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax; |
| 25 | import org.onosproject.yangutils.utils.UtilConstants; |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 26 | import org.onosproject.yangutils.utils.YangConstructType; |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 27 | import org.onosproject.yangutils.utils.io.impl.FileSystemUtil; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 28 | |
| 29 | /*- |
| 30 | * Reference RFC 6020. |
| 31 | * |
| 32 | * The "typedef" statement defines a new type that may be used locally in the |
| 33 | * module, in modules or submodules which include it, and by other modules that |
| 34 | * import from it. The new type is called the "derived type", and the type from |
| 35 | * which it was derived is called the "base type". All derived types can be |
| 36 | * traced back to a YANG built-in type. |
| 37 | * |
| 38 | * The "typedef" statement's argument is an identifier that is the name of the |
| 39 | * type to be defined, and MUST be followed by a block of sub-statements that |
| 40 | * holds detailed typedef information. |
| 41 | * |
| 42 | * The name of the type MUST NOT be one of the YANG built-in types. If the |
| 43 | * typedef is defined at the top level of a YANG module or submodule, the name |
| 44 | * of the type to be defined MUST be unique within the module. |
| 45 | * The typedef's sub-statements |
| 46 | * |
| 47 | * +--------------+---------+-------------+------------------+ |
| 48 | * | substatement | section | cardinality |data model mapping| |
| 49 | * +--------------+---------+-------------+------------------+ |
| 50 | * | default | 7.3.4 | 0..1 |-string | |
| 51 | * | description | 7.19.3 | 0..1 |-string | |
| 52 | * | reference | 7.19.4 | 0..1 |-string | |
| 53 | * | status | 7.19.2 | 0..1 |-YangStatus | |
| 54 | * | type | 7.3.2 | 1 |-yangType | |
| 55 | * | units | 7.3.3 | 0..1 |-string | |
| 56 | * +--------------+---------+-------------+------------------+ |
| 57 | */ |
| 58 | /** |
| 59 | * Data model node to maintain information defined in YANG typedef. |
| 60 | */ |
| 61 | public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 62 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 63 | /** |
| 64 | * Default value in string, needs to be converted to the target object, |
| 65 | * based on the type. |
| 66 | */ |
| 67 | private String defaultValueInString; |
| 68 | |
| 69 | /** |
| 70 | * Description of new type. |
| 71 | */ |
| 72 | private String description; |
| 73 | |
| 74 | /** |
| 75 | * reference string. |
| 76 | */ |
| 77 | private String reference; |
| 78 | |
| 79 | /** |
| 80 | * Status of the data type. |
| 81 | */ |
| 82 | private YangStatusType status; |
| 83 | |
| 84 | /** |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 85 | * Maintain the derived type information. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 86 | */ |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 87 | private YangType<YangDerivedType> derivedType; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * Units of the data type. |
| 91 | */ |
| 92 | private String units; |
| 93 | |
| 94 | /** |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 95 | * package of the generated java code. |
| 96 | */ |
| 97 | private String pkg; |
| 98 | |
| 99 | /** |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 100 | * Cached Java File Handle. |
| 101 | */ |
| 102 | private CachedFileHandle fileHandle; |
| 103 | |
| 104 | /** |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 105 | * Create a typedef node. |
| 106 | */ |
| 107 | public YangTypeDef() { |
| 108 | super(YangNodeType.TYPEDEF_NODE); |
| 109 | } |
| 110 | |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 111 | /** |
| 112 | * Get the default value. |
| 113 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 114 | * @return the default value |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 115 | */ |
| 116 | public String getDefaultValueInString() { |
| 117 | return defaultValueInString; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Set the default value. |
| 122 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 123 | * @param defaultValueInString the default value |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 124 | */ |
| 125 | public void setDefaultValueInString(String defaultValueInString) { |
| 126 | this.defaultValueInString = defaultValueInString; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Get the description. |
| 131 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 132 | * @return the description |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 133 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 134 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 135 | public String getDescription() { |
| 136 | return description; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Set the description. |
| 141 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 142 | * @param description set the description |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 143 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 144 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 145 | public void setDescription(String description) { |
| 146 | this.description = description; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Get the textual reference. |
| 151 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 152 | * @return the reference |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 153 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 154 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 155 | public String getReference() { |
| 156 | return reference; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Set the textual reference. |
| 161 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 162 | * @param reference the reference to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 163 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 164 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 165 | public void setReference(String reference) { |
| 166 | this.reference = reference; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Get the status. |
| 171 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 172 | * @return the status |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 173 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 174 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 175 | public YangStatusType getStatus() { |
| 176 | return status; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Set the status. |
| 181 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 182 | * @param status the status to set |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 183 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 184 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 185 | public void setStatus(YangStatusType status) { |
| 186 | this.status = status; |
| 187 | } |
| 188 | |
| 189 | /** |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 190 | * Get the derived type. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 191 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 192 | * @return the derived type |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 193 | */ |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 194 | public YangType<YangDerivedType> getDerivedType() { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 195 | return derivedType; |
| 196 | } |
| 197 | |
| 198 | /** |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 199 | * Set the derived type. |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 200 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 201 | * @param derivedType the derived type |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 202 | */ |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 203 | public void setDerivedType(YangType<YangDerivedType> derivedType) { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 204 | this.derivedType = derivedType; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Get the unit. |
| 209 | * |
| 210 | * @return the units |
| 211 | */ |
| 212 | public String getUnits() { |
| 213 | return units; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Set the unit. |
| 218 | * |
| 219 | * @param units the units to set |
| 220 | */ |
| 221 | public void setUnits(String units) { |
| 222 | this.units = units; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Returns the type of the data. |
| 227 | * |
| 228 | * @return returns TYPEDEF_DATA |
| 229 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 230 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 231 | public YangConstructType getYangConstructType() { |
| 232 | return YangConstructType.TYPEDEF_DATA; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | /** |
| 236 | * Validate the data on entering the corresponding parse tree node. |
| 237 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 238 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 239 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 240 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 241 | public void validateDataOnEntry() throws DataModelException { |
| 242 | // TODO auto-generated method stub, to be implemented by parser |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * Validate the data on exiting the corresponding parse tree node. |
| 247 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 248 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 249 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 250 | @Override |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 251 | public void validateDataOnExit() throws DataModelException { |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 252 | YangType<YangDerivedType> type = getDerivedType(); |
| 253 | if (type == null) { |
| 254 | throw new DataModelException("Typedef does not have type info."); |
| 255 | } |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 256 | if (type.getDataType() != YangDataTypes.DERIVED |
| 257 | || type.getDataTypeName() == null) { |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 258 | throw new DataModelException("Typedef type is not derived."); |
| 259 | } |
| 260 | |
| 261 | YangDerivedType derivedTypeInfo = type.getDataTypeExtendedInfo(); |
| 262 | if (derivedTypeInfo == null) { |
| 263 | throw new DataModelException("derrived type does not have derived info."); |
| 264 | } |
| 265 | |
| 266 | YangType<?> baseType = derivedTypeInfo.getBaseType(); |
| 267 | if (baseType == null) { |
| 268 | throw new DataModelException("Base type of a derived type is missing."); |
| 269 | } |
| 270 | |
| 271 | if (derivedTypeInfo.getEffectiveYangBuiltInType() == null) { |
| 272 | /* resolve the effective type from the data tree. */ |
| 273 | /* |
| 274 | * TODO: try to resolve the nested reference, if possible in the |
| 275 | * partial tree, otherwise we need to resolve finally when the |
| 276 | * complete module is created. |
| 277 | */ |
| 278 | YangModule.addToResolveList(this); |
| 279 | } |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 280 | } |
| 281 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 282 | /** |
| 283 | * Get the YANG name of the typedef. |
| 284 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 285 | * @return YANG name of the typedef |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 286 | */ |
| 287 | @Override |
| 288 | public String getName() { |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 289 | if (getDerivedType() != null) { |
| 290 | return getDerivedType().getDataTypeName(); |
| 291 | } |
| 292 | return null; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 293 | } |
| 294 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 295 | /** |
| 296 | * Set YANG name of the typedef. |
| 297 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 298 | * @param name YANG name of the typedef |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 299 | */ |
| 300 | @Override |
| 301 | public void setName(String name) { |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 302 | if (getDerivedType() == null) { |
| 303 | throw new RuntimeException( |
| 304 | "Derrived Type info needs to be set in parser when the typedef listner is processed"); |
| 305 | } |
| 306 | getDerivedType().setDataTypeName(name); |
| 307 | getDerivedType().setDataType(YangDataTypes.DERIVED); |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 308 | } |
| 309 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 310 | /** |
| 311 | * Generate java code snippet corresponding to YANG typedef. |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 312 | * |
| 313 | * @param codeGenDir code generation directory |
| 314 | * @throws IOException when fails to generate files for typedef |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 315 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 316 | @Override |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 317 | public void generateJavaCodeEntry(String codeGenDir) throws IOException { |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 318 | |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 319 | YangNode parent = getParent(); |
| 320 | String typeDefPkg = JavaIdentifierSyntax.getPackageFromParent(parent.getPackage(), parent.getName()); |
| 321 | |
| 322 | typeDefPkg = JavaIdentifierSyntax.getCamelCase(typeDefPkg).toLowerCase(); |
| 323 | setPackage(typeDefPkg); |
| 324 | |
| 325 | CachedFileHandle handle = null; |
| 326 | try { |
| 327 | FileSystemUtil.createPackage(codeGenDir + getPackage(), parent.getName() + UtilConstants.CHILDREN); |
| 328 | handle = FileSystemUtil.createSourceFiles(getPackage(), getName(), |
| 329 | GeneratedFileType.GENERATE_TYPEDEF_CLASS); |
| 330 | handle.setRelativeFilePath(getPackage().replace(".", "/")); |
| 331 | handle.setCodeGenFilePath(codeGenDir); |
| 332 | } catch (IOException e) { |
| 333 | throw new IOException("Failed to create the source files."); |
| 334 | } |
| 335 | setFileHandle(handle); |
Bharat saraswal | 8f2a6c5 | 2016-03-09 18:34:56 +0530 | [diff] [blame^] | 336 | getDerivedType().getDataTypeExtendedInfo().getBaseType().setJavaPackage(getPackage()); |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 337 | addAttributeInfo(); |
| 338 | addAttributeInParent(); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Adds current node attribute to parent file. |
| 343 | */ |
| 344 | private void addAttributeInParent() { |
| 345 | if (getParent() != null) { |
| 346 | getParent().getFileHandle().addAttributeInfo(null, getName(), false); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | /** |
| 351 | * Adds attribute to file handle. |
| 352 | */ |
| 353 | private void addAttributeInfo() { |
| 354 | getFileHandle().addAttributeInfo(getDerivedType().getDataTypeExtendedInfo().getBaseType(), |
| 355 | JavaIdentifierSyntax.getCamelCase(getName()), false); |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 356 | } |
| 357 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 358 | /** |
| 359 | * Free resource used for code generation of YANG typedef. |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 360 | * |
| 361 | * @throws IOException when fails to generate files |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 362 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 363 | @Override |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 364 | public void generateJavaCodeExit() throws IOException { |
| 365 | getFileHandle().close(); |
| 366 | return; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 367 | } |
| 368 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 369 | /** |
| 370 | * Get the mapped java package. |
| 371 | * |
| 372 | * @return the java package |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 373 | */ |
| 374 | @Override |
| 375 | public String getPackage() { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 376 | return pkg; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 377 | } |
| 378 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 379 | /** |
| 380 | * Set the mapped java package. |
| 381 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 382 | * @param pakg mapped java package |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 383 | */ |
| 384 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 385 | public void setPackage(String pakg) { |
| 386 | pkg = pakg; |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 387 | |
| 388 | } |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 389 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 390 | /** |
| 391 | * Get the file handle of the cached file used during code generation. |
| 392 | * |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 393 | * @return cached file handle |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 394 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 395 | @Override |
| 396 | public CachedFileHandle getFileHandle() { |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 397 | return fileHandle; |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 398 | } |
| 399 | |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 400 | /** |
| 401 | * Set the file handle to be used used for code generation. |
| 402 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 403 | * @param handle cached file handle |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 404 | */ |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 405 | @Override |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 406 | public void setFileHandle(CachedFileHandle handle) { |
| 407 | fileHandle = handle; |
Bharat saraswal | 594bc6d | 2016-02-22 22:15:21 +0530 | [diff] [blame] | 408 | } |
Vinod Kumar S | 2ff139c | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 409 | } |