blob: dd4c616a3aebdfee38407a3990370c36824fd113 [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 saraswale304c252016-08-16 20:56:20 +053021
Bharat saraswale50edca2016-08-05 01:58:25 +053022import org.onosproject.yangutils.datamodel.YangAugment;
Bharat saraswalaf413b82016-07-14 15:18:20 +053023import org.onosproject.yangutils.datamodel.YangAugmentableNode;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053024import org.onosproject.yangutils.datamodel.YangCase;
Gaurav Agrawal8a147522016-08-10 13:43:01 +053025import org.onosproject.yangutils.datamodel.YangChoice;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053026import org.onosproject.yangutils.datamodel.YangLeaf;
27import org.onosproject.yangutils.datamodel.YangLeafList;
28import org.onosproject.yangutils.datamodel.YangLeavesHolder;
Vidyashree Ramab3670472016-08-06 15:49:56 +053029import org.onosproject.yangutils.datamodel.YangList;
Gaurav Agrawal8a147522016-08-10 13:43:01 +053030import org.onosproject.yangutils.datamodel.YangModule;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053031import org.onosproject.yangutils.datamodel.YangNode;
Bharat saraswalaf413b82016-07-14 15:18:20 +053032import org.onosproject.yangutils.datamodel.YangSubModule;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053033import org.onosproject.yangutils.translator.exception.TranslatorException;
34import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer;
Shankara-Huaweib7564772016-08-02 18:13:13 +053035import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGroupingTranslator;
Bharat saraswal4aaab4d2016-05-17 14:19:38 +053036import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
Gaurav Agrawal8a147522016-08-10 13:43:01 +053037import org.onosproject.yangutils.utils.io.YangPluginConfig;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053038
Bharat saraswalc2d3be12016-06-16 00:29:12 +053039import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053040import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
41import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
Bharat saraswal8beac342016-08-04 02:00:03 +053042import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053043import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
Bharat saraswalaf413b82016-07-14 15:18:20 +053044import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +053045import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
46import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053047import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
Bharat saraswal8beac342016-08-04 02:00:03 +053048import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_IMPL_MASK;
49import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_INTERFACE_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053050import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
Bharat saraswale50edca2016-08-05 01:58:25 +053051import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EDIT_CONTENT_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053052import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
Bharat saraswale50edca2016-08-05 01:58:25 +053053import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK;
54import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_MASK;
55import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_NODES_MASK;
Bharat saraswal250a7472016-05-12 13:16:57 +053056import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053057import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
58import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
59import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK;
Bharat saraswal8beac342016-08-04 02:00:03 +053060import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053061import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
62import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
63import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK;
64import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
Shankara-Huaweib7564772016-08-02 18:13:13 +053065import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedInfoOfFromString;
66import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode;
Gaurav Agrawalbfce9342016-06-15 13:58:01 +053067import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo;
Bharat saraswal8beac342016-08-04 02:00:03 +053068import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString;
69import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefinition;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053070import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
Bharat saraswalaf413b82016-07-14 15:18:20 +053071import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.sortImports;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053072import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile;
73import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile;
Bharat saraswal8beac342016-08-04 02:00:03 +053074import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateDefaultClassFile;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053075import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053076import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
Bharat saraswald14cbe82016-07-14 13:26:18 +053077import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
Bharat saraswal8beac342016-08-04 02:00:03 +053078import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddToListMethodImpl;
79import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddToListMethodInterface;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053080import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053081import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString;
82import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
Bharat saraswal250a7472016-05-12 13:16:57 +053083import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethod;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053084import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
85import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString;
86import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethod;
Bharat saraswale50edca2016-08-05 01:58:25 +053087import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilerContentMatchForLeaf;
88import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilerContentMatchForLeafList;
89import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getIsFilterContentForNodes;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053090import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053091import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
92import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString;
93import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053094import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString;
Bharat saraswal8beac342016-08-04 02:00:03 +053095import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST_IMPORT;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053096import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
Bharat saraswald14cbe82016-07-14 13:26:18 +053097import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
Vinod Kumar S79a374b2016-04-30 21:09:15 +053098import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
99import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530100import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE;
Bharat saraswal8beac342016-08-04 02:00:03 +0530101import static org.onosproject.yangutils.utils.UtilConstants.INVOCATION_TARGET_EXCEPTION_IMPORT;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530102import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
Bharat saraswal8beac342016-08-04 02:00:03 +0530103import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530104import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
Bharat saraswal039f59c2016-07-14 21:57:13 +0530105import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
106import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED;
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530107import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530108import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
Bharat saraswalaf413b82016-07-14 15:18:20 +0530109import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530110import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile;
Bharat saraswal8beac342016-08-04 02:00:03 +0530111import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ADD_TO_LIST;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530112import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
Bharat saraswale304c252016-08-16 20:56:20 +0530113import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD;
Bharat saraswald14cbe82016-07-14 13:26:18 +0530114import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530115import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
Bharat saraswald14cbe82016-07-14 13:26:18 +0530116import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
117import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
118import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530119import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
120import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles;
Bharat saraswalc2d3be12016-06-16 00:29:12 +0530121import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530122
123/**
Bharat saraswalaf413b82016-07-14 15:18:20 +0530124 * Represents implementation of java code fragments temporary implementations. Manages the common temp file required for
125 * Java file(s) generated.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530126 */
127public class TempJavaFragmentFiles {
Bharat saraswal250a7472016-05-12 13:16:57 +0530128
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530129 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530130 * File type extension for java classes.
131 */
132 private static final String JAVA_FILE_EXTENSION = ".java";
Bharat saraswal250a7472016-05-12 13:16:57 +0530133
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530134 /**
135 * File type extension for temporary classes.
136 */
137 private static final String TEMP_FILE_EXTENSION = ".tmp";
Bharat saraswal250a7472016-05-12 13:16:57 +0530138
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530139 /**
140 * Folder suffix for temporary files folder.
141 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530142 private static final String TEMP_FOLDER_NAME_SUFFIX = "-Temp";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530143
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530144 /**
145 * File name for getter method.
146 */
147 private static final String GETTER_METHOD_FILE_NAME = "GetterMethod";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530148
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530149 /**
150 * File name for setter method.
151 */
152 private static final String SETTER_METHOD_FILE_NAME = "SetterMethod";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530153
154 /**
155 * File name for getter method implementation.
156 */
157 private static final String GETTER_METHOD_IMPL_FILE_NAME = "GetterMethodImpl";
158
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530159 /**
160 * File name for setter method implementation.
161 */
162 private static final String SETTER_METHOD_IMPL_FILE_NAME = "SetterMethodImpl";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530163
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530164 /**
165 * File name for attributes.
166 */
167 private static final String ATTRIBUTE_FILE_NAME = "Attributes";
Bharat saraswal250a7472016-05-12 13:16:57 +0530168
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530169 /**
170 * File name for to string method.
171 */
172 private static final String TO_STRING_METHOD_FILE_NAME = "ToString";
Bharat saraswal250a7472016-05-12 13:16:57 +0530173
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530174 /**
175 * File name for hash code method.
176 */
177 private static final String HASH_CODE_METHOD_FILE_NAME = "HashCode";
Bharat saraswal250a7472016-05-12 13:16:57 +0530178
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530179 /**
180 * File name for equals method.
181 */
182 private static final String EQUALS_METHOD_FILE_NAME = "Equals";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530183
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530184 /**
Bharat saraswal250a7472016-05-12 13:16:57 +0530185 * File name for from string method.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530186 */
Bharat saraswal250a7472016-05-12 13:16:57 +0530187 private static final String FROM_STRING_METHOD_FILE_NAME = "FromString";
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530188
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530189 /**
Bharat saraswal8beac342016-08-04 02:00:03 +0530190 * File name for from add to list interface method.
191 */
192 private static final String ADD_TO_LIST_INTERFACE_METHOD_FILE_NAME = "addToList";
193
194 /**
195 * File name for from add to list impl method.
196 */
197 private static final String ADD_TO_LIST_IMPL_METHOD_FILE_NAME = "addToListImpl";
198
199 /**
200 * File name for from leaf identifier attributes.
201 */
202 private static final String LEAF_IDENTIFIER_ATTRIBUTES_FILE_NAME = "leafIdentifierAtr";
203
204 /**
Bharat saraswale50edca2016-08-05 01:58:25 +0530205 * File name for is filter content leaf match.
206 */
207 private static final String FILTER_CONTENT_MATCH_LEAF_FILE_NAME = "isFilterContentMatchLeafMask";
208
209 /**
210 * File name for is filter content leaf-list match.
211 */
212 private static final String FILTER_CONTENT_MATCH_LEAF_LIST_FILE_NAME = "isFilterContentMatchLeafListMask";
213
214 /**
215 * File name for is filter content node match.
216 */
217 private static final String FILTER_CONTENT_MATCH_NODE_FILE_NAME = "isFilterContentMatchNodeMask";
218
219 /**
220 * File name for edit content file.
221 */
222 private static final String EDIT_CONTENT_FILE_NAME = "editContentFile";
223
224 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530225 * File name for interface java file name suffix.
226 */
227 private static final String INTERFACE_FILE_NAME_SUFFIX = EMPTY_STRING;
Bharat saraswal250a7472016-05-12 13:16:57 +0530228
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530229 /**
230 * File name for builder interface file name suffix.
231 */
232 private static final String BUILDER_INTERFACE_FILE_NAME_SUFFIX = BUILDER + INTERFACE;
Bharat saraswal250a7472016-05-12 13:16:57 +0530233
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530234 /**
235 * File name for builder class file name suffix.
236 */
237 private static final String BUILDER_CLASS_FILE_NAME_SUFFIX = BUILDER;
Bharat saraswal250a7472016-05-12 13:16:57 +0530238
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530239 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +0530240 * Information about the java files being generated.
241 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530242 private JavaFileInfoTranslator javaFileInfo;
Bharat saraswalaf413b82016-07-14 15:18:20 +0530243
244 /**
245 * Imported class info.
246 */
247 private JavaImportData javaImportData;
248
249 /**
250 * The variable which guides the types of temporary files generated using the temporary generated file types mask.
251 */
252 private int generatedTempFiles;
253
254 /**
255 * Absolute path where the target java file needs to be generated.
256 */
257 private String absoluteDirPath;
258
259 /**
260 * Contains all the interface(s)/class name which will be extended by generated files.
261 */
262 private JavaExtendsListHolder javaExtendsListHolder;
263
Bharat saraswald14cbe82016-07-14 13:26:18 +0530264 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530265 * Java file handle for interface file.
266 */
267 private File interfaceJavaFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530268
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530269 /**
270 * Java file handle for builder interface file.
271 */
272 private File builderInterfaceJavaFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530273
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530274 /**
275 * Java file handle for builder class file.
276 */
277 private File builderClassJavaFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530278
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530279 /**
280 * Java file handle for impl class file.
281 */
282 private File implClassJavaFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530283
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530284 /**
285 * Temporary file handle for attribute.
286 */
287 private File attributesTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530288
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530289 /**
290 * Temporary file handle for getter of interface.
291 */
292 private File getterInterfaceTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530293
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530294 /**
295 * Temporary file handle for setter of interface.
296 */
297 private File setterInterfaceTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530298
299 /**
300 * Temporary file handle for getter of class.
301 */
302 private File getterImplTempFileHandle;
303
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530304 /**
305 * Temporary file handle for setter of class.
306 */
307 private File setterImplTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530308
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530309 /**
310 * Temporary file handle for hash code method of class.
311 */
312 private File hashCodeImplTempFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530313
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530314 /**
315 * Temporary file handle for equals method of class.
316 */
317 private File equalsImplTempFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530318
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530319 /**
320 * Temporary file handle for to string method of class.
321 */
322 private File toStringImplTempFileHandle;
Bharat saraswal250a7472016-05-12 13:16:57 +0530323
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530324 /**
Bharat saraswal250a7472016-05-12 13:16:57 +0530325 * Temporary file handle for from string method of class.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530326 */
Bharat saraswal250a7472016-05-12 13:16:57 +0530327 private File fromStringImplTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530328
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530329 /**
Bharat saraswal8beac342016-08-04 02:00:03 +0530330 * Temporary file handle for add to list interface method of class.
331 */
332 private File addToListInterfaceTempFileHandle;
333
334 /**
335 * Temporary file handle for add to list impl method of class.
336 */
337 private File addToListImplTempFileHandle;
338
339 /**
340 * Temporary file handle for leaf id attributes of enum.
341 */
342 private File leafIdAttributeTempFileHandle;
343
344 /**
Bharat saraswale50edca2016-08-05 01:58:25 +0530345 * Temporary file handle for is content match method for leaf-list.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530346 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530347 private File isContentMatchLeafListTempFileHandle;
348
349 /**
350 * Temporary file handle for is content match method for node.
351 */
352 private File isContentMatchNodeTempFileHandle;
353
354 /**
355 * Temporary file handle for is content match method for leaf.
356 */
357 private File isContentMatchLeafTempFileHandle;
358
359 /**
360 * Temporary file handle for edit content file.
361 */
362 private File editContentTempFileHandle;
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530363
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530364 /**
Bharat saraswal8beac342016-08-04 02:00:03 +0530365 * Leaf count.
366 */
367 private int leafCount = 0;
368
369 /**
370 * If current node is root node.
371 */
372 private boolean isRooNode;
373
374 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530375 * Is attribute added.
376 */
Bharat saraswal250a7472016-05-12 13:16:57 +0530377 private boolean isAttributePresent;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530378
Bharat saraswalaf413b82016-07-14 15:18:20 +0530379 TempJavaFragmentFiles() {
380 }
381
382 /**
383 * Creates an instance of temporary java code fragment.
384 *
385 * @param javaFileInfo generated java file information
386 * @throws IOException when fails to create new file handle
387 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530388 TempJavaFragmentFiles(JavaFileInfoTranslator javaFileInfo)
Bharat saraswalaf413b82016-07-14 15:18:20 +0530389 throws IOException {
390 setJavaExtendsListHolder(new JavaExtendsListHolder());
391 setJavaImportData(new JavaImportData());
392 setJavaFileInfo(javaFileInfo);
Bharat saraswal8beac342016-08-04 02:00:03 +0530393 setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
394 getJavaFileInfo().getPackageFilePath()));
395
Bharat saraswalaf413b82016-07-14 15:18:20 +0530396 /*
397 * Initialize getter when generation file type matches to interface
398 * mask.
399 */
400 if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) {
401 addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK);
Bharat saraswal8beac342016-08-04 02:00:03 +0530402 addGeneratedTempFile(ADD_TO_LIST_INTERFACE_MASK);
403 addGeneratedTempFile(LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK);
Bharat saraswalaf413b82016-07-14 15:18:20 +0530404 }
405
406 /*
407 * Initialize getter and setter when generation file type matches to
408 * builder interface mask.
409 */
410 if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) {
411 addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK);
412 addGeneratedTempFile(SETTER_FOR_INTERFACE_MASK);
413 }
414
415 /*
416 * Initialize getterImpl, setterImpl and attributes when generation file
417 * type matches to builder class mask.
418 */
419 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) {
420 addGeneratedTempFile(ATTRIBUTES_MASK);
421 addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
422 addGeneratedTempFile(SETTER_FOR_CLASS_MASK);
Bharat saraswalaf413b82016-07-14 15:18:20 +0530423 }
424
425 /*
426 * Initialize getterImpl, attributes, constructor, hash code, equals and
427 * to strings when generation file type matches to impl class mask.
428 */
Bharat saraswal8beac342016-08-04 02:00:03 +0530429 if ((getGeneratedJavaFiles() & DEFAULT_CLASS_MASK) != 0) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530430 addGeneratedTempFile(ATTRIBUTES_MASK);
431 addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
432 addGeneratedTempFile(HASH_CODE_IMPL_MASK);
433 addGeneratedTempFile(EQUALS_IMPL_MASK);
434 addGeneratedTempFile(TO_STRING_IMPL_MASK);
Bharat saraswal8beac342016-08-04 02:00:03 +0530435 addGeneratedTempFile(ADD_TO_LIST_IMPL_MASK);
Bharat saraswale50edca2016-08-05 01:58:25 +0530436 addGeneratedTempFile(FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK);
437 addGeneratedTempFile(FILTER_CONTENT_MATCH_FOR_LEAF_MASK);
438 addGeneratedTempFile(FILTER_CONTENT_MATCH_FOR_NODES_MASK);
Bharat saraswalaf413b82016-07-14 15:18:20 +0530439 }
440
441 /*
442 * Initialize temp files to generate type class.
443 */
444 if ((getGeneratedJavaFiles() & GENERATE_TYPE_CLASS) != 0) {
445 addGeneratedTempFile(ATTRIBUTES_MASK);
446 addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
447 addGeneratedTempFile(HASH_CODE_IMPL_MASK);
448 addGeneratedTempFile(EQUALS_IMPL_MASK);
449 addGeneratedTempFile(TO_STRING_IMPL_MASK);
450 addGeneratedTempFile(FROM_STRING_IMPL_MASK);
451 }
452
Vidyashree Ramab3670472016-08-06 15:49:56 +0530453 //Initialize temp files to generate enum class.
Bharat saraswalaf413b82016-07-14 15:18:20 +0530454 if ((getGeneratedJavaFiles() & GENERATE_ENUM_CLASS) != 0) {
455 addGeneratedTempFile(FROM_STRING_IMPL_MASK);
456 }
457
Vidyashree Ramab3670472016-08-06 15:49:56 +0530458 //Set temporary file handles
Bharat saraswalaf413b82016-07-14 15:18:20 +0530459 if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) {
460 setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME));
461 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530462 if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) {
463 setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME));
464 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530465 if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) {
466 setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME));
467 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530468 if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
469 setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME));
470 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530471 if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) {
472 setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME));
473 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530474 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) {
475 setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME));
476 }
477 if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) {
478 setEqualsImplTempFileHandle(getTemporaryFileHandle(EQUALS_METHOD_FILE_NAME));
479 }
480 if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) {
481 setToStringImplTempFileHandle(getTemporaryFileHandle(TO_STRING_METHOD_FILE_NAME));
482 }
483 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
484 setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME));
485 }
Bharat saraswal8beac342016-08-04 02:00:03 +0530486 if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0) {
487 setAddToListInterfaceTempFileHandle(getTemporaryFileHandle(ADD_TO_LIST_INTERFACE_METHOD_FILE_NAME));
488 }
489 if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0) {
490 setAddToListImplTempFileHandle(getTemporaryFileHandle(ADD_TO_LIST_IMPL_METHOD_FILE_NAME));
491 }
492 if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0) {
493 setLeafIdAttributeTempFileHandle(getTemporaryFileHandle(LEAF_IDENTIFIER_ATTRIBUTES_FILE_NAME));
494 }
Bharat saraswale50edca2016-08-05 01:58:25 +0530495 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0) {
496 setIsContentMatchLeafTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_FILE_NAME));
497 }
498 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0) {
499 setIsContentMatchLeafListTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_LIST_FILE_NAME));
500 }
501 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0) {
502 setIsContentMatchNodeTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_NODE_FILE_NAME));
503 }
504 if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) {
505 setEditContentTempFileHandle(getTemporaryFileHandle(EDIT_CONTENT_FILE_NAME));
506 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530507 }
508
509 /**
510 * Adds current node info as and attribute to the parent generated file.
511 *
512 * @param curNode current node which needs to be added as an attribute in the parent generated code
513 * @param isList is list construct
514 * @param pluginConfig plugin configurations
515 * @throws IOException IO operation exception
516 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530517 static void addCurNodeInfoInParentTempFile(YangNode curNode,
518 boolean isList, YangPluginConfig pluginConfig)
Bharat saraswalaf413b82016-07-14 15:18:20 +0530519 throws IOException {
520 YangNode parent = getParentNodeInGenCode(curNode);
521 if (!(parent instanceof JavaCodeGenerator)) {
522 throw new TranslatorException("missing parent node to contain current node info in generated file");
523 }
Shankara-Huaweib7564772016-08-02 18:13:13 +0530524 if (parent instanceof YangJavaGroupingTranslator) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530525 /*
526 * In case of grouping, there is no need to add the information, it
527 * will be taken care in uses
528 */
529 return;
530 }
531 TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) parent)
532 .getTempJavaCodeFragmentFiles().getBeanTempFiles();
533
534 JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode,
535 parent, isList, tempJavaBeanFragmentFiles);
Bharat saraswal8beac342016-08-04 02:00:03 +0530536 tempJavaBeanFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig);
Bharat saraswalaf413b82016-07-14 15:18:20 +0530537 }
538
539 /**
540 * Creates an attribute info object corresponding to a data model node and return it.
541 *
542 * @param curNode current data model node for which the java code generation is being handled
543 * @param targetNode target node in which the current node is an attribute
544 * @param isListNode is the current added attribute needs to be a list
545 * @param tempJavaFragmentFiles temp java fragment files
546 * @return AttributeInfo attribute details required to add in temporary files
547 */
548 public static JavaAttributeInfo getCurNodeAsAttributeInTarget(YangNode curNode,
549 YangNode targetNode, boolean isListNode,
550 TempJavaFragmentFiles tempJavaFragmentFiles) {
551 String curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName();
552 if (curNodeName == null) {
553 updateJavaFileInfo(curNode, null);
554 curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName();
555 }
556
557 /*
558 * Get the import info corresponding to the attribute for import in
559 * generated java files or qualified access
560 */
Shankara-Huaweib7564772016-08-02 18:13:13 +0530561 JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
Bharat saraswalaf413b82016-07-14 15:18:20 +0530562 getCapitalCase(curNodeName));
563 if (!(targetNode instanceof TempJavaCodeFragmentFilesContainer)) {
564 throw new TranslatorException("Parent node does not have file info");
565 }
566 JavaImportData parentImportData = tempJavaFragmentFiles.getJavaImportData();
Bharat saraswale50edca2016-08-05 01:58:25 +0530567 JavaFileInfoTranslator fileInfo = ((JavaFileInfoContainer) targetNode).getJavaFileInfo();
Bharat saraswalaf413b82016-07-14 15:18:20 +0530568
569 boolean isQualified;
Bharat saraswalaab24b92016-08-02 18:43:16 +0530570 if ((tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles)
Bharat saraswal8beac342016-08-04 02:00:03 +0530571 && (qualifiedTypeInfo.getClassInfo().contentEquals(SERVICE))
572 || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE))) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530573
574 isQualified = true;
575 } else {
576 String className;
Bharat saraswalaab24b92016-08-02 18:43:16 +0530577 if (tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles) {
Bharat saraswal8beac342016-08-04 02:00:03 +0530578 className = getCapitalCase(fileInfo.getJavaName()) + SERVICE;
Bharat saraswalaf413b82016-07-14 15:18:20 +0530579 } else {
580 className = getCapitalCase(fileInfo.getJavaName());
581 }
582
583 isQualified = parentImportData.addImportInfo(qualifiedTypeInfo,
584 className, fileInfo.getPackage());
585 }
Vidyashree Ramab3670472016-08-06 15:49:56 +0530586 boolean collectionSetFlag = false;
587 if (curNode instanceof YangList) {
588 YangList yangList = (YangList) curNode;
589 if (yangList.getCompilerAnnotation() != null && yangList.getCompilerAnnotation()
590 .getYangAppDataStructure() != null) {
591 switch (yangList.getCompilerAnnotation().getYangAppDataStructure().getDataStructure()) {
592 case QUEUE: {
593 parentImportData.setQueueToImport(true);
594 collectionSetFlag = true;
595 break;
596 }
597 case SET: {
598 parentImportData.setSetToImport(true);
599 collectionSetFlag = true;
600 break;
601 }
602 default: {
603 // TODO : to be implemented
604 }
605 }
606 }
607 }
Vidyashree Ramab3670472016-08-06 15:49:56 +0530608 if (isListNode && !(collectionSetFlag)) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530609 parentImportData.setIfListImported(true);
610 }
Vidyashree Ramab3670472016-08-06 15:49:56 +0530611 if (curNode instanceof YangList) {
612 return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, isQualified, isListNode,
613 ((YangList) curNode).getCompilerAnnotation());
614 }
Bharat saraswalaf413b82016-07-14 15:18:20 +0530615 return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, isQualified, isListNode);
616 }
617
618 /**
Bharat saraswal64e7e232016-07-14 23:33:55 +0530619 * Returns java attribute for leaf.
620 *
621 * @param tempJavaFragmentFiles temporary generated file
622 * @param leaf YANG leaf
623 * @param yangPluginConfig plugin configurations
624 * @return java attribute for leaf
625 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530626 private static JavaAttributeInfo getJavaAttributeOfLeaf(TempJavaFragmentFiles tempJavaFragmentFiles, YangLeaf leaf,
627 YangPluginConfig yangPluginConfig) {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530628 JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leaf;
629 javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
630 javaLeaf.updateJavaQualifiedInfo();
631 return getAttributeInfoForTheData(
632 javaLeaf.getJavaQualifiedInfo(),
633 javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()),
634 javaLeaf.getDataType(),
635 tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()),
636 false);
637 }
638
639 /**
640 * Returns java attribute for leaf-list.
641 *
642 * @param tempJavaFragmentFiles temporary generated file
643 * @param leafList YANG leaf-list
644 * @param yangPluginConfig plugin configurations
645 * @return java attribute for leaf-list
646 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530647 private static JavaAttributeInfo getJavaAttributeOfLeafList(TempJavaFragmentFiles tempJavaFragmentFiles,
648 YangLeafList leafList,
649 YangPluginConfig yangPluginConfig) {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530650 JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leafList;
651 javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
652 javaLeaf.updateJavaQualifiedInfo();
653 tempJavaFragmentFiles.getJavaImportData().setIfListImported(true);
654 return getAttributeInfoForTheData(
655 javaLeaf.getJavaQualifiedInfo(),
656 javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()),
657 javaLeaf.getDataType(),
658 tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()),
659 true);
660 }
661
Bharat saraswal039f59c2016-07-14 21:57:13 +0530662 /*
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530663 * Retrieves the absolute path where the file needs to be generated.
664 *
665 * @return absolute path where the file needs to be generated
666 */
667 private String getAbsoluteDirPath() {
668 return absoluteDirPath;
669 }
670
671 /**
672 * Sets absolute path where the file needs to be generated.
673 *
Bharat saraswalaf413b82016-07-14 15:18:20 +0530674 * @param absoluteDirPath absolute path where the file needs to be generated.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530675 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530676 void setAbsoluteDirPath(String absoluteDirPath) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530677 this.absoluteDirPath = absoluteDirPath;
678 }
679
680 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530681 * Retrieves the generated java file information.
682 *
683 * @return generated java file information
684 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530685 public JavaFileInfoTranslator getJavaFileInfo() {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530686 return javaFileInfo;
687 }
688
689 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +0530690 * Sets the generated java file information.
691 *
692 * @param javaFileInfo generated java file information
693 */
Bharat saraswale50edca2016-08-05 01:58:25 +0530694 public void setJavaFileInfo(JavaFileInfoTranslator javaFileInfo) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530695 this.javaFileInfo = javaFileInfo;
696 }
697
698 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530699 * Retrieves the generated temp files.
700 *
701 * @return generated temp files
702 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530703 int getGeneratedTempFiles() {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530704 return generatedTempFiles;
705 }
706
707 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +0530708 * Sets generated file files.
709 *
710 * @param fileType generated file type
711 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530712 private void setGeneratedTempFiles(int fileType) {
Bharat saraswalaf413b82016-07-14 15:18:20 +0530713 generatedTempFiles = fileType;
714 }
715
716 /**
Bharat saraswal250a7472016-05-12 13:16:57 +0530717 * Adds to generated temporary files.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530718 *
719 * @param generatedTempFile generated file
720 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530721 void addGeneratedTempFile(int generatedTempFile) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530722 generatedTempFiles |= generatedTempFile;
Bharat saraswal250a7472016-05-12 13:16:57 +0530723 setGeneratedTempFiles(generatedTempFiles);
724 }
725
726 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530727 * Retrieves the generated Java files.
728 *
729 * @return generated Java files
730 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530731 int getGeneratedJavaFiles() {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530732 return getJavaFileInfo().getGeneratedFileTypes();
733 }
734
735 /**
736 * Retrieves the mapped Java class name.
737 *
738 * @return mapped Java class name
739 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530740 String getGeneratedJavaClassName() {
janani b703cfe42016-05-17 13:12:22 +0530741 return getCapitalCase(getJavaFileInfo().getJavaName());
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530742 }
743
744 /**
745 * Retrieves the import data for the generated Java file.
746 *
747 * @return import data for the generated Java file
748 */
749 public JavaImportData getJavaImportData() {
750 return javaImportData;
751 }
752
753 /**
754 * Sets import data for the generated Java file.
755 *
756 * @param javaImportData import data for the generated Java file
757 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530758 void setJavaImportData(JavaImportData javaImportData) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530759 this.javaImportData = javaImportData;
760 }
761
762 /**
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530763 * Retrieves the status of any attributes added.
764 *
765 * @return status of any attributes added
766 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530767 boolean isAttributePresent() {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530768 return isAttributePresent;
769 }
770
771 /**
772 * Sets status of any attributes added.
773 *
774 * @param attributePresent status of any attributes added
775 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530776 private void setAttributePresent(boolean attributePresent) {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530777 isAttributePresent = attributePresent;
778 }
779
780 /**
781 * Returns getter methods's temporary file handle.
782 *
783 * @return temporary file handle
784 */
785 public File getGetterInterfaceTempFileHandle() {
786 return getterInterfaceTempFileHandle;
787 }
788
789 /**
790 * Sets to getter method's temporary file handle.
791 *
792 * @param getterForInterface file handle for to getter method
793 */
794 private void setGetterInterfaceTempFileHandle(File getterForInterface) {
795 getterInterfaceTempFileHandle = getterForInterface;
796 }
797
798 /**
799 * Returns setter method's temporary file handle.
800 *
801 * @return temporary file handle
802 */
803 public File getSetterInterfaceTempFileHandle() {
804 return setterInterfaceTempFileHandle;
805 }
806
807 /**
808 * Sets to setter method's temporary file handle.
809 *
810 * @param setterForInterface file handle for to setter method
811 */
812 private void setSetterInterfaceTempFileHandle(File setterForInterface) {
813 setterInterfaceTempFileHandle = setterForInterface;
814 }
815
816 /**
817 * Returns setter method's impl's temporary file handle.
818 *
819 * @return temporary file handle
820 */
821 public File getSetterImplTempFileHandle() {
822 return setterImplTempFileHandle;
823 }
824
825 /**
826 * Sets to setter method's impl's temporary file handle.
827 *
828 * @param setterImpl file handle for to setter method's implementation class
829 */
830 private void setSetterImplTempFileHandle(File setterImpl) {
831 setterImplTempFileHandle = setterImpl;
832 }
833
834 /**
Bharat saraswal250a7472016-05-12 13:16:57 +0530835 * Returns from string method's temporary file handle.
836 *
837 * @return from string method's temporary file handle
838 */
839 public File getFromStringImplTempFileHandle() {
840 return fromStringImplTempFileHandle;
841 }
842
843 /**
844 * Sets from string method's temporary file handle.
845 *
Bharat saraswalaf413b82016-07-14 15:18:20 +0530846 * @param fromStringImplTempFileHandle from string method's temporary file handle
Bharat saraswal250a7472016-05-12 13:16:57 +0530847 */
848 private void setFromStringImplTempFileHandle(File fromStringImplTempFileHandle) {
849 this.fromStringImplTempFileHandle = fromStringImplTempFileHandle;
850 }
851
852 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530853 * Returns java file handle for interface file.
854 *
855 * @return java file handle for interface file
856 */
857 private File getInterfaceJavaFileHandle() {
858 return interfaceJavaFileHandle;
859 }
860
861 /**
862 * Sets the java file handle for interface file.
863 *
864 * @param interfaceJavaFileHandle java file handle
865 */
866 private void setInterfaceJavaFileHandle(File interfaceJavaFileHandle) {
867 this.interfaceJavaFileHandle = interfaceJavaFileHandle;
868 }
869
870 /**
871 * Returns java file handle for builder interface file.
872 *
873 * @return java file handle for builder interface file
874 */
875 private File getBuilderInterfaceJavaFileHandle() {
876 return builderInterfaceJavaFileHandle;
877 }
878
879 /**
880 * Sets the java file handle for builder interface file.
881 *
882 * @param builderInterfaceJavaFileHandle java file handle
883 */
884 private void setBuilderInterfaceJavaFileHandle(File builderInterfaceJavaFileHandle) {
885 this.builderInterfaceJavaFileHandle = builderInterfaceJavaFileHandle;
886 }
887
888 /**
889 * Returns java file handle for builder class file.
890 *
891 * @return java file handle for builder class file
892 */
893 private File getBuilderClassJavaFileHandle() {
894 return builderClassJavaFileHandle;
895 }
896
897 /**
898 * Sets the java file handle for builder class file.
899 *
900 * @param builderClassJavaFileHandle java file handle
901 */
902 private void setBuilderClassJavaFileHandle(File builderClassJavaFileHandle) {
903 this.builderClassJavaFileHandle = builderClassJavaFileHandle;
904 }
905
906 /**
907 * Returns java file handle for impl class file.
908 *
909 * @return java file handle for impl class file
910 */
911 private File getImplClassJavaFileHandle() {
912 return implClassJavaFileHandle;
913 }
914
915 /**
916 * Sets the java file handle for impl class file.
917 *
918 * @param implClassJavaFileHandle java file handle
919 */
920 private void setImplClassJavaFileHandle(File implClassJavaFileHandle) {
921 this.implClassJavaFileHandle = implClassJavaFileHandle;
922 }
923
924 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530925 * Returns attribute's temporary file handle.
926 *
927 * @return temporary file handle
928 */
929 public File getAttributesTempFileHandle() {
930 return attributesTempFileHandle;
931 }
932
933 /**
934 * Sets attribute's temporary file handle.
935 *
936 * @param attributeForClass file handle for attribute
937 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530938 private void setAttributesTempFileHandle(File attributeForClass) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530939 attributesTempFileHandle = attributeForClass;
940 }
941
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530942 /**
943 * Returns getter method's impl's temporary file handle.
944 *
945 * @return temporary file handle
946 */
947 public File getGetterImplTempFileHandle() {
948 return getterImplTempFileHandle;
949 }
950
951 /**
952 * Sets to getter method's impl's temporary file handle.
953 *
954 * @param getterImpl file handle for to getter method's impl
955 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530956 private void setGetterImplTempFileHandle(File getterImpl) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530957 getterImplTempFileHandle = getterImpl;
958 }
959
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530960 /**
961 * Returns hash code method's temporary file handle.
962 *
963 * @return temporary file handle
964 */
965 public File getHashCodeImplTempFileHandle() {
966 return hashCodeImplTempFileHandle;
967 }
968
969 /**
970 * Sets hash code method's temporary file handle.
971 *
972 * @param hashCodeMethod file handle for hash code method
973 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530974 private void setHashCodeImplTempFileHandle(File hashCodeMethod) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530975 hashCodeImplTempFileHandle = hashCodeMethod;
976 }
977
978 /**
Bharat saraswal64e7e232016-07-14 23:33:55 +0530979 * Returns equals method's temporary file handle.
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530980 *
981 * @return temporary file handle
982 */
983 public File getEqualsImplTempFileHandle() {
984 return equalsImplTempFileHandle;
985 }
986
987 /**
988 * Sets equals method's temporary file handle.
989 *
990 * @param equalsMethod file handle for to equals method
991 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530992 private void setEqualsImplTempFileHandle(File equalsMethod) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530993 equalsImplTempFileHandle = equalsMethod;
994 }
995
996 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530997 * Returns to string method's temporary file handle.
998 *
999 * @return temporary file handle
1000 */
1001 public File getToStringImplTempFileHandle() {
1002 return toStringImplTempFileHandle;
1003 }
1004
1005 /**
1006 * Sets to string method's temporary file handle.
1007 *
1008 * @param toStringMethod file handle for to string method
1009 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301010 private void setToStringImplTempFileHandle(File toStringMethod) {
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301011 toStringImplTempFileHandle = toStringMethod;
1012 }
1013
1014 /**
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301015 * Returns java extends list holder.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301016 *
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301017 * @return java extends list holder
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301018 */
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301019 public JavaExtendsListHolder getJavaExtendsListHolder() {
1020 return javaExtendsListHolder;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301021 }
1022
1023 /**
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301024 * Sets java extends list holder.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301025 *
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301026 * @param javaExtendsListHolder java extends list holder
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301027 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301028 void setJavaExtendsListHolder(JavaExtendsListHolder javaExtendsListHolder) {
Bharat saraswal4aaab4d2016-05-17 14:19:38 +05301029 this.javaExtendsListHolder = javaExtendsListHolder;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301030 }
1031
1032 /**
Bharat saraswale50edca2016-08-05 01:58:25 +05301033 * Adds is filter content match for leaf.
1034 *
1035 * @param attr java attribute
1036 * @throws IOException when fails to do IO operations
1037 */
1038 private void addIsFilerForLeaf(JavaAttributeInfo attr)
1039 throws IOException {
1040 appendToFile(getIsContentMatchLeafTempFileHandle(),
1041 getIsFilerContentMatchForLeaf(attr, attr.getAttributeType()) + NEW_LINE);
1042 }
1043
1044 /**
1045 * Adds is filter content match for leaf-list.
1046 *
1047 * @param attr java attribute
1048 * @throws IOException when fails to do IO operations
1049 */
1050 private void addIsFilerForLeafList(JavaAttributeInfo attr)
1051 throws IOException {
1052 appendToFile(getIsContentMatchLeafTempFileHandle(),
1053 getIsFilerContentMatchForLeafList(attr) + NEW_LINE);
1054 }
1055
1056 /**
1057 * Adds is filter content match for nodes.
1058 *
1059 * @param attr java attribute
1060 * @throws IOException when fails to do IO operations
1061 */
1062 private void addIsFilerForNode(JavaAttributeInfo attr)
1063 throws IOException {
1064 appendToFile(getIsContentMatchLeafTempFileHandle(),
1065 getIsFilterContentForNodes(attr.getAttributeName(), attr.isListAttr()) + NEW_LINE);
1066 }
1067
1068 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301069 * Adds attribute for class.
1070 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301071 * @param attr attribute info
1072 * @param yangPluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301073 * @throws IOException when fails to append to temporary file
1074 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301075 private void addAttribute(JavaAttributeInfo attr, YangPluginConfig yangPluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301076 throws IOException {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301077 appendToFile(getAttributesTempFileHandle(), parseAttribute(attr, yangPluginConfig)
1078 + FOUR_SPACE_INDENTATION);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301079 }
1080
1081 /**
1082 * Adds getter for interface.
1083 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301084 * @param attr attribute info
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301085 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301086 * @throws IOException when fails to append to temporary file
1087 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301088 private void addGetterForInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301089 throws IOException {
Bharat saraswal250a7472016-05-12 13:16:57 +05301090 appendToFile(getGetterInterfaceTempFileHandle(),
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301091 getGetterString(attr, getGeneratedJavaFiles(), pluginConfig) + NEW_LINE);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301092 }
1093
1094 /**
1095 * Adds setter for interface.
1096 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301097 * @param attr attribute info
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301098 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301099 * @throws IOException when fails to append to temporary file
1100 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301101 private void addSetterForInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301102 throws IOException {
1103 appendToFile(getSetterInterfaceTempFileHandle(),
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301104 getSetterString(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles(), pluginConfig)
1105 + NEW_LINE);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301106 }
1107
1108 /**
1109 * Adds setter's implementation for class.
1110 *
Bharat saraswale304c252016-08-16 20:56:20 +05301111 * @param attr attribute info
1112 * @param pluginConfig
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301113 * @throws IOException when fails to append to temporary file
1114 */
Bharat saraswale304c252016-08-16 20:56:20 +05301115 private void addSetterImpl(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301116 throws IOException {
Bharat saraswal8beac342016-08-04 02:00:03 +05301117 if (isRooNode()) {
Bharat saraswale304c252016-08-16 20:56:20 +05301118 appendToFile(getSetterImplTempFileHandle(), getJavaDoc(SETTER_METHOD, attr.getAttributeName(),
1119 attr.isListAttr(), pluginConfig, null) +
Bharat saraswal8beac342016-08-04 02:00:03 +05301120 getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles())
Bharat saraswale304c252016-08-16 20:56:20 +05301121 + NEW_LINE);
Bharat saraswal8beac342016-08-04 02:00:03 +05301122 } else {
1123 appendToFile(getSetterImplTempFileHandle(), getOverRideString() +
1124 getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles())
1125 + NEW_LINE);
1126 }
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301127 }
1128
1129 /**
1130 * Adds getter method's impl for class.
1131 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301132 * @param attr attribute info
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301133 * @param pluginConfig plugin configurations
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301134 * @throws IOException when fails to append to temporary file
1135 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301136 void addGetterImpl(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301137 throws IOException {
1138 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0
1139 || (getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301140 if (!isRooNode()) {
1141 appendToFile(getGetterImplTempFileHandle(), getOverRideString() + getGetterForClass(attr,
1142 getGeneratedJavaFiles()) + NEW_LINE);
1143 } else {
1144 appendToFile(getGetterImplTempFileHandle(), getGetterForClass(attr,
1145 getGeneratedJavaFiles()) + NEW_LINE);
1146 }
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301147 } else {
Vidyashree Ramab3670472016-08-06 15:49:56 +05301148 String appDataStructure = null;
1149 if (attr.getCompilerAnnotation() != null) {
1150 appDataStructure = attr.getCompilerAnnotation().getYangAppDataStructure().getDataStructure().name();
1151 }
janani b703cfe42016-05-17 13:12:22 +05301152 appendToFile(getGetterImplTempFileHandle(),
Vidyashree Ramab3670472016-08-06 15:49:56 +05301153 getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig,
1154 appDataStructure) + getGetterForClass(attr, getGeneratedJavaFiles()) + NEW_LINE);
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301155 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301156 }
1157
1158 /**
Bharat saraswal8beac342016-08-04 02:00:03 +05301159 * Adds add to list interface method.
1160 *
1161 * @param attr attribute
1162 * @param pluginConfig plugin configurations
1163 * @throws IOException when fails to do IO operations
1164 */
1165 private void addAddToListInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig) throws IOException {
1166 appendToFile(getAddToListInterfaceTempFileHandle(),
Vidyashree Ramab3670472016-08-06 15:49:56 +05301167 getJavaDoc(ADD_TO_LIST, getCapitalCase(attr.getAttributeName()), false, pluginConfig, null)
Bharat saraswal8beac342016-08-04 02:00:03 +05301168 + getAddToListMethodInterface(attr) + NEW_LINE);
1169 }
1170
1171 /**
1172 * Adds add to list interface method.
1173 *
1174 * @param attr attribute
1175 * @throws IOException when fails to do IO operations
1176 */
1177 private void addAddToListImpl(JavaAttributeInfo attr) throws IOException {
1178 appendToFile(getAddToListImplTempFileHandle(),
1179 getAddToListMethodImpl(attr) + NEW_LINE);
1180 }
1181
1182 /**
1183 * Adds leaf identifier enum attributes.
1184 *
1185 * @param attr attribute
1186 * @param value value
1187 * @param yangPluginConfig plugin config
1188 * @throws IOException when fails to do IO operations
1189 */
1190 private void addLeafIdAttributes(JavaAttributeInfo attr, int value, YangPluginConfig yangPluginConfig)
1191 throws IOException {
1192 appendToFile(getLeafIdAttributeTempFileHandle(),
1193 FOUR_SPACE_INDENTATION + generateEnumAttributeString(attr.getAttributeName(),
1194 value, yangPluginConfig));
1195 }
1196
1197 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301198 * Adds build method for interface.
1199 *
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301200 * @param pluginConfig plugin configurations
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301201 * @return build method for interface
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301202 * @throws IOException when fails to append to temporary file
1203 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301204 String addBuildMethodForInterface(YangPluginConfig pluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301205 throws IOException {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301206 return parseBuilderInterfaceBuildMethodString(getGeneratedJavaClassName(), pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301207 }
1208
1209 /**
1210 * Adds build method's implementation for class.
1211 *
1212 * @return build method implementation for class
1213 * @throws IOException when fails to append to temporary file
1214 */
1215 String addBuildMethodImpl()
1216 throws IOException {
Bharat saraswal8beac342016-08-04 02:00:03 +05301217 return getBuildString(getGeneratedJavaClassName(), isRooNode()) + NEW_LINE;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301218 }
1219
1220 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301221 * Adds default constructor for class.
1222 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301223 * @param modifier modifier for constructor.
1224 * @param toAppend string which need to be appended with the class name
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301225 * @param pluginConfig plugin configurations
Bharat saraswal8beac342016-08-04 02:00:03 +05301226 * @param isSuffix is value need to be appended as suffix
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301227 * @return default constructor for class
1228 * @throws IOException when fails to append to file
1229 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301230 String addDefaultConstructor(String modifier, String toAppend, YangPluginConfig pluginConfig, boolean isSuffix)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301231 throws IOException {
Bharat saraswal8beac342016-08-04 02:00:03 +05301232 String name = getGeneratedJavaClassName();
1233 if (isRooNode() && !toAppend.equals(BUILDER)) {
1234 name = name + OP_PARAM;
1235 return NEW_LINE
1236 + getDefaultConstructorString(name, modifier,
1237 pluginConfig);
1238 }
1239 if (isSuffix) {
1240 return NEW_LINE +
1241 getDefaultConstructorString(name + toAppend, modifier, pluginConfig);
1242 }
1243 String appended;
1244 if (toAppend.equals(DEFAULT)) {
1245 appended = getCapitalCase(toAppend);
1246 } else {
1247 appended = toAppend;
1248 }
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301249 return NEW_LINE
Bharat saraswal8beac342016-08-04 02:00:03 +05301250 + getDefaultConstructorString(appended + name, modifier,
1251 pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301252 }
1253
1254 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301255 * Adds hash code method for class.
1256 *
1257 * @param attr attribute info
1258 * @throws IOException when fails to append to temporary file
1259 */
1260 private void addHashCodeMethod(JavaAttributeInfo attr)
1261 throws IOException {
1262 appendToFile(getHashCodeImplTempFileHandle(), getHashCodeMethod(attr) + NEW_LINE);
1263 }
1264
1265 /**
1266 * Adds equals method for class.
1267 *
1268 * @param attr attribute info
1269 * @throws IOException when fails to append to temporary file
1270 */
1271 private void addEqualsMethod(JavaAttributeInfo attr)
1272 throws IOException {
1273 appendToFile(getEqualsImplTempFileHandle(), getEqualsMethod(attr) + NEW_LINE);
1274 }
1275
1276 /**
1277 * Adds ToString method for class.
1278 *
1279 * @param attr attribute info
1280 * @throws IOException when fails to append to temporary file
1281 */
1282 private void addToStringMethod(JavaAttributeInfo attr)
1283 throws IOException {
1284 appendToFile(getToStringImplTempFileHandle(), getToStringMethod(attr) + NEW_LINE);
1285 }
1286
1287 /**
Bharat saraswal250a7472016-05-12 13:16:57 +05301288 * Adds from string method for union class.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301289 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301290 * @param javaAttributeInfo type attribute info
Bharat saraswal250a7472016-05-12 13:16:57 +05301291 * @param fromStringAttributeInfo from string attribute info
1292 * @throws IOException when fails to append to temporary file
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301293 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301294 void addFromStringMethod(JavaAttributeInfo javaAttributeInfo,
1295 JavaAttributeInfo fromStringAttributeInfo)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301296 throws IOException {
Bharat saraswal250a7472016-05-12 13:16:57 +05301297 appendToFile(getFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo,
1298 fromStringAttributeInfo) + NEW_LINE);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301299 }
1300
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301301 /**
1302 * Returns a temporary file handle for the specific file type.
1303 *
1304 * @param fileName file name
1305 * @return temporary file handle
1306 * @throws IOException when fails to create new file handle
1307 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301308 File getTemporaryFileHandle(String fileName)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301309 throws IOException {
Bharat saraswald14cbe82016-07-14 13:26:18 +05301310 String path = getTempDirPath(getAbsoluteDirPath());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301311 File dir = new File(path);
Bharat saraswal8beac342016-08-04 02:00:03 +05301312 boolean isCreated;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301313 if (!dir.exists()) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301314 isCreated = dir.mkdirs();
Shankara-Huaweib7564772016-08-02 18:13:13 +05301315 if (!isCreated) {
1316 throw new IOException("failed to create temporary directory for " + fileName);
1317 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301318 }
1319 File file = new File(path + fileName + TEMP_FILE_EXTENSION);
1320 if (!file.exists()) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301321 isCreated = file.createNewFile();
Shankara-Huaweib7564772016-08-02 18:13:13 +05301322 if (!isCreated) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301323 throw new IOException("failed to create temporary file for " + fileName);
Shankara-Huaweib7564772016-08-02 18:13:13 +05301324 }
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301325 } else {
1326 throw new IOException(fileName + " is reused due to YANG naming");
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301327 }
1328 return file;
1329 }
1330
1331 /**
1332 * Returns a temporary file handle for the specific file type.
1333 *
1334 * @param fileName file name
1335 * @return temporary file handle
1336 * @throws IOException when fails to create new file handle
1337 */
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301338 File getJavaFileHandle(String fileName)
1339 throws IOException {
Bharat saraswal8beac342016-08-04 02:00:03 +05301340 return getFileObject(getDirPath(), fileName, JAVA_FILE_EXTENSION, getJavaFileInfo());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301341 }
1342
1343 /**
1344 * Returns data from the temporary files.
1345 *
Bharat saraswalaf413b82016-07-14 15:18:20 +05301346 * @param file temporary file handle
Bharat saraswald14cbe82016-07-14 13:26:18 +05301347 * @param absolutePath absolute path
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301348 * @return stored data from temporary files
1349 * @throws IOException when failed to get data from the given file
1350 */
Bharat saraswald14cbe82016-07-14 13:26:18 +05301351 public String getTemporaryDataFromFileHandle(File file, String absolutePath)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301352 throws IOException {
Bharat saraswald14cbe82016-07-14 13:26:18 +05301353 String path = getTempDirPath(absolutePath);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301354 if (new File(path + file.getName()).exists()) {
1355 return readAppendFile(path + file.getName(), EMPTY_STRING);
1356 } else {
1357 throw new IOException("Unable to get data from the given "
1358 + file.getName() + " file for " + getGeneratedJavaClassName() + PERIOD);
1359 }
1360 }
1361
1362 /**
1363 * Returns temporary directory path.
1364 *
Bharat saraswald14cbe82016-07-14 13:26:18 +05301365 * @param absolutePath absolute path
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301366 * @return directory path
1367 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301368 private String getTempDirPath(String absolutePath) {
Bharat saraswald14cbe82016-07-14 13:26:18 +05301369 return getPackageDirPathFromJavaJPackage(absolutePath) + SLASH + getGeneratedJavaClassName()
Bharat saraswal64e7e232016-07-14 23:33:55 +05301370 + TEMP_FOLDER_NAME_SUFFIX + SLASH;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301371 }
1372
1373 /**
1374 * Parses attribute to get the attribute string.
1375 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301376 * @param attr attribute info
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301377 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301378 * @return attribute string
1379 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301380 String parseAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) {
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301381 //TODO: check if this utility needs to be called or move to the caller
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301382 String attributeName = getCamelCase(attr.getAttributeName(), pluginConfig.getConflictResolver());
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301383 String attributeAccessType = PRIVATE;
1384 if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_INTERFACE_WITH_BUILDER) != 0) {
1385 attributeAccessType = PROTECTED;
1386 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301387 if (attr.isQualifiedName()) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301388 return getJavaAttributeDefinition(attr.getImportInfo().getPkgInfo(),
Bharat saraswal250a7472016-05-12 13:16:57 +05301389 attr.getImportInfo().getClassInfo(),
Vidyashree Ramab3670472016-08-06 15:49:56 +05301390 attributeName, attr.isListAttr(), attributeAccessType, attr.getCompilerAnnotation());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301391 } else {
Bharat saraswal8beac342016-08-04 02:00:03 +05301392 return getJavaAttributeDefinition(null, attr.getImportInfo().getClassInfo(), attributeName,
Vidyashree Ramab3670472016-08-06 15:49:56 +05301393 attr.isListAttr(), attributeAccessType, attr.getCompilerAnnotation());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301394 }
1395 }
1396
1397 /**
1398 * Appends content to temporary file.
1399 *
1400 * @param file temporary file
1401 * @param data data to be appended
1402 * @throws IOException when fails to append to file
1403 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301404 void appendToFile(File file, String data)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301405 throws IOException {
1406 try {
1407 insertDataIntoJavaFile(file, data);
1408 } catch (IOException ex) {
1409 throw new IOException("failed to write in temp file.");
1410 }
1411 }
1412
1413 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301414 * Adds parent's info to current node import list.
1415 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301416 * @param curNode current node for which import list needs to be updated
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301417 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301418 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301419 void addParentInfoInCurNodeTempFile(YangNode curNode, YangPluginConfig pluginConfig) {
Bharat saraswale50edca2016-08-05 01:58:25 +05301420 JavaQualifiedTypeInfoTranslator caseImportInfo = new JavaQualifiedTypeInfoTranslator();
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301421 YangNode parent = getParentNodeInGenCode(curNode);
Bharat saraswale50edca2016-08-05 01:58:25 +05301422 if (curNode instanceof YangCase && parent instanceof YangAugment) {
1423 return;
1424 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301425 if (!(parent instanceof JavaCodeGenerator)) {
1426 throw new TranslatorException("missing parent node to contain current node info in generated file");
1427 }
1428 if (!(curNode instanceof JavaFileInfoContainer)) {
1429 throw new TranslatorException("missing java file information to get the package details "
1430 + "of attribute corresponding to child node");
1431 }
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301432 caseImportInfo.setClassInfo(getCapitalCase(getCamelCase(parent.getName(),
1433 pluginConfig.getConflictResolver())));
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301434 caseImportInfo.setPkgInfo(((JavaFileInfoContainer) parent).getJavaFileInfo().getPackage());
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301435
Bharat saraswale50edca2016-08-05 01:58:25 +05301436 JavaFileInfoTranslator fileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301437
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301438 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301439 .getBeanTempFiles().getJavaImportData().addImportInfo(caseImportInfo,
Bharat saraswald14cbe82016-07-14 13:26:18 +05301440 getCapitalCase(fileInfo.getJavaName()), fileInfo.getPackage());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301441 }
1442
1443 /**
1444 * Adds leaf attributes in generated files.
1445 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301446 * @param listOfLeaves list of YANG leaf
1447 * @param yangPluginConfig plugin config
Bharat saraswal64e7e232016-07-14 23:33:55 +05301448 * @param curNode current node
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301449 * @throws IOException IO operation fail
1450 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301451 private void addLeavesInfoToTempFiles(List<YangLeaf> listOfLeaves,
1452 YangPluginConfig yangPluginConfig, YangNode curNode)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301453 throws IOException {
1454 if (listOfLeaves != null) {
1455 for (YangLeaf leaf : listOfLeaves) {
1456 if (!(leaf instanceof JavaLeafInfoContainer)) {
1457 throw new TranslatorException("Leaf does not have java information");
1458 }
Bharat saraswal64e7e232016-07-14 23:33:55 +05301459 if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
1460 TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
1461 .getTempJavaCodeFragmentFiles().getBeanTempFiles();
1462 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(tempJavaBeanFragmentFiles, leaf,
1463 yangPluginConfig), yangPluginConfig);
1464 } else {
1465 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(this, leaf, yangPluginConfig),
1466 yangPluginConfig);
1467 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301468 }
1469 }
1470 }
1471
1472 /**
1473 * Adds leaf list's attributes in generated files.
1474 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301475 * @param listOfLeafList list of YANG leaves
1476 * @param yangPluginConfig plugin config
Bharat saraswal64e7e232016-07-14 23:33:55 +05301477 * @param curNode current node
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301478 * @throws IOException IO operation fail
1479 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301480 private void addLeafListInfoToTempFiles(List<YangLeafList> listOfLeafList, YangPluginConfig yangPluginConfig,
1481 YangNode curNode) throws IOException {
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301482 if (listOfLeafList != null) {
1483 for (YangLeafList leafList : listOfLeafList) {
1484 if (!(leafList instanceof JavaLeafInfoContainer)) {
1485 throw new TranslatorException("Leaf-list does not have java information");
1486 }
Bharat saraswal64e7e232016-07-14 23:33:55 +05301487 if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
1488 TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
1489 .getTempJavaCodeFragmentFiles().getBeanTempFiles();
1490 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(tempJavaBeanFragmentFiles,
1491 leafList, yangPluginConfig), yangPluginConfig);
1492 } else {
1493 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(this,
1494 leafList, yangPluginConfig), yangPluginConfig);
1495 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301496 }
1497 }
1498 }
1499
1500 /**
Bharat saraswal64e7e232016-07-14 23:33:55 +05301501 * Adds all the leaves in the current data model node as part of the generated temporary file.
Bharat saraswald14cbe82016-07-14 13:26:18 +05301502 *
Bharat saraswal64e7e232016-07-14 23:33:55 +05301503 * @param curNode current node
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301504 * @param yangPluginConfig plugin config
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301505 * @throws IOException IO operation fail
1506 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301507 void addCurNodeLeavesInfoToTempFiles(YangNode curNode,
Shankara-Huaweib7564772016-08-02 18:13:13 +05301508 YangPluginConfig yangPluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301509 throws IOException {
1510 if (!(curNode instanceof YangLeavesHolder)) {
1511 throw new TranslatorException("Data model node does not have any leaves");
1512 }
1513 YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
Bharat saraswal64e7e232016-07-14 23:33:55 +05301514 addLeavesInfoToTempFiles(leavesHolder.getListOfLeaf(), yangPluginConfig, curNode);
1515 addLeafListInfoToTempFiles(leavesHolder.getListOfLeafList(), yangPluginConfig, curNode);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301516 }
1517
1518 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301519 * Adds the new attribute info to the target generated temporary files.
1520 *
Bharat saraswalaf413b82016-07-14 15:18:20 +05301521 * @param newAttrInfo the attribute info that needs to be added to temporary files
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301522 * @param pluginConfig plugin configurations
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301523 * @throws IOException IO operation fail
1524 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301525 void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo newAttrInfo, YangPluginConfig pluginConfig)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301526 throws IOException {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301527 setAttributePresent(true);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301528 if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301529 addAttribute(newAttrInfo, pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301530 }
1531 if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301532 addGetterForInterface(newAttrInfo, pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301533 }
1534 if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) {
Bharat saraswal715d3fc2016-05-17 19:59:16 +05301535 addSetterForInterface(newAttrInfo, pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301536 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301537 if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) {
Bharat saraswale304c252016-08-16 20:56:20 +05301538 addSetterImpl(newAttrInfo, pluginConfig);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301539 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301540 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) {
1541 addHashCodeMethod(newAttrInfo);
1542 }
1543 if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) {
1544 addEqualsMethod(newAttrInfo);
1545 }
1546 if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) {
1547 addToStringMethod(newAttrInfo);
1548 }
Bharat saraswale50edca2016-08-05 01:58:25 +05301549 if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) {
1550 //TODO: add implementation for edit content match.
1551 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301552 if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0 && newAttrInfo.isListAttr()) {
1553 addAddToListImpl(newAttrInfo);
1554 }
1555 if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0 && newAttrInfo.isListAttr()) {
1556 addAddToListInterface(newAttrInfo, pluginConfig);
1557 }
Bharat saraswale50edca2016-08-05 01:58:25 +05301558 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0
1559 && newAttrInfo.getAttributeType() == null) {
1560 addIsFilerForNode(newAttrInfo);
1561 }
1562 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0 && !newAttrInfo.isListAttr()
1563 && newAttrInfo.getAttributeType() != null) {
1564 addIsFilerForLeaf(newAttrInfo);
1565 }
1566 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0 && newAttrInfo.isListAttr()
1567 && newAttrInfo.getAttributeType() != null) {
1568 addIsFilerForLeafList(newAttrInfo);
1569 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301570 if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0 && !newAttrInfo.isListAttr()
1571 && newAttrInfo.getAttributeType() != null) {
1572 leafCount++;
1573 addLeafIdAttributes(newAttrInfo, leafCount, pluginConfig);
1574 }
Bharat saraswal64e7e232016-07-14 23:33:55 +05301575 if (!newAttrInfo.isIntConflict() &&
1576 !newAttrInfo.isLongConflict()) {
1577 if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
1578 addGetterImpl(newAttrInfo, pluginConfig);
1579 }
1580
1581 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
Shankara-Huaweib7564772016-08-02 18:13:13 +05301582 JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo,
Bharat saraswal64e7e232016-07-14 23:33:55 +05301583 pluginConfig.getConflictResolver());
Bharat saraswal250a7472016-05-12 13:16:57 +05301584 /*
1585 * Create a new java attribute info with qualified information of
1586 * wrapper classes.
1587 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301588 JavaAttributeInfo fromStringAttributeInfo = getAttributeInfoForTheData(qualifiedInfoOfFromString,
1589 newAttrInfo.getAttributeName(),
1590 newAttrInfo.getAttributeType(),
1591 getIsQualifiedAccessOrAddToImportList(qualifiedInfoOfFromString), false);
Bharat saraswal250a7472016-05-12 13:16:57 +05301592
Bharat saraswal64e7e232016-07-14 23:33:55 +05301593 addFromStringMethod(newAttrInfo, fromStringAttributeInfo);
1594 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301595 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301596 }
1597
1598 /**
1599 * Returns java class name.
1600 *
1601 * @param suffix for the class name based on the file type
1602 * @return java class name
1603 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301604 String getJavaClassName(String suffix) {
janani b703cfe42016-05-17 13:12:22 +05301605 return getCapitalCase(getJavaFileInfo().getJavaName()) + suffix;
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301606 }
1607
1608 /**
Bharat saraswald14cbe82016-07-14 13:26:18 +05301609 * Returns java class name.
1610 *
Bharat saraswal8beac342016-08-04 02:00:03 +05301611 * @param node YANG node
Bharat saraswald14cbe82016-07-14 13:26:18 +05301612 * @return java class name
1613 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301614 private String getImplClassName(YangNode node) {
1615 if (node instanceof YangModule || node instanceof YangSubModule) {
1616 return getCapitalCase(getJavaFileInfo().getJavaName()) + OP_PARAM;
1617 }
Bharat saraswald14cbe82016-07-14 13:26:18 +05301618 return getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo().getJavaName());
1619 }
1620
1621 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301622 * Returns the directory path.
1623 *
1624 * @return directory path
1625 */
1626 private String getDirPath() {
1627 return getJavaFileInfo().getPackageFilePath();
1628 }
1629
1630 /**
1631 * Constructs java code exit.
1632 *
1633 * @param fileType generated file type
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301634 * @param curNode current YANG node
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301635 * @throws IOException when fails to generate java files
1636 */
1637 public void generateJavaFile(int fileType, YangNode curNode)
1638 throws IOException {
Bharat saraswalaf413b82016-07-14 15:18:20 +05301639 List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles()
1640 .getJavaImportData().getImports();
Bharat saraswal8beac342016-08-04 02:00:03 +05301641 if (curNode instanceof YangAugmentableNode) {
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301642 addImportsForAugmentableClass(imports, true, true, curNode);
Bharat saraswal8beac342016-08-04 02:00:03 +05301643 }
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301644 createPackage(curNode);
Vidyashree Ramab3670472016-08-06 15:49:56 +05301645
1646 //Generate java code.
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301647 if ((fileType & INTERFACE_MASK) != 0 || (fileType &
1648 BUILDER_INTERFACE_MASK) != 0) {
Vidyashree Ramab3670472016-08-06 15:49:56 +05301649
1650 //Create interface file.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301651 setInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(INTERFACE_FILE_NAME_SUFFIX)));
1652 setInterfaceJavaFileHandle(
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301653 generateInterfaceFile(getInterfaceJavaFileHandle(), imports, curNode, isAttributePresent()));
Bharat saraswal8beac342016-08-04 02:00:03 +05301654 if (!(curNode instanceof YangModule) && !(curNode instanceof YangSubModule)) {
Vidyashree Ramab3670472016-08-06 15:49:56 +05301655
1656 //Create builder interface file.
Bharat saraswal8beac342016-08-04 02:00:03 +05301657 if ((fileType & BUILDER_INTERFACE_MASK) != 0) {
1658 setBuilderInterfaceJavaFileHandle(
1659 getJavaFileHandle(getJavaClassName(BUILDER_INTERFACE_FILE_NAME_SUFFIX)));
1660 setBuilderInterfaceJavaFileHandle(
1661 generateBuilderInterfaceFile(getBuilderInterfaceJavaFileHandle(), curNode,
1662 isAttributePresent()));
Vidyashree Ramab3670472016-08-06 15:49:56 +05301663
1664 //Append builder interface file to interface file and close it.
Bharat saraswal8beac342016-08-04 02:00:03 +05301665 mergeJavaFiles(getBuilderInterfaceJavaFileHandle(), getInterfaceJavaFileHandle());
Bharat saraswal8beac342016-08-04 02:00:03 +05301666 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301667 }
1668 insertDataIntoJavaFile(getInterfaceJavaFileHandle(), getJavaClassDefClose());
Bharat saraswale304c252016-08-16 20:56:20 +05301669 validateLineLength(getInterfaceJavaFileHandle());
Bharat saraswal8beac342016-08-04 02:00:03 +05301670 if (curNode instanceof YangAugmentableNode) {
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301671 addImportsForAugmentableClass(imports, false, true, curNode);
Bharat saraswald14cbe82016-07-14 13:26:18 +05301672 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301673 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301674 if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & DEFAULT_CLASS_MASK) != 0) {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301675 if (isAttributePresent()) {
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301676 addImportsToStringAndHasCodeMethods(imports, true);
Bharat saraswal8beac342016-08-04 02:00:03 +05301677 addArrayListImport(imports);
Bharat saraswalaf413b82016-07-14 15:18:20 +05301678 }
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301679
1680 boolean isLeavesPresent;
1681 if (curNode instanceof YangLeavesHolder) {
1682 YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
1683 isLeavesPresent = leavesHolder.getListOfLeaf() != null && !leavesHolder.getListOfLeaf().isEmpty()
1684 || leavesHolder.getListOfLeafList() != null && !leavesHolder.getListOfLeafList().isEmpty();
1685 if (isLeavesPresent) {
1686 addBitsetImport(imports);
1687 }
1688 }
Bharat saraswalaf413b82016-07-14 15:18:20 +05301689 if (curNode instanceof YangAugmentableNode) {
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301690 addImportsForAugmentableClass(imports, true, false, curNode);
Bharat saraswale50edca2016-08-05 01:58:25 +05301691 addInvocationExceptionImport(imports);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301692 }
Bharat saraswal250a7472016-05-12 13:16:57 +05301693 sortImports(imports);
Vidyashree Ramab3670472016-08-06 15:49:56 +05301694
1695 //Create impl class file.
Bharat saraswal8beac342016-08-04 02:00:03 +05301696 setImplClassJavaFileHandle(getJavaFileHandle(getImplClassName(curNode)));
Bharat saraswald14cbe82016-07-14 13:26:18 +05301697 setImplClassJavaFileHandle(
Bharat saraswal8beac342016-08-04 02:00:03 +05301698 generateDefaultClassFile(getImplClassJavaFileHandle(), curNode, isAttributePresent(), imports));
Vidyashree Ramab3670472016-08-06 15:49:56 +05301699
1700 //Create builder class file.
Bharat saraswald14cbe82016-07-14 13:26:18 +05301701 if ((fileType & BUILDER_CLASS_MASK) != 0) {
1702 setBuilderClassJavaFileHandle(getJavaFileHandle(getJavaClassName(BUILDER_CLASS_FILE_NAME_SUFFIX)));
1703 setBuilderClassJavaFileHandle(
1704 generateBuilderClassFile(getBuilderClassJavaFileHandle(), curNode,
1705 isAttributePresent()));
Vidyashree Ramab3670472016-08-06 15:49:56 +05301706
1707 //Append impl class to builder class and close it.
Bharat saraswald14cbe82016-07-14 13:26:18 +05301708 mergeJavaFiles(getBuilderClassJavaFileHandle(), getImplClassJavaFileHandle());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301709 }
Bharat saraswald14cbe82016-07-14 13:26:18 +05301710 insertDataIntoJavaFile(getImplClassJavaFileHandle(), getJavaClassDefClose());
Bharat saraswale304c252016-08-16 20:56:20 +05301711 validateLineLength(getImplClassJavaFileHandle());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301712 }
Vidyashree Ramab3670472016-08-06 15:49:56 +05301713 //Close all the file handles.
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301714 freeTemporaryResources(false);
1715 }
1716
Vidyashree Ramab3670472016-08-06 15:49:56 +05301717 //Adds import for array list.
Bharat saraswal8beac342016-08-04 02:00:03 +05301718 private void addArrayListImport(List<String> imports) {
1719 if (imports.contains(getJavaImportData().getImportForList())) {
1720 imports.add(ARRAY_LIST_IMPORT);
1721 }
1722 }
1723
Bharat saraswal8beac342016-08-04 02:00:03 +05301724 private void addBitsetImport(List<String> imports) {
1725 imports.add(getJavaImportData().getImportForToBitSet());
Bharat saraswald14cbe82016-07-14 13:26:18 +05301726 }
1727
1728 /**
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301729 * Adds imports for ToString and HashCodeMethod.
1730 *
Bharat saraswal039f59c2016-07-14 21:57:13 +05301731 * @param imports import list
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301732 * @param operation add or remove
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301733 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301734 void addImportsToStringAndHasCodeMethods(List<String> imports, boolean operation) {
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301735 if (operation) {
1736 imports.add(getJavaImportData().getImportForHashAndEquals());
1737 imports.add(getJavaImportData().getImportForToString());
1738 } else {
1739 imports.remove(getJavaImportData().getImportForHashAndEquals());
1740 imports.remove(getJavaImportData().getImportForToString());
1741 }
1742 }
1743
1744 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +05301745 * Adds import for map and hash map.
1746 *
Bharat saraswal8beac342016-08-04 02:00:03 +05301747 * @param imports import list
1748 * @param operations true for adding and false for deletion
1749 * @param isInterfaceFile if need to add in interface file
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301750 * @param curNode current node
Bharat saraswalaf413b82016-07-14 15:18:20 +05301751 */
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301752 private void addImportsForAugmentableClass(List<String> imports, boolean operations, boolean isInterfaceFile,
1753 YangNode curNode) {
Bharat saraswal039f59c2016-07-14 21:57:13 +05301754 if (operations) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301755 if (!isInterfaceFile) {
1756 imports.add(getJavaImportData().getHashMapImport());
1757 }
Gaurav Agrawal8a147522016-08-10 13:43:01 +05301758 // Add import for hash map only if node is not a YANG choice.
1759 if (!(curNode instanceof YangChoice)) {
1760 imports.add(getJavaImportData().getMapImport());
1761 }
Bharat saraswal039f59c2016-07-14 21:57:13 +05301762 } else {
Bharat saraswal8beac342016-08-04 02:00:03 +05301763 if (!isInterfaceFile) {
1764 imports.remove(getJavaImportData().getHashMapImport());
1765 }
Bharat saraswal039f59c2016-07-14 21:57:13 +05301766 imports.remove(getJavaImportData().getMapImport());
Bharat saraswald14cbe82016-07-14 13:26:18 +05301767 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301768 sortImports(imports);
Bharat saraswald14cbe82016-07-14 13:26:18 +05301769 }
1770
1771 /**
Bharat saraswal8beac342016-08-04 02:00:03 +05301772 * Adds invocation exception import.
Bharat saraswal039f59c2016-07-14 21:57:13 +05301773 *
1774 * @param imports list of imports
Bharat saraswal039f59c2016-07-14 21:57:13 +05301775 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301776 private void addInvocationExceptionImport(List<String> imports) {
1777 imports.add(INVOCATION_TARGET_EXCEPTION_IMPORT);
Bharat saraswal039f59c2016-07-14 21:57:13 +05301778 }
1779
1780 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301781 * Removes all temporary file handles.
1782 *
Bharat saraswal64e7e232016-07-14 23:33:55 +05301783 * @param isErrorOccurred flag to tell translator that error has occurred while file generation
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301784 * @throws IOException when failed to delete the temporary files
1785 */
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301786 public void freeTemporaryResources(boolean isErrorOccurred)
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301787 throws IOException {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301788 /*
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301789 * Close all java file handles and when error occurs delete the files.
1790 */
1791 if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) {
Bharat saraswal64e7e232016-07-14 23:33:55 +05301792 closeFile(getInterfaceJavaFileHandle(), isErrorOccurred);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301793 }
1794 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) {
Bharat saraswald14cbe82016-07-14 13:26:18 +05301795 closeFile(getBuilderClassJavaFileHandle(), true);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301796 }
1797 if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) {
1798 closeFile(getBuilderInterfaceJavaFileHandle(), true);
1799 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301800 if ((getGeneratedJavaFiles() & DEFAULT_CLASS_MASK) != 0) {
Bharat saraswal64e7e232016-07-14 23:33:55 +05301801 closeFile(getImplClassJavaFileHandle(), isErrorOccurred);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301802 }
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +05301803 /*
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301804 * Close all temporary file handles and delete the files.
1805 */
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301806 if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
1807 closeFile(getGetterImplTempFileHandle(), true);
1808 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301809 if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) {
1810 closeFile(getAttributesTempFileHandle(), true);
1811 }
1812 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) {
1813 closeFile(getHashCodeImplTempFileHandle(), true);
1814 }
1815 if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) {
1816 closeFile(getToStringImplTempFileHandle(), true);
1817 }
1818 if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) {
1819 closeFile(getEqualsImplTempFileHandle(), true);
1820 }
Bharat saraswal250a7472016-05-12 13:16:57 +05301821 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
1822 closeFile(getFromStringImplTempFileHandle(), true);
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301823 }
Bharat saraswal8beac342016-08-04 02:00:03 +05301824 if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0) {
1825 closeFile(getAddToListImplTempFileHandle(), true);
1826 }
1827 if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0) {
1828 closeFile(getAddToListInterfaceTempFileHandle(), true);
1829 }
1830 if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0) {
1831 closeFile(getLeafIdAttributeTempFileHandle(), true);
1832 }
Bharat saraswale50edca2016-08-05 01:58:25 +05301833 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0) {
1834 closeFile(getIsContentMatchLeafTempFileHandle(), true);
1835 }
1836 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0) {
1837 closeFile(getIsContentMatchLeafListTempFileHandle(), true);
1838 }
1839 if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0) {
1840 closeFile(getIsContentMatchNodeTempFileHandle(), true);
1841 }
1842 if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) {
1843 closeFile(getEditContentTempFileHandle(), true);
1844 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301845 }
1846
1847 /**
Bharat saraswalaf413b82016-07-14 15:18:20 +05301848 * Returns if the attribute needs to be accessed in a qualified manner or not, if it needs to be imported, then the
1849 * same needs to be done.
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301850 *
1851 * @param importInfo import info for the current attribute being added
1852 * @return status of the qualified access to the attribute
1853 */
Bharat saraswal64e7e232016-07-14 23:33:55 +05301854 boolean getIsQualifiedAccessOrAddToImportList(
Shankara-Huaweib7564772016-08-02 18:13:13 +05301855 JavaQualifiedTypeInfoTranslator importInfo) {
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +05301856 return getJavaImportData().addImportInfo(importInfo, getGeneratedJavaClassName(),
1857 getJavaFileInfo().getPackage());
Vinod Kumar S79a374b2016-04-30 21:09:15 +05301858 }
1859
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301860 /**
Bharat saraswal8beac342016-08-04 02:00:03 +05301861 * Returns temp file handle for add to list interface.
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301862 *
Bharat saraswal8beac342016-08-04 02:00:03 +05301863 * @return temp file handle for add to list interface
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301864 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301865 public File getAddToListInterfaceTempFileHandle() {
1866 return addToListInterfaceTempFileHandle;
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301867 }
1868
1869 /**
Bharat saraswal8beac342016-08-04 02:00:03 +05301870 * Sets temp file handle for add to list interface.
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301871 *
Bharat saraswal8beac342016-08-04 02:00:03 +05301872 * @param addToListInterfaceTempFileHandle temp file handle for add to list interface
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301873 */
Bharat saraswal8beac342016-08-04 02:00:03 +05301874 private void setAddToListInterfaceTempFileHandle(File addToListInterfaceTempFileHandle) {
1875 this.addToListInterfaceTempFileHandle = addToListInterfaceTempFileHandle;
1876 }
1877
1878 /**
1879 * Returns temp file handle for add to list impl.
1880 *
1881 * @return temp file handle for add to list impl
1882 */
1883 public File getAddToListImplTempFileHandle() {
1884 return addToListImplTempFileHandle;
1885 }
1886
1887 /**
1888 * Sets temp file handle for add to list impl.
1889 *
1890 * @param addToListImplTempFileHandle temp file handle for add to list impl
1891 */
1892 private void setAddToListImplTempFileHandle(File addToListImplTempFileHandle) {
1893 this.addToListImplTempFileHandle = addToListImplTempFileHandle;
1894 }
1895
1896 /**
1897 * Returns temp file handle for leaf identifier attributes.
1898 *
1899 * @return temp file handle for leaf identifier attributes
1900 */
1901 public File getLeafIdAttributeTempFileHandle() {
1902 return leafIdAttributeTempFileHandle;
1903 }
1904
1905 /**
1906 * Sets temp file handle for leaf identifier attributes.
1907 *
Bharat saraswale50edca2016-08-05 01:58:25 +05301908 * @param leafIdAttributeTempFileHandle temp file handle for leaf identifier attributes
Bharat saraswal8beac342016-08-04 02:00:03 +05301909 */
1910 private void setLeafIdAttributeTempFileHandle(File leafIdAttributeTempFileHandle) {
1911 this.leafIdAttributeTempFileHandle = leafIdAttributeTempFileHandle;
1912 }
1913
1914 /**
1915 * Returns if root node is set.
1916 *
1917 * @return true if root node
1918 */
1919 private boolean isRooNode() {
1920 return isRooNode;
1921 }
1922
1923 /**
1924 * Sets true if root node.
1925 *
1926 * @param rooNode true if root node
1927 */
Bharat saraswale50edca2016-08-05 01:58:25 +05301928 void setRooNode(boolean rooNode) {
Bharat saraswal8beac342016-08-04 02:00:03 +05301929 isRooNode = rooNode;
Shankara-Huaweia1039e52016-07-14 16:53:09 +05301930 }
Bharat saraswale50edca2016-08-05 01:58:25 +05301931
1932 /**
1933 * Returns temp file for is content match.
1934 *
1935 * @return temp file for is content match
1936 */
1937 public File getIsContentMatchLeafTempFileHandle() {
1938 return isContentMatchLeafTempFileHandle;
1939 }
1940
1941 /**
1942 * Sets temp file handle for is content match.
1943 *
1944 * @param isContentMatchLeafTempFileHandle temp file handle for is content match
1945 */
1946 private void setIsContentMatchLeafTempFileHandle(File isContentMatchLeafTempFileHandle) {
1947 this.isContentMatchLeafTempFileHandle = isContentMatchLeafTempFileHandle;
1948 }
1949
1950 /**
1951 * Returns temp file for edit content file.
1952 *
1953 * @return temp file for edit content file
1954 */
1955 public File getEditContentTempFileHandle() {
1956 return editContentTempFileHandle;
1957 }
1958
1959 /**
1960 * Sets temp file for edit content file.
1961 *
1962 * @param editContentTempFileHandle temp file for edit content file
1963 */
1964 private void setEditContentTempFileHandle(File editContentTempFileHandle) {
1965 this.editContentTempFileHandle = editContentTempFileHandle;
1966 }
1967
1968 /**
1969 * Returns temp file for is content match.
1970 *
1971 * @return temp file for is content match
1972 */
1973 public File getIsContentMatchLeafListTempFileHandle() {
1974 return isContentMatchLeafListTempFileHandle;
1975 }
1976
1977 /**
1978 * Sets temp file handle for is content match.
1979 *
1980 * @param isContentMatchLeafListTempFileHandle temp file handle for is content match
1981 */
1982 private void setIsContentMatchLeafListTempFileHandle(File isContentMatchLeafListTempFileHandle) {
1983 this.isContentMatchLeafListTempFileHandle = isContentMatchLeafListTempFileHandle;
1984 }
1985
1986 /**
1987 * Returns temp file for is content match.
1988 *
1989 * @return temp file for is content match
1990 */
1991 public File getIsContentMatchNodeTempFileHandle() {
1992 return isContentMatchNodeTempFileHandle;
1993 }
1994
1995 /**
1996 * Sets temp file handle for is content match.
1997 *
1998 * @param isContentMatchNodeTempFileHandle temp file handle for is content match
1999 */
2000 private void setIsContentMatchNodeTempFileHandle(File isContentMatchNodeTempFileHandle) {
2001 this.isContentMatchNodeTempFileHandle = isContentMatchNodeTempFileHandle;
2002 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +05302003}