blob: 18913d4a957c482f023b7cda2cb53a3d8a8f6cae [file] [log] [blame]
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301/*
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 */
16package org.onosproject.yangutils.translator.tojava;
17
18import java.io.File;
19import java.io.IOException;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053020import java.util.List;
Bharat saraswale50edca2016-08-05 01:58:25 +053021import org.onosproject.yangutils.datamodel.YangAugment;
Bharat saraswalaf413b82016-07-14 15:18:20 +053022import org.onosproject.yangutils.datamodel.YangAugmentableNode;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053023import org.onosproject.yangutils.datamodel.YangCase;
Gaurav Agrawal8a147522016-08-10 13:43:01 +053024import org.onosproject.yangutils.datamodel.YangChoice;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053025import org.onosproject.yangutils.datamodel.YangLeaf;
26import org.onosproject.yangutils.datamodel.YangLeafList;
27import org.onosproject.yangutils.datamodel.YangLeavesHolder;
Vidyashree Ramab3670472016-08-06 15:49:56 +053028import org.onosproject.yangutils.datamodel.YangList;
Gaurav Agrawal8a147522016-08-10 13:43:01 +053029import org.onosproject.yangutils.datamodel.YangModule;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053030import org.onosproject.yangutils.datamodel.YangNode;
Bharat saraswalaf413b82016-07-14 15:18:20 +053031import org.onosproject.yangutils.datamodel.YangSubModule;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053032import org.onosproject.yangutils.translator.exception.TranslatorException;
33import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer;
Shankara-Huaweib7564772016-08-02 18:13:13 +053034import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGroupingTranslator;
Bharat saraswal4aaab4d2016-05-17 14:19:38 +053035import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
Gaurav Agrawal8a147522016-08-10 13:43:01 +053036import org.onosproject.yangutils.utils.io.YangPluginConfig;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053037
Bharat saraswalc2d3be12016-06-16 00:29:12 +053038import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053039import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
40import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
Bharat saraswal8beac342016-08-04 02:00:03 +053041import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053042import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
Bharat saraswalaf413b82016-07-14 15:18:20 +053043import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +053044import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
45import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053046import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
Bharat saraswal8beac342016-08-04 02:00:03 +053047import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_IMPL_MASK;
48import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_INTERFACE_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053049import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
Bharat saraswale50edca2016-08-05 01:58:25 +053050import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EDIT_CONTENT_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053051import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
Bharat saraswale50edca2016-08-05 01:58:25 +053052import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK;
53import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_MASK;
54import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_NODES_MASK;
Bharat saraswal250a7472016-05-12 13:16:57 +053055import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053056import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
57import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
58import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK;
Bharat saraswal8beac342016-08-04 02:00:03 +053059import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053060import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
61import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
62import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK;
63import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
Shankara-Huaweib7564772016-08-02 18:13:13 +053064import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedInfoOfFromString;
65import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode;
Gaurav Agrawalbfce9342016-06-15 13:58:01 +053066import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo;
Bharat saraswal8beac342016-08-04 02:00:03 +053067import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString;
68import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefinition;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053069import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
Bharat saraswalaf413b82016-07-14 15:18:20 +053070import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.sortImports;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053071import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile;
72import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile;
Bharat saraswal8beac342016-08-04 02:00:03 +053073import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateDefaultClassFile;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053074import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053075import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
Bharat saraswald14cbe82016-07-14 13:26:18 +053076import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
Bharat saraswal8beac342016-08-04 02:00:03 +053077import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddToListMethodImpl;
78import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddToListMethodInterface;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053079import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053080import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString;
81import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
Bharat saraswal250a7472016-05-12 13:16:57 +053082import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethod;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053083import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
84import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString;
85import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethod;
Bharat saraswale50edca2016-08-05 01:58:25 +053086import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilerContentMatchForLeaf;
87import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilerContentMatchForLeafList;
88import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilterContentForNodes;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053089import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053090import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
91import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString;
92import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053093import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString;
Bharat saraswal8beac342016-08-04 02:00:03 +053094import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST_IMPORT;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053095import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
Bharat saraswald14cbe82016-07-14 13:26:18 +053096import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053097import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
98import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053099import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE;
Bharat saraswal8beac342016-08-04 02:00:03 +0530100import static org.onosproject.yangutils.utils.UtilConstants.INVOCATION_TARGET_EXCEPTION_IMPORT;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530101import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
Bharat saraswal8beac342016-08-04 02:00:03 +0530102import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530103import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
Bharat saraswal039f59c2016-07-14 21:57:13 +0530104import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
105import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED;
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530106import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530107import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
Bharat saraswalaf413b82016-07-14 15:18:20 +0530108import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530109import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile;
Bharat saraswal8beac342016-08-04 02:00:03 +0530110import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ADD_TO_LIST;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530111import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
Bharat saraswald14cbe82016-07-14 13:26:18 +0530112import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530113import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
Bharat saraswald14cbe82016-07-14 13:26:18 +0530114import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
115import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
116import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530117import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
118import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles;
Bharat saraswalc2d3be12016-06-16 00:29:12 +0530119import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530120
121/**
Bharat saraswalaf413b82016-07-14 15:18:20 +0530122 * Represents implementation of java code fragments temporary implementations. Manages the common temp file required for
123 * Java file(s) generated.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530124 */
125public class TempJavaFragmentFiles {
Bharat saraswal250a7472016-05-12 13:16:57 +0530126
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530127 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530128 * File type extension for java classes.
129 */
130 private static final String JAVA_FILE_EXTENSION = ".java";
Bharat saraswal250a7472016-05-12 13:16:57 +0530131
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530132 /**
133 * File type extension for temporary classes.
134 */
135 private static final String TEMP_FILE_EXTENSION = ".tmp";
Bharat saraswal250a7472016-05-12 13:16:57 +0530136
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530137 /**
138 * Folder suffix for temporary files folder.
139 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530140 private static final String TEMP_FOLDER_NAME_SUFFIX = "-Temp";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530141
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530142 /**
143 * File name for getter method.
144 */
145 private static final String GETTER_METHOD_FILE_NAME = "GetterMethod";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530146
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530147 /**
148 * File name for setter method.
149 */
150 private static final String SETTER_METHOD_FILE_NAME = "SetterMethod";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530151
152 /**
153 * File name for getter method implementation.
154 */
155 private static final String GETTER_METHOD_IMPL_FILE_NAME = "GetterMethodImpl";
156
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530157 /**
158 * File name for setter method implementation.
159 */
160 private static final String SETTER_METHOD_IMPL_FILE_NAME = "SetterMethodImpl";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530161
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530162 /**
163 * File name for attributes.
164 */
165 private static final String ATTRIBUTE_FILE_NAME = "Attributes";
Bharat saraswal250a7472016-05-12 13:16:57 +0530166
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530167 /**
168 * File name for to string method.
169 */
170 private static final String TO_STRING_METHOD_FILE_NAME = "ToString";
Bharat saraswal250a7472016-05-12 13:16:57 +0530171
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530172 /**
173 * File name for hash code method.
174 */
175 private static final String HASH_CODE_METHOD_FILE_NAME = "HashCode";
Bharat saraswal250a7472016-05-12 13:16:57 +0530176
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530177 /**
178 * File name for equals method.
179 */
180 private static final String EQUALS_METHOD_FILE_NAME = "Equals";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530181
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530182 /**
Bharat saraswal250a7472016-05-12 13:16:57 +0530183 * File name for from string method.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530184 */
Bharat saraswal250a7472016-05-12 13:16:57 +0530185 private static final String FROM_STRING_METHOD_FILE_NAME = "FromString";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530186
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530187 /**
Bharat saraswal8beac342016-08-04 02:00:03 +0530188 * File name for from add to list interface method.
189 */
190 private static final String ADD_TO_LIST_INTERFACE_METHOD_FILE_NAME = "addToList";
191
192 /**
193 * File name for from add to list impl method.
194 */
195 private static final String ADD_TO_LIST_IMPL_METHOD_FILE_NAME = "addToListImpl";
196
197 /**
198 * File name for from leaf identifier attributes.
199 */
200 private static final String LEAF_IDENTIFIER_ATTRIBUTES_FILE_NAME = "leafIdentifierAtr";
201
202 /**
Bharat saraswale50edca2016-08-05 01:58:25 +0530203 * File name for is filter content leaf match.
204 */
205 private static final String FILTER_CONTENT_MATCH_LEAF_FILE_NAME = "isFilterContentMatchLeafMask";
206
207 /**
208 * File name for is filter content leaf-list match.
209 */
210 private static final String FILTER_CONTENT_MATCH_LEAF_LIST_FILE_NAME = "isFilterContentMatchLeafListMask";
211
212 /**
213 * File name for is filter content node match.
214 */
215 private static final String FILTER_CONTENT_MATCH_NODE_FILE_NAME = "isFilterContentMatchNodeMask";
216
217 /**
218 * File name for edit content file.
219 */
220 private static final String EDIT_CONTENT_FILE_NAME = "editContentFile";
221
222 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530223 * File name for interface java file name suffix.
224 */
225 private static final String INTERFACE_FILE_NAME_SUFFIX = EMPTY_STRING;
Bharat saraswal250a7472016-05-12 13:16:57 +0530226
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530227 /**
228 * File name for builder interface file name suffix.
229 */
230 private static final String BUILDER_INTERFACE_FILE_NAME_SUFFIX = BUILDER + INTERFACE;
Bharat saraswal250a7472016-05-12 13:16:57 +0530231
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530232 /**
233 * File name for builder class file name suffix.
234 */
235 private static final String BUILDER_CLASS_FILE_NAME_SUFFIX = BUILDER;
Bharat saraswal250a7472016-05-12 13:16:57 +0530236
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530237 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +0530238 * Information about the java files being generated.
239 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530240 private JavaFileInfoTranslator javaFileInfo;
Bharat saraswalaf413b82016-07-14 15:18:20 +0530241
242 /**
243 * Imported class info.
244 */
245 private JavaImportData javaImportData;
246
247 /**
248 * The variable which guides the types of temporary files generated using the temporary generated file types mask.
249 */
250 private int generatedTempFiles;
251
252 /**
253 * Absolute path where the target java file needs to be generated.
254 */
255 private String absoluteDirPath;
256
257 /**
258 * Contains all the interface(s)/class name which will be extended by generated files.
259 */
260 private JavaExtendsListHolder javaExtendsListHolder;
261
Bharat saraswald14cbe82016-07-14 13:26:18 +0530262 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530263 * Java file handle for interface file.
264 */
265 private File interfaceJavaFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530266
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530267 /**
268 * Java file handle for builder interface file.
269 */
270 private File builderInterfaceJavaFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530271
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530272 /**
273 * Java file handle for builder class file.
274 */
275 private File builderClassJavaFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530276
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530277 /**
278 * Java file handle for impl class file.
279 */
280 private File implClassJavaFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530281
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530282 /**
283 * Temporary file handle for attribute.
284 */
285 private File attributesTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530286
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530287 /**
288 * Temporary file handle for getter of interface.
289 */
290 private File getterInterfaceTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530291
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530292 /**
293 * Temporary file handle for setter of interface.
294 */
295 private File setterInterfaceTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530296
297 /**
298 * Temporary file handle for getter of class.
299 */
300 private File getterImplTempFileHandle;
301
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530302 /**
303 * Temporary file handle for setter of class.
304 */
305 private File setterImplTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530306
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530307 /**
308 * Temporary file handle for hash code method of class.
309 */
310 private File hashCodeImplTempFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530311
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530312 /**
313 * Temporary file handle for equals method of class.
314 */
315 private File equalsImplTempFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530316
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530317 /**
318 * Temporary file handle for to string method of class.
319 */
320 private File toStringImplTempFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530321
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530322 /**
Bharat saraswal250a7472016-05-12 13:16:57 +0530323 * Temporary file handle for from string method of class.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530324 */
Bharat saraswal250a7472016-05-12 13:16:57 +0530325 private File fromStringImplTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530326
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530327 /**
Bharat saraswal8beac342016-08-04 02:00:03 +0530328 * Temporary file handle for add to list interface method of class.
329 */
330 private File addToListInterfaceTempFileHandle;
331
332 /**
333 * Temporary file handle for add to list impl method of class.
334 */
335 private File addToListImplTempFileHandle;
336
337 /**
338 * Temporary file handle for leaf id attributes of enum.
339 */
340 private File leafIdAttributeTempFileHandle;
341
342 /**
Bharat saraswale50edca2016-08-05 01:58:25 +0530343 * Temporary file handle for is content match method for leaf-list.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530344 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530345 private File isContentMatchLeafListTempFileHandle;
346
347 /**
348 * Temporary file handle for is content match method for node.
349 */
350 private File isContentMatchNodeTempFileHandle;
351
352 /**
353 * Temporary file handle for is content match method for leaf.
354 */
355 private File isContentMatchLeafTempFileHandle;
356
357 /**
358 * Temporary file handle for edit content file.
359 */
360 private File editContentTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530361
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530362 /**
Bharat saraswal8beac342016-08-04 02:00:03 +0530363 * Leaf count.
364 */
365 private int leafCount = 0;
366
367 /**
368 * If current node is root node.
369 */
370 private boolean isRooNode;
371
372 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530373 * Is attribute added.
374 */
Bharat saraswal250a7472016-05-12 13:16:57 +0530375 private boolean isAttributePresent;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530376
Bharat saraswalaf413b82016-07-14 15:18:20 +0530377 TempJavaFragmentFiles() {
378 }
379
380 /**
381 * Creates an instance of temporary java code fragment.
382 *
383 * @param javaFileInfo generated java file information
384 * @throws IOException when fails to create new file handle
385 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530386 TempJavaFragmentFiles(JavaFileInfoTranslator javaFileInfo)
Bharat saraswalaf413b82016-07-14 15:18:20 +0530387 throws IOException {
388 setJavaExtendsListHolder(new JavaExtendsListHolder());
389 setJavaImportData(new JavaImportData());
390 setJavaFileInfo(javaFileInfo);
Bharat saraswal8beac342016-08-04 02:00:03 +0530391 setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
392 getJavaFileInfo().getPackageFilePath()));
393
Bharat saraswalaf413b82016-07-14 15:18:20 +0530394 /*
395 * Initialize getter when generation file type matches to interface
396 * mask.
397 */
398 if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) {
399 addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK);
Bharat saraswal8beac342016-08-04 02:00:03 +0530400 addGeneratedTempFile(ADD_TO_LIST_INTERFACE_MASK);
401 addGeneratedTempFile(LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK);
Bharat saraswalaf413b82016-07-14 15:18:20 +0530402 }
403
404 /*
405 * Initialize getter and setter when generation file type matches to
406 * builder interface mask.
407 */
408 if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) {
409 addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK);
410 addGeneratedTempFile(SETTER_FOR_INTERFACE_MASK);
411 }
412
413 /*
414 * Initialize getterImpl, setterImpl and attributes when generation file
415 * type matches to builder class mask.
416 */
417 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) {
418 addGeneratedTempFile(ATTRIBUTES_MASK);
419 addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
420 addGeneratedTempFile(SETTER_FOR_CLASS_MASK);
Bharat saraswalaf413b82016-07-14 15:18:20 +0530421 }
422
423 /*
424 * Initialize getterImpl, attributes, constructor, hash code, equals and
425 * to strings when generation file type matches to impl class mask.
426 */
Bharat saraswal8beac342016-08-04 02:00:03 +0530427 if ((getGeneratedJavaFiles() & DEFAULT_CLASS_MASK) != 0) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530428 addGeneratedTempFile(ATTRIBUTES_MASK);
429 addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
430 addGeneratedTempFile(HASH_CODE_IMPL_MASK);
431 addGeneratedTempFile(EQUALS_IMPL_MASK);
432 addGeneratedTempFile(TO_STRING_IMPL_MASK);
Bharat saraswal8beac342016-08-04 02:00:03 +0530433 addGeneratedTempFile(ADD_TO_LIST_IMPL_MASK);
Bharat saraswale50edca2016-08-05 01:58:25 +0530434 addGeneratedTempFile(FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK);
435 addGeneratedTempFile(FILTER_CONTENT_MATCH_FOR_LEAF_MASK);
436 addGeneratedTempFile(FILTER_CONTENT_MATCH_FOR_NODES_MASK);
Bharat saraswalaf413b82016-07-14 15:18:20 +0530437 }
438
439 /*
440 * Initialize temp files to generate type class.
441 */
442 if ((getGeneratedJavaFiles() & GENERATE_TYPE_CLASS) != 0) {
443 addGeneratedTempFile(ATTRIBUTES_MASK);
444 addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
445 addGeneratedTempFile(HASH_CODE_IMPL_MASK);
446 addGeneratedTempFile(EQUALS_IMPL_MASK);
447 addGeneratedTempFile(TO_STRING_IMPL_MASK);
448 addGeneratedTempFile(FROM_STRING_IMPL_MASK);
449 }
450
Vidyashree Ramab3670472016-08-06 15:49:56 +0530451 //Initialize temp files to generate enum class.
Bharat saraswalaf413b82016-07-14 15:18:20 +0530452 if ((getGeneratedJavaFiles() & GENERATE_ENUM_CLASS) != 0) {
453 addGeneratedTempFile(FROM_STRING_IMPL_MASK);
454 }
455
Vidyashree Ramab3670472016-08-06 15:49:56 +0530456 //Set temporary file handles
Bharat saraswalaf413b82016-07-14 15:18:20 +0530457 if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) {
458 setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME));
459 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530460 if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) {
461 setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME));
462 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530463 if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) {
464 setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME));
465 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530466 if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
467 setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME));
468 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530469 if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) {
470 setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME));
471 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530472 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) {
473 setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME));
474 }
475 if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) {
476 setEqualsImplTempFileHandle(getTemporaryFileHandle(EQUALS_METHOD_FILE_NAME));
477 }
478 if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) {
479 setToStringImplTempFileHandle(getTemporaryFileHandle(TO_STRING_METHOD_FILE_NAME));
480 }
481 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
482 setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME));
483 }
Bharat saraswal8beac342016-08-04 02:00:03 +0530484 if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0) {
485 setAddToListInterfaceTempFileHandle(getTemporaryFileHandle(ADD_TO_LIST_INTERFACE_METHOD_FILE_NAME));
486 }
487 if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0) {
488 setAddToListImplTempFileHandle(getTemporaryFileHandle(ADD_TO_LIST_IMPL_METHOD_FILE_NAME));
489 }
490 if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0) {
491 setLeafIdAttributeTempFileHandle(getTemporaryFileHandle(LEAF_IDENTIFIER_ATTRIBUTES_FILE_NAME));
492 }
Bharat saraswale50edca2016-08-05 01:58:25 +0530493 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0) {
494 setIsContentMatchLeafTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_FILE_NAME));
495 }
496 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0) {
497 setIsContentMatchLeafListTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_LIST_FILE_NAME));
498 }
499 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0) {
500 setIsContentMatchNodeTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_NODE_FILE_NAME));
501 }
502 if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) {
503 setEditContentTempFileHandle(getTemporaryFileHandle(EDIT_CONTENT_FILE_NAME));
504 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530505 }
506
507 /**
508 * Adds current node info as and attribute to the parent generated file.
509 *
510 * @param curNode current node which needs to be added as an attribute in the parent generated code
511 * @param isList is list construct
512 * @param pluginConfig plugin configurations
513 * @throws IOException IO operation exception
514 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530515 static void addCurNodeInfoInParentTempFile(YangNode curNode,
516 boolean isList, YangPluginConfig pluginConfig)
Bharat saraswalaf413b82016-07-14 15:18:20 +0530517 throws IOException {
518 YangNode parent = getParentNodeInGenCode(curNode);
519 if (!(parent instanceof JavaCodeGenerator)) {
520 throw new TranslatorException("missing parent node to contain current node info in generated file");
521 }
Shankara-Huaweib7564772016-08-02 18:13:13 +0530522 if (parent instanceof YangJavaGroupingTranslator) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530523 /*
524 * In case of grouping, there is no need to add the information, it
525 * will be taken care in uses
526 */
527 return;
528 }
529 TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) parent)
530 .getTempJavaCodeFragmentFiles().getBeanTempFiles();
531
532 JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode,
533 parent, isList, tempJavaBeanFragmentFiles);
Bharat saraswal8beac342016-08-04 02:00:03 +0530534 tempJavaBeanFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig);
Bharat saraswalaf413b82016-07-14 15:18:20 +0530535 }
536
537 /**
538 * Creates an attribute info object corresponding to a data model node and return it.
539 *
540 * @param curNode current data model node for which the java code generation is being handled
541 * @param targetNode target node in which the current node is an attribute
542 * @param isListNode is the current added attribute needs to be a list
543 * @param tempJavaFragmentFiles temp java fragment files
544 * @return AttributeInfo attribute details required to add in temporary files
545 */
546 public static JavaAttributeInfo getCurNodeAsAttributeInTarget(YangNode curNode,
547 YangNode targetNode, boolean isListNode,
548 TempJavaFragmentFiles tempJavaFragmentFiles) {
549 String curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName();
550 if (curNodeName == null) {
551 updateJavaFileInfo(curNode, null);
552 curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName();
553 }
554
555 /*
556 * Get the import info corresponding to the attribute for import in
557 * generated java files or qualified access
558 */
Shankara-Huaweib7564772016-08-02 18:13:13 +0530559 JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
Bharat saraswalaf413b82016-07-14 15:18:20 +0530560 getCapitalCase(curNodeName));
561 if (!(targetNode instanceof TempJavaCodeFragmentFilesContainer)) {
562 throw new TranslatorException("Parent node does not have file info");
563 }
564 JavaImportData parentImportData = tempJavaFragmentFiles.getJavaImportData();
Bharat saraswale50edca2016-08-05 01:58:25 +0530565 JavaFileInfoTranslator fileInfo = ((JavaFileInfoContainer) targetNode).getJavaFileInfo();
Bharat saraswalaf413b82016-07-14 15:18:20 +0530566
567 boolean isQualified;
Bharat saraswalaab24b92016-08-02 18:43:16 +0530568 if ((tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles)
Bharat saraswal8beac342016-08-04 02:00:03 +0530569 && (qualifiedTypeInfo.getClassInfo().contentEquals(SERVICE))
570 || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE))) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530571
572 isQualified = true;
573 } else {
574 String className;
Bharat saraswalaab24b92016-08-02 18:43:16 +0530575 if (tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles) {
Bharat saraswal8beac342016-08-04 02:00:03 +0530576 className = getCapitalCase(fileInfo.getJavaName()) + SERVICE;
Bharat saraswalaf413b82016-07-14 15:18:20 +0530577 } else {
578 className = getCapitalCase(fileInfo.getJavaName());
579 }
580
581 isQualified = parentImportData.addImportInfo(qualifiedTypeInfo,
582 className, fileInfo.getPackage());
583 }
Vidyashree Ramab3670472016-08-06 15:49:56 +0530584 boolean collectionSetFlag = false;
585 if (curNode instanceof YangList) {
586 YangList yangList = (YangList) curNode;
587 if (yangList.getCompilerAnnotation() != null && yangList.getCompilerAnnotation()
588 .getYangAppDataStructure() != null) {
589 switch (yangList.getCompilerAnnotation().getYangAppDataStructure().getDataStructure()) {
590 case QUEUE: {
591 parentImportData.setQueueToImport(true);
592 collectionSetFlag = true;
593 break;
594 }
595 case SET: {
596 parentImportData.setSetToImport(true);
597 collectionSetFlag = true;
598 break;
599 }
600 default: {
601 // TODO : to be implemented
602 }
603 }
604 }
605 }
Vidyashree Ramab3670472016-08-06 15:49:56 +0530606 if (isListNode && !(collectionSetFlag)) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530607 parentImportData.setIfListImported(true);
608 }
Vidyashree Ramab3670472016-08-06 15:49:56 +0530609 if (curNode instanceof YangList) {
610 return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, isQualified, isListNode,
611 ((YangList) curNode).getCompilerAnnotation());
612 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530613 return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, isQualified, isListNode);
614 }
615
616 /**
Bharat saraswal64e7e232016-07-14 23:33:55 +0530617 * Returns java attribute for leaf.
618 *
619 * @param tempJavaFragmentFiles temporary generated file
620 * @param leaf YANG leaf
621 * @param yangPluginConfig plugin configurations
622 * @return java attribute for leaf
623 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530624 private static JavaAttributeInfo getJavaAttributeOfLeaf(TempJavaFragmentFiles tempJavaFragmentFiles, YangLeaf leaf,
625 YangPluginConfig yangPluginConfig) {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530626 JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leaf;
627 javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
628 javaLeaf.updateJavaQualifiedInfo();
629 return getAttributeInfoForTheData(
630 javaLeaf.getJavaQualifiedInfo(),
631 javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()),
632 javaLeaf.getDataType(),
633 tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()),
634 false);
635 }
636
637 /**
638 * Returns java attribute for leaf-list.
639 *
640 * @param tempJavaFragmentFiles temporary generated file
641 * @param leafList YANG leaf-list
642 * @param yangPluginConfig plugin configurations
643 * @return java attribute for leaf-list
644 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530645 private static JavaAttributeInfo getJavaAttributeOfLeafList(TempJavaFragmentFiles tempJavaFragmentFiles,
646 YangLeafList leafList,
647 YangPluginConfig yangPluginConfig) {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530648 JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leafList;
649 javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
650 javaLeaf.updateJavaQualifiedInfo();
651 tempJavaFragmentFiles.getJavaImportData().setIfListImported(true);
652 return getAttributeInfoForTheData(
653 javaLeaf.getJavaQualifiedInfo(),
654 javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()),
655 javaLeaf.getDataType(),
656 tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()),
657 true);
658 }
659
Bharat saraswal039f59c2016-07-14 21:57:13 +0530660 /*
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530661 * Retrieves the absolute path where the file needs to be generated.
662 *
663 * @return absolute path where the file needs to be generated
664 */
665 private String getAbsoluteDirPath() {
666 return absoluteDirPath;
667 }
668
669 /**
670 * Sets absolute path where the file needs to be generated.
671 *
Bharat saraswalaf413b82016-07-14 15:18:20 +0530672 * @param absoluteDirPath absolute path where the file needs to be generated.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530673 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530674 void setAbsoluteDirPath(String absoluteDirPath) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530675 this.absoluteDirPath = absoluteDirPath;
676 }
677
678 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530679 * Retrieves the generated java file information.
680 *
681 * @return generated java file information
682 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530683 public JavaFileInfoTranslator getJavaFileInfo() {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530684 return javaFileInfo;
685 }
686
687 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +0530688 * Sets the generated java file information.
689 *
690 * @param javaFileInfo generated java file information
691 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530692 public void setJavaFileInfo(JavaFileInfoTranslator javaFileInfo) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530693 this.javaFileInfo = javaFileInfo;
694 }
695
696 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530697 * Retrieves the generated temp files.
698 *
699 * @return generated temp files
700 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530701 int getGeneratedTempFiles() {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530702 return generatedTempFiles;
703 }
704
705 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +0530706 * Sets generated file files.
707 *
708 * @param fileType generated file type
709 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530710 private void setGeneratedTempFiles(int fileType) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530711 generatedTempFiles = fileType;
712 }
713
714 /**
Bharat saraswal250a7472016-05-12 13:16:57 +0530715 * Adds to generated temporary files.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530716 *
717 * @param generatedTempFile generated file
718 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530719 void addGeneratedTempFile(int generatedTempFile) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530720 generatedTempFiles |= generatedTempFile;
Bharat saraswal250a7472016-05-12 13:16:57 +0530721 setGeneratedTempFiles(generatedTempFiles);
722 }
723
724 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530725 * Retrieves the generated Java files.
726 *
727 * @return generated Java files
728 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530729 int getGeneratedJavaFiles() {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530730 return getJavaFileInfo().getGeneratedFileTypes();
731 }
732
733 /**
734 * Retrieves the mapped Java class name.
735 *
736 * @return mapped Java class name
737 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530738 String getGeneratedJavaClassName() {
janani b703cfe42016-05-17 13:12:22 +0530739 return getCapitalCase(getJavaFileInfo().getJavaName());
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530740 }
741
742 /**
743 * Retrieves the import data for the generated Java file.
744 *
745 * @return import data for the generated Java file
746 */
747 public JavaImportData getJavaImportData() {
748 return javaImportData;
749 }
750
751 /**
752 * Sets import data for the generated Java file.
753 *
754 * @param javaImportData import data for the generated Java file
755 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530756 void setJavaImportData(JavaImportData javaImportData) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530757 this.javaImportData = javaImportData;
758 }
759
760 /**
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530761 * Retrieves the status of any attributes added.
762 *
763 * @return status of any attributes added
764 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530765 boolean isAttributePresent() {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530766 return isAttributePresent;
767 }
768
769 /**
770 * Sets status of any attributes added.
771 *
772 * @param attributePresent status of any attributes added
773 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530774 private void setAttributePresent(boolean attributePresent) {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530775 isAttributePresent = attributePresent;
776 }
777
778 /**
779 * Returns getter methods's temporary file handle.
780 *
781 * @return temporary file handle
782 */
783 public File getGetterInterfaceTempFileHandle() {
784 return getterInterfaceTempFileHandle;
785 }
786
787 /**
788 * Sets to getter method's temporary file handle.
789 *
790 * @param getterForInterface file handle for to getter method
791 */
792 private void setGetterInterfaceTempFileHandle(File getterForInterface) {
793 getterInterfaceTempFileHandle = getterForInterface;
794 }
795
796 /**
797 * Returns setter method's temporary file handle.
798 *
799 * @return temporary file handle
800 */
801 public File getSetterInterfaceTempFileHandle() {
802 return setterInterfaceTempFileHandle;
803 }
804
805 /**
806 * Sets to setter method's temporary file handle.
807 *
808 * @param setterForInterface file handle for to setter method
809 */
810 private void setSetterInterfaceTempFileHandle(File setterForInterface) {
811 setterInterfaceTempFileHandle = setterForInterface;
812 }
813
814 /**
815 * Returns setter method's impl's temporary file handle.
816 *
817 * @return temporary file handle
818 */
819 public File getSetterImplTempFileHandle() {
820 return setterImplTempFileHandle;
821 }
822
823 /**
824 * Sets to setter method's impl's temporary file handle.
825 *
826 * @param setterImpl file handle for to setter method's implementation class
827 */
828 private void setSetterImplTempFileHandle(File setterImpl) {
829 setterImplTempFileHandle = setterImpl;
830 }
831
832 /**
Bharat saraswal250a7472016-05-12 13:16:57 +0530833 * Returns from string method's temporary file handle.
834 *
835 * @return from string method's temporary file handle
836 */
837 public File getFromStringImplTempFileHandle() {
838 return fromStringImplTempFileHandle;
839 }
840
841 /**
842 * Sets from string method's temporary file handle.
843 *
Bharat saraswalaf413b82016-07-14 15:18:20 +0530844 * @param fromStringImplTempFileHandle from string method's temporary file handle
Bharat saraswal250a7472016-05-12 13:16:57 +0530845 */
846 private void setFromStringImplTempFileHandle(File fromStringImplTempFileHandle) {
847 this.fromStringImplTempFileHandle = fromStringImplTempFileHandle;
848 }
849
850 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530851 * Returns java file handle for interface file.
852 *
853 * @return java file handle for interface file
854 */
855 private File getInterfaceJavaFileHandle() {
856 return interfaceJavaFileHandle;
857 }
858
859 /**
860 * Sets the java file handle for interface file.
861 *
862 * @param interfaceJavaFileHandle java file handle
863 */
864 private void setInterfaceJavaFileHandle(File interfaceJavaFileHandle) {
865 this.interfaceJavaFileHandle = interfaceJavaFileHandle;
866 }
867
868 /**
869 * Returns java file handle for builder interface file.
870 *
871 * @return java file handle for builder interface file
872 */
873 private File getBuilderInterfaceJavaFileHandle() {
874 return builderInterfaceJavaFileHandle;
875 }
876
877 /**
878 * Sets the java file handle for builder interface file.
879 *
880 * @param builderInterfaceJavaFileHandle java file handle
881 */
882 private void setBuilderInterfaceJavaFileHandle(File builderInterfaceJavaFileHandle) {
883 this.builderInterfaceJavaFileHandle = builderInterfaceJavaFileHandle;
884 }
885
886 /**
887 * Returns java file handle for builder class file.
888 *
889 * @return java file handle for builder class file
890 */
891 private File getBuilderClassJavaFileHandle() {
892 return builderClassJavaFileHandle;
893 }
894
895 /**
896 * Sets the java file handle for builder class file.
897 *
898 * @param builderClassJavaFileHandle java file handle
899 */
900 private void setBuilderClassJavaFileHandle(File builderClassJavaFileHandle) {
901 this.builderClassJavaFileHandle = builderClassJavaFileHandle;
902 }
903
904 /**
905 * Returns java file handle for impl class file.
906 *
907 * @return java file handle for impl class file
908 */
909 private File getImplClassJavaFileHandle() {
910 return implClassJavaFileHandle;
911 }
912
913 /**
914 * Sets the java file handle for impl class file.
915 *
916 * @param implClassJavaFileHandle java file handle
917 */
918 private void setImplClassJavaFileHandle(File implClassJavaFileHandle) {
919 this.implClassJavaFileHandle = implClassJavaFileHandle;
920 }
921
922 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530923 * Returns attribute's temporary file handle.
924 *
925 * @return temporary file handle
926 */
927 public File getAttributesTempFileHandle() {
928 return attributesTempFileHandle;
929 }
930
931 /**
932 * Sets attribute's temporary file handle.
933 *
934 * @param attributeForClass file handle for attribute
935 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530936 private void setAttributesTempFileHandle(File attributeForClass) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530937 attributesTempFileHandle = attributeForClass;
938 }
939
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530940 /**
941 * Returns getter method's impl's temporary file handle.
942 *
943 * @return temporary file handle
944 */
945 public File getGetterImplTempFileHandle() {
946 return getterImplTempFileHandle;
947 }
948
949 /**
950 * Sets to getter method's impl's temporary file handle.
951 *
952 * @param getterImpl file handle for to getter method's impl
953 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530954 private void setGetterImplTempFileHandle(File getterImpl) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530955 getterImplTempFileHandle = getterImpl;
956 }
957
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530958 /**
959 * Returns hash code method's temporary file handle.
960 *
961 * @return temporary file handle
962 */
963 public File getHashCodeImplTempFileHandle() {
964 return hashCodeImplTempFileHandle;
965 }
966
967 /**
968 * Sets hash code method's temporary file handle.
969 *
970 * @param hashCodeMethod file handle for hash code method
971 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530972 private void setHashCodeImplTempFileHandle(File hashCodeMethod) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530973 hashCodeImplTempFileHandle = hashCodeMethod;
974 }
975
976 /**
Bharat saraswal64e7e232016-07-14 23:33:55 +0530977 * Returns equals method's temporary file handle.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530978 *
979 * @return temporary file handle
980 */
981 public File getEqualsImplTempFileHandle() {
982 return equalsImplTempFileHandle;
983 }
984
985 /**
986 * Sets equals method's temporary file handle.
987 *
988 * @param equalsMethod file handle for to equals method
989 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530990 private void setEqualsImplTempFileHandle(File equalsMethod) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530991 equalsImplTempFileHandle = equalsMethod;
992 }
993
994 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530995 * Returns to string method's temporary file handle.
996 *
997 * @return temporary file handle
998 */
999 public File getToStringImplTempFileHandle() {
1000 return toStringImplTempFileHandle;
1001 }
1002
1003 /**
1004 * Sets to string method's temporary file handle.
1005 *
1006 * @param toStringMethod file handle for to string method
1007 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301008 private void setToStringImplTempFileHandle(File toStringMethod) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301009 toStringImplTempFileHandle = toStringMethod;
1010 }
1011
1012 /**
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301013 * Returns java extends list holder.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301014 *
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301015 * @return java extends list holder
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301016 */
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301017 public JavaExtendsListHolder getJavaExtendsListHolder() {
1018 return javaExtendsListHolder;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301019 }
1020
1021 /**
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301022 * Sets java extends list holder.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301023 *
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301024 * @param javaExtendsListHolder java extends list holder
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301025 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301026 void setJavaExtendsListHolder(JavaExtendsListHolder javaExtendsListHolder) {
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301027 this.javaExtendsListHolder = javaExtendsListHolder;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301028 }
1029
1030 /**
Bharat saraswale50edca2016-08-05 01:58:25 +05301031 * Adds is filter content match for leaf.
1032 *
1033 * @param attr java attribute
1034 * @throws IOException when fails to do IO operations
1035 */
1036 private void addIsFilerForLeaf(JavaAttributeInfo attr)
1037 throws IOException {
1038 appendToFile(getIsContentMatchLeafTempFileHandle(),
1039 getIsFilerContentMatchForLeaf(attr, attr.getAttributeType()) + NEW_LINE);
1040 }
1041
1042 /**
1043 * Adds is filter content match for leaf-list.
1044 *
1045 * @param attr java attribute
1046 * @throws IOException when fails to do IO operations
1047 */
1048 private void addIsFilerForLeafList(JavaAttributeInfo attr)
1049 throws IOException {
1050 appendToFile(getIsContentMatchLeafTempFileHandle(),
1051 getIsFilerContentMatchForLeafList(attr) + NEW_LINE);
1052 }
1053
1054 /**
1055 * Adds is filter content match for nodes.
1056 *
1057 * @param attr java attribute
1058 * @throws IOException when fails to do IO operations
1059 */
1060 private void addIsFilerForNode(JavaAttributeInfo attr)
1061 throws IOException {
1062 appendToFile(getIsContentMatchLeafTempFileHandle(),
1063 getIsFilterContentForNodes(attr.getAttributeName(), attr.isListAttr()) + NEW_LINE);
1064 }
1065
1066 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301067 * Adds attribute for class.
1068 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301069 * @param attr attribute info
1070 * @param yangPluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301071 * @throws IOException when fails to append to temporary file
1072 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301073 private void addAttribute(JavaAttributeInfo attr, YangPluginConfig yangPluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301074 throws IOException {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301075 appendToFile(getAttributesTempFileHandle(), parseAttribute(attr, yangPluginConfig)
1076 + FOUR_SPACE_INDENTATION);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301077 }
1078
1079 /**
1080 * Adds getter for interface.
1081 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301082 * @param attr attribute info
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301083 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301084 * @throws IOException when fails to append to temporary file
1085 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301086 private void addGetterForInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301087 throws IOException {
Bharat saraswal250a7472016-05-12 13:16:57 +05301088 appendToFile(getGetterInterfaceTempFileHandle(),
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301089 getGetterString(attr, getGeneratedJavaFiles(), pluginConfig) + NEW_LINE);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301090 }
1091
1092 /**
1093 * Adds setter for interface.
1094 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301095 * @param attr attribute info
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301096 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301097 * @throws IOException when fails to append to temporary file
1098 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301099 private void addSetterForInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301100 throws IOException {
1101 appendToFile(getSetterInterfaceTempFileHandle(),
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301102 getSetterString(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles(), pluginConfig)
1103 + NEW_LINE);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301104 }
1105
1106 /**
1107 * Adds setter's implementation for class.
1108 *
1109 * @param attr attribute info
1110 * @throws IOException when fails to append to temporary file
1111 */
1112 private void addSetterImpl(JavaAttributeInfo attr)
1113 throws IOException {
Bharat saraswal8beac342016-08-04 02:00:03 +05301114 if (isRooNode()) {
1115 appendToFile(getSetterImplTempFileHandle(),
1116 getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles())
1117 + NEW_LINE);
1118 } else {
1119 appendToFile(getSetterImplTempFileHandle(), getOverRideString() +
1120 getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles())
1121 + NEW_LINE);
1122 }
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301123 }
1124
1125 /**
1126 * Adds getter method's impl for class.
1127 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301128 * @param attr attribute info
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301129 * @param pluginConfig plugin configurations
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301130 * @throws IOException when fails to append to temporary file
1131 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301132 void addGetterImpl(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301133 throws IOException {
1134 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0
1135 || (getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301136 if (!isRooNode()) {
1137 appendToFile(getGetterImplTempFileHandle(), getOverRideString() + getGetterForClass(attr,
1138 getGeneratedJavaFiles()) + NEW_LINE);
1139 } else {
1140 appendToFile(getGetterImplTempFileHandle(), getGetterForClass(attr,
1141 getGeneratedJavaFiles()) + NEW_LINE);
1142 }
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301143 } else {
Vidyashree Ramab3670472016-08-06 15:49:56 +05301144 String appDataStructure = null;
1145 if (attr.getCompilerAnnotation() != null) {
1146 appDataStructure = attr.getCompilerAnnotation().getYangAppDataStructure().getDataStructure().name();
1147 }
janani b703cfe42016-05-17 13:12:22 +05301148 appendToFile(getGetterImplTempFileHandle(),
Vidyashree Ramab3670472016-08-06 15:49:56 +05301149 getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig,
1150 appDataStructure) + getGetterForClass(attr, getGeneratedJavaFiles()) + NEW_LINE);
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301151 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301152 }
1153
1154 /**
Bharat saraswal8beac342016-08-04 02:00:03 +05301155 * Adds add to list interface method.
1156 *
1157 * @param attr attribute
1158 * @param pluginConfig plugin configurations
1159 * @throws IOException when fails to do IO operations
1160 */
1161 private void addAddToListInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig) throws IOException {
1162 appendToFile(getAddToListInterfaceTempFileHandle(),
Vidyashree Ramab3670472016-08-06 15:49:56 +05301163 getJavaDoc(ADD_TO_LIST, getCapitalCase(attr.getAttributeName()), false, pluginConfig, null)
Bharat saraswal8beac342016-08-04 02:00:03 +05301164 + getAddToListMethodInterface(attr) + NEW_LINE);
1165 }
1166
1167 /**
1168 * Adds add to list interface method.
1169 *
1170 * @param attr attribute
1171 * @throws IOException when fails to do IO operations
1172 */
1173 private void addAddToListImpl(JavaAttributeInfo attr) throws IOException {
1174 appendToFile(getAddToListImplTempFileHandle(),
1175 getAddToListMethodImpl(attr) + NEW_LINE);
1176 }
1177
1178 /**
1179 * Adds leaf identifier enum attributes.
1180 *
1181 * @param attr attribute
1182 * @param value value
1183 * @param yangPluginConfig plugin config
1184 * @throws IOException when fails to do IO operations
1185 */
1186 private void addLeafIdAttributes(JavaAttributeInfo attr, int value, YangPluginConfig yangPluginConfig)
1187 throws IOException {
1188 appendToFile(getLeafIdAttributeTempFileHandle(),
1189 FOUR_SPACE_INDENTATION + generateEnumAttributeString(attr.getAttributeName(),
1190 value, yangPluginConfig));
1191 }
1192
1193 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301194 * Adds build method for interface.
1195 *
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301196 * @param pluginConfig plugin configurations
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301197 * @return build method for interface
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301198 * @throws IOException when fails to append to temporary file
1199 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301200 String addBuildMethodForInterface(YangPluginConfig pluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301201 throws IOException {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301202 return parseBuilderInterfaceBuildMethodString(getGeneratedJavaClassName(), pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301203 }
1204
1205 /**
1206 * Adds build method's implementation for class.
1207 *
1208 * @return build method implementation for class
1209 * @throws IOException when fails to append to temporary file
1210 */
1211 String addBuildMethodImpl()
1212 throws IOException {
Bharat saraswal8beac342016-08-04 02:00:03 +05301213 return getBuildString(getGeneratedJavaClassName(), isRooNode()) + NEW_LINE;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301214 }
1215
1216 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301217 * Adds default constructor for class.
1218 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301219 * @param modifier modifier for constructor.
1220 * @param toAppend string which need to be appended with the class name
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301221 * @param pluginConfig plugin configurations
Bharat saraswal8beac342016-08-04 02:00:03 +05301222 * @param isSuffix is value need to be appended as suffix
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301223 * @return default constructor for class
1224 * @throws IOException when fails to append to file
1225 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301226 String addDefaultConstructor(String modifier, String toAppend, YangPluginConfig pluginConfig, boolean isSuffix)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301227 throws IOException {
Bharat saraswal8beac342016-08-04 02:00:03 +05301228 String name = getGeneratedJavaClassName();
1229 if (isRooNode() && !toAppend.equals(BUILDER)) {
1230 name = name + OP_PARAM;
1231 return NEW_LINE
1232 + getDefaultConstructorString(name, modifier,
1233 pluginConfig);
1234 }
1235 if (isSuffix) {
1236 return NEW_LINE +
1237 getDefaultConstructorString(name + toAppend, modifier, pluginConfig);
1238 }
1239 String appended;
1240 if (toAppend.equals(DEFAULT)) {
1241 appended = getCapitalCase(toAppend);
1242 } else {
1243 appended = toAppend;
1244 }
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301245 return NEW_LINE
Bharat saraswal8beac342016-08-04 02:00:03 +05301246 + getDefaultConstructorString(appended + name, modifier,
1247 pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301248 }
1249
1250 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301251 * Adds hash code method for class.
1252 *
1253 * @param attr attribute info
1254 * @throws IOException when fails to append to temporary file
1255 */
1256 private void addHashCodeMethod(JavaAttributeInfo attr)
1257 throws IOException {
1258 appendToFile(getHashCodeImplTempFileHandle(), getHashCodeMethod(attr) + NEW_LINE);
1259 }
1260
1261 /**
1262 * Adds equals method for class.
1263 *
1264 * @param attr attribute info
1265 * @throws IOException when fails to append to temporary file
1266 */
1267 private void addEqualsMethod(JavaAttributeInfo attr)
1268 throws IOException {
1269 appendToFile(getEqualsImplTempFileHandle(), getEqualsMethod(attr) + NEW_LINE);
1270 }
1271
1272 /**
1273 * Adds ToString method for class.
1274 *
1275 * @param attr attribute info
1276 * @throws IOException when fails to append to temporary file
1277 */
1278 private void addToStringMethod(JavaAttributeInfo attr)
1279 throws IOException {
1280 appendToFile(getToStringImplTempFileHandle(), getToStringMethod(attr) + NEW_LINE);
1281 }
1282
1283 /**
Bharat saraswal250a7472016-05-12 13:16:57 +05301284 * Adds from string method for union class.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301285 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301286 * @param javaAttributeInfo type attribute info
Bharat saraswal250a7472016-05-12 13:16:57 +05301287 * @param fromStringAttributeInfo from string attribute info
1288 * @throws IOException when fails to append to temporary file
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301289 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301290 void addFromStringMethod(JavaAttributeInfo javaAttributeInfo,
1291 JavaAttributeInfo fromStringAttributeInfo)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301292 throws IOException {
Bharat saraswal250a7472016-05-12 13:16:57 +05301293 appendToFile(getFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo,
1294 fromStringAttributeInfo) + NEW_LINE);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301295 }
1296
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301297 /**
1298 * Returns a temporary file handle for the specific file type.
1299 *
1300 * @param fileName file name
1301 * @return temporary file handle
1302 * @throws IOException when fails to create new file handle
1303 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301304 File getTemporaryFileHandle(String fileName)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301305 throws IOException {
Bharat saraswald14cbe82016-07-14 13:26:18 +05301306 String path = getTempDirPath(getAbsoluteDirPath());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301307 File dir = new File(path);
Bharat saraswal8beac342016-08-04 02:00:03 +05301308 boolean isCreated;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301309 if (!dir.exists()) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301310 isCreated = dir.mkdirs();
Shankara-Huaweib7564772016-08-02 18:13:13 +05301311 if (!isCreated) {
1312 throw new IOException("failed to create temporary directory for " + fileName);
1313 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301314 }
1315 File file = new File(path + fileName + TEMP_FILE_EXTENSION);
1316 if (!file.exists()) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301317 isCreated = file.createNewFile();
Shankara-Huaweib7564772016-08-02 18:13:13 +05301318 if (!isCreated) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301319 throw new IOException("failed to create temporary file for " + fileName);
Shankara-Huaweib7564772016-08-02 18:13:13 +05301320 }
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301321 } else {
1322 throw new IOException(fileName + " is reused due to YANG naming");
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301323 }
1324 return file;
1325 }
1326
1327 /**
1328 * Returns a temporary file handle for the specific file type.
1329 *
1330 * @param fileName file name
1331 * @return temporary file handle
1332 * @throws IOException when fails to create new file handle
1333 */
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301334 File getJavaFileHandle(String fileName)
1335 throws IOException {
Bharat saraswal8beac342016-08-04 02:00:03 +05301336 return getFileObject(getDirPath(), fileName, JAVA_FILE_EXTENSION, getJavaFileInfo());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301337 }
1338
1339 /**
1340 * Returns data from the temporary files.
1341 *
Bharat saraswalaf413b82016-07-14 15:18:20 +05301342 * @param file temporary file handle
Bharat saraswald14cbe82016-07-14 13:26:18 +05301343 * @param absolutePath absolute path
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301344 * @return stored data from temporary files
1345 * @throws IOException when failed to get data from the given file
1346 */
Bharat saraswald14cbe82016-07-14 13:26:18 +05301347 public String getTemporaryDataFromFileHandle(File file, String absolutePath)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301348 throws IOException {
Bharat saraswald14cbe82016-07-14 13:26:18 +05301349 String path = getTempDirPath(absolutePath);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301350 if (new File(path + file.getName()).exists()) {
1351 return readAppendFile(path + file.getName(), EMPTY_STRING);
1352 } else {
1353 throw new IOException("Unable to get data from the given "
1354 + file.getName() + " file for " + getGeneratedJavaClassName() + PERIOD);
1355 }
1356 }
1357
1358 /**
1359 * Returns temporary directory path.
1360 *
Bharat saraswald14cbe82016-07-14 13:26:18 +05301361 * @param absolutePath absolute path
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301362 * @return directory path
1363 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301364 private String getTempDirPath(String absolutePath) {
Bharat saraswald14cbe82016-07-14 13:26:18 +05301365 return getPackageDirPathFromJavaJPackage(absolutePath) + SLASH + getGeneratedJavaClassName()
Bharat saraswal64e7e232016-07-14 23:33:55 +05301366 + TEMP_FOLDER_NAME_SUFFIX + SLASH;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301367 }
1368
1369 /**
1370 * Parses attribute to get the attribute string.
1371 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301372 * @param attr attribute info
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301373 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301374 * @return attribute string
1375 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301376 String parseAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) {
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301377 //TODO: check if this utility needs to be called or move to the caller
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301378 String attributeName = getCamelCase(attr.getAttributeName(), pluginConfig.getConflictResolver());
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301379 String attributeAccessType = PRIVATE;
1380 if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_INTERFACE_WITH_BUILDER) != 0) {
1381 attributeAccessType = PROTECTED;
1382 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301383 if (attr.isQualifiedName()) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301384 return getJavaAttributeDefinition(attr.getImportInfo().getPkgInfo(),
Bharat saraswal250a7472016-05-12 13:16:57 +05301385 attr.getImportInfo().getClassInfo(),
Vidyashree Ramab3670472016-08-06 15:49:56 +05301386 attributeName, attr.isListAttr(), attributeAccessType, attr.getCompilerAnnotation());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301387 } else {
Bharat saraswal8beac342016-08-04 02:00:03 +05301388 return getJavaAttributeDefinition(null, attr.getImportInfo().getClassInfo(), attributeName,
Vidyashree Ramab3670472016-08-06 15:49:56 +05301389 attr.isListAttr(), attributeAccessType, attr.getCompilerAnnotation());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301390 }
1391 }
1392
1393 /**
1394 * Appends content to temporary file.
1395 *
1396 * @param file temporary file
1397 * @param data data to be appended
1398 * @throws IOException when fails to append to file
1399 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301400 void appendToFile(File file, String data)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301401 throws IOException {
1402 try {
1403 insertDataIntoJavaFile(file, data);
1404 } catch (IOException ex) {
1405 throw new IOException("failed to write in temp file.");
1406 }
1407 }
1408
1409 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301410 * Adds parent's info to current node import list.
1411 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301412 * @param curNode current node for which import list needs to be updated
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301413 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301414 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301415 void addParentInfoInCurNodeTempFile(YangNode curNode, YangPluginConfig pluginConfig) {
Bharat saraswale50edca2016-08-05 01:58:25 +05301416 JavaQualifiedTypeInfoTranslator caseImportInfo = new JavaQualifiedTypeInfoTranslator();
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301417 YangNode parent = getParentNodeInGenCode(curNode);
Bharat saraswale50edca2016-08-05 01:58:25 +05301418 if (curNode instanceof YangCase && parent instanceof YangAugment) {
1419 return;
1420 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301421 if (!(parent instanceof JavaCodeGenerator)) {
1422 throw new TranslatorException("missing parent node to contain current node info in generated file");
1423 }
1424 if (!(curNode instanceof JavaFileInfoContainer)) {
1425 throw new TranslatorException("missing java file information to get the package details "
1426 + "of attribute corresponding to child node");
1427 }
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301428 caseImportInfo.setClassInfo(getCapitalCase(getCamelCase(parent.getName(),
1429 pluginConfig.getConflictResolver())));
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301430 caseImportInfo.setPkgInfo(((JavaFileInfoContainer) parent).getJavaFileInfo().getPackage());
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301431
Bharat saraswale50edca2016-08-05 01:58:25 +05301432 JavaFileInfoTranslator fileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301433
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301434 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301435 .getBeanTempFiles().getJavaImportData().addImportInfo(caseImportInfo,
Bharat saraswald14cbe82016-07-14 13:26:18 +05301436 getCapitalCase(fileInfo.getJavaName()), fileInfo.getPackage());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301437 }
1438
1439 /**
1440 * Adds leaf attributes in generated files.
1441 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301442 * @param listOfLeaves list of YANG leaf
1443 * @param yangPluginConfig plugin config
Bharat saraswal64e7e232016-07-14 23:33:55 +05301444 * @param curNode current node
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301445 * @throws IOException IO operation fail
1446 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301447 private void addLeavesInfoToTempFiles(List<YangLeaf> listOfLeaves,
1448 YangPluginConfig yangPluginConfig, YangNode curNode)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301449 throws IOException {
1450 if (listOfLeaves != null) {
1451 for (YangLeaf leaf : listOfLeaves) {
1452 if (!(leaf instanceof JavaLeafInfoContainer)) {
1453 throw new TranslatorException("Leaf does not have java information");
1454 }
Bharat saraswal64e7e232016-07-14 23:33:55 +05301455 if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
1456 TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
1457 .getTempJavaCodeFragmentFiles().getBeanTempFiles();
1458 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(tempJavaBeanFragmentFiles, leaf,
1459 yangPluginConfig), yangPluginConfig);
1460 } else {
1461 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(this, leaf, yangPluginConfig),
1462 yangPluginConfig);
1463 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301464 }
1465 }
1466 }
1467
1468 /**
1469 * Adds leaf list's attributes in generated files.
1470 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301471 * @param listOfLeafList list of YANG leaves
1472 * @param yangPluginConfig plugin config
Bharat saraswal64e7e232016-07-14 23:33:55 +05301473 * @param curNode current node
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301474 * @throws IOException IO operation fail
1475 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301476 private void addLeafListInfoToTempFiles(List<YangLeafList> listOfLeafList, YangPluginConfig yangPluginConfig,
1477 YangNode curNode) throws IOException {
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301478 if (listOfLeafList != null) {
1479 for (YangLeafList leafList : listOfLeafList) {
1480 if (!(leafList instanceof JavaLeafInfoContainer)) {
1481 throw new TranslatorException("Leaf-list does not have java information");
1482 }
Bharat saraswal64e7e232016-07-14 23:33:55 +05301483 if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
1484 TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
1485 .getTempJavaCodeFragmentFiles().getBeanTempFiles();
1486 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(tempJavaBeanFragmentFiles,
1487 leafList, yangPluginConfig), yangPluginConfig);
1488 } else {
1489 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(this,
1490 leafList, yangPluginConfig), yangPluginConfig);
1491 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301492 }
1493 }
1494 }
1495
1496 /**
Bharat saraswal64e7e232016-07-14 23:33:55 +05301497 * Adds all the leaves in the current data model node as part of the generated temporary file.
Bharat saraswald14cbe82016-07-14 13:26:18 +05301498 *
Bharat saraswal64e7e232016-07-14 23:33:55 +05301499 * @param curNode current node
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301500 * @param yangPluginConfig plugin config
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301501 * @throws IOException IO operation fail
1502 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301503 void addCurNodeLeavesInfoToTempFiles(YangNode curNode,
Shankara-Huaweib7564772016-08-02 18:13:13 +05301504 YangPluginConfig yangPluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301505 throws IOException {
1506 if (!(curNode instanceof YangLeavesHolder)) {
1507 throw new TranslatorException("Data model node does not have any leaves");
1508 }
1509 YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
Bharat saraswal64e7e232016-07-14 23:33:55 +05301510 addLeavesInfoToTempFiles(leavesHolder.getListOfLeaf(), yangPluginConfig, curNode);
1511 addLeafListInfoToTempFiles(leavesHolder.getListOfLeafList(), yangPluginConfig, curNode);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301512 }
1513
1514 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301515 * Adds the new attribute info to the target generated temporary files.
1516 *
Bharat saraswalaf413b82016-07-14 15:18:20 +05301517 * @param newAttrInfo the attribute info that needs to be added to temporary files
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301518 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301519 * @throws IOException IO operation fail
1520 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301521 void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo newAttrInfo, YangPluginConfig pluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301522 throws IOException {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301523 setAttributePresent(true);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301524 if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301525 addAttribute(newAttrInfo, pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301526 }
1527 if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301528 addGetterForInterface(newAttrInfo, pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301529 }
1530 if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301531 addSetterForInterface(newAttrInfo, pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301532 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301533 if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) {
1534 addSetterImpl(newAttrInfo);
1535 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301536 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) {
1537 addHashCodeMethod(newAttrInfo);
1538 }
1539 if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) {
1540 addEqualsMethod(newAttrInfo);
1541 }
1542 if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) {
1543 addToStringMethod(newAttrInfo);
1544 }
Bharat saraswale50edca2016-08-05 01:58:25 +05301545 if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) {
1546 //TODO: add implementation for edit content match.
1547 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301548 if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0 && newAttrInfo.isListAttr()) {
1549 addAddToListImpl(newAttrInfo);
1550 }
1551 if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0 && newAttrInfo.isListAttr()) {
1552 addAddToListInterface(newAttrInfo, pluginConfig);
1553 }
Bharat saraswale50edca2016-08-05 01:58:25 +05301554 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0
1555 && newAttrInfo.getAttributeType() == null) {
1556 addIsFilerForNode(newAttrInfo);
1557 }
1558 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0 && !newAttrInfo.isListAttr()
1559 && newAttrInfo.getAttributeType() != null) {
1560 addIsFilerForLeaf(newAttrInfo);
1561 }
1562 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0 && newAttrInfo.isListAttr()
1563 && newAttrInfo.getAttributeType() != null) {
1564 addIsFilerForLeafList(newAttrInfo);
1565 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301566 if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0 && !newAttrInfo.isListAttr()
1567 && newAttrInfo.getAttributeType() != null) {
1568 leafCount++;
1569 addLeafIdAttributes(newAttrInfo, leafCount, pluginConfig);
1570 }
Bharat saraswal64e7e232016-07-14 23:33:55 +05301571 if (!newAttrInfo.isIntConflict() &&
1572 !newAttrInfo.isLongConflict()) {
1573 if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
1574 addGetterImpl(newAttrInfo, pluginConfig);
1575 }
1576
1577 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
Shankara-Huaweib7564772016-08-02 18:13:13 +05301578 JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo,
Bharat saraswal64e7e232016-07-14 23:33:55 +05301579 pluginConfig.getConflictResolver());
Bharat saraswal250a7472016-05-12 13:16:57 +05301580 /*
1581 * Create a new java attribute info with qualified information of
1582 * wrapper classes.
1583 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301584 JavaAttributeInfo fromStringAttributeInfo = getAttributeInfoForTheData(qualifiedInfoOfFromString,
1585 newAttrInfo.getAttributeName(),
1586 newAttrInfo.getAttributeType(),
1587 getIsQualifiedAccessOrAddToImportList(qualifiedInfoOfFromString), false);
Bharat saraswal250a7472016-05-12 13:16:57 +05301588
Bharat saraswal64e7e232016-07-14 23:33:55 +05301589 addFromStringMethod(newAttrInfo, fromStringAttributeInfo);
1590 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301591 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301592 }
1593
1594 /**
1595 * Returns java class name.
1596 *
1597 * @param suffix for the class name based on the file type
1598 * @return java class name
1599 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301600 String getJavaClassName(String suffix) {
janani b703cfe42016-05-17 13:12:22 +05301601 return getCapitalCase(getJavaFileInfo().getJavaName()) + suffix;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301602 }
1603
1604 /**
Bharat saraswald14cbe82016-07-14 13:26:18 +05301605 * Returns java class name.
1606 *
Bharat saraswal8beac342016-08-04 02:00:03 +05301607 * @param node YANG node
Bharat saraswald14cbe82016-07-14 13:26:18 +05301608 * @return java class name
1609 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301610 private String getImplClassName(YangNode node) {
1611 if (node instanceof YangModule || node instanceof YangSubModule) {
1612 return getCapitalCase(getJavaFileInfo().getJavaName()) + OP_PARAM;
1613 }
Bharat saraswald14cbe82016-07-14 13:26:18 +05301614 return getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo().getJavaName());
1615 }
1616
1617 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301618 * Returns the directory path.
1619 *
1620 * @return directory path
1621 */
1622 private String getDirPath() {
1623 return getJavaFileInfo().getPackageFilePath();
1624 }
1625
1626 /**
1627 * Constructs java code exit.
1628 *
1629 * @param fileType generated file type
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301630 * @param curNode current YANG node
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301631 * @throws IOException when fails to generate java files
1632 */
1633 public void generateJavaFile(int fileType, YangNode curNode)
1634 throws IOException {
Bharat saraswalaf413b82016-07-14 15:18:20 +05301635 List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles()
1636 .getJavaImportData().getImports();
Bharat saraswal8beac342016-08-04 02:00:03 +05301637 if (curNode instanceof YangAugmentableNode) {
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301638 addImportsForAugmentableClass(imports, true, true, curNode);
Bharat saraswal8beac342016-08-04 02:00:03 +05301639 }
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301640 createPackage(curNode);
Vidyashree Ramab3670472016-08-06 15:49:56 +05301641
1642 //Generate java code.
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301643 if ((fileType & INTERFACE_MASK) != 0 || (fileType &
1644 BUILDER_INTERFACE_MASK) != 0) {
Vidyashree Ramab3670472016-08-06 15:49:56 +05301645
1646 //Create interface file.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301647 setInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(INTERFACE_FILE_NAME_SUFFIX)));
1648 setInterfaceJavaFileHandle(
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301649 generateInterfaceFile(getInterfaceJavaFileHandle(), imports, curNode, isAttributePresent()));
Bharat saraswal8beac342016-08-04 02:00:03 +05301650 if (!(curNode instanceof YangModule) && !(curNode instanceof YangSubModule)) {
Vidyashree Ramab3670472016-08-06 15:49:56 +05301651
1652 //Create builder interface file.
Bharat saraswal8beac342016-08-04 02:00:03 +05301653 if ((fileType & BUILDER_INTERFACE_MASK) != 0) {
1654 setBuilderInterfaceJavaFileHandle(
1655 getJavaFileHandle(getJavaClassName(BUILDER_INTERFACE_FILE_NAME_SUFFIX)));
1656 setBuilderInterfaceJavaFileHandle(
1657 generateBuilderInterfaceFile(getBuilderInterfaceJavaFileHandle(), curNode,
1658 isAttributePresent()));
Vidyashree Ramab3670472016-08-06 15:49:56 +05301659
1660 //Append builder interface file to interface file and close it.
Bharat saraswal8beac342016-08-04 02:00:03 +05301661 mergeJavaFiles(getBuilderInterfaceJavaFileHandle(), getInterfaceJavaFileHandle());
1662 validateLineLength(getInterfaceJavaFileHandle());
1663 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301664 }
1665 insertDataIntoJavaFile(getInterfaceJavaFileHandle(), getJavaClassDefClose());
Bharat saraswal8beac342016-08-04 02:00:03 +05301666 if (curNode instanceof YangAugmentableNode) {
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301667 addImportsForAugmentableClass(imports, false, true, curNode);
Bharat saraswald14cbe82016-07-14 13:26:18 +05301668 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301669 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301670 if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & DEFAULT_CLASS_MASK) != 0) {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301671 if (isAttributePresent()) {
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301672 addImportsToStringAndHasCodeMethods(imports, true);
Bharat saraswal8beac342016-08-04 02:00:03 +05301673 addArrayListImport(imports);
Bharat saraswalaf413b82016-07-14 15:18:20 +05301674 }
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301675
1676 boolean isLeavesPresent;
1677 if (curNode instanceof YangLeavesHolder) {
1678 YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
1679 isLeavesPresent = leavesHolder.getListOfLeaf() != null && !leavesHolder.getListOfLeaf().isEmpty()
1680 || leavesHolder.getListOfLeafList() != null && !leavesHolder.getListOfLeafList().isEmpty();
1681 if (isLeavesPresent) {
1682 addBitsetImport(imports);
1683 }
1684 }
Bharat saraswalaf413b82016-07-14 15:18:20 +05301685 if (curNode instanceof YangAugmentableNode) {
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301686 addImportsForAugmentableClass(imports, true, false, curNode);
Bharat saraswale50edca2016-08-05 01:58:25 +05301687 addInvocationExceptionImport(imports);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301688 }
Bharat saraswal250a7472016-05-12 13:16:57 +05301689 sortImports(imports);
Vidyashree Ramab3670472016-08-06 15:49:56 +05301690
1691 //Create impl class file.
Bharat saraswal8beac342016-08-04 02:00:03 +05301692 setImplClassJavaFileHandle(getJavaFileHandle(getImplClassName(curNode)));
Bharat saraswald14cbe82016-07-14 13:26:18 +05301693 setImplClassJavaFileHandle(
Bharat saraswal8beac342016-08-04 02:00:03 +05301694 generateDefaultClassFile(getImplClassJavaFileHandle(), curNode, isAttributePresent(), imports));
Vidyashree Ramab3670472016-08-06 15:49:56 +05301695
1696 //Create builder class file.
Bharat saraswald14cbe82016-07-14 13:26:18 +05301697 if ((fileType & BUILDER_CLASS_MASK) != 0) {
1698 setBuilderClassJavaFileHandle(getJavaFileHandle(getJavaClassName(BUILDER_CLASS_FILE_NAME_SUFFIX)));
1699 setBuilderClassJavaFileHandle(
1700 generateBuilderClassFile(getBuilderClassJavaFileHandle(), curNode,
1701 isAttributePresent()));
Vidyashree Ramab3670472016-08-06 15:49:56 +05301702
1703 //Append impl class to builder class and close it.
Bharat saraswald14cbe82016-07-14 13:26:18 +05301704 mergeJavaFiles(getBuilderClassJavaFileHandle(), getImplClassJavaFileHandle());
1705 validateLineLength(getImplClassJavaFileHandle());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301706 }
Bharat saraswald14cbe82016-07-14 13:26:18 +05301707 insertDataIntoJavaFile(getImplClassJavaFileHandle(), getJavaClassDefClose());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301708 }
Vidyashree Ramab3670472016-08-06 15:49:56 +05301709 //Close all the file handles.
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301710 freeTemporaryResources(false);
1711 }
1712
Vidyashree Ramab3670472016-08-06 15:49:56 +05301713 //Adds import for array list.
Bharat saraswal8beac342016-08-04 02:00:03 +05301714 private void addArrayListImport(List<String> imports) {
1715 if (imports.contains(getJavaImportData().getImportForList())) {
1716 imports.add(ARRAY_LIST_IMPORT);
1717 }
1718 }
1719
Bharat saraswal8beac342016-08-04 02:00:03 +05301720 private void addBitsetImport(List<String> imports) {
1721 imports.add(getJavaImportData().getImportForToBitSet());
Bharat saraswald14cbe82016-07-14 13:26:18 +05301722 }
1723
1724 /**
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301725 * Adds imports for ToString and HashCodeMethod.
1726 *
Bharat saraswal039f59c2016-07-14 21:57:13 +05301727 * @param imports import list
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301728 * @param operation add or remove
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301729 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301730 void addImportsToStringAndHasCodeMethods(List<String> imports, boolean operation) {
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301731 if (operation) {
1732 imports.add(getJavaImportData().getImportForHashAndEquals());
1733 imports.add(getJavaImportData().getImportForToString());
1734 } else {
1735 imports.remove(getJavaImportData().getImportForHashAndEquals());
1736 imports.remove(getJavaImportData().getImportForToString());
1737 }
1738 }
1739
1740 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +05301741 * Adds import for map and hash map.
1742 *
Bharat saraswal8beac342016-08-04 02:00:03 +05301743 * @param imports import list
1744 * @param operations true for adding and false for deletion
1745 * @param isInterfaceFile if need to add in interface file
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301746 * @param curNode current node
Bharat saraswalaf413b82016-07-14 15:18:20 +05301747 */
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301748 private void addImportsForAugmentableClass(List<String> imports, boolean operations, boolean isInterfaceFile,
1749 YangNode curNode) {
Bharat saraswal039f59c2016-07-14 21:57:13 +05301750 if (operations) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301751 if (!isInterfaceFile) {
1752 imports.add(getJavaImportData().getHashMapImport());
1753 }
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301754 // Add import for hash map only if node is not a YANG choice.
1755 if (!(curNode instanceof YangChoice)) {
1756 imports.add(getJavaImportData().getMapImport());
1757 }
Bharat saraswal039f59c2016-07-14 21:57:13 +05301758 } else {
Bharat saraswal8beac342016-08-04 02:00:03 +05301759 if (!isInterfaceFile) {
1760 imports.remove(getJavaImportData().getHashMapImport());
1761 }
Bharat saraswal039f59c2016-07-14 21:57:13 +05301762 imports.remove(getJavaImportData().getMapImport());
Bharat saraswald14cbe82016-07-14 13:26:18 +05301763 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301764 sortImports(imports);
Bharat saraswald14cbe82016-07-14 13:26:18 +05301765 }
1766
1767 /**
Bharat saraswal8beac342016-08-04 02:00:03 +05301768 * Adds invocation exception import.
Bharat saraswal039f59c2016-07-14 21:57:13 +05301769 *
1770 * @param imports list of imports
Bharat saraswal039f59c2016-07-14 21:57:13 +05301771 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301772 private void addInvocationExceptionImport(List<String> imports) {
1773 imports.add(INVOCATION_TARGET_EXCEPTION_IMPORT);
Bharat saraswal039f59c2016-07-14 21:57:13 +05301774 }
1775
1776 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301777 * Removes all temporary file handles.
1778 *
Bharat saraswal64e7e232016-07-14 23:33:55 +05301779 * @param isErrorOccurred flag to tell translator that error has occurred while file generation
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301780 * @throws IOException when failed to delete the temporary files
1781 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301782 public void freeTemporaryResources(boolean isErrorOccurred)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301783 throws IOException {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301784 /*
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301785 * Close all java file handles and when error occurs delete the files.
1786 */
1787 if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) {
Bharat saraswal64e7e232016-07-14 23:33:55 +05301788 closeFile(getInterfaceJavaFileHandle(), isErrorOccurred);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301789 }
1790 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) {
Bharat saraswald14cbe82016-07-14 13:26:18 +05301791 closeFile(getBuilderClassJavaFileHandle(), true);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301792 }
1793 if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) {
1794 closeFile(getBuilderInterfaceJavaFileHandle(), true);
1795 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301796 if ((getGeneratedJavaFiles() & DEFAULT_CLASS_MASK) != 0) {
Bharat saraswal64e7e232016-07-14 23:33:55 +05301797 closeFile(getImplClassJavaFileHandle(), isErrorOccurred);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301798 }
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301799 /*
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301800 * Close all temporary file handles and delete the files.
1801 */
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301802 if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
1803 closeFile(getGetterImplTempFileHandle(), true);
1804 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301805 if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) {
1806 closeFile(getAttributesTempFileHandle(), true);
1807 }
1808 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) {
1809 closeFile(getHashCodeImplTempFileHandle(), true);
1810 }
1811 if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) {
1812 closeFile(getToStringImplTempFileHandle(), true);
1813 }
1814 if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) {
1815 closeFile(getEqualsImplTempFileHandle(), true);
1816 }
Bharat saraswal250a7472016-05-12 13:16:57 +05301817 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
1818 closeFile(getFromStringImplTempFileHandle(), true);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301819 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301820 if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0) {
1821 closeFile(getAddToListImplTempFileHandle(), true);
1822 }
1823 if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0) {
1824 closeFile(getAddToListInterfaceTempFileHandle(), true);
1825 }
1826 if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0) {
1827 closeFile(getLeafIdAttributeTempFileHandle(), true);
1828 }
Bharat saraswale50edca2016-08-05 01:58:25 +05301829 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0) {
1830 closeFile(getIsContentMatchLeafTempFileHandle(), true);
1831 }
1832 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0) {
1833 closeFile(getIsContentMatchLeafListTempFileHandle(), true);
1834 }
1835 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0) {
1836 closeFile(getIsContentMatchNodeTempFileHandle(), true);
1837 }
1838 if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) {
1839 closeFile(getEditContentTempFileHandle(), true);
1840 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301841 }
1842
1843 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +05301844 * Returns if the attribute needs to be accessed in a qualified manner or not, if it needs to be imported, then the
1845 * same needs to be done.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301846 *
1847 * @param importInfo import info for the current attribute being added
1848 * @return status of the qualified access to the attribute
1849 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301850 boolean getIsQualifiedAccessOrAddToImportList(
Shankara-Huaweib7564772016-08-02 18:13:13 +05301851 JavaQualifiedTypeInfoTranslator importInfo) {
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301852 return getJavaImportData().addImportInfo(importInfo, getGeneratedJavaClassName(),
1853 getJavaFileInfo().getPackage());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301854 }
1855
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301856 /**
Bharat saraswal8beac342016-08-04 02:00:03 +05301857 * Returns temp file handle for add to list interface.
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301858 *
Bharat saraswal8beac342016-08-04 02:00:03 +05301859 * @return temp file handle for add to list interface
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301860 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301861 public File getAddToListInterfaceTempFileHandle() {
1862 return addToListInterfaceTempFileHandle;
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301863 }
1864
1865 /**
Bharat saraswal8beac342016-08-04 02:00:03 +05301866 * Sets temp file handle for add to list interface.
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301867 *
Bharat saraswal8beac342016-08-04 02:00:03 +05301868 * @param addToListInterfaceTempFileHandle temp file handle for add to list interface
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301869 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301870 private void setAddToListInterfaceTempFileHandle(File addToListInterfaceTempFileHandle) {
1871 this.addToListInterfaceTempFileHandle = addToListInterfaceTempFileHandle;
1872 }
1873
1874 /**
1875 * Returns temp file handle for add to list impl.
1876 *
1877 * @return temp file handle for add to list impl
1878 */
1879 public File getAddToListImplTempFileHandle() {
1880 return addToListImplTempFileHandle;
1881 }
1882
1883 /**
1884 * Sets temp file handle for add to list impl.
1885 *
1886 * @param addToListImplTempFileHandle temp file handle for add to list impl
1887 */
1888 private void setAddToListImplTempFileHandle(File addToListImplTempFileHandle) {
1889 this.addToListImplTempFileHandle = addToListImplTempFileHandle;
1890 }
1891
1892 /**
1893 * Returns temp file handle for leaf identifier attributes.
1894 *
1895 * @return temp file handle for leaf identifier attributes
1896 */
1897 public File getLeafIdAttributeTempFileHandle() {
1898 return leafIdAttributeTempFileHandle;
1899 }
1900
1901 /**
1902 * Sets temp file handle for leaf identifier attributes.
1903 *
Bharat saraswale50edca2016-08-05 01:58:25 +05301904 * @param leafIdAttributeTempFileHandle temp file handle for leaf identifier attributes
Bharat saraswal8beac342016-08-04 02:00:03 +05301905 */
1906 private void setLeafIdAttributeTempFileHandle(File leafIdAttributeTempFileHandle) {
1907 this.leafIdAttributeTempFileHandle = leafIdAttributeTempFileHandle;
1908 }
1909
1910 /**
1911 * Returns if root node is set.
1912 *
1913 * @return true if root node
1914 */
1915 private boolean isRooNode() {
1916 return isRooNode;
1917 }
1918
1919 /**
1920 * Sets true if root node.
1921 *
1922 * @param rooNode true if root node
1923 */
Bharat saraswale50edca2016-08-05 01:58:25 +05301924 void setRooNode(boolean rooNode) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301925 isRooNode = rooNode;
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301926 }
Bharat saraswale50edca2016-08-05 01:58:25 +05301927
1928 /**
1929 * Returns temp file for is content match.
1930 *
1931 * @return temp file for is content match
1932 */
1933 public File getIsContentMatchLeafTempFileHandle() {
1934 return isContentMatchLeafTempFileHandle;
1935 }
1936
1937 /**
1938 * Sets temp file handle for is content match.
1939 *
1940 * @param isContentMatchLeafTempFileHandle temp file handle for is content match
1941 */
1942 private void setIsContentMatchLeafTempFileHandle(File isContentMatchLeafTempFileHandle) {
1943 this.isContentMatchLeafTempFileHandle = isContentMatchLeafTempFileHandle;
1944 }
1945
1946 /**
1947 * Returns temp file for edit content file.
1948 *
1949 * @return temp file for edit content file
1950 */
1951 public File getEditContentTempFileHandle() {
1952 return editContentTempFileHandle;
1953 }
1954
1955 /**
1956 * Sets temp file for edit content file.
1957 *
1958 * @param editContentTempFileHandle temp file for edit content file
1959 */
1960 private void setEditContentTempFileHandle(File editContentTempFileHandle) {
1961 this.editContentTempFileHandle = editContentTempFileHandle;
1962 }
1963
1964 /**
1965 * Returns temp file for is content match.
1966 *
1967 * @return temp file for is content match
1968 */
1969 public File getIsContentMatchLeafListTempFileHandle() {
1970 return isContentMatchLeafListTempFileHandle;
1971 }
1972
1973 /**
1974 * Sets temp file handle for is content match.
1975 *
1976 * @param isContentMatchLeafListTempFileHandle temp file handle for is content match
1977 */
1978 private void setIsContentMatchLeafListTempFileHandle(File isContentMatchLeafListTempFileHandle) {
1979 this.isContentMatchLeafListTempFileHandle = isContentMatchLeafListTempFileHandle;
1980 }
1981
1982 /**
1983 * Returns temp file for is content match.
1984 *
1985 * @return temp file for is content match
1986 */
1987 public File getIsContentMatchNodeTempFileHandle() {
1988 return isContentMatchNodeTempFileHandle;
1989 }
1990
1991 /**
1992 * Sets temp file handle for is content match.
1993 *
1994 * @param isContentMatchNodeTempFileHandle temp file handle for is content match
1995 */
1996 private void setIsContentMatchNodeTempFileHandle(File isContentMatchNodeTempFileHandle) {
1997 this.isContentMatchNodeTempFileHandle = isContentMatchNodeTempFileHandle;
1998 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301999}