Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yangutils.translator.tojava; |
| 18 | |
| 19 | import java.io.File; |
| 20 | import java.io.IOException; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 21 | import java.util.ArrayList; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 22 | import java.util.List; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 23 | import java.util.Set; |
| 24 | |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 25 | import org.onosproject.yangutils.datamodel.HasType; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 26 | import org.onosproject.yangutils.datamodel.YangEnum; |
| 27 | import org.onosproject.yangutils.datamodel.YangEnumeration; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 28 | import org.onosproject.yangutils.datamodel.YangLeaf; |
| 29 | import org.onosproject.yangutils.datamodel.YangLeafList; |
| 30 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
| 31 | import org.onosproject.yangutils.datamodel.YangNode; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 32 | import org.onosproject.yangutils.datamodel.YangType; |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 33 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 34 | |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 35 | import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK; |
| 37 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 38 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 39 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 40 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 41 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK; |
| 42 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; |
| 43 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 44 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 45 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 46 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 47 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK; |
| 48 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; |
| 49 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK; |
| 50 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 51 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 52 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK; |
| 53 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK; |
| 54 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 55 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.UNION_FROM_STRING_IMPL_MASK; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 56 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoOfEnumAttribute; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 57 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoOfLeaf; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 58 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoOfType; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 59 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getCurNodeAsAttributeInParent; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 60 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getFromStringAttributeInfo; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 61 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 62 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination; |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 63 | import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 64 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile; |
| 65 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 66 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 67 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile; |
| 68 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile; |
| 69 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateTypeDefClassFile; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 70 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateUnionClassFile; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 71 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 72 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase; |
| 73 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase; |
| 74 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 75 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode; |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 76 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 77 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString; |
| 78 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor; |
| 79 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString; |
| 80 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 81 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getFromStringMethod; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 82 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass; |
| 83 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString; |
| 84 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethod; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 85 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethod; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 86 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 87 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString; |
| 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; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 91 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 92 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString; |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 93 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addArrayListImport; |
| 94 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addAugmentedInfoImport; |
| 95 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addHasAugmentationImport; |
| 96 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addImportsToStringAndHasCodeMethods; |
| 97 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.closeFile; |
| 98 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.isAugmentedInfoExtended; |
| 99 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.isHasAugmentationExtended; |
| 100 | import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.prepareJavaFileGeneratorForExtendsList; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 101 | import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; |
| 102 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
| 103 | import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; |
| 104 | import static org.onosproject.yangutils.utils.UtilConstants.IMPL; |
| 105 | import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE; |
| 106 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 107 | import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC_OF_CHILD; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 108 | import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; |
| 109 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
| 110 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage; |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 111 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 112 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 113 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 114 | import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 115 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.clean; |
| 116 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; |
| 117 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 118 | |
| 119 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 120 | * Represents implementation of java code fragments temporary implementations. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 121 | */ |
| 122 | public class TempJavaCodeFragmentFiles { |
| 123 | |
| 124 | /** |
| 125 | * The variable which guides the types of temporary files generated using |
| 126 | * the temporary generated file types mask. |
| 127 | */ |
| 128 | private int generatedTempFiles; |
| 129 | |
| 130 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 131 | * The variable which guides the types of files generated using |
| 132 | * the generated file types mask. |
| 133 | */ |
| 134 | private int generatedJavaFiles; |
| 135 | |
| 136 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 137 | * Absolute path where the target java file needs to be generated. |
| 138 | */ |
| 139 | private String absoluteDirPath; |
| 140 | |
| 141 | /** |
| 142 | * Name of java file that needs to be generated. |
| 143 | */ |
| 144 | private String generatedJavaClassName; |
| 145 | |
| 146 | /** |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 147 | * Contains all the class name which will be extended by generated files. |
| 148 | */ |
| 149 | private List<String> extendsList = new ArrayList<>(); |
| 150 | |
| 151 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 152 | * File type extension for java classes. |
| 153 | */ |
| 154 | private static final String JAVA_FILE_EXTENSION = ".java"; |
| 155 | |
| 156 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 157 | * File type extension for temporary classes. |
| 158 | */ |
| 159 | private static final String TEMP_FILE_EXTENSION = ".tmp"; |
| 160 | |
| 161 | /** |
| 162 | * Folder suffix for temporary files folder. |
| 163 | */ |
| 164 | private static final String TEMP_FOLDER_NAME_SUFIX = "-Temp"; |
| 165 | |
| 166 | /** |
| 167 | * File name for getter method. |
| 168 | */ |
| 169 | private static final String GETTER_METHOD_FILE_NAME = "GetterMethod"; |
| 170 | |
| 171 | /** |
| 172 | * File name for getter method implementation. |
| 173 | */ |
| 174 | private static final String GETTER_METHOD_IMPL_FILE_NAME = "GetterMethodImpl"; |
| 175 | |
| 176 | /** |
| 177 | * File name for setter method. |
| 178 | */ |
| 179 | private static final String SETTER_METHOD_FILE_NAME = "SetterMethod"; |
| 180 | |
| 181 | /** |
| 182 | * File name for setter method implementation. |
| 183 | */ |
| 184 | private static final String SETTER_METHOD_IMPL_FILE_NAME = "SetterMethodImpl"; |
| 185 | |
| 186 | /** |
| 187 | * File name for constructor. |
| 188 | */ |
| 189 | private static final String CONSTRUCTOR_FILE_NAME = "Constructor"; |
| 190 | |
| 191 | /** |
| 192 | * File name for attributes. |
| 193 | */ |
| 194 | private static final String ATTRIBUTE_FILE_NAME = "Attributes"; |
| 195 | |
| 196 | /** |
| 197 | * File name for to string method. |
| 198 | */ |
| 199 | private static final String TO_STRING_METHOD_FILE_NAME = "ToString"; |
| 200 | |
| 201 | /** |
| 202 | * File name for hash code method. |
| 203 | */ |
| 204 | private static final String HASH_CODE_METHOD_FILE_NAME = "HashCode"; |
| 205 | |
| 206 | /** |
| 207 | * File name for equals method. |
| 208 | */ |
| 209 | private static final String EQUALS_METHOD_FILE_NAME = "Equals"; |
| 210 | |
| 211 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 212 | * File name for of string method. |
| 213 | */ |
| 214 | private static final String OF_STRING_METHOD_FILE_NAME = "OfString"; |
| 215 | |
| 216 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 217 | * File name for temporary enum class. |
| 218 | */ |
| 219 | private static final String ENUM_CLASS_TEMP_FILE_NAME = "EnumClass"; |
| 220 | |
| 221 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 222 | * File name for construction for special type like union, typedef. |
| 223 | */ |
| 224 | private static final String CONSTRUCTOR_FOR_TYPE_FILE_NAME = "ConstructorForType"; |
| 225 | |
| 226 | /** |
| 227 | * File name for from string method. |
| 228 | */ |
| 229 | private static final String UNION_FROM_STRING_METHOD_FILE_NAME = "UnionFromString"; |
| 230 | |
| 231 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 232 | * File name for interface java file name suffix. |
| 233 | */ |
| 234 | private static final String INTERFACE_FILE_NAME_SUFFIX = EMPTY_STRING; |
| 235 | |
| 236 | /** |
| 237 | * File name for builder interface file name suffix. |
| 238 | */ |
| 239 | private static final String BUILDER_INTERFACE_FILE_NAME_SUFFIX = BUILDER + INTERFACE; |
| 240 | |
| 241 | /** |
| 242 | * File name for builder class file name suffix. |
| 243 | */ |
| 244 | private static final String BUILDER_CLASS_FILE_NAME_SUFFIX = BUILDER; |
| 245 | |
| 246 | /** |
| 247 | * File name for impl class file name suffix. |
| 248 | */ |
| 249 | private static final String IMPL_CLASS_FILE_NAME_SUFFIX = IMPL; |
| 250 | |
| 251 | /** |
| 252 | * File name for typedef class file name suffix. |
| 253 | */ |
| 254 | private static final String TYPEDEF_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING; |
| 255 | |
| 256 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 257 | * File name for enum class file name suffix. |
| 258 | */ |
| 259 | private static final String ENUM_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING; |
| 260 | |
| 261 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 262 | * File name for generated class file for special type like union, typedef suffix. |
| 263 | */ |
| 264 | private static final String UNION_TYPE_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING; |
| 265 | |
| 266 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 267 | * Java file handle for interface file. |
| 268 | */ |
| 269 | private File interfaceJavaFileHandle; |
| 270 | |
| 271 | /** |
| 272 | * Java file handle for builder interface file. |
| 273 | */ |
| 274 | private File builderInterfaceJavaFileHandle; |
| 275 | |
| 276 | /** |
| 277 | * Java file handle for builder class file. |
| 278 | */ |
| 279 | private File builderClassJavaFileHandle; |
| 280 | |
| 281 | /** |
| 282 | * Java file handle for impl class file. |
| 283 | */ |
| 284 | private File implClassJavaFileHandle; |
| 285 | |
| 286 | /** |
| 287 | * Java file handle for typedef class file. |
| 288 | */ |
| 289 | private File typedefClassJavaFileHandle; |
| 290 | |
| 291 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 292 | * Java file handle for type class like union, typedef file. |
| 293 | */ |
| 294 | private File typeClassJavaFileHandle; |
| 295 | |
| 296 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 297 | * Temporary file handle for attribute. |
| 298 | */ |
| 299 | private File attributesTempFileHandle; |
| 300 | |
| 301 | /** |
| 302 | * Temporary file handle for getter of interface. |
| 303 | */ |
| 304 | private File getterInterfaceTempFileHandle; |
| 305 | |
| 306 | /** |
| 307 | * Temporary file handle for getter of class. |
| 308 | */ |
| 309 | private File getterImplTempFileHandle; |
| 310 | |
| 311 | /** |
| 312 | * Temporary file handle for setter of interface. |
| 313 | */ |
| 314 | private File setterInterfaceTempFileHandle; |
| 315 | |
| 316 | /** |
| 317 | * Temporary file handle for setter of class. |
| 318 | */ |
| 319 | private File setterImplTempFileHandle; |
| 320 | |
| 321 | /** |
| 322 | * Temporary file handle for constructor of class. |
| 323 | */ |
| 324 | private File constructorImplTempFileHandle; |
| 325 | |
| 326 | /** |
| 327 | * Temporary file handle for hash code method of class. |
| 328 | */ |
| 329 | private File hashCodeImplTempFileHandle; |
| 330 | |
| 331 | /** |
| 332 | * Temporary file handle for equals method of class. |
| 333 | */ |
| 334 | private File equalsImplTempFileHandle; |
| 335 | |
| 336 | /** |
| 337 | * Temporary file handle for to string method of class. |
| 338 | */ |
| 339 | private File toStringImplTempFileHandle; |
| 340 | |
| 341 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 342 | * Temporary file handle for enum class file. |
| 343 | */ |
| 344 | private File enumClassTempFileHandle; |
| 345 | |
| 346 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 347 | * Temporary file handle for of string method of class. |
| 348 | */ |
| 349 | private File ofStringImplTempFileHandle; |
| 350 | |
| 351 | /** |
| 352 | * Temporary file handle for constructor for type class. |
| 353 | */ |
| 354 | private File constructorForTypeTempFileHandle; |
| 355 | |
| 356 | /** |
| 357 | * Temporary file handle for union's from string method of class. |
| 358 | */ |
| 359 | private File unionFromStringImplTempFileHandle; |
| 360 | |
| 361 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 362 | * Java attribute info. |
| 363 | */ |
| 364 | private JavaAttributeInfo newAttrInfo; |
| 365 | |
| 366 | /** |
| 367 | * Current YANG node. |
| 368 | */ |
| 369 | private YangNode curYangNode; |
| 370 | |
| 371 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 372 | * Current enum's value. |
| 373 | */ |
| 374 | private int enumValue; |
| 375 | |
| 376 | /** |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 377 | * Is attribute added. |
| 378 | */ |
| 379 | private boolean isAttributePresent = false; |
| 380 | |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 381 | /* |
| 382 | * Java file handle for enum class. |
| 383 | */ |
| 384 | private File enumClassJavaFileHandle; |
| 385 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 386 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 387 | * Creates an instance of temporary java code fragment. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 388 | * |
| 389 | * @param genFileType file generation type |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 390 | * @param genDir file generation directory |
| 391 | * @param className class name |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 392 | * @throws IOException when fails to create new file handle |
| 393 | */ |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 394 | public TempJavaCodeFragmentFiles(int genFileType, String genDir, String className) |
| 395 | throws IOException { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 396 | |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 397 | setExtendsList(new ArrayList<>()); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 398 | generatedTempFiles = 0; |
| 399 | absoluteDirPath = genDir; |
| 400 | generatedJavaClassName = className; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 401 | generatedJavaFiles = genFileType; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 402 | /** |
| 403 | * Initialize getter when generation file type matches to interface |
| 404 | * mask. |
| 405 | */ |
| 406 | if ((genFileType & INTERFACE_MASK) != 0) { |
| 407 | generatedTempFiles |= GETTER_FOR_INTERFACE_MASK; |
| 408 | } |
| 409 | |
| 410 | /** |
| 411 | * Initialize getter and setter when generation file type matches to |
| 412 | * builder interface mask. |
| 413 | */ |
| 414 | if ((genFileType & BUILDER_INTERFACE_MASK) != 0) { |
| 415 | generatedTempFiles |= GETTER_FOR_INTERFACE_MASK; |
| 416 | generatedTempFiles |= SETTER_FOR_INTERFACE_MASK; |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * Initialize getterImpl, setterImpl and attributes when generation file |
| 421 | * type matches to builder class mask. |
| 422 | */ |
| 423 | if ((genFileType & BUILDER_CLASS_MASK) != 0) { |
| 424 | generatedTempFiles |= ATTRIBUTES_MASK; |
| 425 | generatedTempFiles |= GETTER_FOR_CLASS_MASK; |
| 426 | generatedTempFiles |= SETTER_FOR_CLASS_MASK; |
| 427 | } |
| 428 | |
| 429 | /** |
| 430 | * Initialize getterImpl, attributes, constructor, hash code, equals and |
| 431 | * to strings when generation file type matches to impl class mask. |
| 432 | */ |
| 433 | if ((genFileType & IMPL_CLASS_MASK) != 0) { |
| 434 | generatedTempFiles |= ATTRIBUTES_MASK; |
| 435 | generatedTempFiles |= GETTER_FOR_CLASS_MASK; |
| 436 | generatedTempFiles |= CONSTRUCTOR_IMPL_MASK; |
| 437 | generatedTempFiles |= HASH_CODE_IMPL_MASK; |
| 438 | generatedTempFiles |= EQUALS_IMPL_MASK; |
| 439 | generatedTempFiles |= TO_STRING_IMPL_MASK; |
| 440 | } |
| 441 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 442 | /** |
| 443 | * Initialize getterImpl, attributes, hash code, equals and |
| 444 | * to strings when generation file type matches to typeDef class mask. |
| 445 | */ |
| 446 | if ((genFileType & GENERATE_TYPEDEF_CLASS) != 0) { |
| 447 | generatedTempFiles |= ATTRIBUTES_MASK; |
| 448 | generatedTempFiles |= GETTER_FOR_CLASS_MASK; |
| 449 | generatedTempFiles |= HASH_CODE_IMPL_MASK; |
| 450 | generatedTempFiles |= EQUALS_IMPL_MASK; |
| 451 | generatedTempFiles |= TO_STRING_IMPL_MASK; |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 452 | generatedTempFiles |= OF_STRING_IMPL_MASK; |
| 453 | generatedTempFiles |= CONSTRUCTOR_FOR_TYPE_MASK; |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * Initialize getterImpl, attributes, hash code, equals, of string, |
| 458 | * constructor, union's to string, union's from string when generation |
| 459 | * file type matches to union class mask. |
| 460 | */ |
| 461 | if ((genFileType & GENERATE_UNION_CLASS) != 0) { |
| 462 | generatedTempFiles |= ATTRIBUTES_MASK; |
| 463 | generatedTempFiles |= GETTER_FOR_CLASS_MASK; |
| 464 | generatedTempFiles |= HASH_CODE_IMPL_MASK; |
| 465 | generatedTempFiles |= EQUALS_IMPL_MASK; |
| 466 | generatedTempFiles |= OF_STRING_IMPL_MASK; |
| 467 | generatedTempFiles |= CONSTRUCTOR_FOR_TYPE_MASK; |
| 468 | generatedTempFiles |= TO_STRING_IMPL_MASK; |
| 469 | generatedTempFiles |= UNION_FROM_STRING_IMPL_MASK; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 470 | } |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 471 | /** |
| 472 | * Initialize enum when generation file type matches to enum class mask. |
| 473 | */ |
| 474 | if ((genFileType & GENERATE_ENUM_CLASS) != 0) { |
| 475 | generatedTempFiles |= ENUM_IMPL_MASK; |
| 476 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 477 | |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 478 | /** |
| 479 | * Set temporary file handles. |
| 480 | */ |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 481 | if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) { |
| 482 | setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME)); |
| 483 | } |
| 484 | |
| 485 | if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) { |
| 486 | setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME)); |
| 487 | } |
| 488 | |
| 489 | if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) { |
| 490 | setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME)); |
| 491 | } |
| 492 | |
| 493 | if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) { |
| 494 | setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME)); |
| 495 | } |
| 496 | |
| 497 | if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) { |
| 498 | setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME)); |
| 499 | } |
| 500 | |
| 501 | if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) { |
| 502 | setConstructorImplTempFileHandle(getTemporaryFileHandle(CONSTRUCTOR_FILE_NAME)); |
| 503 | } |
| 504 | |
| 505 | if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) { |
| 506 | setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME)); |
| 507 | } |
| 508 | |
| 509 | if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) { |
| 510 | setEqualsImplTempFileHandle(getTemporaryFileHandle(EQUALS_METHOD_FILE_NAME)); |
| 511 | } |
| 512 | if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) { |
| 513 | setToStringImplTempFileHandle(getTemporaryFileHandle(TO_STRING_METHOD_FILE_NAME)); |
| 514 | } |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 515 | if ((generatedTempFiles & ENUM_IMPL_MASK) != 0) { |
| 516 | setEnumClassTempFileHandle(getTemporaryFileHandle(ENUM_CLASS_TEMP_FILE_NAME)); |
| 517 | } |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 518 | if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) { |
| 519 | setOfStringImplTempFileHandle(getTemporaryFileHandle(OF_STRING_METHOD_FILE_NAME)); |
| 520 | } |
| 521 | |
| 522 | if ((generatedTempFiles & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { |
| 523 | setConstructorForTypeTempFileHandle(getTemporaryFileHandle(CONSTRUCTOR_FOR_TYPE_FILE_NAME)); |
| 524 | } |
| 525 | |
| 526 | if ((generatedTempFiles & UNION_FROM_STRING_IMPL_MASK) != 0) { |
| 527 | setUnionFromStringImplTempFileHandle(getTemporaryFileHandle(UNION_FROM_STRING_METHOD_FILE_NAME)); |
| 528 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 532 | * Returns java file handle for interface file. |
| 533 | * |
| 534 | * @return java file handle for interface file |
| 535 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 536 | private File getInterfaceJavaFileHandle() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 537 | return interfaceJavaFileHandle; |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Sets the java file handle for interface file. |
| 542 | * |
| 543 | * @param interfaceJavaFileHandle java file handle |
| 544 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 545 | private void setInterfaceJavaFileHandle(File interfaceJavaFileHandle) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 546 | this.interfaceJavaFileHandle = interfaceJavaFileHandle; |
| 547 | } |
| 548 | |
| 549 | /** |
| 550 | * Returns java file handle for builder interface file. |
| 551 | * |
| 552 | * @return java file handle for builder interface file |
| 553 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 554 | private File getBuilderInterfaceJavaFileHandle() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 555 | return builderInterfaceJavaFileHandle; |
| 556 | } |
| 557 | |
| 558 | /** |
| 559 | * Sets the java file handle for builder interface file. |
| 560 | * |
| 561 | * @param builderInterfaceJavaFileHandle java file handle |
| 562 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 563 | private void setBuilderInterfaceJavaFileHandle(File builderInterfaceJavaFileHandle) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 564 | this.builderInterfaceJavaFileHandle = builderInterfaceJavaFileHandle; |
| 565 | } |
| 566 | |
| 567 | /** |
| 568 | * Returns java file handle for builder class file. |
| 569 | * |
| 570 | * @return java file handle for builder class file |
| 571 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 572 | private File getBuilderClassJavaFileHandle() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 573 | return builderClassJavaFileHandle; |
| 574 | } |
| 575 | |
| 576 | /** |
| 577 | * Sets the java file handle for builder class file. |
| 578 | * |
| 579 | * @param builderClassJavaFileHandle java file handle |
| 580 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 581 | private void setBuilderClassJavaFileHandle(File builderClassJavaFileHandle) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 582 | this.builderClassJavaFileHandle = builderClassJavaFileHandle; |
| 583 | } |
| 584 | |
| 585 | /** |
| 586 | * Returns java file handle for impl class file. |
| 587 | * |
| 588 | * @return java file handle for impl class file |
| 589 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 590 | private File getImplClassJavaFileHandle() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 591 | return implClassJavaFileHandle; |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * Sets the java file handle for impl class file. |
| 596 | * |
| 597 | * @param implClassJavaFileHandle java file handle |
| 598 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 599 | private void setImplClassJavaFileHandle(File implClassJavaFileHandle) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 600 | this.implClassJavaFileHandle = implClassJavaFileHandle; |
| 601 | } |
| 602 | |
| 603 | /** |
| 604 | * Returns java file handle for typedef class file. |
| 605 | * |
| 606 | * @return java file handle for typedef class file |
| 607 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 608 | private File getTypedefClassJavaFileHandle() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 609 | return typedefClassJavaFileHandle; |
| 610 | } |
| 611 | |
| 612 | /** |
| 613 | * Sets the java file handle for typedef class file. |
| 614 | * |
| 615 | * @param typedefClassJavaFileHandle java file handle |
| 616 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 617 | private void setTypedefClassJavaFileHandle(File typedefClassJavaFileHandle) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 618 | this.typedefClassJavaFileHandle = typedefClassJavaFileHandle; |
| 619 | } |
| 620 | |
| 621 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 622 | * Returns enum class java file handle. |
| 623 | * |
| 624 | * @return enum class java file handle |
| 625 | */ |
| 626 | private File getEnumClassJavaFileHandle() { |
| 627 | return enumClassJavaFileHandle; |
| 628 | } |
| 629 | |
| 630 | /** |
| 631 | * Sets enum class java file handle. |
| 632 | * |
| 633 | * @param enumClassJavaFileHandle enum class java file handle |
| 634 | */ |
| 635 | |
| 636 | private void setEnumClassJavaFileHandle(File enumClassJavaFileHandle) { |
| 637 | this.enumClassJavaFileHandle = enumClassJavaFileHandle; |
| 638 | } |
| 639 | |
| 640 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 641 | * Returns java file handle for type class file. |
| 642 | * |
| 643 | * @return java file handle for type class file |
| 644 | */ |
| 645 | private File getTypeClassJavaFileHandle() { |
| 646 | return typeClassJavaFileHandle; |
| 647 | } |
| 648 | |
| 649 | /** |
| 650 | * Sets the java file handle for type class file. |
| 651 | * |
| 652 | * @param typeClassJavaFileHandle type file handle |
| 653 | */ |
| 654 | private void setTypeClassJavaFileHandle(File typeClassJavaFileHandle) { |
| 655 | this.typeClassJavaFileHandle = typeClassJavaFileHandle; |
| 656 | } |
| 657 | |
| 658 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 659 | * Returns attribute's temporary file handle. |
| 660 | * |
| 661 | * @return temporary file handle |
| 662 | */ |
| 663 | public File getAttributesTempFileHandle() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 664 | return attributesTempFileHandle; |
| 665 | } |
| 666 | |
| 667 | /** |
| 668 | * Sets attribute's temporary file handle. |
| 669 | * |
| 670 | * @param attributeForClass file handle for attribute |
| 671 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 672 | private void setAttributesTempFileHandle(File attributeForClass) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 673 | attributesTempFileHandle = attributeForClass; |
| 674 | } |
| 675 | |
| 676 | /** |
| 677 | * Returns getter methods's temporary file handle. |
| 678 | * |
| 679 | * @return temporary file handle |
| 680 | */ |
| 681 | public File getGetterInterfaceTempFileHandle() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 682 | return getterInterfaceTempFileHandle; |
| 683 | } |
| 684 | |
| 685 | /** |
| 686 | * Sets to getter method's temporary file handle. |
| 687 | * |
| 688 | * @param getterForInterface file handle for to getter method |
| 689 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 690 | private void setGetterInterfaceTempFileHandle(File getterForInterface) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 691 | getterInterfaceTempFileHandle = getterForInterface; |
| 692 | } |
| 693 | |
| 694 | /** |
| 695 | * Returns getter method's impl's temporary file handle. |
| 696 | * |
| 697 | * @return temporary file handle |
| 698 | */ |
| 699 | public File getGetterImplTempFileHandle() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 700 | return getterImplTempFileHandle; |
| 701 | } |
| 702 | |
| 703 | /** |
| 704 | * Sets to getter method's impl's temporary file handle. |
| 705 | * |
| 706 | * @param getterImpl file handle for to getter method's impl |
| 707 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 708 | private void setGetterImplTempFileHandle(File getterImpl) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 709 | getterImplTempFileHandle = getterImpl; |
| 710 | } |
| 711 | |
| 712 | /** |
| 713 | * Returns setter method's temporary file handle. |
| 714 | * |
| 715 | * @return temporary file handle |
| 716 | */ |
| 717 | public File getSetterInterfaceTempFileHandle() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 718 | return setterInterfaceTempFileHandle; |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * Sets to setter method's temporary file handle. |
| 723 | * |
| 724 | * @param setterForInterface file handle for to setter method |
| 725 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 726 | private void setSetterInterfaceTempFileHandle(File setterForInterface) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 727 | setterInterfaceTempFileHandle = setterForInterface; |
| 728 | } |
| 729 | |
| 730 | /** |
| 731 | * Returns setter method's impl's temporary file handle. |
| 732 | * |
| 733 | * @return temporary file handle |
| 734 | */ |
| 735 | public File getSetterImplTempFileHandle() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 736 | return setterImplTempFileHandle; |
| 737 | } |
| 738 | |
| 739 | /** |
| 740 | * Sets to setter method's impl's temporary file handle. |
| 741 | * |
| 742 | * @param setterImpl file handle for to setter method's implementation class |
| 743 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 744 | private void setSetterImplTempFileHandle(File setterImpl) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 745 | setterImplTempFileHandle = setterImpl; |
| 746 | } |
| 747 | |
| 748 | /** |
| 749 | * Returns constructor's temporary file handle. |
| 750 | * |
| 751 | * @return temporary file handle |
| 752 | */ |
| 753 | public File getConstructorImplTempFileHandle() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 754 | return constructorImplTempFileHandle; |
| 755 | } |
| 756 | |
| 757 | /** |
| 758 | * Sets to constructor's temporary file handle. |
| 759 | * |
| 760 | * @param constructor file handle for to constructor |
| 761 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 762 | private void setConstructorImplTempFileHandle(File constructor) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 763 | constructorImplTempFileHandle = constructor; |
| 764 | } |
| 765 | |
| 766 | /** |
| 767 | * Returns hash code method's temporary file handle. |
| 768 | * |
| 769 | * @return temporary file handle |
| 770 | */ |
| 771 | public File getHashCodeImplTempFileHandle() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 772 | return hashCodeImplTempFileHandle; |
| 773 | } |
| 774 | |
| 775 | /** |
| 776 | * Sets hash code method's temporary file handle. |
| 777 | * |
| 778 | * @param hashCodeMethod file handle for hash code method |
| 779 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 780 | private void setHashCodeImplTempFileHandle(File hashCodeMethod) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 781 | hashCodeImplTempFileHandle = hashCodeMethod; |
| 782 | } |
| 783 | |
| 784 | /** |
| 785 | * Returns equals mehtod's temporary file handle. |
| 786 | * |
| 787 | * @return temporary file handle |
| 788 | */ |
| 789 | public File getEqualsImplTempFileHandle() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 790 | return equalsImplTempFileHandle; |
| 791 | } |
| 792 | |
| 793 | /** |
| 794 | * Sets equals method's temporary file handle. |
| 795 | * |
| 796 | * @param equalsMethod file handle for to equals method |
| 797 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 798 | private void setEqualsImplTempFileHandle(File equalsMethod) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 799 | equalsImplTempFileHandle = equalsMethod; |
| 800 | } |
| 801 | |
| 802 | /** |
| 803 | * Returns to string method's temporary file handle. |
| 804 | * |
| 805 | * @return temporary file handle |
| 806 | */ |
| 807 | public File getToStringImplTempFileHandle() { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 808 | return toStringImplTempFileHandle; |
| 809 | } |
| 810 | |
| 811 | /** |
| 812 | * Sets to string method's temporary file handle. |
| 813 | * |
| 814 | * @param toStringMethod file handle for to string method |
| 815 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 816 | private void setToStringImplTempFileHandle(File toStringMethod) { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 817 | toStringImplTempFileHandle = toStringMethod; |
| 818 | } |
| 819 | |
| 820 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 821 | * Returns temporary file handle for enum class file. |
| 822 | * |
| 823 | * @return temporary file handle for enum class file |
| 824 | */ |
| 825 | public File getEnumClassTempFileHandle() { |
| 826 | return enumClassTempFileHandle; |
| 827 | } |
| 828 | |
| 829 | /** |
| 830 | * Sets temporary file handle for enum class file. |
| 831 | * |
| 832 | * @param enumClassTempFileHandle temporary file handle for enum class file |
| 833 | */ |
| 834 | |
| 835 | private void setEnumClassTempFileHandle(File enumClassTempFileHandle) { |
| 836 | this.enumClassTempFileHandle = enumClassTempFileHandle; |
| 837 | } |
| 838 | |
| 839 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 840 | * Returns of string method's temporary file handle. |
| 841 | * |
| 842 | * @return of string method's temporary file handle |
| 843 | */ |
| 844 | public File getOfStringImplTempFileHandle() { |
| 845 | return ofStringImplTempFileHandle; |
| 846 | } |
| 847 | |
| 848 | /** |
| 849 | * Set of string method's temporary file handle. |
| 850 | * |
| 851 | * @param ofStringImplTempFileHandle of string method's temporary file handle |
| 852 | */ |
| 853 | private void setOfStringImplTempFileHandle(File ofStringImplTempFileHandle) { |
| 854 | this.ofStringImplTempFileHandle = ofStringImplTempFileHandle; |
| 855 | } |
| 856 | |
| 857 | /** |
| 858 | * Returns type class constructor method's temporary file handle. |
| 859 | * |
| 860 | * @return type class constructor method's temporary file handle |
| 861 | */ |
| 862 | public File getConstructorForTypeTempFileHandle() { |
| 863 | return constructorForTypeTempFileHandle; |
| 864 | } |
| 865 | |
| 866 | /** |
| 867 | * Sets type class constructor method's temporary file handle. |
| 868 | * |
| 869 | * @param constructorForTypeTempFileHandle type class constructor method's temporary file handle |
| 870 | */ |
| 871 | private void setConstructorForTypeTempFileHandle(File constructorForTypeTempFileHandle) { |
| 872 | this.constructorForTypeTempFileHandle = constructorForTypeTempFileHandle; |
| 873 | } |
| 874 | |
| 875 | /** |
| 876 | * Returns union's from string method's temporary file handle. |
| 877 | * |
| 878 | * @return union's from string method's temporary file handle |
| 879 | */ |
| 880 | public File getUnionFromStringImplTempFileHandle() { |
| 881 | return unionFromStringImplTempFileHandle; |
| 882 | } |
| 883 | |
| 884 | /** |
| 885 | * Sets union's from string method's temporary file handle. |
| 886 | * |
| 887 | * @param unionFromStringImplTempFileHandle union's from string method's temporary file handle |
| 888 | */ |
| 889 | private void setUnionFromStringImplTempFileHandle(File unionFromStringImplTempFileHandle) { |
| 890 | this.unionFromStringImplTempFileHandle = unionFromStringImplTempFileHandle; |
| 891 | } |
| 892 | |
| 893 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 894 | * Returns java attribute info. |
| 895 | * |
| 896 | * @return java attribute info |
| 897 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 898 | private JavaAttributeInfo getNewAttrInfo() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 899 | return newAttrInfo; |
| 900 | } |
| 901 | |
| 902 | /** |
| 903 | * Sets java attribute info. |
| 904 | * |
| 905 | * @param newAttrInfo java attribute info |
| 906 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 907 | private void setNewAttrInfo(JavaAttributeInfo newAttrInfo) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 908 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 909 | if (newAttrInfo != null) { |
| 910 | isAttributePresent = true; |
| 911 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 912 | this.newAttrInfo = newAttrInfo; |
| 913 | } |
| 914 | |
| 915 | /** |
| 916 | * Returns current YANG node. |
| 917 | * |
| 918 | * @return current YANG node |
| 919 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 920 | private YangNode getCurYangNode() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 921 | return curYangNode; |
| 922 | } |
| 923 | |
| 924 | /** |
| 925 | * Sets current YANG node. |
| 926 | * |
| 927 | * @param curYangNode YANG node |
| 928 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 929 | private void setCurYangNode(YangNode curYangNode) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 930 | this.curYangNode = curYangNode; |
| 931 | } |
| 932 | |
| 933 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 934 | * Returns enum's value. |
| 935 | * |
| 936 | * @return enum's value |
| 937 | */ |
| 938 | public int getEnumValue() { |
| 939 | return enumValue; |
| 940 | } |
| 941 | |
| 942 | /** |
| 943 | * Sets enum's value. |
| 944 | * |
| 945 | * @param enumValue enum's value |
| 946 | */ |
| 947 | public void setEnumValue(int enumValue) { |
| 948 | this.enumValue = enumValue; |
| 949 | } |
| 950 | |
| 951 | /** |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 952 | * Returns list of classes to be extended by generated files. |
| 953 | * |
| 954 | * @return list of classes to be extended by generated files |
| 955 | */ |
| 956 | private List<String> getExtendsList() { |
| 957 | return extendsList; |
| 958 | } |
| 959 | |
| 960 | /** |
| 961 | * Sets class to be extended by generated file. |
| 962 | * |
| 963 | * @param extendsList list of classes to be extended |
| 964 | */ |
| 965 | |
| 966 | private void setExtendsList(List<String> extendsList) { |
| 967 | this.extendsList = extendsList; |
| 968 | } |
| 969 | |
| 970 | /** |
| 971 | * Adds class to the extends list. |
| 972 | * |
| 973 | * @param extend class to be extended |
| 974 | */ |
| 975 | public void addToExtendsList(String extend) { |
| 976 | getExtendsList().add(extend); |
| 977 | } |
| 978 | |
| 979 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 980 | * Adds of string for type. |
| 981 | * |
| 982 | * @param attr attribute info |
| 983 | * @throws IOException when fails to append to temporary file |
| 984 | */ |
| 985 | private void addOfStringMethod(JavaAttributeInfo attr) throws IOException { |
| 986 | appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(attr, generatedJavaClassName) |
| 987 | + NEW_LINE); |
| 988 | } |
| 989 | |
| 990 | /** |
| 991 | * Adds type constructor. |
| 992 | * |
| 993 | * @param attr attribute info |
| 994 | * @throws IOException when fails to append to temporary file |
| 995 | */ |
| 996 | private void addTypeConstructor(JavaAttributeInfo attr) throws IOException { |
| 997 | appendToFile(getConstructorForTypeTempFileHandle(), getTypeConstructorStringAndJavaDoc(attr, |
| 998 | generatedJavaClassName) + NEW_LINE); |
| 999 | } |
| 1000 | |
| 1001 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1002 | * Adds attribute for class. |
| 1003 | * |
| 1004 | * @param attr attribute info |
| 1005 | * @throws IOException when fails to append to temporary file |
| 1006 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1007 | private void addAttribute(JavaAttributeInfo attr) throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1008 | appendToFile(getAttributesTempFileHandle(), parseAttribute(attr) + FOUR_SPACE_INDENTATION); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1009 | } |
| 1010 | |
| 1011 | /** |
| 1012 | * Adds getter for interface. |
| 1013 | * |
| 1014 | * @param attr attribute info |
| 1015 | * @throws IOException when fails to append to temporary file |
| 1016 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1017 | private void addGetterForInterface(JavaAttributeInfo attr) throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1018 | appendToFile(getGetterInterfaceTempFileHandle(), getGetterString(attr) + NEW_LINE); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | /** |
| 1022 | * Adds getter method's impl for class. |
| 1023 | * |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1024 | * @param attr attribute info |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1025 | * @param genFiletype generated file type |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1026 | * @throws IOException when fails to append to temporary file |
| 1027 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1028 | private void addGetterImpl(JavaAttributeInfo attr, int genFiletype) throws IOException { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1029 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1030 | if ((genFiletype & BUILDER_CLASS_MASK) != 0) { |
| 1031 | appendToFile(getGetterImplTempFileHandle(), getOverRideString() + getGetterForClass(attr) + NEW_LINE); |
| 1032 | } else { |
| 1033 | appendToFile(getGetterImplTempFileHandle(), getJavaDoc(GETTER_METHOD, attr.getAttributeName(), false) |
| 1034 | + getGetterForClass(attr) + NEW_LINE); |
| 1035 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | /** |
| 1039 | * Adds setter for interface. |
| 1040 | * |
| 1041 | * @param attr attribute info |
| 1042 | * @throws IOException when fails to append to temporary file |
| 1043 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1044 | private void addSetterForInterface(JavaAttributeInfo attr) throws IOException { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1045 | appendToFile(getSetterInterfaceTempFileHandle(), |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1046 | getSetterString(attr, generatedJavaClassName) + NEW_LINE); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | /** |
| 1050 | * Adds setter's implementation for class. |
| 1051 | * |
| 1052 | * @param attr attribute info |
| 1053 | * @throws IOException when fails to append to temporary file |
| 1054 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1055 | private void addSetterImpl(JavaAttributeInfo attr) throws IOException { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1056 | appendToFile(getSetterImplTempFileHandle(), |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1057 | getOverRideString() + getSetterForClass(attr, generatedJavaClassName) + NEW_LINE); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1058 | } |
| 1059 | |
| 1060 | /** |
| 1061 | * Adds build method for interface. |
| 1062 | * |
| 1063 | * @return build method for interface |
| 1064 | * @throws IOException when fails to append to temporary file |
| 1065 | */ |
| 1066 | public String addBuildMethodForInterface() throws IOException { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1067 | return parseBuilderInterfaceBuildMethodString(generatedJavaClassName); |
| 1068 | } |
| 1069 | |
| 1070 | /** |
| 1071 | * Adds build method's implementation for class. |
| 1072 | * |
| 1073 | * @return build method implementation for class |
| 1074 | * @throws IOException when fails to append to temporary file |
| 1075 | */ |
| 1076 | public String addBuildMethodImpl() throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1077 | return getBuildString(generatedJavaClassName) + NEW_LINE; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1078 | } |
| 1079 | |
| 1080 | /** |
| 1081 | * Adds constructor for class. |
| 1082 | * |
| 1083 | * @param attr attribute info |
| 1084 | * @throws IOException when fails to append to temporary file |
| 1085 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1086 | private void addConstructor(JavaAttributeInfo attr) throws IOException { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1087 | appendToFile(getConstructorImplTempFileHandle(), getConstructor(generatedJavaClassName, attr)); |
| 1088 | } |
| 1089 | |
| 1090 | /** |
| 1091 | * Adds default constructor for class. |
| 1092 | * |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1093 | * @param modifier modifier for constructor. |
| 1094 | * @param toAppend string which need to be appended with the class name |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1095 | * @return default constructor for class |
| 1096 | * @throws IOException when fails to append to file |
| 1097 | */ |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1098 | public String addDefaultConstructor(String modifier, String toAppend) throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1099 | return NEW_LINE + getDefaultConstructorString(generatedJavaClassName + toAppend, modifier); |
| 1100 | } |
| 1101 | |
| 1102 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1103 | * Adds default constructor for class. |
| 1104 | * |
| 1105 | * @return default constructor for class |
| 1106 | * @throws IOException when fails to append to file |
| 1107 | */ |
| 1108 | public String addOfMethod() throws IOException { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1109 | return getJavaDoc(OF_METHOD, generatedJavaClassName, false) |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1110 | + getOfMethod(generatedJavaClassName, newAttrInfo); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1111 | } |
| 1112 | |
| 1113 | /** |
| 1114 | * Adds hash code method for class. |
| 1115 | * |
| 1116 | * @param attr attribute info |
| 1117 | * @throws IOException when fails to append to temporary file |
| 1118 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1119 | private void addHashCodeMethod(JavaAttributeInfo attr) throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1120 | appendToFile(getHashCodeImplTempFileHandle(), getHashCodeMethod(attr) + NEW_LINE); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | /** |
| 1124 | * Adds equals method for class. |
| 1125 | * |
| 1126 | * @param attr attribute info |
| 1127 | * @throws IOException when fails to append to temporary file |
| 1128 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1129 | private void addEqualsMethod(JavaAttributeInfo attr) throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1130 | appendToFile(getEqualsImplTempFileHandle(), getEqualsMethod(attr) + NEW_LINE); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1131 | } |
| 1132 | |
| 1133 | /** |
| 1134 | * Adds ToString method for class. |
| 1135 | * |
| 1136 | * @param attr attribute info |
| 1137 | * @throws IOException when fails to append to temporary file |
| 1138 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1139 | private void addToStringMethod(JavaAttributeInfo attr) throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1140 | appendToFile(getToStringImplTempFileHandle(), getToStringMethod(attr) + NEW_LINE); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 1144 | * Adds enum class attributes to temporary file. |
| 1145 | * |
| 1146 | * @param curEnum current YANG enum |
| 1147 | * @throws IOException when fails to do IO operations. |
| 1148 | */ |
| 1149 | private void addAttributesForEnumClass(JavaAttributeInfo curEnumInfo) throws IOException { |
| 1150 | appendToFile(getEnumClassTempFileHandle(), |
| 1151 | generateEnumAttributeString(curEnumInfo.getAttributeName(), getEnumValue())); |
| 1152 | } |
| 1153 | |
| 1154 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1155 | * Add from string method for union class. |
| 1156 | * |
| 1157 | * @param javaAttributeInfo type attribute info |
| 1158 | * @param fromStringAttributeInfo from string attribute info |
| 1159 | * @throws IOException when fails to append to temporary file |
| 1160 | */ |
| 1161 | private void addUnionFromStringMethod(JavaAttributeInfo javaAttributeInfo, |
| 1162 | JavaAttributeInfo fromStringAttributeInfo) throws IOException { |
| 1163 | appendToFile(getUnionFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo, |
| 1164 | fromStringAttributeInfo) + NEW_LINE); |
| 1165 | } |
| 1166 | |
| 1167 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1168 | * Returns a temporary file handle for the specific file type. |
| 1169 | * |
| 1170 | * @param fileName file name |
| 1171 | * @return temporary file handle |
| 1172 | * @throws IOException when fails to create new file handle |
| 1173 | */ |
| 1174 | private File getTemporaryFileHandle(String fileName) throws IOException { |
| 1175 | |
| 1176 | String path = getTempDirPath(); |
| 1177 | File dir = new File(path); |
| 1178 | if (!dir.exists()) { |
| 1179 | dir.mkdirs(); |
| 1180 | } |
| 1181 | |
| 1182 | File file = new File(path + fileName + TEMP_FILE_EXTENSION); |
| 1183 | if (!file.exists()) { |
| 1184 | file.createNewFile(); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1185 | } |
| 1186 | return file; |
| 1187 | } |
| 1188 | |
| 1189 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1190 | * Returns a temporary file handle for the specific file type. |
| 1191 | * |
| 1192 | * @param fileName file name |
| 1193 | * @return temporary file handle |
| 1194 | * @throws IOException when fails to create new file handle |
| 1195 | */ |
| 1196 | private File getJavaFileHandle(String fileName) throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1197 | return getFileObject(getDirPath(), fileName, JAVA_FILE_EXTENSION, getJavaFileInfo()); |
| 1198 | } |
| 1199 | |
| 1200 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1201 | * Returns data from the temporary files. |
| 1202 | * |
| 1203 | * @param file temporary file handle |
| 1204 | * @return stored data from temporary files |
| 1205 | * @throws IOException when failed to get data from the given file |
| 1206 | */ |
| 1207 | public String getTemporaryDataFromFileHandle(File file) throws IOException { |
| 1208 | |
| 1209 | String path = getTempDirPath(); |
| 1210 | if (new File(path + file.getName()).exists()) { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1211 | return readAppendFile(path + file.getName(), EMPTY_STRING); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1212 | } else { |
| 1213 | throw new IOException("Unable to get data from the given " |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1214 | + file.getName() + " file for " + generatedJavaClassName + PERIOD); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1215 | } |
| 1216 | } |
| 1217 | |
| 1218 | /** |
| 1219 | * Returns temporary directory path. |
| 1220 | * |
| 1221 | * @return directory path |
| 1222 | */ |
| 1223 | private String getTempDirPath() { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1224 | return getPackageDirPathFromJavaJPackage(absoluteDirPath) + SLASH + generatedJavaClassName |
| 1225 | + TEMP_FOLDER_NAME_SUFIX + SLASH; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1226 | } |
| 1227 | |
| 1228 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 1229 | * Parses attribute to get the attribute string. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1230 | * |
| 1231 | * @param attr attribute info |
| 1232 | * @return attribute string |
| 1233 | */ |
| 1234 | private String parseAttribute(JavaAttributeInfo attr) { |
| 1235 | |
| 1236 | /* |
| 1237 | * TODO: check if this utility needs to be called or move to the caller |
| 1238 | */ |
janani b | 1c6acc4 | 2016-04-15 16:18:30 +0530 | [diff] [blame] | 1239 | String attributeName = getCamelCase(getSmallCase(attr.getAttributeName()), null); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1240 | if (attr.isQualifiedName()) { |
| 1241 | return getJavaAttributeDefination(attr.getImportInfo().getPkgInfo(), attr.getImportInfo().getClassInfo(), |
| 1242 | attributeName, attr.isListAttr()); |
| 1243 | } else { |
| 1244 | return getJavaAttributeDefination(null, attr.getImportInfo().getClassInfo(), attributeName, |
| 1245 | attr.isListAttr()); |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 1250 | * Appends content to temporary file. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1251 | * |
| 1252 | * @param file temporary file |
| 1253 | * @param data data to be appended |
| 1254 | * @throws IOException when fails to append to file |
| 1255 | */ |
| 1256 | private void appendToFile(File file, String data) throws IOException { |
| 1257 | |
| 1258 | try { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1259 | insertDataIntoJavaFile(file, data); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1260 | } catch (IOException ex) { |
| 1261 | throw new IOException("failed to write in temp file."); |
| 1262 | } |
| 1263 | } |
| 1264 | |
| 1265 | /** |
| 1266 | * Adds current node info as and attribute to the parent generated file. |
| 1267 | * |
| 1268 | * @param curNode current node which needs to be added as an attribute in |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1269 | * the parent generated code |
| 1270 | * @param isList is list construct |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1271 | * @throws IOException IO operation exception |
| 1272 | */ |
| 1273 | public void addCurNodeInfoInParentTempFile(YangNode curNode, |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1274 | boolean isList) throws IOException { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1275 | |
| 1276 | YangNode parent = getParentNodeInGenCode(curNode); |
| 1277 | if (!(parent instanceof JavaCodeGenerator)) { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1278 | throw new TranslatorException("missing parent node to contain current node info in generated file"); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1279 | } |
| 1280 | JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInParent(curNode, |
| 1281 | parent, isList); |
| 1282 | |
| 1283 | if (!(parent instanceof HasTempJavaCodeFragmentFiles)) { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1284 | throw new TranslatorException("missing parent temp file handle"); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1285 | } |
| 1286 | ((HasTempJavaCodeFragmentFiles) parent) |
| 1287 | .getTempJavaCodeFragmentFiles() |
| 1288 | .addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); |
| 1289 | } |
| 1290 | |
| 1291 | /** |
| 1292 | * Adds leaf attributes in generated files. |
| 1293 | * |
| 1294 | * @param listOfLeaves list of YANG leaf |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1295 | * @param curNode current data model node |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1296 | * @throws IOException IO operation fail |
| 1297 | */ |
| 1298 | private void addLeavesInfoToTempFiles(List<YangLeaf> listOfLeaves, |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1299 | YangNode curNode) throws IOException { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1300 | |
| 1301 | if (listOfLeaves != null) { |
| 1302 | for (YangLeaf leaf : listOfLeaves) { |
| 1303 | JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfLeaf(curNode, |
| 1304 | leaf.getDataType(), |
| 1305 | leaf.getLeafName(), false); |
| 1306 | addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); |
| 1307 | } |
| 1308 | } |
| 1309 | } |
| 1310 | |
| 1311 | /** |
| 1312 | * Adds leaf list's attributes in generated files. |
| 1313 | * |
| 1314 | * @param listOfLeafList list of YANG leaves |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1315 | * @param curNode cached file handle |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1316 | * @throws IOException IO operation fail |
| 1317 | */ |
| 1318 | private void addLeafListInfoToTempFiles(List<YangLeafList> listOfLeafList, |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1319 | YangNode curNode) throws IOException { |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1320 | |
| 1321 | if (listOfLeafList != null) { |
| 1322 | |
| 1323 | /* |
| 1324 | * Check if the attribute is of type list, then the java.lang.list |
| 1325 | * needs to be imported. |
| 1326 | */ |
| 1327 | if (listOfLeafList.size() != 0) { |
| 1328 | if (!(curNode instanceof HasJavaImportData)) { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1329 | throw new TranslatorException("missing import info in current data model node"); |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1330 | |
| 1331 | } |
| 1332 | ((HasJavaImportData) curNode).getJavaImportData() |
| 1333 | .setIfListImported(true); |
| 1334 | |
| 1335 | } |
| 1336 | |
| 1337 | for (YangLeafList leafList : listOfLeafList) { |
| 1338 | JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfLeaf( |
| 1339 | curNode, leafList.getDataType(), leafList.getLeafName(), |
| 1340 | true); |
| 1341 | addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); |
| 1342 | } |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | /** |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1347 | * Adds all the leaves in the current data model node as part of the |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1348 | * generated temporary file. |
| 1349 | * |
| 1350 | * @param curNode java file info of the generated file |
| 1351 | * @throws IOException IO operation fail |
| 1352 | */ |
| 1353 | public void addCurNodeLeavesInfoToTempFiles(YangNode curNode) throws IOException { |
| 1354 | |
| 1355 | if (curNode instanceof YangLeavesHolder) { |
| 1356 | YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode; |
| 1357 | addLeavesInfoToTempFiles(leavesHolder.getListOfLeaf(), curNode); |
| 1358 | addLeafListInfoToTempFiles(leavesHolder.getListOfLeafList(), curNode); |
| 1359 | } |
| 1360 | } |
| 1361 | |
| 1362 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1363 | * Add all the type in the current data model node as part of the |
| 1364 | * generated temporary file. |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1365 | * |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1366 | * @param hasType YANG java data model node which has type info, eg union / typedef |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1367 | * @throws IOException IO operation fail |
| 1368 | */ |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1369 | public void addTypeInfoToTempFiles(HasType hasType) throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1370 | |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1371 | List<YangType<?>> typeList = hasType.getTypeList(); |
| 1372 | if (typeList != null) { |
| 1373 | for (YangType<?> yangType : typeList) { |
| 1374 | JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfType((YangNode) hasType, |
| 1375 | yangType, getTypeName(yangType.getDataTypeName()), false); |
| 1376 | addJavaSnippetInfoToApplicableTempFiles((YangNode) hasType, javaAttributeInfo); |
| 1377 | } |
| 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | private String getTypeName(String dataTypeName) { |
| 1382 | return dataTypeName; |
| 1383 | //TODO: implement the method. |
| 1384 | } |
| 1385 | |
| 1386 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 1387 | * Adds enum attributes to temporary files. |
| 1388 | * |
| 1389 | * @param curNode current YANG node |
| 1390 | * @throws IOException when fails to do IO operations |
| 1391 | */ |
| 1392 | public void addEnumAttributeToTempFiles(YangNode curNode) throws IOException { |
| 1393 | |
| 1394 | if (curNode instanceof YangEnumeration) { |
| 1395 | Set<YangEnum> enumSet = ((YangEnumeration) curNode).getEnumSet(); |
| 1396 | for (YangEnum curEnum : enumSet) { |
| 1397 | JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfEnumAttribute(curNode, curEnum.getNamedValue()); |
| 1398 | setEnumValue(curEnum.getValue()); |
| 1399 | addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); |
| 1400 | } |
| 1401 | } else { |
| 1402 | throw new TranslatorException("curnode should be of type enum."); |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1407 | * Adds the new attribute info to the target generated temporary files for union class. |
| 1408 | * |
| 1409 | * @param hasType the node for which the type is being added as an attribute |
| 1410 | * @param javaAttributeInfo the attribute info that needs to be added to temporary |
| 1411 | * files |
| 1412 | * @throws IOException IO operation fail |
| 1413 | */ |
| 1414 | private void addJavaSnippetInfoToApplicableTempFiles(YangNode hasType, JavaAttributeInfo javaAttributeInfo) |
| 1415 | throws IOException { |
| 1416 | |
| 1417 | JavaAttributeInfo fromStringAttributeInfo = getFromStringAttributeInfo(hasType, javaAttributeInfo); |
| 1418 | |
| 1419 | if ((generatedTempFiles & UNION_FROM_STRING_IMPL_MASK) != 0) { |
| 1420 | addUnionFromStringMethod(javaAttributeInfo, fromStringAttributeInfo); |
| 1421 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1422 | addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo); |
| 1423 | } |
| 1424 | |
| 1425 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 1426 | * Adds the new attribute info to the target generated temporary files. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1427 | * |
| 1428 | * @param newAttrInfo the attribute info that needs to be added to temporary |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1429 | * files |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1430 | * @throws IOException IO operation fail |
| 1431 | */ |
| 1432 | void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo newAttrInfo) |
| 1433 | throws IOException { |
| 1434 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1435 | setNewAttrInfo(newAttrInfo); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1436 | if (isAttributePresent) { |
| 1437 | if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) { |
| 1438 | addAttribute(newAttrInfo); |
| 1439 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1440 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1441 | if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) { |
| 1442 | addGetterForInterface(newAttrInfo); |
| 1443 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1444 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1445 | if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) { |
| 1446 | addSetterForInterface(newAttrInfo); |
| 1447 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1448 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1449 | if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) { |
| 1450 | addGetterImpl(newAttrInfo, generatedJavaFiles); |
| 1451 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1452 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1453 | if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) { |
| 1454 | addSetterImpl(newAttrInfo); |
| 1455 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1456 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1457 | if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) { |
| 1458 | addConstructor(newAttrInfo); |
| 1459 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1460 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1461 | if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) { |
| 1462 | addHashCodeMethod(newAttrInfo); |
| 1463 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1464 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1465 | if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) { |
| 1466 | addEqualsMethod(newAttrInfo); |
| 1467 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1468 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1469 | if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) { |
| 1470 | addToStringMethod(newAttrInfo); |
| 1471 | } |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1472 | |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 1473 | if ((generatedTempFiles & ENUM_IMPL_MASK) != 0) { |
| 1474 | addAttributesForEnumClass(newAttrInfo); |
| 1475 | } |
| 1476 | |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1477 | if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) { |
| 1478 | addOfStringMethod(newAttrInfo); |
| 1479 | } |
| 1480 | |
| 1481 | if ((generatedTempFiles & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { |
| 1482 | addTypeConstructor(newAttrInfo); |
| 1483 | } |
| 1484 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1485 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1486 | } |
| 1487 | |
| 1488 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 1489 | * Returns java file info. |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1490 | * |
| 1491 | * @return java file info |
| 1492 | */ |
| 1493 | private JavaFileInfo getJavaFileInfo() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1494 | return ((HasJavaFileInfo) getCurYangNode()).getJavaFileInfo(); |
| 1495 | } |
| 1496 | |
| 1497 | /** |
| 1498 | * Returns java class name. |
| 1499 | * |
| 1500 | * @param suffix for the class name based on the file type |
| 1501 | * @return java class name |
| 1502 | */ |
| 1503 | private String getJavaClassName(String suffix) { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1504 | return getCaptialCase(getJavaFileInfo().getJavaName()) + suffix; |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1505 | } |
| 1506 | |
| 1507 | /** |
| 1508 | * Returns the directory path. |
| 1509 | * |
| 1510 | * @return directory path |
| 1511 | */ |
| 1512 | private String getDirPath() { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1513 | return getJavaFileInfo().getPackageFilePath(); |
| 1514 | } |
| 1515 | |
| 1516 | /** |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1517 | * Constructs java code exit. |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1518 | * |
| 1519 | * @param fileType generated file type |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1520 | * @param curNode current YANG node |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1521 | * @throws IOException when fails to generate java files |
| 1522 | */ |
| 1523 | public void generateJavaFile(int fileType, YangNode curNode) throws IOException { |
| 1524 | |
| 1525 | setCurYangNode(curNode); |
| 1526 | List<String> imports = new ArrayList<>(); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1527 | if (curNode instanceof HasJavaImportData && isAttributePresent) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1528 | imports = ((HasJavaImportData) curNode).getJavaImportData().getImports(getNewAttrInfo()); |
| 1529 | } |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1530 | |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1531 | /** |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1532 | * Prepares java file generator for extends list. |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1533 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1534 | prepareJavaFileGeneratorForExtendsList(getExtendsList()); |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 1535 | if (curNode.getNodeType().equals(MODULE_NODE)) { |
| 1536 | createPackage(absoluteDirPath, getJavaFileInfo().getJavaName()); |
| 1537 | } else { |
| 1538 | createPackage(absoluteDirPath, ((HasJavaFileInfo) curNode.getParent()).getJavaFileInfo().getJavaName() |
| 1539 | + PACKAGE_INFO_JAVADOC_OF_CHILD); |
| 1540 | } |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1541 | /** |
| 1542 | * Generate java code. |
| 1543 | */ |
| 1544 | if ((fileType & INTERFACE_MASK) != 0 | (fileType & BUILDER_INTERFACE_MASK) != 0) { |
| 1545 | |
| 1546 | /** |
| 1547 | * Adds import for HasAugmentation class. |
| 1548 | */ |
| 1549 | if (isHasAugmentationExtended(getExtendsList())) { |
| 1550 | addHasAugmentationImport(curNode, imports, true); |
| 1551 | } |
| 1552 | |
| 1553 | if (isAugmentedInfoExtended(getExtendsList())) { |
| 1554 | addAugmentedInfoImport(curNode, imports, true); |
| 1555 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1556 | |
| 1557 | /** |
| 1558 | * Create interface file. |
| 1559 | */ |
| 1560 | setInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(INTERFACE_FILE_NAME_SUFFIX))); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1561 | setInterfaceJavaFileHandle( |
| 1562 | generateInterfaceFile(getInterfaceJavaFileHandle(), imports, curNode, isAttributePresent)); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1563 | /** |
| 1564 | * Create builder interface file. |
| 1565 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1566 | if ((fileType & BUILDER_INTERFACE_MASK) != 0) { |
| 1567 | |
| 1568 | setBuilderInterfaceJavaFileHandle( |
| 1569 | getJavaFileHandle(getJavaClassName(BUILDER_INTERFACE_FILE_NAME_SUFFIX))); |
| 1570 | setBuilderInterfaceJavaFileHandle( |
| 1571 | generateBuilderInterfaceFile(getBuilderInterfaceJavaFileHandle(), curNode, isAttributePresent)); |
| 1572 | /** |
| 1573 | * Append builder interface file to interface file and close it. |
| 1574 | */ |
| 1575 | mergeJavaFiles(getBuilderInterfaceJavaFileHandle(), getInterfaceJavaFileHandle()); |
| 1576 | } |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1577 | insertDataIntoJavaFile(getInterfaceJavaFileHandle(), getJavaClassDefClose()); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1578 | |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1579 | if (isHasAugmentationExtended(getExtendsList())) { |
| 1580 | addHasAugmentationImport(curNode, imports, false); |
| 1581 | } |
| 1582 | if (isAugmentedInfoExtended(getExtendsList())) { |
| 1583 | addAugmentedInfoImport(curNode, imports, false); |
| 1584 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1585 | } |
| 1586 | |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1587 | if ((fileType & BUILDER_CLASS_MASK) != 0 | (fileType & IMPL_CLASS_MASK) != 0) { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1588 | |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1589 | if (isAttributePresent) { |
| 1590 | addImportsToStringAndHasCodeMethods(curNode, imports); |
| 1591 | } |
| 1592 | if (isHasAugmentationExtended(getExtendsList())) { |
| 1593 | addAugmentedInfoImport(curNode, imports, true); |
| 1594 | addArrayListImport(curNode, imports, true); |
| 1595 | } |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1596 | |
| 1597 | /** |
| 1598 | * Create builder class file. |
| 1599 | */ |
| 1600 | setBuilderClassJavaFileHandle(getJavaFileHandle(getJavaClassName(BUILDER_CLASS_FILE_NAME_SUFFIX))); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1601 | setBuilderClassJavaFileHandle( |
| 1602 | generateBuilderClassFile(getBuilderClassJavaFileHandle(), imports, curNode, isAttributePresent)); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1603 | /** |
| 1604 | * Create impl class file. |
| 1605 | */ |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1606 | if ((fileType & IMPL_CLASS_MASK) != 0) { |
| 1607 | setImplClassJavaFileHandle(getJavaFileHandle(getJavaClassName(IMPL_CLASS_FILE_NAME_SUFFIX))); |
| 1608 | setImplClassJavaFileHandle( |
| 1609 | generateImplClassFile(getImplClassJavaFileHandle(), curNode, isAttributePresent)); |
| 1610 | /** |
| 1611 | * Append impl class to builder class and close it. |
| 1612 | */ |
| 1613 | mergeJavaFiles(getImplClassJavaFileHandle(), getBuilderClassJavaFileHandle()); |
| 1614 | } |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1615 | insertDataIntoJavaFile(getBuilderClassJavaFileHandle(), getJavaClassDefClose()); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1616 | } |
| 1617 | |
| 1618 | /** |
| 1619 | * Creates type def class file. |
| 1620 | */ |
| 1621 | if ((fileType & GENERATE_TYPEDEF_CLASS) != 0) { |
Bharat saraswal | e2bc60d | 2016-04-16 02:28:25 +0530 | [diff] [blame] | 1622 | addImportsToStringAndHasCodeMethods(curNode, imports); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1623 | setTypedefClassJavaFileHandle(getJavaFileHandle(getJavaClassName(TYPEDEF_CLASS_FILE_NAME_SUFFIX))); |
| 1624 | setTypedefClassJavaFileHandle(generateTypeDefClassFile(getTypedefClassJavaFileHandle(), curNode, imports)); |
| 1625 | } |
| 1626 | |
| 1627 | /** |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1628 | * Creates type class file. |
| 1629 | */ |
| 1630 | if ((fileType & GENERATE_UNION_CLASS) != 0) { |
| 1631 | addImportsToStringAndHasCodeMethods(curNode, imports); |
| 1632 | setTypeClassJavaFileHandle(getJavaFileHandle(getJavaClassName(UNION_TYPE_CLASS_FILE_NAME_SUFFIX))); |
| 1633 | setTypeClassJavaFileHandle(generateUnionClassFile(getTypeClassJavaFileHandle(), curNode, imports)); |
| 1634 | } |
| 1635 | |
| 1636 | /** |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 1637 | * Creates type enum class file. |
| 1638 | */ |
| 1639 | if ((fileType & GENERATE_ENUM_CLASS) != 0) { |
| 1640 | setEnumClassJavaFileHandle(getJavaFileHandle(getJavaClassName(ENUM_CLASS_FILE_NAME_SUFFIX))); |
| 1641 | setEnumClassJavaFileHandle(generateEnumClassFile(getEnumClassJavaFileHandle(), curNode)); |
| 1642 | } |
| 1643 | |
| 1644 | /** |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1645 | * Close all the file handles. |
| 1646 | */ |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1647 | close(false); |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1648 | } |
| 1649 | |
| 1650 | /** |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1651 | * Removes all temporary file handles. |
| 1652 | * |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1653 | * @param isErrorOccurred when translator fails to generate java files we need to close |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1654 | * all open file handles include temporary files and java files. |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1655 | * @throws IOException when failed to delete the temporary files |
| 1656 | */ |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1657 | public void close(boolean isErrorOccurred) throws IOException { |
Bharat saraswal | 84366c5 | 2016-03-23 19:40:35 +0530 | [diff] [blame] | 1658 | |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1659 | boolean isError = isErrorOccurred; |
| 1660 | /** |
| 1661 | * Close all java file handles and when error occurs delete the files. |
| 1662 | */ |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1663 | if ((generatedJavaFiles & INTERFACE_MASK) != 0) { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1664 | closeFile(getInterfaceJavaFileHandle(), isError); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1665 | } |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1666 | if ((generatedJavaFiles & BUILDER_CLASS_MASK) != 0) { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1667 | closeFile(getBuilderClassJavaFileHandle(), isError); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1668 | } |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1669 | if ((generatedJavaFiles & BUILDER_INTERFACE_MASK) != 0) { |
| 1670 | closeFile(getBuilderInterfaceJavaFileHandle(), true); |
| 1671 | } |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1672 | if ((generatedJavaFiles & IMPL_CLASS_MASK) != 0) { |
| 1673 | closeFile(getImplClassJavaFileHandle(), true); |
| 1674 | } |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1675 | if ((generatedJavaFiles & GENERATE_TYPEDEF_CLASS) != 0) { |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1676 | closeFile(getTypedefClassJavaFileHandle(), isError); |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1677 | } |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 1678 | if ((generatedJavaFiles & GENERATE_ENUM_CLASS) != 0) { |
| 1679 | closeFile(getEnumClassJavaFileHandle(), isError); |
| 1680 | } |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1681 | if ((generatedJavaFiles & GENERATE_UNION_CLASS) != 0) { |
| 1682 | closeFile(getTypeClassJavaFileHandle(), isError); |
| 1683 | } |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1684 | |
Bharat saraswal | d532a4c | 2016-03-25 18:19:46 +0530 | [diff] [blame] | 1685 | /** |
| 1686 | * Close all temporary file handles and delete the files. |
| 1687 | */ |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1688 | if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) { |
| 1689 | closeFile(getGetterInterfaceTempFileHandle(), true); |
| 1690 | } |
| 1691 | if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) { |
| 1692 | closeFile(getGetterImplTempFileHandle(), true); |
| 1693 | } |
| 1694 | if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) { |
| 1695 | closeFile(getSetterInterfaceTempFileHandle(), true); |
| 1696 | } |
| 1697 | if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) { |
| 1698 | closeFile(getSetterImplTempFileHandle(), true); |
| 1699 | } |
| 1700 | if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) { |
| 1701 | closeFile(getConstructorImplTempFileHandle(), true); |
| 1702 | } |
| 1703 | if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) { |
| 1704 | closeFile(getAttributesTempFileHandle(), true); |
| 1705 | } |
| 1706 | if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) { |
| 1707 | closeFile(getHashCodeImplTempFileHandle(), true); |
| 1708 | } |
| 1709 | if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) { |
| 1710 | closeFile(getToStringImplTempFileHandle(), true); |
| 1711 | } |
| 1712 | if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) { |
| 1713 | closeFile(getEqualsImplTempFileHandle(), true); |
| 1714 | } |
Bharat saraswal | 68fa0d1 | 2016-04-19 01:00:16 +0530 | [diff] [blame] | 1715 | if ((generatedTempFiles & ENUM_IMPL_MASK) != 0) { |
| 1716 | closeFile(getEnumClassTempFileHandle(), true); |
| 1717 | } |
Gaurav Agrawal | 97a5e1c | 2016-04-18 18:53:11 +0530 | [diff] [blame] | 1718 | if ((generatedTempFiles & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { |
| 1719 | closeFile(getConstructorForTypeTempFileHandle(), true); |
| 1720 | } |
| 1721 | if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) { |
| 1722 | closeFile(getOfStringImplTempFileHandle(), true); |
| 1723 | } |
| 1724 | if ((generatedTempFiles & UNION_FROM_STRING_IMPL_MASK) != 0) { |
| 1725 | closeFile(getUnionFromStringImplTempFileHandle(), true); |
| 1726 | } |
Bharat saraswal | 780eca3 | 2016-04-05 12:45:45 +0530 | [diff] [blame] | 1727 | clean(getTempDirPath()); |
| 1728 | generatedTempFiles = 0; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1729 | } |
| 1730 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 1731 | } |