Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +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.translator.tojava; |
| 18 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 19 | import java.io.File; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 20 | import java.io.IOException; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 21 | import java.util.ArrayList; |
| 22 | import java.util.List; |
| 23 | |
| 24 | import org.onosproject.yangutils.datamodel.YangNode; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 25 | import org.onosproject.yangutils.datamodel.YangNotification; |
| 26 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; |
| 27 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule; |
| 28 | import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 29 | |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 30 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; |
| 31 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE; |
| 32 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS; |
| 33 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_ENUM_MASK; |
| 34 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_METHOD_MASK; |
| 35 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_ATTRIBUTE_MASK; |
| 36 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_GETTER_MASK; |
| 37 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EVENT_SUBJECT_SETTER_MASK; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 38 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_IMPL_MASK; |
| 39 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 40 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
| 41 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 42 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 43 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventFile; |
| 44 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventListenerFile; |
| 45 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEventSubjectFile; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 46 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile; |
| 47 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 48 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; |
| 49 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 50 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 51 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; |
| 52 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 53 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod; |
| 54 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 55 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; |
| 56 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addAnnotationsImports; |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 57 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addListnersImport; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 58 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 59 | import static org.onosproject.yangutils.utils.UtilConstants.COMMA; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 60 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 61 | import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; |
| 62 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 63 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_REG; |
| 64 | import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 65 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 66 | import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 67 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 68 | import static org.onosproject.yangutils.utils.UtilConstants.VOID; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 69 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage; |
| 70 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 71 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
| 72 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; |
| 73 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; |
| 74 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 75 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 76 | |
| 77 | /** |
| 78 | * Represents implementation of java service code fragments temporary implementations. |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 79 | * Maintains the temp files required specific for service and manager java snippet generation. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 80 | */ |
| 81 | public class TempJavaServiceFragmentFiles |
| 82 | extends TempJavaFragmentFiles { |
| 83 | |
| 84 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 85 | * File name for rpc method. |
| 86 | */ |
| 87 | private static final String RPC_INTERFACE_FILE_NAME = "Rpc"; |
| 88 | |
| 89 | /** |
| 90 | * File name for rpc implementation method. |
| 91 | */ |
| 92 | private static final String RPC_IMPL_FILE_NAME = "RpcImpl"; |
| 93 | |
| 94 | /** |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 95 | * File name for event enum temp file. |
| 96 | */ |
| 97 | private static final String EVENT_ENUM_FILE_NAME = "EventEnum"; |
| 98 | |
| 99 | /** |
| 100 | * File name for event method temp file. |
| 101 | */ |
| 102 | private static final String EVENT_METHOD_FILE_NAME = "EventMethod"; |
| 103 | |
| 104 | /** |
| 105 | * File name for event subject attribute temp file. |
| 106 | */ |
| 107 | private static final String EVENT_SUBJECT_ATTRIBUTE_FILE_NAME = "EventSubjectAttribute"; |
| 108 | |
| 109 | /** |
| 110 | * File name for event subject getter temp file. |
| 111 | */ |
| 112 | private static final String EVENT_SUBJECT_GETTER_FILE_NAME = "EventSubjectGetter"; |
| 113 | |
| 114 | /** |
| 115 | * File name for event subject setter temp file. |
| 116 | */ |
| 117 | private static final String EVENT_SUBJECT_SETTER_FILE_NAME = "EventSubjectSetter"; |
| 118 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 119 | * File name for generated class file for service |
| 120 | * suffix. |
| 121 | */ |
| 122 | private static final String SERVICE_FILE_NAME_SUFFIX = "Service"; |
| 123 | |
| 124 | /** |
| 125 | * File name for generated class file for manager |
| 126 | * suffix. |
| 127 | */ |
| 128 | private static final String MANAGER_FILE_NAME_SUFFIX = "Manager"; |
| 129 | |
| 130 | /** |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 131 | * File name for generated class file for special type like union, typedef |
| 132 | * suffix. |
| 133 | */ |
| 134 | private static final String EVENT_FILE_NAME_SUFFIX = "Event"; |
| 135 | |
| 136 | /** |
| 137 | * File name for generated class file for special type like union, typedef |
| 138 | * suffix. |
| 139 | */ |
| 140 | private static final String EVENT_LISTENER_FILE_NAME_SUFFIX = "Listener"; |
| 141 | |
| 142 | /** |
| 143 | * File name for generated class file for special type like union, typedef |
| 144 | * suffix. |
| 145 | */ |
| 146 | public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject"; |
| 147 | |
| 148 | private static final String JAVA_FILE_EXTENSION = ".java"; |
| 149 | |
| 150 | /** |
| 151 | * Java file handle for event subject file. |
| 152 | */ |
| 153 | private File eventSubjectJavaFileHandle; |
| 154 | |
| 155 | /** |
| 156 | * Java file handle for event listener file. |
| 157 | */ |
| 158 | private File eventListenerJavaFileHandle; |
| 159 | |
| 160 | /** |
| 161 | * Java file handle for event file. |
| 162 | */ |
| 163 | private File eventJavaFileHandle; |
| 164 | |
| 165 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 166 | * Temporary file handle for rpc interface. |
| 167 | */ |
| 168 | private File rpcInterfaceTempFileHandle; |
| 169 | |
| 170 | /** |
| 171 | * Temporary file handle for rpc manager impl. |
| 172 | */ |
| 173 | private File rpcImplTempFileHandle; |
| 174 | |
| 175 | /** |
| 176 | * Java file handle for rpc interface file. |
| 177 | */ |
| 178 | private File serviceInterfaceJavaFileHandle; |
| 179 | |
| 180 | /** |
| 181 | * Java file handle for manager impl file. |
| 182 | */ |
| 183 | private File managerJavaFileHandle; |
| 184 | |
| 185 | /** |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 186 | * Java file handle for event enum impl file. |
| 187 | */ |
| 188 | private File eventEnumTempFileHandle; |
| 189 | |
| 190 | /** |
| 191 | * Java file handle for event method impl file. |
| 192 | */ |
| 193 | private File eventMethodTempFileHandle; |
| 194 | |
| 195 | /** |
| 196 | * Java file handle for event subject attribute file. |
| 197 | */ |
| 198 | private File eventSubjectAttributeTempFileHandle; |
| 199 | |
| 200 | /** |
| 201 | * Java file handle for event subject getter impl file. |
| 202 | */ |
| 203 | private File eventSubjectGetterTempFileHandle; |
| 204 | |
| 205 | /** |
| 206 | * Java file handle for event subject setter impl file. |
| 207 | */ |
| 208 | private File eventSubjectSetterTempFileHandle; |
| 209 | |
| 210 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 211 | * Returns rpc method's java file handle. |
| 212 | * |
| 213 | * @return java file handle |
| 214 | */ |
| 215 | private File getServiceInterfaceJavaFileHandle() { |
| 216 | return serviceInterfaceJavaFileHandle; |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Sets rpc method's java file handle. |
| 221 | * |
| 222 | * @param serviceInterfaceJavaFileHandle file handle for to rpc method |
| 223 | */ |
| 224 | private void setServiceInterfaceJavaFileHandle(File serviceInterfaceJavaFileHandle) { |
| 225 | this.serviceInterfaceJavaFileHandle = serviceInterfaceJavaFileHandle; |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Returns managers java file handle. |
| 230 | * |
| 231 | * @return java file handle |
| 232 | */ |
| 233 | public File getManagerJavaFileHandle() { |
| 234 | return managerJavaFileHandle; |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Sets manager java file handle. |
| 239 | * |
| 240 | * @param managerJavaFileHandle file handle for to manager |
| 241 | */ |
| 242 | public void setManagerJavaFileHandle(File managerJavaFileHandle) { |
| 243 | this.managerJavaFileHandle = managerJavaFileHandle; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Returns rpc method's temporary file handle. |
| 248 | * |
| 249 | * @return temporary file handle |
| 250 | */ |
| 251 | public File getRpcInterfaceTempFileHandle() { |
| 252 | return rpcInterfaceTempFileHandle; |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Sets rpc method's temporary file handle. |
| 257 | * |
| 258 | * @param rpcInterfaceTempFileHandle file handle for to rpc method |
| 259 | */ |
| 260 | private void setRpcInterfaceTempFileHandle(File rpcInterfaceTempFileHandle) { |
| 261 | this.rpcInterfaceTempFileHandle = rpcInterfaceTempFileHandle; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * Retrieves the manager impl temp file. |
| 266 | * |
| 267 | * @return the manager impl temp file |
| 268 | */ |
| 269 | public File getRpcImplTempFileHandle() { |
| 270 | return rpcImplTempFileHandle; |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Sets the manager impl temp file. |
| 275 | * |
| 276 | * @param rpcImplTempFileHandle the manager impl temp file |
| 277 | */ |
| 278 | public void setRpcImplTempFileHandle(File rpcImplTempFileHandle) { |
| 279 | this.rpcImplTempFileHandle = rpcImplTempFileHandle; |
| 280 | } |
| 281 | |
| 282 | /** |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 283 | * Returns event's java file handle. |
| 284 | * |
| 285 | * @return java file handle |
| 286 | */ |
| 287 | private File getEventJavaFileHandle() { |
| 288 | return eventJavaFileHandle; |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Sets event's java file handle. |
| 293 | * |
| 294 | * @param eventJavaFileHandle file handle for event |
| 295 | */ |
| 296 | private void setEventJavaFileHandle(File eventJavaFileHandle) { |
| 297 | this.eventJavaFileHandle = eventJavaFileHandle; |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Returns event listeners's java file handle. |
| 302 | * |
| 303 | * @return java file handle |
| 304 | */ |
| 305 | private File getEventListenerJavaFileHandle() { |
| 306 | return eventListenerJavaFileHandle; |
| 307 | } |
| 308 | |
| 309 | /** |
| 310 | * Sets event's java file handle. |
| 311 | * |
| 312 | * @param eventListenerJavaFileHandle file handle for event |
| 313 | */ |
| 314 | private void setEventListenerJavaFileHandle(File eventListenerJavaFileHandle) { |
| 315 | this.eventListenerJavaFileHandle = eventListenerJavaFileHandle; |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * Returns event subject's java file handle. |
| 320 | * |
| 321 | * @return java file handle |
| 322 | */ |
| 323 | private File getEventSubjectJavaFileHandle() { |
| 324 | return eventSubjectJavaFileHandle; |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Sets event's subject java file handle. |
| 329 | * |
| 330 | * @param eventSubjectJavaFileHandle file handle for event's subject |
| 331 | */ |
| 332 | private void setEventSubjectJavaFileHandle(File eventSubjectJavaFileHandle) { |
| 333 | this.eventSubjectJavaFileHandle = eventSubjectJavaFileHandle; |
| 334 | } |
| 335 | |
| 336 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 337 | * Creates an instance of temporary java code fragment. |
| 338 | * |
| 339 | * @param javaFileInfo generated file information |
| 340 | * @throws IOException when fails to create new file handle |
| 341 | */ |
| 342 | public TempJavaServiceFragmentFiles(JavaFileInfo javaFileInfo) |
| 343 | throws IOException { |
| 344 | super(javaFileInfo); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 345 | |
| 346 | addGeneratedTempFile(RPC_INTERFACE_MASK); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 347 | addGeneratedTempFile(RPC_IMPL_MASK); |
| 348 | |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 349 | addGeneratedTempFile(EVENT_ENUM_MASK); |
| 350 | addGeneratedTempFile(EVENT_METHOD_MASK); |
| 351 | addGeneratedTempFile(EVENT_SUBJECT_ATTRIBUTE_MASK); |
| 352 | addGeneratedTempFile(EVENT_SUBJECT_GETTER_MASK); |
| 353 | addGeneratedTempFile(EVENT_SUBJECT_SETTER_MASK); |
| 354 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 355 | setRpcInterfaceTempFileHandle(getTemporaryFileHandle(RPC_INTERFACE_FILE_NAME)); |
| 356 | setRpcImplTempFileHandle(getTemporaryFileHandle(RPC_IMPL_FILE_NAME)); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 357 | |
| 358 | setEventEnumTempFileHandle(getTemporaryFileHandle(EVENT_ENUM_FILE_NAME)); |
| 359 | setEventMethodTempFileHandle(getTemporaryFileHandle(EVENT_METHOD_FILE_NAME)); |
| 360 | setEventSubjectAttributeTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_ATTRIBUTE_FILE_NAME)); |
| 361 | setEventSubjectGetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_GETTER_FILE_NAME)); |
| 362 | setEventSubjectSetterTempFileHandle(getTemporaryFileHandle(EVENT_SUBJECT_SETTER_FILE_NAME)); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | /** |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 366 | * Constructs java code exit. |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 367 | * |
| 368 | * @param fileType generated file type |
| 369 | * @param curNode current YANG node |
| 370 | * @throws IOException when fails to generate java files |
| 371 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 372 | @Override |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 373 | public void generateJavaFile(int fileType, YangNode curNode) |
| 374 | throws IOException { |
| 375 | List<String> imports = new ArrayList<>(); |
| 376 | imports = getJavaImportData().getImports(); |
| 377 | |
| 378 | createPackage(curNode); |
| 379 | |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 380 | boolean isNotification = false; |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 381 | if (curNode instanceof YangJavaModule) { |
| 382 | if (!((YangJavaModule) curNode).getNotificationNodes().isEmpty()) { |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 383 | isNotification = true; |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 384 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 385 | } else if (curNode instanceof YangJavaSubModule) { |
| 386 | if (!((YangJavaSubModule) curNode).getNotificationNodes().isEmpty()) { |
| 387 | isNotification = true; |
| 388 | } |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | if (isNotification) { |
| 392 | addListnersImport(curNode, imports, true, LISTENER_SERVICE); |
| 393 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 394 | /** |
| 395 | * Creates rpc interface file. |
| 396 | */ |
| 397 | setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX))); |
| 398 | generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports, isAttributePresent()); |
| 399 | |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 400 | if (isNotification) { |
| 401 | addListnersImport(curNode, imports, false, LISTENER_SERVICE); |
| 402 | addListnersImport(curNode, imports, true, LISTENER_REG); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 403 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 404 | addAnnotationsImports(imports, true); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 405 | /** |
| 406 | * Create builder class file. |
| 407 | */ |
| 408 | setManagerJavaFileHandle(getJavaFileHandle(getJavaClassName(MANAGER_FILE_NAME_SUFFIX))); |
| 409 | generateManagerClassFile(getManagerJavaFileHandle(), imports, curNode, isAttributePresent()); |
| 410 | |
| 411 | insertDataIntoJavaFile(getManagerJavaFileHandle(), getJavaClassDefClose()); |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 412 | if (isNotification) { |
| 413 | addListnersImport(curNode, imports, false, LISTENER_REG); |
| 414 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 415 | addAnnotationsImports(imports, false); |
| 416 | |
| 417 | if (isNotification) { |
| 418 | generateEventJavaFile(GENERATE_EVENT_CLASS, curNode); |
| 419 | generateEventListenerJavaFile(GENERATE_EVENT_LISTENER_INTERFACE, curNode); |
| 420 | generateEventSubjectJavaFile(GENERATE_EVENT_SUBJECT_CLASS, curNode); |
| 421 | } |
| 422 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 423 | /** |
| 424 | * Close all the file handles. |
| 425 | */ |
| 426 | freeTemporaryResources(false); |
| 427 | } |
| 428 | |
| 429 | /** |
| 430 | * Adds rpc string information to applicable temp file. |
| 431 | * |
| 432 | * @param javaAttributeInfoOfInput rpc's input node attribute info |
| 433 | * @param javaAttributeInfoOfOutput rpc's output node attribute info |
| 434 | * @param rpcName name of the rpc function |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 435 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 436 | * @throws IOException IO operation fail |
| 437 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 438 | private void addRpcString(JavaAttributeInfo javaAttributeInfoOfInput, |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 439 | JavaAttributeInfo javaAttributeInfoOfOutput, YangPluginConfig pluginConfig, |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 440 | String rpcName) throws IOException { |
| 441 | String rpcInput = EMPTY_STRING; |
| 442 | String rpcOutput = VOID; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 443 | if (javaAttributeInfoOfInput != null) { |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 444 | rpcInput = getCapitalCase(javaAttributeInfoOfInput.getAttributeName()); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 445 | } |
| 446 | if (javaAttributeInfoOfOutput != null) { |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 447 | rpcOutput = getCapitalCase(javaAttributeInfoOfOutput.getAttributeName()); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 448 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 449 | appendToFile(getRpcInterfaceTempFileHandle(), |
| 450 | generateJavaDocForRpc(rpcName, RPC_INPUT_VAR_NAME, rpcOutput, pluginConfig) |
| 451 | + getRpcServiceMethod(rpcName, rpcInput, rpcOutput, pluginConfig) + NEW_LINE); |
| 452 | appendToFile(getRpcImplTempFileHandle(), |
| 453 | getRpcManagerMethod(rpcName, rpcInput, rpcOutput, pluginConfig) + NEW_LINE); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | /** |
| 457 | * Adds the JAVA rpc snippet information. |
| 458 | * |
| 459 | * @param javaAttributeInfoOfInput rpc's input node attribute info |
| 460 | * @param javaAttributeInfoOfOutput rpc's output node attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 461 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 462 | * @param rpcName name of the rpc function |
| 463 | * @throws IOException IO operation fail |
| 464 | */ |
| 465 | public void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo javaAttributeInfoOfInput, |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 466 | JavaAttributeInfo javaAttributeInfoOfOutput, YangPluginConfig pluginConfig, |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 467 | String rpcName) |
| 468 | throws IOException { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 469 | addRpcString(javaAttributeInfoOfInput, javaAttributeInfoOfOutput, pluginConfig, rpcName); |
| 470 | } |
| 471 | |
| 472 | /** |
| 473 | * Constructs java code exit. |
| 474 | * |
| 475 | * @param fileType generated file type |
| 476 | * @param curNode current YANG node |
| 477 | * @throws IOException when fails to generate java files |
| 478 | */ |
| 479 | public void generateEventJavaFile(int fileType, YangNode curNode) |
| 480 | throws IOException { |
| 481 | |
| 482 | List<String> imports = new ArrayList<>(); |
| 483 | |
| 484 | imports.add(getJavaImportData().getAbstractEventsImport()); |
| 485 | String curNodeInfo = |
| 486 | getCapitalCase(((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()); |
| 487 | String nodeName = curNodeInfo + EVENT_STRING; |
| 488 | |
| 489 | addEnumMethod(nodeName, curNodeInfo + EVENT_SUBJECT_NAME_SUFFIX); |
| 490 | |
| 491 | /** |
| 492 | * Creates event interface file. |
| 493 | */ |
| 494 | setEventJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo + EVENT_FILE_NAME_SUFFIX)); |
| 495 | generateEventFile(getEventJavaFileHandle(), curNode, imports); |
| 496 | |
| 497 | /** |
| 498 | * Close all the file handles. |
| 499 | */ |
| 500 | freeTemporaryResources(false); |
| 501 | } |
| 502 | |
| 503 | /** |
| 504 | * Constructs java code exit. |
| 505 | * |
| 506 | * @param fileType generated file type |
| 507 | * @param curNode current YANG node |
| 508 | * @throws IOException when fails to generate java files |
| 509 | */ |
| 510 | public void generateEventListenerJavaFile(int fileType, YangNode curNode) |
| 511 | throws IOException { |
| 512 | |
| 513 | List<String> imports = new ArrayList<>(); |
| 514 | |
| 515 | imports.add(getJavaImportData().getEventListenerImport()); |
| 516 | String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) |
| 517 | .getJavaFileInfo().getJavaName()); |
| 518 | /** |
| 519 | * Creates event listener interface file. |
| 520 | */ |
| 521 | setEventListenerJavaFileHandle( |
| 522 | getJavaFileHandle(curNode, curNodeInfo + EVENT_LISTENER_FILE_NAME_SUFFIX)); |
| 523 | generateEventListenerFile(getEventListenerJavaFileHandle(), curNode, imports); |
| 524 | |
| 525 | /** |
| 526 | * Close all the file handles. |
| 527 | */ |
| 528 | freeTemporaryResources(false); |
| 529 | } |
| 530 | |
| 531 | /** |
| 532 | * Constructs java code exit. |
| 533 | * |
| 534 | * @param fileType generated file type |
| 535 | * @param curNode current YANG node |
| 536 | * @throws IOException when fails to generate java files |
| 537 | */ |
| 538 | public void generateEventSubjectJavaFile(int fileType, YangNode curNode) |
| 539 | throws IOException { |
| 540 | |
| 541 | String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) |
| 542 | .getJavaFileInfo().getJavaName()); |
| 543 | /** |
| 544 | * Creates event interface file. |
| 545 | */ |
| 546 | setEventSubjectJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo + |
| 547 | EVENT_SUBJECT_NAME_SUFFIX)); |
| 548 | generateEventSubjectFile(getEventSubjectJavaFileHandle(), curNode); |
| 549 | |
| 550 | /** |
| 551 | * Close all the file handles. |
| 552 | */ |
| 553 | freeTemporaryResources(false); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | /** |
| 557 | * Removes all temporary file handles. |
| 558 | * |
| 559 | * @param isErrorOccurred when translator fails to generate java files we |
| 560 | * need to close all open file handles include temporary files |
| 561 | * and java files. |
| 562 | * @throws IOException when failed to delete the temporary files |
| 563 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 564 | @Override |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 565 | public void freeTemporaryResources(boolean isErrorOccurred) |
| 566 | throws IOException { |
| 567 | boolean isError = isErrorOccurred; |
| 568 | |
| 569 | closeFile(getServiceInterfaceJavaFileHandle(), isError); |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 570 | closeFile(getManagerJavaFileHandle(), isError); |
| 571 | |
| 572 | if (getEventJavaFileHandle() != null) { |
| 573 | closeFile(getEventJavaFileHandle(), isError); |
| 574 | } |
| 575 | if (getEventListenerJavaFileHandle() != null) { |
| 576 | closeFile(getEventListenerJavaFileHandle(), isError); |
| 577 | } |
| 578 | if (getEventSubjectJavaFileHandle() != null) { |
| 579 | closeFile(getEventSubjectJavaFileHandle(), isError); |
| 580 | } |
| 581 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 582 | closeFile(getRpcInterfaceTempFileHandle(), true); |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 583 | closeFile(getRpcImplTempFileHandle(), true); |
| 584 | closeFile(getGetterInterfaceTempFileHandle(), true); |
| 585 | closeFile(getSetterInterfaceTempFileHandle(), true); |
| 586 | closeFile(getSetterImplTempFileHandle(), true); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 587 | |
| 588 | super.freeTemporaryResources(isErrorOccurred); |
| 589 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 590 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 591 | |
| 592 | /** |
| 593 | * Returns event enum temp file. |
| 594 | * |
| 595 | * @return event enum temp file |
| 596 | */ |
| 597 | public File getEventEnumTempFileHandle() { |
| 598 | return eventEnumTempFileHandle; |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * Sets event enum temp file. |
| 603 | * |
| 604 | * @param eventEnumTempFileHandle event enum temp file |
| 605 | */ |
| 606 | public void setEventEnumTempFileHandle(File eventEnumTempFileHandle) { |
| 607 | this.eventEnumTempFileHandle = eventEnumTempFileHandle; |
| 608 | } |
| 609 | |
| 610 | /** |
| 611 | * Returns event method temp file. |
| 612 | * |
| 613 | * @return event method temp file |
| 614 | */ |
| 615 | public File getEventMethodTempFileHandle() { |
| 616 | return eventMethodTempFileHandle; |
| 617 | } |
| 618 | |
| 619 | /** |
| 620 | * Sets event method temp file. |
| 621 | * |
| 622 | * @param eventMethodTempFileHandle event method temp file |
| 623 | */ |
| 624 | public void setEventMethodTempFileHandle(File eventMethodTempFileHandle) { |
| 625 | this.eventMethodTempFileHandle = eventMethodTempFileHandle; |
| 626 | } |
| 627 | |
| 628 | /** |
| 629 | * Returns event subject attribute temp file. |
| 630 | * |
| 631 | * @return event subject attribute temp file |
| 632 | */ |
| 633 | public File getEventSubjectAttributeTempFileHandle() { |
| 634 | return eventSubjectAttributeTempFileHandle; |
| 635 | } |
| 636 | |
| 637 | /** |
| 638 | * Sets event subject attribute temp file. |
| 639 | * |
| 640 | * @param eventSubjectAttributeTempFileHandle event subject attribute temp file |
| 641 | */ |
| 642 | public void setEventSubjectAttributeTempFileHandle(File eventSubjectAttributeTempFileHandle) { |
| 643 | this.eventSubjectAttributeTempFileHandle = eventSubjectAttributeTempFileHandle; |
| 644 | } |
| 645 | |
| 646 | /** |
| 647 | * Returns event subject getter temp file. |
| 648 | * |
| 649 | * @return event subject getter temp file |
| 650 | */ |
| 651 | public File getEventSubjectGetterTempFileHandle() { |
| 652 | return eventSubjectGetterTempFileHandle; |
| 653 | } |
| 654 | |
| 655 | /** |
| 656 | * Sets event subject getter temp file. |
| 657 | * |
| 658 | * @param eventSubjectGetterTempFileHandle event subject getter temp file |
| 659 | */ |
| 660 | public void setEventSubjectGetterTempFileHandle(File eventSubjectGetterTempFileHandle) { |
| 661 | this.eventSubjectGetterTempFileHandle = eventSubjectGetterTempFileHandle; |
| 662 | } |
| 663 | |
| 664 | /** |
| 665 | * Returns event subject setter temp file. |
| 666 | * |
| 667 | * @return event subject setter temp file |
| 668 | */ |
| 669 | public File getEventSubjectSetterTempFileHandle() { |
| 670 | return eventSubjectSetterTempFileHandle; |
| 671 | } |
| 672 | |
| 673 | /** |
| 674 | * Sets event subject setter temp file. |
| 675 | * |
| 676 | * @param eventSubjectSetterTempFileHandle event subject setter temp file |
| 677 | */ |
| 678 | public void setEventSubjectSetterTempFileHandle(File eventSubjectSetterTempFileHandle) { |
| 679 | this.eventSubjectSetterTempFileHandle = eventSubjectSetterTempFileHandle; |
| 680 | } |
| 681 | |
| 682 | /** |
| 683 | * Adds java snippet for events to event subject file. |
| 684 | * |
| 685 | * @param curNode current node |
| 686 | * @param pluginConfig plugin configurations |
| 687 | * @throws IOException when fails to do IO operations |
| 688 | */ |
| 689 | public void addJavaSnippetOfEvent(YangNode curNode, YangPluginConfig pluginConfig) throws IOException { |
| 690 | |
| 691 | String currentInfo = getCapitalCase(getCamelCase(((YangNotification) curNode).getName(), |
| 692 | pluginConfig.getConflictResolver())); |
| 693 | |
| 694 | JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode.getParent(), |
| 695 | getCapitalCase(currentInfo)); |
| 696 | |
| 697 | JavaAttributeInfo javaAttributeInfo = |
| 698 | getAttributeInfoForTheData(qualifiedTypeInfo, getSmallCase(currentInfo), |
| 699 | null, false, false); |
| 700 | |
| 701 | /*Adds java info for event in respective temp files.*/ |
| 702 | addEventEnum(currentInfo, pluginConfig); |
| 703 | addEventSubjectAttribute(javaAttributeInfo, pluginConfig); |
| 704 | addEventSubjectGetter(javaAttributeInfo, pluginConfig); |
| 705 | addEventSubjectSetter(javaAttributeInfo, pluginConfig, currentInfo); |
| 706 | } |
| 707 | |
| 708 | /*Adds event to enum temp file.*/ |
| 709 | private void addEventEnum(String notificationName, YangPluginConfig pluginConfig) throws IOException { |
| 710 | appendToFile(getEventEnumTempFileHandle(), |
| 711 | getJavaDoc(ENUM_ATTRIBUTE, notificationName, false, pluginConfig) + FOUR_SPACE_INDENTATION |
| 712 | + notificationName.toUpperCase() + COMMA + NEW_LINE); |
| 713 | } |
| 714 | |
| 715 | /*Adds event method in event class*/ |
| 716 | private void addEnumMethod(String eventClassname, String className) throws IOException { |
| 717 | appendToFile(getEventMethodTempFileHandle(), getEventFileContents(eventClassname, className)); |
| 718 | } |
| 719 | |
| 720 | /*Adds event method contents to event file.*/ |
| 721 | private static String getEventFileContents(String eventClassname, String classname) { |
| 722 | return "\n" + |
| 723 | " /**\n" + |
| 724 | " * Creates " + classname + " event with type and subject.\n" + |
| 725 | " *\n" + |
| 726 | " * @param type event type\n" + |
| 727 | " * @param subject subject " + classname + "\n" + |
| 728 | " */\n" + |
| 729 | " public " + eventClassname + "(Type type, " + getCapitalCase(classname) + " subject) {\n" + |
| 730 | " super(type, subject);\n" + |
| 731 | " }\n" + |
| 732 | "\n" + |
| 733 | " /**\n" + |
| 734 | " * Creates " + classname + " event with type, subject and time.\n" + |
| 735 | " *\n" + |
| 736 | " * @param type event type\n" + |
| 737 | " * @param subject subject " + classname + "\n" + |
| 738 | " * @param time time of event\n" + |
| 739 | " */\n" + |
| 740 | " public " + eventClassname + "(Type type, " + getCapitalCase(classname) |
| 741 | + " subject, long time) {\n" + |
| 742 | " super(type, subject, time);\n" + |
| 743 | " }\n" + |
| 744 | "\n"; |
| 745 | } |
| 746 | |
| 747 | /*Adds events to event subject file.*/ |
| 748 | private void addEventSubjectAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
| 749 | throws IOException { |
| 750 | appendToFile(getEventSubjectAttributeTempFileHandle(), |
| 751 | FOUR_SPACE_INDENTATION + parseAttribute(attr, pluginConfig)); |
| 752 | } |
| 753 | |
| 754 | /*Adds getter method for event in event subject class.*/ |
| 755 | private void addEventSubjectGetter(JavaAttributeInfo attr, YangPluginConfig pluginConfig) throws IOException { |
| 756 | appendToFile(getEventSubjectGetterTempFileHandle(), |
| 757 | getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig) |
| 758 | + getGetterForClass(attr, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE); |
| 759 | } |
| 760 | |
| 761 | /*Adds setter method for event in event subject class.*/ |
| 762 | private void addEventSubjectSetter(JavaAttributeInfo attr, YangPluginConfig pluginConfig, String className) |
| 763 | throws IOException { |
| 764 | appendToFile(getEventSubjectSetterTempFileHandle(), |
| 765 | getJavaDoc(MANAGER_SETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig) |
| 766 | + getSetterForClass(attr, className, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE); |
| 767 | } |
| 768 | |
| 769 | /** |
| 770 | * Returns a temporary file handle for the event's file type. |
| 771 | * |
| 772 | * @param fileName file name |
| 773 | * @return temporary file handle |
| 774 | * @throws IOException when fails to create new file handle |
| 775 | */ |
| 776 | private File getJavaFileHandle(YangNode curNode, String name) |
| 777 | throws IOException { |
| 778 | |
| 779 | JavaFileInfo parentInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
| 780 | |
| 781 | return getFileObject(getDirPath(parentInfo), name, JAVA_FILE_EXTENSION, |
| 782 | parentInfo); |
| 783 | } |
| 784 | |
| 785 | /** |
| 786 | * Returns the directory path. |
| 787 | * |
| 788 | * @return directory path |
| 789 | */ |
| 790 | private String getDirPath(JavaFileInfo parentInfo) { |
| 791 | return (parentInfo.getPackageFilePath() + SLASH + parentInfo.getJavaName()).toLowerCase(); |
| 792 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 793 | } |