Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.yangutils.translator.tojava; |
| 17 | |
| 18 | import java.io.File; |
| 19 | import java.io.IOException; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 20 | import java.util.List; |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 21 | |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.datamodel.YangAugment; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.datamodel.YangAugmentableNode; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 24 | import org.onosproject.yangutils.datamodel.YangCase; |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 25 | import org.onosproject.yangutils.datamodel.YangChoice; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 26 | import org.onosproject.yangutils.datamodel.YangLeaf; |
| 27 | import org.onosproject.yangutils.datamodel.YangLeafList; |
| 28 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 29 | import org.onosproject.yangutils.datamodel.YangList; |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 30 | import org.onosproject.yangutils.datamodel.YangModule; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 31 | import org.onosproject.yangutils.datamodel.YangNode; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 32 | import org.onosproject.yangutils.datamodel.YangSubModule; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 33 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
| 34 | import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 35 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGroupingTranslator; |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 36 | import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder; |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 37 | import org.onosproject.yangutils.utils.io.YangPluginConfig; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 38 | |
Bharat saraswal | c2d3be1 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 39 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 40 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
| 41 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 42 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 43 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 44 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 45 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; |
| 46 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 47 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 48 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_IMPL_MASK; |
| 49 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_INTERFACE_MASK; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 50 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 51 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EDIT_CONTENT_MASK; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 52 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 53 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK; |
| 54 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_LEAF_MASK; |
| 55 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FILTER_CONTENT_MATCH_FOR_NODES_MASK; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 56 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 57 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; |
| 58 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK; |
| 59 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 60 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 61 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; |
| 62 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; |
| 63 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; |
| 64 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 65 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedInfoOfFromString; |
| 66 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedTypeInfoOfCurNode; |
Gaurav Agrawal | bfce934 | 2016-06-15 13:58:01 +0530 | [diff] [blame] | 67 | import static org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 68 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString; |
| 69 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefinition; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 70 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 71 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.sortImports; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 72 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile; |
| 73 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 74 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateDefaultClassFile; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 75 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 76 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 77 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 78 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddToListMethodImpl; |
| 79 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddToListMethodInterface; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 80 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 81 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString; |
| 82 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 83 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethod; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 84 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; |
| 85 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString; |
| 86 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethod; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 87 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 88 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass; |
| 89 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString; |
| 90 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 91 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString; |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 92 | import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator |
| 93 | .getSubtreeFilteringForLeaf; |
| 94 | import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator |
| 95 | .getSubtreeFilteringForLeafList; |
| 96 | import static org.onosproject.yangutils.translator.tojava.utils.SubtreeFilteringMethodsGenerator |
| 97 | .getSubtreeFilteringForNode; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 98 | import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST_IMPORT; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 99 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 100 | import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 101 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
| 102 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 103 | import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 104 | import static org.onosproject.yangutils.utils.UtilConstants.INVOCATION_TARGET_EXCEPTION_IMPORT; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 105 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 106 | import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 107 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 108 | import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE; |
| 109 | import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED; |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 110 | import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 111 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 112 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 113 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 114 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ADD_TO_LIST; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 115 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 116 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD; |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 117 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 118 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath; |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 119 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
| 120 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
| 121 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 122 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; |
| 123 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles; |
Bharat saraswal | c2d3be1 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 124 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 125 | |
| 126 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 127 | * Represents implementation of java code fragments temporary implementations. Manages the common temp file required for |
| 128 | * Java file(s) generated. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 129 | */ |
| 130 | public class TempJavaFragmentFiles { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 131 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 132 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 133 | * File type extension for java classes. |
| 134 | */ |
| 135 | private static final String JAVA_FILE_EXTENSION = ".java"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 136 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 137 | /** |
| 138 | * File type extension for temporary classes. |
| 139 | */ |
| 140 | private static final String TEMP_FILE_EXTENSION = ".tmp"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 141 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 142 | /** |
| 143 | * Folder suffix for temporary files folder. |
| 144 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 145 | private static final String TEMP_FOLDER_NAME_SUFFIX = "-Temp"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 146 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 147 | /** |
| 148 | * File name for getter method. |
| 149 | */ |
| 150 | private static final String GETTER_METHOD_FILE_NAME = "GetterMethod"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 151 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 152 | /** |
| 153 | * File name for setter method. |
| 154 | */ |
| 155 | private static final String SETTER_METHOD_FILE_NAME = "SetterMethod"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 156 | |
| 157 | /** |
| 158 | * File name for getter method implementation. |
| 159 | */ |
| 160 | private static final String GETTER_METHOD_IMPL_FILE_NAME = "GetterMethodImpl"; |
| 161 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 162 | /** |
| 163 | * File name for setter method implementation. |
| 164 | */ |
| 165 | private static final String SETTER_METHOD_IMPL_FILE_NAME = "SetterMethodImpl"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 166 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 167 | /** |
| 168 | * File name for attributes. |
| 169 | */ |
| 170 | private static final String ATTRIBUTE_FILE_NAME = "Attributes"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 171 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 172 | /** |
| 173 | * File name for to string method. |
| 174 | */ |
| 175 | private static final String TO_STRING_METHOD_FILE_NAME = "ToString"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 176 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 177 | /** |
| 178 | * File name for hash code method. |
| 179 | */ |
| 180 | private static final String HASH_CODE_METHOD_FILE_NAME = "HashCode"; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 181 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 182 | /** |
| 183 | * File name for equals method. |
| 184 | */ |
| 185 | private static final String EQUALS_METHOD_FILE_NAME = "Equals"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 186 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 187 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 188 | * File name for from string method. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 189 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 190 | private static final String FROM_STRING_METHOD_FILE_NAME = "FromString"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 191 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 192 | /** |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 193 | * File name for from add to list interface method. |
| 194 | */ |
| 195 | private static final String ADD_TO_LIST_INTERFACE_METHOD_FILE_NAME = "addToList"; |
| 196 | |
| 197 | /** |
| 198 | * File name for from add to list impl method. |
| 199 | */ |
| 200 | private static final String ADD_TO_LIST_IMPL_METHOD_FILE_NAME = "addToListImpl"; |
| 201 | |
| 202 | /** |
| 203 | * File name for from leaf identifier attributes. |
| 204 | */ |
| 205 | private static final String LEAF_IDENTIFIER_ATTRIBUTES_FILE_NAME = "leafIdentifierAtr"; |
| 206 | |
| 207 | /** |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 208 | * File name for is filter content leaf match. |
| 209 | */ |
| 210 | private static final String FILTER_CONTENT_MATCH_LEAF_FILE_NAME = "isFilterContentMatchLeafMask"; |
| 211 | |
| 212 | /** |
| 213 | * File name for is filter content leaf-list match. |
| 214 | */ |
| 215 | private static final String FILTER_CONTENT_MATCH_LEAF_LIST_FILE_NAME = "isFilterContentMatchLeafListMask"; |
| 216 | |
| 217 | /** |
| 218 | * File name for is filter content node match. |
| 219 | */ |
| 220 | private static final String FILTER_CONTENT_MATCH_NODE_FILE_NAME = "isFilterContentMatchNodeMask"; |
| 221 | |
| 222 | /** |
| 223 | * File name for edit content file. |
| 224 | */ |
| 225 | private static final String EDIT_CONTENT_FILE_NAME = "editContentFile"; |
| 226 | |
| 227 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 228 | * File name for interface java file name suffix. |
| 229 | */ |
| 230 | private static final String INTERFACE_FILE_NAME_SUFFIX = EMPTY_STRING; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 231 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 232 | /** |
| 233 | * File name for builder interface file name suffix. |
| 234 | */ |
| 235 | private static final String BUILDER_INTERFACE_FILE_NAME_SUFFIX = BUILDER + INTERFACE; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 236 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 237 | /** |
| 238 | * File name for builder class file name suffix. |
| 239 | */ |
| 240 | private static final String BUILDER_CLASS_FILE_NAME_SUFFIX = BUILDER; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 241 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 242 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 243 | * Information about the java files being generated. |
| 244 | */ |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 245 | private JavaFileInfoTranslator javaFileInfo; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 246 | |
| 247 | /** |
| 248 | * Imported class info. |
| 249 | */ |
| 250 | private JavaImportData javaImportData; |
| 251 | |
| 252 | /** |
| 253 | * The variable which guides the types of temporary files generated using the temporary generated file types mask. |
| 254 | */ |
| 255 | private int generatedTempFiles; |
| 256 | |
| 257 | /** |
| 258 | * Absolute path where the target java file needs to be generated. |
| 259 | */ |
| 260 | private String absoluteDirPath; |
| 261 | |
| 262 | /** |
| 263 | * Contains all the interface(s)/class name which will be extended by generated files. |
| 264 | */ |
| 265 | private JavaExtendsListHolder javaExtendsListHolder; |
| 266 | |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 267 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 268 | * Java file handle for interface file. |
| 269 | */ |
| 270 | private File interfaceJavaFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 271 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 272 | /** |
| 273 | * Java file handle for builder interface file. |
| 274 | */ |
| 275 | private File builderInterfaceJavaFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 276 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 277 | /** |
| 278 | * Java file handle for builder class file. |
| 279 | */ |
| 280 | private File builderClassJavaFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 281 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 282 | /** |
| 283 | * Java file handle for impl class file. |
| 284 | */ |
| 285 | private File implClassJavaFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 286 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 287 | /** |
| 288 | * Temporary file handle for attribute. |
| 289 | */ |
| 290 | private File attributesTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 291 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 292 | /** |
| 293 | * Temporary file handle for getter of interface. |
| 294 | */ |
| 295 | private File getterInterfaceTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 296 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 297 | /** |
| 298 | * Temporary file handle for setter of interface. |
| 299 | */ |
| 300 | private File setterInterfaceTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 301 | |
| 302 | /** |
| 303 | * Temporary file handle for getter of class. |
| 304 | */ |
| 305 | private File getterImplTempFileHandle; |
| 306 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 307 | /** |
| 308 | * Temporary file handle for setter of class. |
| 309 | */ |
| 310 | private File setterImplTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 311 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 312 | /** |
| 313 | * Temporary file handle for hash code method of class. |
| 314 | */ |
| 315 | private File hashCodeImplTempFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 316 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 317 | /** |
| 318 | * Temporary file handle for equals method of class. |
| 319 | */ |
| 320 | private File equalsImplTempFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 321 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 322 | /** |
| 323 | * Temporary file handle for to string method of class. |
| 324 | */ |
| 325 | private File toStringImplTempFileHandle; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 326 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 327 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 328 | * Temporary file handle for from string method of class. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 329 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 330 | private File fromStringImplTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 331 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 332 | /** |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 333 | * Temporary file handle for add to list interface method of class. |
| 334 | */ |
| 335 | private File addToListInterfaceTempFileHandle; |
| 336 | |
| 337 | /** |
| 338 | * Temporary file handle for add to list impl method of class. |
| 339 | */ |
| 340 | private File addToListImplTempFileHandle; |
| 341 | |
| 342 | /** |
| 343 | * Temporary file handle for leaf id attributes of enum. |
| 344 | */ |
| 345 | private File leafIdAttributeTempFileHandle; |
| 346 | |
| 347 | /** |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 348 | * Temporary file handle for is content match method for leaf-list. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 349 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 350 | private File getSubtreeFilteringForListTempFileHandle; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 351 | |
| 352 | /** |
| 353 | * Temporary file handle for is content match method for node. |
| 354 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 355 | private File getSubtreeFilteringForChildNodeTempFileHandle; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 356 | |
| 357 | /** |
| 358 | * Temporary file handle for is content match method for leaf. |
| 359 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 360 | private File subtreeFilteringForLeafTempFileHandle; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 361 | |
| 362 | /** |
| 363 | * Temporary file handle for edit content file. |
| 364 | */ |
| 365 | private File editContentTempFileHandle; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 366 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 367 | /** |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 368 | * Leaf count. |
| 369 | */ |
| 370 | private int leafCount = 0; |
| 371 | |
| 372 | /** |
| 373 | * If current node is root node. |
| 374 | */ |
| 375 | private boolean isRooNode; |
| 376 | |
| 377 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 378 | * Is attribute added. |
| 379 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 380 | private boolean isAttributePresent; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 381 | |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 382 | TempJavaFragmentFiles() { |
| 383 | } |
| 384 | |
| 385 | /** |
| 386 | * Creates an instance of temporary java code fragment. |
| 387 | * |
| 388 | * @param javaFileInfo generated java file information |
| 389 | * @throws IOException when fails to create new file handle |
| 390 | */ |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 391 | TempJavaFragmentFiles(JavaFileInfoTranslator javaFileInfo) |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 392 | throws IOException { |
| 393 | setJavaExtendsListHolder(new JavaExtendsListHolder()); |
| 394 | setJavaImportData(new JavaImportData()); |
| 395 | setJavaFileInfo(javaFileInfo); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 396 | setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(), |
| 397 | getJavaFileInfo().getPackageFilePath())); |
| 398 | |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 399 | /* |
| 400 | * Initialize getter when generation file type matches to interface |
| 401 | * mask. |
| 402 | */ |
| 403 | if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) { |
| 404 | addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 405 | addGeneratedTempFile(ADD_TO_LIST_INTERFACE_MASK); |
| 406 | addGeneratedTempFile(LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK); |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | /* |
| 410 | * Initialize getter and setter when generation file type matches to |
| 411 | * builder interface mask. |
| 412 | */ |
| 413 | if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) { |
| 414 | addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK); |
| 415 | addGeneratedTempFile(SETTER_FOR_INTERFACE_MASK); |
| 416 | } |
| 417 | |
| 418 | /* |
| 419 | * Initialize getterImpl, setterImpl and attributes when generation file |
| 420 | * type matches to builder class mask. |
| 421 | */ |
| 422 | if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) { |
| 423 | addGeneratedTempFile(ATTRIBUTES_MASK); |
| 424 | addGeneratedTempFile(GETTER_FOR_CLASS_MASK); |
| 425 | addGeneratedTempFile(SETTER_FOR_CLASS_MASK); |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | /* |
| 429 | * Initialize getterImpl, attributes, constructor, hash code, equals and |
| 430 | * to strings when generation file type matches to impl class mask. |
| 431 | */ |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 432 | if ((getGeneratedJavaFiles() & DEFAULT_CLASS_MASK) != 0) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 433 | addGeneratedTempFile(ATTRIBUTES_MASK); |
| 434 | addGeneratedTempFile(GETTER_FOR_CLASS_MASK); |
| 435 | addGeneratedTempFile(HASH_CODE_IMPL_MASK); |
| 436 | addGeneratedTempFile(EQUALS_IMPL_MASK); |
| 437 | addGeneratedTempFile(TO_STRING_IMPL_MASK); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 438 | addGeneratedTempFile(ADD_TO_LIST_IMPL_MASK); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 439 | addGeneratedTempFile(FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK); |
| 440 | addGeneratedTempFile(FILTER_CONTENT_MATCH_FOR_LEAF_MASK); |
| 441 | addGeneratedTempFile(FILTER_CONTENT_MATCH_FOR_NODES_MASK); |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | /* |
| 445 | * Initialize temp files to generate type class. |
| 446 | */ |
| 447 | if ((getGeneratedJavaFiles() & GENERATE_TYPE_CLASS) != 0) { |
| 448 | addGeneratedTempFile(ATTRIBUTES_MASK); |
| 449 | addGeneratedTempFile(GETTER_FOR_CLASS_MASK); |
| 450 | addGeneratedTempFile(HASH_CODE_IMPL_MASK); |
| 451 | addGeneratedTempFile(EQUALS_IMPL_MASK); |
| 452 | addGeneratedTempFile(TO_STRING_IMPL_MASK); |
| 453 | addGeneratedTempFile(FROM_STRING_IMPL_MASK); |
| 454 | } |
| 455 | |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 456 | //Initialize temp files to generate enum class. |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 457 | if ((getGeneratedJavaFiles() & GENERATE_ENUM_CLASS) != 0) { |
| 458 | addGeneratedTempFile(FROM_STRING_IMPL_MASK); |
| 459 | } |
| 460 | |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 461 | //Set temporary file handles |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 462 | if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) { |
| 463 | setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME)); |
| 464 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 465 | if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) { |
| 466 | setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME)); |
| 467 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 468 | if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) { |
| 469 | setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME)); |
| 470 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 471 | if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) { |
| 472 | setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME)); |
| 473 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 474 | if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) { |
| 475 | setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME)); |
| 476 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 477 | if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) { |
| 478 | setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME)); |
| 479 | } |
| 480 | if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) { |
| 481 | setEqualsImplTempFileHandle(getTemporaryFileHandle(EQUALS_METHOD_FILE_NAME)); |
| 482 | } |
| 483 | if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) { |
| 484 | setToStringImplTempFileHandle(getTemporaryFileHandle(TO_STRING_METHOD_FILE_NAME)); |
| 485 | } |
| 486 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
| 487 | setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME)); |
| 488 | } |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 489 | if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0) { |
| 490 | setAddToListInterfaceTempFileHandle(getTemporaryFileHandle(ADD_TO_LIST_INTERFACE_METHOD_FILE_NAME)); |
| 491 | } |
| 492 | if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0) { |
| 493 | setAddToListImplTempFileHandle(getTemporaryFileHandle(ADD_TO_LIST_IMPL_METHOD_FILE_NAME)); |
| 494 | } |
| 495 | if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0) { |
| 496 | setLeafIdAttributeTempFileHandle(getTemporaryFileHandle(LEAF_IDENTIFIER_ATTRIBUTES_FILE_NAME)); |
| 497 | } |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 498 | if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 499 | setSubtreeFilteringForLeafTempFileHandle(getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_FILE_NAME)); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 500 | } |
| 501 | if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 502 | setGetSubtreeFilteringForListTempFileHandle( |
| 503 | getTemporaryFileHandle(FILTER_CONTENT_MATCH_LEAF_LIST_FILE_NAME)); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 504 | } |
| 505 | if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 506 | setGetSubtreeFilteringForChildNodeTempFileHandle( |
| 507 | getTemporaryFileHandle(FILTER_CONTENT_MATCH_NODE_FILE_NAME)); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 508 | } |
| 509 | if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) { |
| 510 | setEditContentTempFileHandle(getTemporaryFileHandle(EDIT_CONTENT_FILE_NAME)); |
| 511 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | /** |
| 515 | * Adds current node info as and attribute to the parent generated file. |
| 516 | * |
| 517 | * @param curNode current node which needs to be added as an attribute in the parent generated code |
| 518 | * @param isList is list construct |
| 519 | * @param pluginConfig plugin configurations |
| 520 | * @throws IOException IO operation exception |
| 521 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 522 | static void addCurNodeInfoInParentTempFile(YangNode curNode, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 523 | boolean isList, YangPluginConfig pluginConfig) |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 524 | throws IOException { |
| 525 | YangNode parent = getParentNodeInGenCode(curNode); |
| 526 | if (!(parent instanceof JavaCodeGenerator)) { |
| 527 | throw new TranslatorException("missing parent node to contain current node info in generated file"); |
| 528 | } |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 529 | |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 530 | if (parent instanceof YangJavaGroupingTranslator) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 531 | /* |
| 532 | * In case of grouping, there is no need to add the information, it |
| 533 | * will be taken care in uses |
| 534 | */ |
| 535 | return; |
| 536 | } |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 537 | |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 538 | TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) parent) |
| 539 | .getTempJavaCodeFragmentFiles().getBeanTempFiles(); |
| 540 | |
| 541 | JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode, |
| 542 | parent, isList, tempJavaBeanFragmentFiles); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 543 | tempJavaBeanFragmentFiles.addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig); |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | /** |
| 547 | * Creates an attribute info object corresponding to a data model node and return it. |
| 548 | * |
| 549 | * @param curNode current data model node for which the java code generation is being handled |
| 550 | * @param targetNode target node in which the current node is an attribute |
| 551 | * @param isListNode is the current added attribute needs to be a list |
| 552 | * @param tempJavaFragmentFiles temp java fragment files |
| 553 | * @return AttributeInfo attribute details required to add in temporary files |
| 554 | */ |
| 555 | public static JavaAttributeInfo getCurNodeAsAttributeInTarget(YangNode curNode, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 556 | YangNode targetNode, boolean isListNode, |
| 557 | TempJavaFragmentFiles tempJavaFragmentFiles) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 558 | String curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName(); |
| 559 | if (curNodeName == null) { |
| 560 | updateJavaFileInfo(curNode, null); |
| 561 | curNodeName = ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName(); |
| 562 | } |
| 563 | |
| 564 | /* |
| 565 | * Get the import info corresponding to the attribute for import in |
| 566 | * generated java files or qualified access |
| 567 | */ |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 568 | JavaQualifiedTypeInfoTranslator qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 569 | getCapitalCase(curNodeName)); |
| 570 | if (!(targetNode instanceof TempJavaCodeFragmentFilesContainer)) { |
| 571 | throw new TranslatorException("Parent node does not have file info"); |
| 572 | } |
| 573 | JavaImportData parentImportData = tempJavaFragmentFiles.getJavaImportData(); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 574 | JavaFileInfoTranslator fileInfo = ((JavaFileInfoContainer) targetNode).getJavaFileInfo(); |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 575 | |
| 576 | boolean isQualified; |
Bharat saraswal | aab24b9 | 2016-08-02 18:43:16 +0530 | [diff] [blame] | 577 | if ((tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles) |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 578 | && (qualifiedTypeInfo.getClassInfo().contentEquals(SERVICE)) |
| 579 | || qualifiedTypeInfo.getClassInfo().contentEquals(getCapitalCase(fileInfo.getJavaName() + SERVICE))) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 580 | |
| 581 | isQualified = true; |
| 582 | } else { |
| 583 | String className; |
Bharat saraswal | aab24b9 | 2016-08-02 18:43:16 +0530 | [diff] [blame] | 584 | if (tempJavaFragmentFiles instanceof TempJavaServiceFragmentFiles) { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 585 | className = getCapitalCase(fileInfo.getJavaName()) + SERVICE; |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 586 | } else { |
| 587 | className = getCapitalCase(fileInfo.getJavaName()); |
| 588 | } |
| 589 | |
| 590 | isQualified = parentImportData.addImportInfo(qualifiedTypeInfo, |
| 591 | className, fileInfo.getPackage()); |
| 592 | } |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 593 | boolean collectionSetFlag = false; |
| 594 | if (curNode instanceof YangList) { |
| 595 | YangList yangList = (YangList) curNode; |
| 596 | if (yangList.getCompilerAnnotation() != null && yangList.getCompilerAnnotation() |
| 597 | .getYangAppDataStructure() != null) { |
| 598 | switch (yangList.getCompilerAnnotation().getYangAppDataStructure().getDataStructure()) { |
| 599 | case QUEUE: { |
| 600 | parentImportData.setQueueToImport(true); |
| 601 | collectionSetFlag = true; |
| 602 | break; |
| 603 | } |
| 604 | case SET: { |
| 605 | parentImportData.setSetToImport(true); |
| 606 | collectionSetFlag = true; |
| 607 | break; |
| 608 | } |
| 609 | default: { |
| 610 | // TODO : to be implemented |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | } |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 615 | if (isListNode && !(collectionSetFlag)) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 616 | parentImportData.setIfListImported(true); |
| 617 | } |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 618 | if (curNode instanceof YangList) { |
| 619 | return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, isQualified, isListNode, |
| 620 | ((YangList) curNode).getCompilerAnnotation()); |
| 621 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 622 | return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, isQualified, isListNode); |
| 623 | } |
| 624 | |
| 625 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 626 | * Returns java attribute for leaf. |
| 627 | * |
| 628 | * @param tempJavaFragmentFiles temporary generated file |
| 629 | * @param leaf YANG leaf |
| 630 | * @param yangPluginConfig plugin configurations |
| 631 | * @return java attribute for leaf |
| 632 | */ |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 633 | private static JavaAttributeInfo getJavaAttributeOfLeaf(TempJavaFragmentFiles tempJavaFragmentFiles, YangLeaf leaf, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 634 | YangPluginConfig yangPluginConfig) { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 635 | JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leaf; |
| 636 | javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver()); |
| 637 | javaLeaf.updateJavaQualifiedInfo(); |
| 638 | return getAttributeInfoForTheData( |
| 639 | javaLeaf.getJavaQualifiedInfo(), |
| 640 | javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()), |
| 641 | javaLeaf.getDataType(), |
| 642 | tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()), |
| 643 | false); |
| 644 | } |
| 645 | |
| 646 | /** |
| 647 | * Returns java attribute for leaf-list. |
| 648 | * |
| 649 | * @param tempJavaFragmentFiles temporary generated file |
| 650 | * @param leafList YANG leaf-list |
| 651 | * @param yangPluginConfig plugin configurations |
| 652 | * @return java attribute for leaf-list |
| 653 | */ |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 654 | private static JavaAttributeInfo getJavaAttributeOfLeafList(TempJavaFragmentFiles tempJavaFragmentFiles, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 655 | YangLeafList leafList, |
| 656 | YangPluginConfig yangPluginConfig) { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 657 | JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leafList; |
| 658 | javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver()); |
| 659 | javaLeaf.updateJavaQualifiedInfo(); |
| 660 | tempJavaFragmentFiles.getJavaImportData().setIfListImported(true); |
| 661 | return getAttributeInfoForTheData( |
| 662 | javaLeaf.getJavaQualifiedInfo(), |
| 663 | javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()), |
| 664 | javaLeaf.getDataType(), |
| 665 | tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()), |
| 666 | true); |
| 667 | } |
| 668 | |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 669 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 670 | * Retrieves the absolute path where the file needs to be generated. |
| 671 | * |
| 672 | * @return absolute path where the file needs to be generated |
| 673 | */ |
| 674 | private String getAbsoluteDirPath() { |
| 675 | return absoluteDirPath; |
| 676 | } |
| 677 | |
| 678 | /** |
| 679 | * Sets absolute path where the file needs to be generated. |
| 680 | * |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 681 | * @param absoluteDirPath absolute path where the file needs to be generated. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 682 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 683 | void setAbsoluteDirPath(String absoluteDirPath) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 684 | this.absoluteDirPath = absoluteDirPath; |
| 685 | } |
| 686 | |
| 687 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 688 | * Retrieves the generated java file information. |
| 689 | * |
| 690 | * @return generated java file information |
| 691 | */ |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 692 | public JavaFileInfoTranslator getJavaFileInfo() { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 693 | return javaFileInfo; |
| 694 | } |
| 695 | |
| 696 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 697 | * Sets the generated java file information. |
| 698 | * |
| 699 | * @param javaFileInfo generated java file information |
| 700 | */ |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 701 | public void setJavaFileInfo(JavaFileInfoTranslator javaFileInfo) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 702 | this.javaFileInfo = javaFileInfo; |
| 703 | } |
| 704 | |
| 705 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 706 | * Retrieves the generated temp files. |
| 707 | * |
| 708 | * @return generated temp files |
| 709 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 710 | int getGeneratedTempFiles() { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 711 | return generatedTempFiles; |
| 712 | } |
| 713 | |
| 714 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 715 | * Sets generated file files. |
| 716 | * |
| 717 | * @param fileType generated file type |
| 718 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 719 | private void setGeneratedTempFiles(int fileType) { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 720 | generatedTempFiles = fileType; |
| 721 | } |
| 722 | |
| 723 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 724 | * Adds to generated temporary files. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 725 | * |
| 726 | * @param generatedTempFile generated file |
| 727 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 728 | void addGeneratedTempFile(int generatedTempFile) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 729 | generatedTempFiles |= generatedTempFile; |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 730 | setGeneratedTempFiles(generatedTempFiles); |
| 731 | } |
| 732 | |
| 733 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 734 | * Retrieves the generated Java files. |
| 735 | * |
| 736 | * @return generated Java files |
| 737 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 738 | int getGeneratedJavaFiles() { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 739 | return getJavaFileInfo().getGeneratedFileTypes(); |
| 740 | } |
| 741 | |
| 742 | /** |
| 743 | * Retrieves the mapped Java class name. |
| 744 | * |
| 745 | * @return mapped Java class name |
| 746 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 747 | String getGeneratedJavaClassName() { |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 748 | return getCapitalCase(getJavaFileInfo().getJavaName()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | /** |
| 752 | * Retrieves the import data for the generated Java file. |
| 753 | * |
| 754 | * @return import data for the generated Java file |
| 755 | */ |
| 756 | public JavaImportData getJavaImportData() { |
| 757 | return javaImportData; |
| 758 | } |
| 759 | |
| 760 | /** |
| 761 | * Sets import data for the generated Java file. |
| 762 | * |
| 763 | * @param javaImportData import data for the generated Java file |
| 764 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 765 | void setJavaImportData(JavaImportData javaImportData) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 766 | this.javaImportData = javaImportData; |
| 767 | } |
| 768 | |
| 769 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 770 | * Retrieves the status of any attributes added. |
| 771 | * |
| 772 | * @return status of any attributes added |
| 773 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 774 | boolean isAttributePresent() { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 775 | return isAttributePresent; |
| 776 | } |
| 777 | |
| 778 | /** |
| 779 | * Sets status of any attributes added. |
| 780 | * |
| 781 | * @param attributePresent status of any attributes added |
| 782 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 783 | private void setAttributePresent(boolean attributePresent) { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 784 | isAttributePresent = attributePresent; |
| 785 | } |
| 786 | |
| 787 | /** |
| 788 | * Returns getter methods's temporary file handle. |
| 789 | * |
| 790 | * @return temporary file handle |
| 791 | */ |
| 792 | public File getGetterInterfaceTempFileHandle() { |
| 793 | return getterInterfaceTempFileHandle; |
| 794 | } |
| 795 | |
| 796 | /** |
| 797 | * Sets to getter method's temporary file handle. |
| 798 | * |
| 799 | * @param getterForInterface file handle for to getter method |
| 800 | */ |
| 801 | private void setGetterInterfaceTempFileHandle(File getterForInterface) { |
| 802 | getterInterfaceTempFileHandle = getterForInterface; |
| 803 | } |
| 804 | |
| 805 | /** |
| 806 | * Returns setter method's temporary file handle. |
| 807 | * |
| 808 | * @return temporary file handle |
| 809 | */ |
| 810 | public File getSetterInterfaceTempFileHandle() { |
| 811 | return setterInterfaceTempFileHandle; |
| 812 | } |
| 813 | |
| 814 | /** |
| 815 | * Sets to setter method's temporary file handle. |
| 816 | * |
| 817 | * @param setterForInterface file handle for to setter method |
| 818 | */ |
| 819 | private void setSetterInterfaceTempFileHandle(File setterForInterface) { |
| 820 | setterInterfaceTempFileHandle = setterForInterface; |
| 821 | } |
| 822 | |
| 823 | /** |
| 824 | * Returns setter method's impl's temporary file handle. |
| 825 | * |
| 826 | * @return temporary file handle |
| 827 | */ |
| 828 | public File getSetterImplTempFileHandle() { |
| 829 | return setterImplTempFileHandle; |
| 830 | } |
| 831 | |
| 832 | /** |
| 833 | * Sets to setter method's impl's temporary file handle. |
| 834 | * |
| 835 | * @param setterImpl file handle for to setter method's implementation class |
| 836 | */ |
| 837 | private void setSetterImplTempFileHandle(File setterImpl) { |
| 838 | setterImplTempFileHandle = setterImpl; |
| 839 | } |
| 840 | |
| 841 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 842 | * Returns from string method's temporary file handle. |
| 843 | * |
| 844 | * @return from string method's temporary file handle |
| 845 | */ |
| 846 | public File getFromStringImplTempFileHandle() { |
| 847 | return fromStringImplTempFileHandle; |
| 848 | } |
| 849 | |
| 850 | /** |
| 851 | * Sets from string method's temporary file handle. |
| 852 | * |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 853 | * @param fromStringImplTempFileHandle from string method's temporary file handle |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 854 | */ |
| 855 | private void setFromStringImplTempFileHandle(File fromStringImplTempFileHandle) { |
| 856 | this.fromStringImplTempFileHandle = fromStringImplTempFileHandle; |
| 857 | } |
| 858 | |
| 859 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 860 | * Returns java file handle for interface file. |
| 861 | * |
| 862 | * @return java file handle for interface file |
| 863 | */ |
| 864 | private File getInterfaceJavaFileHandle() { |
| 865 | return interfaceJavaFileHandle; |
| 866 | } |
| 867 | |
| 868 | /** |
| 869 | * Sets the java file handle for interface file. |
| 870 | * |
| 871 | * @param interfaceJavaFileHandle java file handle |
| 872 | */ |
| 873 | private void setInterfaceJavaFileHandle(File interfaceJavaFileHandle) { |
| 874 | this.interfaceJavaFileHandle = interfaceJavaFileHandle; |
| 875 | } |
| 876 | |
| 877 | /** |
| 878 | * Returns java file handle for builder interface file. |
| 879 | * |
| 880 | * @return java file handle for builder interface file |
| 881 | */ |
| 882 | private File getBuilderInterfaceJavaFileHandle() { |
| 883 | return builderInterfaceJavaFileHandle; |
| 884 | } |
| 885 | |
| 886 | /** |
| 887 | * Sets the java file handle for builder interface file. |
| 888 | * |
| 889 | * @param builderInterfaceJavaFileHandle java file handle |
| 890 | */ |
| 891 | private void setBuilderInterfaceJavaFileHandle(File builderInterfaceJavaFileHandle) { |
| 892 | this.builderInterfaceJavaFileHandle = builderInterfaceJavaFileHandle; |
| 893 | } |
| 894 | |
| 895 | /** |
| 896 | * Returns java file handle for builder class file. |
| 897 | * |
| 898 | * @return java file handle for builder class file |
| 899 | */ |
| 900 | private File getBuilderClassJavaFileHandle() { |
| 901 | return builderClassJavaFileHandle; |
| 902 | } |
| 903 | |
| 904 | /** |
| 905 | * Sets the java file handle for builder class file. |
| 906 | * |
| 907 | * @param builderClassJavaFileHandle java file handle |
| 908 | */ |
| 909 | private void setBuilderClassJavaFileHandle(File builderClassJavaFileHandle) { |
| 910 | this.builderClassJavaFileHandle = builderClassJavaFileHandle; |
| 911 | } |
| 912 | |
| 913 | /** |
| 914 | * Returns java file handle for impl class file. |
| 915 | * |
| 916 | * @return java file handle for impl class file |
| 917 | */ |
| 918 | private File getImplClassJavaFileHandle() { |
| 919 | return implClassJavaFileHandle; |
| 920 | } |
| 921 | |
| 922 | /** |
| 923 | * Sets the java file handle for impl class file. |
| 924 | * |
| 925 | * @param implClassJavaFileHandle java file handle |
| 926 | */ |
| 927 | private void setImplClassJavaFileHandle(File implClassJavaFileHandle) { |
| 928 | this.implClassJavaFileHandle = implClassJavaFileHandle; |
| 929 | } |
| 930 | |
| 931 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 932 | * Returns attribute's temporary file handle. |
| 933 | * |
| 934 | * @return temporary file handle |
| 935 | */ |
| 936 | public File getAttributesTempFileHandle() { |
| 937 | return attributesTempFileHandle; |
| 938 | } |
| 939 | |
| 940 | /** |
| 941 | * Sets attribute's temporary file handle. |
| 942 | * |
| 943 | * @param attributeForClass file handle for attribute |
| 944 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 945 | private void setAttributesTempFileHandle(File attributeForClass) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 946 | attributesTempFileHandle = attributeForClass; |
| 947 | } |
| 948 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 949 | /** |
| 950 | * Returns getter method's impl's temporary file handle. |
| 951 | * |
| 952 | * @return temporary file handle |
| 953 | */ |
| 954 | public File getGetterImplTempFileHandle() { |
| 955 | return getterImplTempFileHandle; |
| 956 | } |
| 957 | |
| 958 | /** |
| 959 | * Sets to getter method's impl's temporary file handle. |
| 960 | * |
| 961 | * @param getterImpl file handle for to getter method's impl |
| 962 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 963 | private void setGetterImplTempFileHandle(File getterImpl) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 964 | getterImplTempFileHandle = getterImpl; |
| 965 | } |
| 966 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 967 | /** |
| 968 | * Returns hash code method's temporary file handle. |
| 969 | * |
| 970 | * @return temporary file handle |
| 971 | */ |
| 972 | public File getHashCodeImplTempFileHandle() { |
| 973 | return hashCodeImplTempFileHandle; |
| 974 | } |
| 975 | |
| 976 | /** |
| 977 | * Sets hash code method's temporary file handle. |
| 978 | * |
| 979 | * @param hashCodeMethod file handle for hash code method |
| 980 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 981 | private void setHashCodeImplTempFileHandle(File hashCodeMethod) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 982 | hashCodeImplTempFileHandle = hashCodeMethod; |
| 983 | } |
| 984 | |
| 985 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 986 | * Returns equals method's temporary file handle. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 987 | * |
| 988 | * @return temporary file handle |
| 989 | */ |
| 990 | public File getEqualsImplTempFileHandle() { |
| 991 | return equalsImplTempFileHandle; |
| 992 | } |
| 993 | |
| 994 | /** |
| 995 | * Sets equals method's temporary file handle. |
| 996 | * |
| 997 | * @param equalsMethod file handle for to equals method |
| 998 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 999 | private void setEqualsImplTempFileHandle(File equalsMethod) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1000 | equalsImplTempFileHandle = equalsMethod; |
| 1001 | } |
| 1002 | |
| 1003 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1004 | * Returns to string method's temporary file handle. |
| 1005 | * |
| 1006 | * @return temporary file handle |
| 1007 | */ |
| 1008 | public File getToStringImplTempFileHandle() { |
| 1009 | return toStringImplTempFileHandle; |
| 1010 | } |
| 1011 | |
| 1012 | /** |
| 1013 | * Sets to string method's temporary file handle. |
| 1014 | * |
| 1015 | * @param toStringMethod file handle for to string method |
| 1016 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1017 | private void setToStringImplTempFileHandle(File toStringMethod) { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1018 | toStringImplTempFileHandle = toStringMethod; |
| 1019 | } |
| 1020 | |
| 1021 | /** |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 1022 | * Returns java extends list holder. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1023 | * |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 1024 | * @return java extends list holder |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1025 | */ |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 1026 | public JavaExtendsListHolder getJavaExtendsListHolder() { |
| 1027 | return javaExtendsListHolder; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | /** |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 1031 | * Sets java extends list holder. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1032 | * |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 1033 | * @param javaExtendsListHolder java extends list holder |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1034 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1035 | void setJavaExtendsListHolder(JavaExtendsListHolder javaExtendsListHolder) { |
Bharat saraswal | 4aaab4d | 2016-05-17 14:19:38 +0530 | [diff] [blame] | 1036 | this.javaExtendsListHolder = javaExtendsListHolder; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | /** |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1040 | * Adds is filter content match for leaf. |
| 1041 | * |
| 1042 | * @param attr java attribute |
| 1043 | * @throws IOException when fails to do IO operations |
| 1044 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1045 | private void addSubTreeFilteringForLeaf(JavaAttributeInfo attr) |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1046 | throws IOException { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1047 | appendToFile(getSubtreeFilteringForLeafTempFileHandle(), |
| 1048 | getSubtreeFilteringForLeaf(attr, attr.getAttributeType()) + NEW_LINE); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | /** |
| 1052 | * Adds is filter content match for leaf-list. |
| 1053 | * |
| 1054 | * @param attr java attribute |
| 1055 | * @throws IOException when fails to do IO operations |
| 1056 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1057 | private void addSubtreeFilteringForLeafList(JavaAttributeInfo attr) |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1058 | throws IOException { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1059 | appendToFile(getGetSubtreeFilteringForListTempFileHandle(), |
| 1060 | getSubtreeFilteringForLeafList(attr) + NEW_LINE); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1061 | } |
| 1062 | |
| 1063 | /** |
| 1064 | * Adds is filter content match for nodes. |
| 1065 | * |
| 1066 | * @param attr java attribute |
| 1067 | * @throws IOException when fails to do IO operations |
| 1068 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1069 | private void addSubtreeFilteringForChildNode(JavaAttributeInfo attr) |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1070 | throws IOException { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1071 | appendToFile(getGetSubtreeFilteringForChildNodeTempFileHandle(), |
| 1072 | getSubtreeFilteringForNode(attr) + NEW_LINE); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1076 | * Adds attribute for class. |
| 1077 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1078 | * @param attr attribute info |
| 1079 | * @param yangPluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1080 | * @throws IOException when fails to append to temporary file |
| 1081 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1082 | private void addAttribute(JavaAttributeInfo attr, YangPluginConfig yangPluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1083 | throws IOException { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1084 | appendToFile(getAttributesTempFileHandle(), parseAttribute(attr, yangPluginConfig) |
| 1085 | + FOUR_SPACE_INDENTATION); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1086 | } |
| 1087 | |
| 1088 | /** |
| 1089 | * Adds getter for interface. |
| 1090 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1091 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1092 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1093 | * @throws IOException when fails to append to temporary file |
| 1094 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1095 | private void addGetterForInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1096 | throws IOException { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1097 | appendToFile(getGetterInterfaceTempFileHandle(), |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1098 | getGetterString(attr, getGeneratedJavaFiles(), pluginConfig) + NEW_LINE); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1099 | } |
| 1100 | |
| 1101 | /** |
| 1102 | * Adds setter for interface. |
| 1103 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1104 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1105 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1106 | * @throws IOException when fails to append to temporary file |
| 1107 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1108 | private void addSetterForInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1109 | throws IOException { |
| 1110 | appendToFile(getSetterInterfaceTempFileHandle(), |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1111 | getSetterString(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles(), pluginConfig) |
| 1112 | + NEW_LINE); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | /** |
| 1116 | * Adds setter's implementation for class. |
| 1117 | * |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1118 | * @param attr attribute info |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1119 | * @throws IOException when fails to append to temporary file |
| 1120 | */ |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 1121 | private void addSetterImpl(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1122 | throws IOException { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1123 | if (isRooNode()) { |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 1124 | appendToFile(getSetterImplTempFileHandle(), getJavaDoc(SETTER_METHOD, attr.getAttributeName(), |
| 1125 | attr.isListAttr(), pluginConfig, null) + |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1126 | getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles()) |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 1127 | + NEW_LINE); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1128 | } else { |
| 1129 | appendToFile(getSetterImplTempFileHandle(), getOverRideString() + |
| 1130 | getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles()) |
| 1131 | + NEW_LINE); |
| 1132 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | /** |
| 1136 | * Adds getter method's impl for class. |
| 1137 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1138 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1139 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1140 | * @throws IOException when fails to append to temporary file |
| 1141 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1142 | void addGetterImpl(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1143 | throws IOException { |
| 1144 | if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0 |
| 1145 | || (getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1146 | if (!isRooNode()) { |
| 1147 | appendToFile(getGetterImplTempFileHandle(), getOverRideString() + getGetterForClass(attr, |
| 1148 | getGeneratedJavaFiles()) + NEW_LINE); |
| 1149 | } else { |
| 1150 | appendToFile(getGetterImplTempFileHandle(), getGetterForClass(attr, |
| 1151 | getGeneratedJavaFiles()) + NEW_LINE); |
| 1152 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1153 | } else { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1154 | String appDataStructure = null; |
| 1155 | if (attr.getCompilerAnnotation() != null) { |
| 1156 | appDataStructure = attr.getCompilerAnnotation().getYangAppDataStructure().getDataStructure().name(); |
| 1157 | } |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 1158 | appendToFile(getGetterImplTempFileHandle(), |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1159 | getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig, |
| 1160 | appDataStructure) + getGetterForClass(attr, getGeneratedJavaFiles()) + NEW_LINE); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1161 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | /** |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1165 | * Adds add to list interface method. |
| 1166 | * |
| 1167 | * @param attr attribute |
| 1168 | * @param pluginConfig plugin configurations |
| 1169 | * @throws IOException when fails to do IO operations |
| 1170 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1171 | private void addAddToListInterface(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
| 1172 | throws IOException { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1173 | appendToFile(getAddToListInterfaceTempFileHandle(), |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1174 | getJavaDoc(ADD_TO_LIST, getCapitalCase(attr.getAttributeName()), false, pluginConfig, null) |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1175 | + getAddToListMethodInterface(attr, getGeneratedJavaClassName()) + NEW_LINE); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | /** |
| 1179 | * Adds add to list interface method. |
| 1180 | * |
| 1181 | * @param attr attribute |
| 1182 | * @throws IOException when fails to do IO operations |
| 1183 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1184 | private void addAddToListImpl(JavaAttributeInfo attr) |
| 1185 | throws IOException { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1186 | appendToFile(getAddToListImplTempFileHandle(), |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1187 | getAddToListMethodImpl(attr, getGeneratedJavaClassName(), isRooNode()) + NEW_LINE); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1188 | } |
| 1189 | |
| 1190 | /** |
| 1191 | * Adds leaf identifier enum attributes. |
| 1192 | * |
| 1193 | * @param attr attribute |
| 1194 | * @param value value |
| 1195 | * @param yangPluginConfig plugin config |
| 1196 | * @throws IOException when fails to do IO operations |
| 1197 | */ |
| 1198 | private void addLeafIdAttributes(JavaAttributeInfo attr, int value, YangPluginConfig yangPluginConfig) |
| 1199 | throws IOException { |
| 1200 | appendToFile(getLeafIdAttributeTempFileHandle(), |
| 1201 | FOUR_SPACE_INDENTATION + generateEnumAttributeString(attr.getAttributeName(), |
| 1202 | value, yangPluginConfig)); |
| 1203 | } |
| 1204 | |
| 1205 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1206 | * Adds build method for interface. |
| 1207 | * |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1208 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1209 | * @return build method for interface |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1210 | * @throws IOException when fails to append to temporary file |
| 1211 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1212 | String addBuildMethodForInterface(YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1213 | throws IOException { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1214 | return parseBuilderInterfaceBuildMethodString(getGeneratedJavaClassName(), pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1215 | } |
| 1216 | |
| 1217 | /** |
| 1218 | * Adds build method's implementation for class. |
| 1219 | * |
| 1220 | * @return build method implementation for class |
| 1221 | * @throws IOException when fails to append to temporary file |
| 1222 | */ |
| 1223 | String addBuildMethodImpl() |
| 1224 | throws IOException { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1225 | return getBuildString(getGeneratedJavaClassName(), isRooNode()) + NEW_LINE; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1226 | } |
| 1227 | |
| 1228 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1229 | * Adds default constructor for class. |
| 1230 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1231 | * @param modifier modifier for constructor. |
| 1232 | * @param toAppend string which need to be appended with the class name |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1233 | * @param pluginConfig plugin configurations |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1234 | * @param isSuffix is value need to be appended as suffix |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1235 | * @return default constructor for class |
| 1236 | * @throws IOException when fails to append to file |
| 1237 | */ |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1238 | String addDefaultConstructor(String modifier, String toAppend, YangPluginConfig pluginConfig, boolean isSuffix) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1239 | throws IOException { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1240 | String name = getGeneratedJavaClassName(); |
| 1241 | if (isRooNode() && !toAppend.equals(BUILDER)) { |
| 1242 | name = name + OP_PARAM; |
| 1243 | return NEW_LINE |
| 1244 | + getDefaultConstructorString(name, modifier, |
| 1245 | pluginConfig); |
| 1246 | } |
| 1247 | if (isSuffix) { |
| 1248 | return NEW_LINE + |
| 1249 | getDefaultConstructorString(name + toAppend, modifier, pluginConfig); |
| 1250 | } |
| 1251 | String appended; |
| 1252 | if (toAppend.equals(DEFAULT)) { |
| 1253 | appended = getCapitalCase(toAppend); |
| 1254 | } else { |
| 1255 | appended = toAppend; |
| 1256 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1257 | return NEW_LINE |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1258 | + getDefaultConstructorString(appended + name, modifier, |
| 1259 | pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1263 | * Adds hash code method for class. |
| 1264 | * |
| 1265 | * @param attr attribute info |
| 1266 | * @throws IOException when fails to append to temporary file |
| 1267 | */ |
| 1268 | private void addHashCodeMethod(JavaAttributeInfo attr) |
| 1269 | throws IOException { |
| 1270 | appendToFile(getHashCodeImplTempFileHandle(), getHashCodeMethod(attr) + NEW_LINE); |
| 1271 | } |
| 1272 | |
| 1273 | /** |
| 1274 | * Adds equals method for class. |
| 1275 | * |
| 1276 | * @param attr attribute info |
| 1277 | * @throws IOException when fails to append to temporary file |
| 1278 | */ |
| 1279 | private void addEqualsMethod(JavaAttributeInfo attr) |
| 1280 | throws IOException { |
| 1281 | appendToFile(getEqualsImplTempFileHandle(), getEqualsMethod(attr) + NEW_LINE); |
| 1282 | } |
| 1283 | |
| 1284 | /** |
| 1285 | * Adds ToString method for class. |
| 1286 | * |
| 1287 | * @param attr attribute info |
| 1288 | * @throws IOException when fails to append to temporary file |
| 1289 | */ |
| 1290 | private void addToStringMethod(JavaAttributeInfo attr) |
| 1291 | throws IOException { |
| 1292 | appendToFile(getToStringImplTempFileHandle(), getToStringMethod(attr) + NEW_LINE); |
| 1293 | } |
| 1294 | |
| 1295 | /** |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1296 | * Adds from string method for union class. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1297 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1298 | * @param javaAttributeInfo type attribute info |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1299 | * @param fromStringAttributeInfo from string attribute info |
| 1300 | * @throws IOException when fails to append to temporary file |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1301 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1302 | void addFromStringMethod(JavaAttributeInfo javaAttributeInfo, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1303 | JavaAttributeInfo fromStringAttributeInfo) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1304 | throws IOException { |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1305 | appendToFile(getFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo, |
| 1306 | fromStringAttributeInfo) + NEW_LINE); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1307 | } |
| 1308 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1309 | /** |
| 1310 | * Returns a temporary file handle for the specific file type. |
| 1311 | * |
| 1312 | * @param fileName file name |
| 1313 | * @return temporary file handle |
| 1314 | * @throws IOException when fails to create new file handle |
| 1315 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1316 | File getTemporaryFileHandle(String fileName) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1317 | throws IOException { |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1318 | String path = getTempDirPath(getAbsoluteDirPath()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1319 | File dir = new File(path); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1320 | boolean isCreated; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1321 | if (!dir.exists()) { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1322 | isCreated = dir.mkdirs(); |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 1323 | if (!isCreated) { |
| 1324 | throw new IOException("failed to create temporary directory for " + fileName); |
| 1325 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1326 | } |
| 1327 | File file = new File(path + fileName + TEMP_FILE_EXTENSION); |
| 1328 | if (!file.exists()) { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1329 | isCreated = file.createNewFile(); |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 1330 | if (!isCreated) { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1331 | throw new IOException("failed to create temporary file for " + fileName); |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 1332 | } |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1333 | } else { |
| 1334 | throw new IOException(fileName + " is reused due to YANG naming"); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1335 | } |
| 1336 | return file; |
| 1337 | } |
| 1338 | |
| 1339 | /** |
| 1340 | * Returns a temporary file handle for the specific file type. |
| 1341 | * |
| 1342 | * @param fileName file name |
| 1343 | * @return temporary file handle |
| 1344 | * @throws IOException when fails to create new file handle |
| 1345 | */ |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1346 | File getJavaFileHandle(String fileName) |
| 1347 | throws IOException { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1348 | return getFileObject(getDirPath(), fileName, JAVA_FILE_EXTENSION, getJavaFileInfo()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1349 | } |
| 1350 | |
| 1351 | /** |
| 1352 | * Returns data from the temporary files. |
| 1353 | * |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1354 | * @param file temporary file handle |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1355 | * @param absolutePath absolute path |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1356 | * @return stored data from temporary files |
| 1357 | * @throws IOException when failed to get data from the given file |
| 1358 | */ |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1359 | public String getTemporaryDataFromFileHandle(File file, String absolutePath) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1360 | throws IOException { |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1361 | String path = getTempDirPath(absolutePath); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1362 | if (new File(path + file.getName()).exists()) { |
| 1363 | return readAppendFile(path + file.getName(), EMPTY_STRING); |
| 1364 | } else { |
| 1365 | throw new IOException("Unable to get data from the given " |
| 1366 | + file.getName() + " file for " + getGeneratedJavaClassName() + PERIOD); |
| 1367 | } |
| 1368 | } |
| 1369 | |
| 1370 | /** |
| 1371 | * Returns temporary directory path. |
| 1372 | * |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1373 | * @param absolutePath absolute path |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1374 | * @return directory path |
| 1375 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1376 | private String getTempDirPath(String absolutePath) { |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1377 | return getPackageDirPathFromJavaJPackage(absolutePath) + SLASH + getGeneratedJavaClassName() |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1378 | + TEMP_FOLDER_NAME_SUFFIX + SLASH; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1379 | } |
| 1380 | |
| 1381 | /** |
| 1382 | * Parses attribute to get the attribute string. |
| 1383 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1384 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1385 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1386 | * @return attribute string |
| 1387 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1388 | String parseAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1389 | /* |
| 1390 | * TODO: check if this utility needs to be called or move to the caller |
| 1391 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1392 | String attributeName = getCamelCase(attr.getAttributeName(), pluginConfig.getConflictResolver()); |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1393 | String attributeAccessType = PRIVATE; |
| 1394 | if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_INTERFACE_WITH_BUILDER) != 0) { |
| 1395 | attributeAccessType = PROTECTED; |
| 1396 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1397 | if (attr.isQualifiedName()) { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1398 | return getJavaAttributeDefinition(attr.getImportInfo().getPkgInfo(), |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1399 | attr.getImportInfo().getClassInfo(), |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1400 | attributeName, attr.isListAttr(), attributeAccessType, attr.getCompilerAnnotation()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1401 | } else { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1402 | return getJavaAttributeDefinition(null, attr.getImportInfo().getClassInfo(), attributeName, |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1403 | attr.isListAttr(), attributeAccessType, attr.getCompilerAnnotation()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1404 | } |
| 1405 | } |
| 1406 | |
| 1407 | /** |
| 1408 | * Appends content to temporary file. |
| 1409 | * |
| 1410 | * @param file temporary file |
| 1411 | * @param data data to be appended |
| 1412 | * @throws IOException when fails to append to file |
| 1413 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1414 | void appendToFile(File file, String data) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1415 | throws IOException { |
| 1416 | try { |
| 1417 | insertDataIntoJavaFile(file, data); |
| 1418 | } catch (IOException ex) { |
| 1419 | throw new IOException("failed to write in temp file."); |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1424 | * Adds parent's info to current node import list. |
| 1425 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1426 | * @param curNode current node for which import list needs to be updated |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1427 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1428 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1429 | void addParentInfoInCurNodeTempFile(YangNode curNode, YangPluginConfig pluginConfig) { |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1430 | JavaQualifiedTypeInfoTranslator caseImportInfo = new JavaQualifiedTypeInfoTranslator(); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1431 | YangNode parent = getParentNodeInGenCode(curNode); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1432 | if (curNode instanceof YangCase && parent instanceof YangAugment) { |
| 1433 | return; |
| 1434 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1435 | if (!(parent instanceof JavaCodeGenerator)) { |
| 1436 | throw new TranslatorException("missing parent node to contain current node info in generated file"); |
| 1437 | } |
| 1438 | if (!(curNode instanceof JavaFileInfoContainer)) { |
| 1439 | throw new TranslatorException("missing java file information to get the package details " |
| 1440 | + "of attribute corresponding to child node"); |
| 1441 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1442 | caseImportInfo.setClassInfo(getCapitalCase(getCamelCase(parent.getName(), |
| 1443 | pluginConfig.getConflictResolver()))); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1444 | caseImportInfo.setPkgInfo(((JavaFileInfoContainer) parent).getJavaFileInfo().getPackage()); |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1445 | |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1446 | JavaFileInfoTranslator fileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1447 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1448 | ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1449 | .getBeanTempFiles().getJavaImportData().addImportInfo(caseImportInfo, |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1450 | getCapitalCase(fileInfo.getJavaName()), fileInfo.getPackage()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1451 | } |
| 1452 | |
| 1453 | /** |
| 1454 | * Adds leaf attributes in generated files. |
| 1455 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1456 | * @param listOfLeaves list of YANG leaf |
| 1457 | * @param yangPluginConfig plugin config |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1458 | * @param curNode current node |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1459 | * @throws IOException IO operation fail |
| 1460 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1461 | private void addLeavesInfoToTempFiles(List<YangLeaf> listOfLeaves, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1462 | YangPluginConfig yangPluginConfig, YangNode curNode) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1463 | throws IOException { |
| 1464 | if (listOfLeaves != null) { |
| 1465 | for (YangLeaf leaf : listOfLeaves) { |
| 1466 | if (!(leaf instanceof JavaLeafInfoContainer)) { |
| 1467 | throw new TranslatorException("Leaf does not have java information"); |
| 1468 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1469 | if (curNode instanceof YangModule || curNode instanceof YangSubModule) { |
| 1470 | TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode) |
| 1471 | .getTempJavaCodeFragmentFiles().getBeanTempFiles(); |
| 1472 | addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(tempJavaBeanFragmentFiles, leaf, |
| 1473 | yangPluginConfig), yangPluginConfig); |
| 1474 | } else { |
| 1475 | addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(this, leaf, yangPluginConfig), |
| 1476 | yangPluginConfig); |
| 1477 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1478 | } |
| 1479 | } |
| 1480 | } |
| 1481 | |
| 1482 | /** |
| 1483 | * Adds leaf list's attributes in generated files. |
| 1484 | * |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1485 | * @param listOfLeafList list of YANG leaves |
| 1486 | * @param yangPluginConfig plugin config |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1487 | * @param curNode current node |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1488 | * @throws IOException IO operation fail |
| 1489 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1490 | private void addLeafListInfoToTempFiles(List<YangLeafList> listOfLeafList, YangPluginConfig yangPluginConfig, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1491 | YangNode curNode) |
| 1492 | throws IOException { |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1493 | if (listOfLeafList != null) { |
| 1494 | for (YangLeafList leafList : listOfLeafList) { |
| 1495 | if (!(leafList instanceof JavaLeafInfoContainer)) { |
| 1496 | throw new TranslatorException("Leaf-list does not have java information"); |
| 1497 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1498 | if (curNode instanceof YangModule || curNode instanceof YangSubModule) { |
| 1499 | TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode) |
| 1500 | .getTempJavaCodeFragmentFiles().getBeanTempFiles(); |
| 1501 | addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(tempJavaBeanFragmentFiles, |
| 1502 | leafList, yangPluginConfig), yangPluginConfig); |
| 1503 | } else { |
| 1504 | addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(this, |
| 1505 | leafList, yangPluginConfig), yangPluginConfig); |
| 1506 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1507 | } |
| 1508 | } |
| 1509 | } |
| 1510 | |
| 1511 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1512 | * Adds all the leaves in the current data model node as part of the generated temporary file. |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1513 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1514 | * @param curNode current node |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1515 | * @param yangPluginConfig plugin config |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1516 | * @throws IOException IO operation fail |
| 1517 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1518 | void addCurNodeLeavesInfoToTempFiles(YangNode curNode, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1519 | YangPluginConfig yangPluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1520 | throws IOException { |
| 1521 | if (!(curNode instanceof YangLeavesHolder)) { |
| 1522 | throw new TranslatorException("Data model node does not have any leaves"); |
| 1523 | } |
| 1524 | YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1525 | addLeavesInfoToTempFiles(leavesHolder.getListOfLeaf(), yangPluginConfig, curNode); |
| 1526 | addLeafListInfoToTempFiles(leavesHolder.getListOfLeafList(), yangPluginConfig, curNode); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1527 | } |
| 1528 | |
| 1529 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1530 | * Adds the new attribute info to the target generated temporary files. |
| 1531 | * |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1532 | * @param newAttrInfo the attribute info that needs to be added to temporary files |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1533 | * @param pluginConfig plugin configurations |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1534 | * @throws IOException IO operation fail |
| 1535 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1536 | void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo newAttrInfo, YangPluginConfig pluginConfig) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1537 | throws IOException { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1538 | setAttributePresent(true); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1539 | if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1540 | addAttribute(newAttrInfo, pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1541 | } |
| 1542 | if ((getGeneratedTempFiles() & GETTER_FOR_INTERFACE_MASK) != 0) { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1543 | addGetterForInterface(newAttrInfo, pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1544 | } |
| 1545 | if ((getGeneratedTempFiles() & SETTER_FOR_INTERFACE_MASK) != 0) { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 1546 | addSetterForInterface(newAttrInfo, pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1547 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1548 | if ((getGeneratedTempFiles() & SETTER_FOR_CLASS_MASK) != 0) { |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 1549 | addSetterImpl(newAttrInfo, pluginConfig); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1550 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1551 | if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) { |
| 1552 | addHashCodeMethod(newAttrInfo); |
| 1553 | } |
| 1554 | if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) { |
| 1555 | addEqualsMethod(newAttrInfo); |
| 1556 | } |
| 1557 | if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) { |
| 1558 | addToStringMethod(newAttrInfo); |
| 1559 | } |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1560 | if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) { |
| 1561 | //TODO: add implementation for edit content match. |
| 1562 | } |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1563 | if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0 && newAttrInfo.isListAttr()) { |
| 1564 | addAddToListImpl(newAttrInfo); |
| 1565 | } |
| 1566 | if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0 && newAttrInfo.isListAttr()) { |
| 1567 | addAddToListInterface(newAttrInfo, pluginConfig); |
| 1568 | } |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1569 | if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0 |
| 1570 | && newAttrInfo.getAttributeType() == null) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1571 | addSubtreeFilteringForChildNode(newAttrInfo); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1572 | } |
| 1573 | if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0 && !newAttrInfo.isListAttr() |
| 1574 | && newAttrInfo.getAttributeType() != null) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1575 | addSubTreeFilteringForLeaf(newAttrInfo); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1576 | } |
| 1577 | if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0 && newAttrInfo.isListAttr() |
| 1578 | && newAttrInfo.getAttributeType() != null) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1579 | addSubtreeFilteringForLeafList(newAttrInfo); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1580 | } |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1581 | if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0 && !newAttrInfo.isListAttr() |
| 1582 | && newAttrInfo.getAttributeType() != null) { |
| 1583 | leafCount++; |
| 1584 | addLeafIdAttributes(newAttrInfo, leafCount, pluginConfig); |
| 1585 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1586 | if (!newAttrInfo.isIntConflict() && |
| 1587 | !newAttrInfo.isLongConflict()) { |
| 1588 | if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) { |
| 1589 | addGetterImpl(newAttrInfo, pluginConfig); |
| 1590 | } |
| 1591 | |
| 1592 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 1593 | JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo, |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1594 | pluginConfig.getConflictResolver()); |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1595 | /* |
| 1596 | * Create a new java attribute info with qualified information of |
| 1597 | * wrapper classes. |
| 1598 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1599 | JavaAttributeInfo fromStringAttributeInfo = getAttributeInfoForTheData(qualifiedInfoOfFromString, |
| 1600 | newAttrInfo.getAttributeName(), |
| 1601 | newAttrInfo.getAttributeType(), |
| 1602 | getIsQualifiedAccessOrAddToImportList(qualifiedInfoOfFromString), false); |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1603 | |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1604 | addFromStringMethod(newAttrInfo, fromStringAttributeInfo); |
| 1605 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1606 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1607 | } |
| 1608 | |
| 1609 | /** |
| 1610 | * Returns java class name. |
| 1611 | * |
| 1612 | * @param suffix for the class name based on the file type |
| 1613 | * @return java class name |
| 1614 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1615 | String getJavaClassName(String suffix) { |
janani b | 703cfe4 | 2016-05-17 13:12:22 +0530 | [diff] [blame] | 1616 | return getCapitalCase(getJavaFileInfo().getJavaName()) + suffix; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1617 | } |
| 1618 | |
| 1619 | /** |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1620 | * Returns java class name. |
| 1621 | * |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1622 | * @param node YANG node |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1623 | * @return java class name |
| 1624 | */ |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1625 | private String getImplClassName(YangNode node) { |
| 1626 | if (node instanceof YangModule || node instanceof YangSubModule) { |
| 1627 | return getCapitalCase(getJavaFileInfo().getJavaName()) + OP_PARAM; |
| 1628 | } |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1629 | return getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo().getJavaName()); |
| 1630 | } |
| 1631 | |
| 1632 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1633 | * Returns the directory path. |
| 1634 | * |
| 1635 | * @return directory path |
| 1636 | */ |
| 1637 | private String getDirPath() { |
| 1638 | return getJavaFileInfo().getPackageFilePath(); |
| 1639 | } |
| 1640 | |
| 1641 | /** |
| 1642 | * Constructs java code exit. |
| 1643 | * |
| 1644 | * @param fileType generated file type |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1645 | * @param curNode current YANG node |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1646 | * @throws IOException when fails to generate java files |
| 1647 | */ |
| 1648 | public void generateJavaFile(int fileType, YangNode curNode) |
| 1649 | throws IOException { |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1650 | List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles() |
| 1651 | .getJavaImportData().getImports(); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1652 | if (curNode instanceof YangAugmentableNode) { |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 1653 | addImportsForAugmentableClass(imports, true, true, curNode); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1654 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1655 | createPackage(curNode); |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1656 | |
| 1657 | //Generate java code. |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1658 | if ((fileType & INTERFACE_MASK) != 0 || (fileType & |
| 1659 | BUILDER_INTERFACE_MASK) != 0) { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1660 | |
| 1661 | //Create interface file. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1662 | setInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(INTERFACE_FILE_NAME_SUFFIX))); |
| 1663 | setInterfaceJavaFileHandle( |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1664 | generateInterfaceFile(getInterfaceJavaFileHandle(), imports, curNode, isAttributePresent())); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1665 | if (!(curNode instanceof YangModule) && !(curNode instanceof YangSubModule)) { |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1666 | |
| 1667 | //Create builder interface file. |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1668 | if ((fileType & BUILDER_INTERFACE_MASK) != 0) { |
| 1669 | setBuilderInterfaceJavaFileHandle( |
| 1670 | getJavaFileHandle(getJavaClassName(BUILDER_INTERFACE_FILE_NAME_SUFFIX))); |
| 1671 | setBuilderInterfaceJavaFileHandle( |
| 1672 | generateBuilderInterfaceFile(getBuilderInterfaceJavaFileHandle(), curNode, |
| 1673 | isAttributePresent())); |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1674 | |
| 1675 | //Append builder interface file to interface file and close it. |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1676 | mergeJavaFiles(getBuilderInterfaceJavaFileHandle(), getInterfaceJavaFileHandle()); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1677 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1678 | } |
| 1679 | insertDataIntoJavaFile(getInterfaceJavaFileHandle(), getJavaClassDefClose()); |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 1680 | validateLineLength(getInterfaceJavaFileHandle()); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1681 | if (curNode instanceof YangAugmentableNode) { |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 1682 | addImportsForAugmentableClass(imports, false, true, curNode); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1683 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1684 | } |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1685 | if ((fileType & BUILDER_CLASS_MASK) != 0 || (fileType & DEFAULT_CLASS_MASK) != 0) { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1686 | if (isAttributePresent()) { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1687 | addImportsToStringAndHasCodeMethods(imports, true); |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1688 | addArrayListImport(imports); |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1689 | } |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 1690 | |
| 1691 | boolean isLeavesPresent; |
| 1692 | if (curNode instanceof YangLeavesHolder) { |
| 1693 | YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode; |
| 1694 | isLeavesPresent = leavesHolder.getListOfLeaf() != null && !leavesHolder.getListOfLeaf().isEmpty() |
| 1695 | || leavesHolder.getListOfLeafList() != null && !leavesHolder.getListOfLeafList().isEmpty(); |
| 1696 | if (isLeavesPresent) { |
| 1697 | addBitsetImport(imports); |
| 1698 | } |
| 1699 | } |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1700 | if (curNode instanceof YangAugmentableNode) { |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 1701 | addImportsForAugmentableClass(imports, true, false, curNode); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1702 | addInvocationExceptionImport(imports); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1703 | } |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1704 | sortImports(imports); |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1705 | |
| 1706 | //Create impl class file. |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1707 | setImplClassJavaFileHandle(getJavaFileHandle(getImplClassName(curNode))); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1708 | setImplClassJavaFileHandle( |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1709 | generateDefaultClassFile(getImplClassJavaFileHandle(), curNode, isAttributePresent(), imports)); |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1710 | |
| 1711 | //Create builder class file. |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1712 | if ((fileType & BUILDER_CLASS_MASK) != 0) { |
| 1713 | setBuilderClassJavaFileHandle(getJavaFileHandle(getJavaClassName(BUILDER_CLASS_FILE_NAME_SUFFIX))); |
| 1714 | setBuilderClassJavaFileHandle( |
| 1715 | generateBuilderClassFile(getBuilderClassJavaFileHandle(), curNode, |
| 1716 | isAttributePresent())); |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1717 | |
| 1718 | //Append impl class to builder class and close it. |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1719 | mergeJavaFiles(getBuilderClassJavaFileHandle(), getImplClassJavaFileHandle()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1720 | } |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1721 | insertDataIntoJavaFile(getImplClassJavaFileHandle(), getJavaClassDefClose()); |
Bharat saraswal | e304c25 | 2016-08-16 20:56:20 +0530 | [diff] [blame] | 1722 | validateLineLength(getImplClassJavaFileHandle()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1723 | } |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1724 | //Close all the file handles. |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1725 | freeTemporaryResources(false); |
| 1726 | } |
| 1727 | |
Vidyashree Rama | b367047 | 2016-08-06 15:49:56 +0530 | [diff] [blame] | 1728 | //Adds import for array list. |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1729 | private void addArrayListImport(List<String> imports) { |
| 1730 | if (imports.contains(getJavaImportData().getImportForList())) { |
| 1731 | imports.add(ARRAY_LIST_IMPORT); |
| 1732 | } |
| 1733 | } |
| 1734 | |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1735 | private void addBitsetImport(List<String> imports) { |
| 1736 | imports.add(getJavaImportData().getImportForToBitSet()); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1737 | } |
| 1738 | |
| 1739 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1740 | * Adds imports for ToString and HashCodeMethod. |
| 1741 | * |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1742 | * @param imports import list |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1743 | * @param operation add or remove |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1744 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1745 | void addImportsToStringAndHasCodeMethods(List<String> imports, boolean operation) { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1746 | if (operation) { |
| 1747 | imports.add(getJavaImportData().getImportForHashAndEquals()); |
| 1748 | imports.add(getJavaImportData().getImportForToString()); |
| 1749 | } else { |
| 1750 | imports.remove(getJavaImportData().getImportForHashAndEquals()); |
| 1751 | imports.remove(getJavaImportData().getImportForToString()); |
| 1752 | } |
| 1753 | } |
| 1754 | |
| 1755 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1756 | * Adds import for map and hash map. |
| 1757 | * |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1758 | * @param imports import list |
| 1759 | * @param operations true for adding and false for deletion |
| 1760 | * @param isInterfaceFile if need to add in interface file |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 1761 | * @param curNode current node |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1762 | */ |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 1763 | private void addImportsForAugmentableClass(List<String> imports, boolean operations, boolean isInterfaceFile, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1764 | YangNode curNode) { |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1765 | if (operations) { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1766 | if (!isInterfaceFile) { |
| 1767 | imports.add(getJavaImportData().getHashMapImport()); |
| 1768 | } |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 1769 | // Add import for hash map only if node is not a YANG choice. |
| 1770 | if (!(curNode instanceof YangChoice)) { |
| 1771 | imports.add(getJavaImportData().getMapImport()); |
| 1772 | } |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1773 | } else { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1774 | if (!isInterfaceFile) { |
| 1775 | imports.remove(getJavaImportData().getHashMapImport()); |
| 1776 | } |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1777 | imports.remove(getJavaImportData().getMapImport()); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1778 | } |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1779 | sortImports(imports); |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1780 | } |
| 1781 | |
| 1782 | /** |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1783 | * Adds invocation exception import. |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1784 | * |
| 1785 | * @param imports list of imports |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1786 | */ |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1787 | private void addInvocationExceptionImport(List<String> imports) { |
| 1788 | imports.add(INVOCATION_TARGET_EXCEPTION_IMPORT); |
Bharat saraswal | 039f59c | 2016-07-14 21:57:13 +0530 | [diff] [blame] | 1789 | } |
| 1790 | |
| 1791 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1792 | * Removes all temporary file handles. |
| 1793 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1794 | * @param isErrorOccurred flag to tell translator that error has occurred while file generation |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1795 | * @throws IOException when failed to delete the temporary files |
| 1796 | */ |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1797 | public void freeTemporaryResources(boolean isErrorOccurred) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1798 | throws IOException { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1799 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1800 | * Close all java file handles and when error occurs delete the files. |
| 1801 | */ |
| 1802 | if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1803 | closeFile(getInterfaceJavaFileHandle(), isErrorOccurred); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1804 | } |
| 1805 | if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) { |
Bharat saraswal | d14cbe8 | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1806 | closeFile(getBuilderClassJavaFileHandle(), true); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1807 | } |
| 1808 | if ((getGeneratedJavaFiles() & BUILDER_INTERFACE_MASK) != 0) { |
| 1809 | closeFile(getBuilderInterfaceJavaFileHandle(), true); |
| 1810 | } |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1811 | if ((getGeneratedJavaFiles() & DEFAULT_CLASS_MASK) != 0) { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1812 | closeFile(getImplClassJavaFileHandle(), isErrorOccurred); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1813 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 1814 | /* |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1815 | * Close all temporary file handles and delete the files. |
| 1816 | */ |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1817 | if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) { |
| 1818 | closeFile(getGetterImplTempFileHandle(), true); |
| 1819 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1820 | if ((getGeneratedTempFiles() & ATTRIBUTES_MASK) != 0) { |
| 1821 | closeFile(getAttributesTempFileHandle(), true); |
| 1822 | } |
| 1823 | if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) { |
| 1824 | closeFile(getHashCodeImplTempFileHandle(), true); |
| 1825 | } |
| 1826 | if ((getGeneratedTempFiles() & TO_STRING_IMPL_MASK) != 0) { |
| 1827 | closeFile(getToStringImplTempFileHandle(), true); |
| 1828 | } |
| 1829 | if ((getGeneratedTempFiles() & EQUALS_IMPL_MASK) != 0) { |
| 1830 | closeFile(getEqualsImplTempFileHandle(), true); |
| 1831 | } |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 1832 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
| 1833 | closeFile(getFromStringImplTempFileHandle(), true); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1834 | } |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1835 | if ((getGeneratedTempFiles() & ADD_TO_LIST_IMPL_MASK) != 0) { |
| 1836 | closeFile(getAddToListImplTempFileHandle(), true); |
| 1837 | } |
| 1838 | if ((getGeneratedTempFiles() & ADD_TO_LIST_INTERFACE_MASK) != 0) { |
| 1839 | closeFile(getAddToListInterfaceTempFileHandle(), true); |
| 1840 | } |
| 1841 | if ((getGeneratedTempFiles() & LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK) != 0) { |
| 1842 | closeFile(getLeafIdAttributeTempFileHandle(), true); |
| 1843 | } |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1844 | if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_MASK) != 0) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1845 | closeFile(getSubtreeFilteringForLeafTempFileHandle(), true); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1846 | } |
| 1847 | if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_LEAF_LIST_MASK) != 0) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1848 | closeFile(getGetSubtreeFilteringForListTempFileHandle(), true); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1849 | } |
| 1850 | if ((getGeneratedTempFiles() & FILTER_CONTENT_MATCH_FOR_NODES_MASK) != 0) { |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1851 | closeFile(getGetSubtreeFilteringForChildNodeTempFileHandle(), true); |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1852 | } |
| 1853 | if ((getGeneratedTempFiles() & EDIT_CONTENT_MASK) != 0) { |
| 1854 | closeFile(getEditContentTempFileHandle(), true); |
| 1855 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1856 | } |
| 1857 | |
| 1858 | /** |
Bharat saraswal | af413b8 | 2016-07-14 15:18:20 +0530 | [diff] [blame] | 1859 | * Returns if the attribute needs to be accessed in a qualified manner or not, if it needs to be imported, then the |
| 1860 | * same needs to be done. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1861 | * |
| 1862 | * @param importInfo import info for the current attribute being added |
| 1863 | * @return status of the qualified access to the attribute |
| 1864 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 1865 | boolean getIsQualifiedAccessOrAddToImportList( |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 1866 | JavaQualifiedTypeInfoTranslator importInfo) { |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 1867 | return getJavaImportData().addImportInfo(importInfo, getGeneratedJavaClassName(), |
| 1868 | getJavaFileInfo().getPackage()); |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1869 | } |
| 1870 | |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1871 | /** |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1872 | * Returns temp file handle for add to list interface. |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1873 | * |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1874 | * @return temp file handle for add to list interface |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1875 | */ |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1876 | public File getAddToListInterfaceTempFileHandle() { |
| 1877 | return addToListInterfaceTempFileHandle; |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1878 | } |
| 1879 | |
| 1880 | /** |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1881 | * Sets temp file handle for add to list interface. |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1882 | * |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1883 | * @param addToListInterfaceTempFileHandle temp file handle for add to list interface |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1884 | */ |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1885 | private void setAddToListInterfaceTempFileHandle(File addToListInterfaceTempFileHandle) { |
| 1886 | this.addToListInterfaceTempFileHandle = addToListInterfaceTempFileHandle; |
| 1887 | } |
| 1888 | |
| 1889 | /** |
| 1890 | * Returns temp file handle for add to list impl. |
| 1891 | * |
| 1892 | * @return temp file handle for add to list impl |
| 1893 | */ |
| 1894 | public File getAddToListImplTempFileHandle() { |
| 1895 | return addToListImplTempFileHandle; |
| 1896 | } |
| 1897 | |
| 1898 | /** |
| 1899 | * Sets temp file handle for add to list impl. |
| 1900 | * |
| 1901 | * @param addToListImplTempFileHandle temp file handle for add to list impl |
| 1902 | */ |
| 1903 | private void setAddToListImplTempFileHandle(File addToListImplTempFileHandle) { |
| 1904 | this.addToListImplTempFileHandle = addToListImplTempFileHandle; |
| 1905 | } |
| 1906 | |
| 1907 | /** |
| 1908 | * Returns temp file handle for leaf identifier attributes. |
| 1909 | * |
| 1910 | * @return temp file handle for leaf identifier attributes |
| 1911 | */ |
| 1912 | public File getLeafIdAttributeTempFileHandle() { |
| 1913 | return leafIdAttributeTempFileHandle; |
| 1914 | } |
| 1915 | |
| 1916 | /** |
| 1917 | * Sets temp file handle for leaf identifier attributes. |
| 1918 | * |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1919 | * @param leafIdAttributeTempFileHandle temp file handle for leaf identifier attributes |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1920 | */ |
| 1921 | private void setLeafIdAttributeTempFileHandle(File leafIdAttributeTempFileHandle) { |
| 1922 | this.leafIdAttributeTempFileHandle = leafIdAttributeTempFileHandle; |
| 1923 | } |
| 1924 | |
| 1925 | /** |
| 1926 | * Returns if root node is set. |
| 1927 | * |
| 1928 | * @return true if root node |
| 1929 | */ |
| 1930 | private boolean isRooNode() { |
| 1931 | return isRooNode; |
| 1932 | } |
| 1933 | |
| 1934 | /** |
| 1935 | * Sets true if root node. |
| 1936 | * |
| 1937 | * @param rooNode true if root node |
| 1938 | */ |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1939 | void setRooNode(boolean rooNode) { |
Bharat saraswal | 8beac34 | 2016-08-04 02:00:03 +0530 | [diff] [blame] | 1940 | isRooNode = rooNode; |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 1941 | } |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1942 | |
| 1943 | /** |
| 1944 | * Returns temp file for is content match. |
| 1945 | * |
| 1946 | * @return temp file for is content match |
| 1947 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1948 | public File getSubtreeFilteringForLeafTempFileHandle() { |
| 1949 | return subtreeFilteringForLeafTempFileHandle; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1950 | } |
| 1951 | |
| 1952 | /** |
| 1953 | * Sets temp file handle for is content match. |
| 1954 | * |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1955 | * @param subtreeFilteringForLeafTempFileHandle temp file handle for is content match |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1956 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1957 | private void setSubtreeFilteringForLeafTempFileHandle(File subtreeFilteringForLeafTempFileHandle) { |
| 1958 | this.subtreeFilteringForLeafTempFileHandle = subtreeFilteringForLeafTempFileHandle; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | /** |
| 1962 | * Returns temp file for edit content file. |
| 1963 | * |
| 1964 | * @return temp file for edit content file |
| 1965 | */ |
| 1966 | public File getEditContentTempFileHandle() { |
| 1967 | return editContentTempFileHandle; |
| 1968 | } |
| 1969 | |
| 1970 | /** |
| 1971 | * Sets temp file for edit content file. |
| 1972 | * |
| 1973 | * @param editContentTempFileHandle temp file for edit content file |
| 1974 | */ |
| 1975 | private void setEditContentTempFileHandle(File editContentTempFileHandle) { |
| 1976 | this.editContentTempFileHandle = editContentTempFileHandle; |
| 1977 | } |
| 1978 | |
| 1979 | /** |
| 1980 | * Returns temp file for is content match. |
| 1981 | * |
| 1982 | * @return temp file for is content match |
| 1983 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1984 | public File getGetSubtreeFilteringForListTempFileHandle() { |
| 1985 | return getSubtreeFilteringForListTempFileHandle; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1986 | } |
| 1987 | |
| 1988 | /** |
| 1989 | * Sets temp file handle for is content match. |
| 1990 | * |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1991 | * @param getSubtreeFilteringForListTempFileHandle temp file handle for is content match |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1992 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 1993 | private void setGetSubtreeFilteringForListTempFileHandle(File getSubtreeFilteringForListTempFileHandle) { |
| 1994 | this.getSubtreeFilteringForListTempFileHandle = getSubtreeFilteringForListTempFileHandle; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 1995 | } |
| 1996 | |
| 1997 | /** |
| 1998 | * Returns temp file for is content match. |
| 1999 | * |
| 2000 | * @return temp file for is content match |
| 2001 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 2002 | public File getGetSubtreeFilteringForChildNodeTempFileHandle() { |
| 2003 | return getSubtreeFilteringForChildNodeTempFileHandle; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 2004 | } |
| 2005 | |
| 2006 | /** |
| 2007 | * Sets temp file handle for is content match. |
| 2008 | * |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 2009 | * @param getSubtreeFilteringForChildNodeTempFileHandle temp file handle for is content match |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 2010 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 2011 | private void setGetSubtreeFilteringForChildNodeTempFileHandle(File getSubtreeFilteringForChildNodeTempFileHandle) { |
| 2012 | this.getSubtreeFilteringForChildNodeTempFileHandle = getSubtreeFilteringForChildNodeTempFileHandle; |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 2013 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 2014 | } |