Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yangutils.translator.tojava; |
| 18 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 19 | import java.io.File; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 20 | import java.io.IOException; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 21 | import java.util.ArrayList; |
| 22 | import java.util.List; |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 23 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 24 | import org.onosproject.yangutils.datamodel.YangNode; |
| 25 | import org.onosproject.yangutils.datamodel.YangType; |
| 26 | import org.onosproject.yangutils.datamodel.YangTypeHolder; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 27 | import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 28 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 29 | import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeTranslator; |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 30 | import org.onosproject.yangutils.utils.io.YangPluginConfig; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 31 | |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 32 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32; |
| 33 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT64; |
| 34 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT16; |
| 35 | import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT32; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 36 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; |
| 37 | import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; |
| 38 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; |
| 39 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; |
| 40 | import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK; |
| 41 | import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 42 | import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoTranslator.getQualifiedInfoOfFromString; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 43 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateTypeDefClassFile; |
| 44 | import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateUnionClassFile; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 45 | import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 46 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc; |
| 47 | import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 48 | import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.INT_TYPE_CONFLICT; |
| 49 | import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.LONG_TYPE_CONFLICT; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 50 | import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; |
| 51 | import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 52 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; |
| 53 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 54 | |
| 55 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 56 | * Represents implementation of java data type code fragments temporary implementations. Maintains the temp files |
| 57 | * required specific for user defined data type java snippet generation. |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 58 | */ |
| 59 | public class TempJavaTypeFragmentFiles |
| 60 | extends TempJavaFragmentFiles { |
| 61 | |
| 62 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 63 | * File name for of string method. |
| 64 | */ |
| 65 | private static final String OF_STRING_METHOD_FILE_NAME = "OfString"; |
| 66 | |
| 67 | /** |
| 68 | * File name for construction for special type like union, typedef. |
| 69 | */ |
| 70 | private static final String CONSTRUCTOR_FOR_TYPE_FILE_NAME = "ConstructorForType"; |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * File name for typedef class file name suffix. |
| 74 | */ |
| 75 | private static final String TYPEDEF_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING; |
| 76 | |
| 77 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 78 | * File name for generated class file for special type like union, typedef suffix. |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 79 | */ |
| 80 | private static final String UNION_TYPE_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING; |
| 81 | |
| 82 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 83 | * Integer index in type list. |
| 84 | */ |
| 85 | private int intIndex = 0; |
| 86 | |
| 87 | /** |
| 88 | * UInt index in type list. |
| 89 | */ |
| 90 | private int uIntIndex = 0; |
| 91 | |
| 92 | /** |
| 93 | * long index in type list. |
| 94 | */ |
| 95 | private int longIndex = 0; |
| 96 | |
| 97 | /** |
| 98 | * ULong index in type list. |
| 99 | */ |
| 100 | private int uLongIndex = 0; |
| 101 | |
| 102 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 103 | * Temporary file handle for of string method of class. |
| 104 | */ |
| 105 | private File ofStringImplTempFileHandle; |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 106 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 107 | /** |
| 108 | * Temporary file handle for constructor for type class. |
| 109 | */ |
| 110 | private File constructorForTypeTempFileHandle; |
| 111 | |
| 112 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 113 | * Java file handle for typedef class file. |
| 114 | */ |
| 115 | private File typedefClassJavaFileHandle; |
VinodKumarS-Huawei | d81eccb | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 116 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 117 | /** |
| 118 | * Java file handle for type class like union, typedef file. |
| 119 | */ |
| 120 | private File typeClassJavaFileHandle; |
| 121 | |
| 122 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 123 | * Java attribute for int. |
| 124 | */ |
| 125 | private JavaAttributeInfo intAttribute; |
| 126 | |
| 127 | /** |
| 128 | * Java attribute for long. |
| 129 | */ |
| 130 | private JavaAttributeInfo longAttribute; |
| 131 | |
| 132 | /** |
| 133 | * Java attribute for uInt. |
| 134 | */ |
| 135 | private JavaAttributeInfo uIntAttribute; |
| 136 | |
| 137 | /** |
| 138 | * Java attribute for uLong. |
| 139 | */ |
| 140 | private JavaAttributeInfo uLongAttribute; |
| 141 | |
| 142 | /** |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 143 | * Creates an instance of temporary java code fragment. |
| 144 | * |
| 145 | * @param javaFileInfo generated java file info |
| 146 | * @throws IOException when fails to create new file handle |
| 147 | */ |
Bharat saraswal | e50edca | 2016-08-05 01:58:25 +0530 | [diff] [blame] | 148 | TempJavaTypeFragmentFiles(JavaFileInfoTranslator javaFileInfo) |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 149 | throws IOException { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 150 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 151 | super(javaFileInfo); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 152 | |
| 153 | /* |
| 154 | * Initialize getterImpl, attributes, hash code, equals and to strings |
| 155 | * when generation file type matches to typeDef class mask. |
| 156 | */ |
| 157 | addGeneratedTempFile(OF_STRING_IMPL_MASK); |
| 158 | addGeneratedTempFile(CONSTRUCTOR_FOR_TYPE_MASK); |
| 159 | addGeneratedTempFile(FROM_STRING_IMPL_MASK); |
| 160 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 161 | setOfStringImplTempFileHandle(getTemporaryFileHandle(OF_STRING_METHOD_FILE_NAME)); |
| 162 | setConstructorForTypeTempFileHandle(getTemporaryFileHandle(CONSTRUCTOR_FOR_TYPE_FILE_NAME)); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 163 | |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 164 | } |
| 165 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 166 | /** |
| 167 | * Returns type class constructor method's temporary file handle. |
| 168 | * |
| 169 | * @return type class constructor method's temporary file handle |
| 170 | */ |
| 171 | |
| 172 | public File getConstructorForTypeTempFileHandle() { |
| 173 | return constructorForTypeTempFileHandle; |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Sets type class constructor method's temporary file handle. |
| 178 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 179 | * @param constructorForTypeTempFileHandle type class constructor method's temporary file handle |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 180 | */ |
| 181 | private void setConstructorForTypeTempFileHandle(File constructorForTypeTempFileHandle) { |
| 182 | this.constructorForTypeTempFileHandle = constructorForTypeTempFileHandle; |
| 183 | } |
| 184 | |
| 185 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 186 | * Returns java file handle for typedef class file. |
| 187 | * |
| 188 | * @return java file handle for typedef class file |
| 189 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 190 | private File getTypedefClassJavaFileHandle() { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 191 | return typedefClassJavaFileHandle; |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * Sets the java file handle for typedef class file. |
| 196 | * |
| 197 | * @param typedefClassJavaFileHandle java file handle |
| 198 | */ |
| 199 | private void setTypedefClassJavaFileHandle(File typedefClassJavaFileHandle) { |
| 200 | this.typedefClassJavaFileHandle = typedefClassJavaFileHandle; |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Returns java file handle for type class file. |
| 205 | * |
| 206 | * @return java file handle for type class file |
| 207 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 208 | private File getTypeClassJavaFileHandle() { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 209 | return typeClassJavaFileHandle; |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Sets the java file handle for type class file. |
| 214 | * |
| 215 | * @param typeClassJavaFileHandle type file handle |
| 216 | */ |
| 217 | private void setTypeClassJavaFileHandle(File typeClassJavaFileHandle) { |
| 218 | this.typeClassJavaFileHandle = typeClassJavaFileHandle; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Returns of string method's temporary file handle. |
| 223 | * |
| 224 | * @return of string method's temporary file handle |
| 225 | */ |
| 226 | |
| 227 | public File getOfStringImplTempFileHandle() { |
| 228 | return ofStringImplTempFileHandle; |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Set of string method's temporary file handle. |
| 233 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 234 | * @param ofStringImplTempFileHandle of string method's temporary file handle |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 235 | */ |
| 236 | private void setOfStringImplTempFileHandle(File ofStringImplTempFileHandle) { |
| 237 | this.ofStringImplTempFileHandle = ofStringImplTempFileHandle; |
| 238 | } |
| 239 | |
| 240 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 241 | * Adds all the type in the current data model node as part of the generated temporary file. |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 242 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 243 | * @param yangTypeHolder YANG java data model node which has type info, eg union / typedef |
| 244 | * @param pluginConfig plugin configurations for naming conventions |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 245 | * @throws IOException IO operation fail |
| 246 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 247 | void addTypeInfoToTempFiles(YangTypeHolder yangTypeHolder, YangPluginConfig pluginConfig) |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 248 | throws IOException { |
| 249 | |
| 250 | List<YangType<?>> typeList = yangTypeHolder.getTypeList(); |
| 251 | if (typeList != null) { |
| 252 | for (YangType<?> yangType : typeList) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 253 | if (!(yangType instanceof YangJavaTypeTranslator)) { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 254 | throw new TranslatorException("Type does not have Java info"); |
| 255 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 256 | JavaAttributeInfo javaAttributeInfo = getAttributeForType(yangType, pluginConfig); |
| 257 | addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, |
| 258 | pluginConfig, typeList); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 259 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 260 | addTypeConstructor(pluginConfig); |
| 261 | addMethodsInConflictCase(pluginConfig); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 262 | } |
| 263 | } |
| 264 | |
| 265 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 266 | * Returns java attribute. |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 267 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 268 | * @param yangType YANG type |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 269 | * @param pluginConfig plugin configurations |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 270 | * @return java attribute |
| 271 | */ |
| 272 | private JavaAttributeInfo getAttributeForType(YangType yangType, YangPluginConfig pluginConfig) { |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 273 | YangJavaTypeTranslator<?> javaType = (YangJavaTypeTranslator<?>) yangType; |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 274 | javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver()); |
| 275 | String typeName = javaType.getDataTypeName(); |
| 276 | typeName = getCamelCase(typeName, pluginConfig.getConflictResolver()); |
| 277 | return getAttributeInfoForTheData( |
| 278 | javaType.getJavaQualifiedInfo(), |
| 279 | typeName, javaType, |
| 280 | getIsQualifiedAccessOrAddToImportList(javaType.getJavaQualifiedInfo()), |
| 281 | false); |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * Adds the new attribute info to the target generated temporary files for union class. |
| 286 | * |
| 287 | * @param javaAttributeInfo the attribute info that needs to be added to temporary files |
| 288 | * @param pluginConfig plugin configurations |
| 289 | * @param typeList type list |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 290 | * @throws IOException IO operation fail |
| 291 | */ |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 292 | private void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo javaAttributeInfo, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 293 | YangPluginConfig pluginConfig, List<YangType<?>> typeList) |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 294 | throws IOException { |
| 295 | |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 296 | YangDataTypes attrType = javaAttributeInfo.getAttributeType().getDataType(); |
| 297 | |
| 298 | if (attrType == INT32 || attrType == UINT16) { |
| 299 | boolean isIntConflict = validateForConflictingIntTypes(typeList); |
| 300 | javaAttributeInfo.setIntConflict(isIntConflict); |
| 301 | updateAttributeCondition(javaAttributeInfo); |
| 302 | if (!isIntConflict) { |
| 303 | addMethodsWhenNoConflictingTypes(javaAttributeInfo, pluginConfig); |
| 304 | } |
| 305 | } else if (attrType == INT64 || attrType == UINT32) { |
| 306 | boolean isLongConflict = validateForConflictingLongTypes(typeList); |
| 307 | javaAttributeInfo.setLongConflict(isLongConflict); |
| 308 | updateAttributeCondition(javaAttributeInfo); |
| 309 | if (!isLongConflict) { |
| 310 | addMethodsWhenNoConflictingTypes(javaAttributeInfo, pluginConfig); |
| 311 | } |
| 312 | } else { |
| 313 | addMethodsWhenNoConflictingTypes(javaAttributeInfo, pluginConfig); |
| 314 | } |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 315 | super.addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 316 | |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | /** |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 320 | * Adds of method and constructor when there is no conflicting types. |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 321 | * |
| 322 | * @param javaAttributeInfo java attribute info |
| 323 | * @param pluginConfig plugin configurations |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 324 | * @throws IOException when fails to do IO operations |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 325 | */ |
| 326 | private void addMethodsWhenNoConflictingTypes(JavaAttributeInfo javaAttributeInfo, |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 327 | YangPluginConfig pluginConfig) |
| 328 | throws IOException { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 329 | if ((getGeneratedTempFiles() & OF_STRING_IMPL_MASK) != 0) { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 330 | addOfStringMethod(javaAttributeInfo, pluginConfig); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 331 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 332 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 333 | if ((getGeneratedTempFiles() & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 334 | addTypeConstructor(javaAttributeInfo, pluginConfig); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 335 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 339 | * Adds of, getter and from string method in conflict cases. |
| 340 | * |
| 341 | * @param pluginConfig plugin configurations |
| 342 | * @throws IOException when fails to do IO operations |
| 343 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 344 | private void addMethodsInConflictCase(YangPluginConfig pluginConfig) |
| 345 | throws IOException { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 346 | JavaAttributeInfo attr = getIntAttribute(); |
| 347 | if (attr != null) { |
| 348 | attr = getUIntAttribute(); |
| 349 | } |
| 350 | if (attr != null) { |
| 351 | if (attr.isIntConflict()) { |
| 352 | if (getIntIndex() < getUIntIndex()) { |
| 353 | appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(getIntAttribute(), |
| 354 | getGeneratedJavaClassName(), pluginConfig) |
| 355 | + NEW_LINE); |
| 356 | addGetterImpl(getIntAttribute(), pluginConfig); |
| 357 | addFromStringMethod(getIntAttribute(), pluginConfig); |
| 358 | } else { |
| 359 | appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(getUIntAttribute(), |
| 360 | getGeneratedJavaClassName(), pluginConfig) |
| 361 | + NEW_LINE); |
| 362 | addGetterImpl(getUIntAttribute(), pluginConfig); |
| 363 | addFromStringMethod(getUIntAttribute(), pluginConfig); |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | attr = getLongAttribute(); |
| 368 | if (attr != null) { |
| 369 | attr = getULongAttribute(); |
| 370 | } |
| 371 | if (attr != null) { |
| 372 | if (attr.isLongConflict()) { |
| 373 | if (getLongIndex() < getULongIndex()) { |
| 374 | appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(getLongAttribute(), |
| 375 | getGeneratedJavaClassName(), pluginConfig) |
| 376 | + NEW_LINE); |
| 377 | addGetterImpl(getLongAttribute(), pluginConfig); |
| 378 | addFromStringMethod(getLongAttribute(), pluginConfig); |
| 379 | } else { |
| 380 | appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(getULongAttribute(), |
| 381 | getGeneratedJavaClassName(), pluginConfig) |
| 382 | + NEW_LINE); |
| 383 | addGetterImpl(getULongAttribute(), pluginConfig); |
| 384 | addFromStringMethod(getULongAttribute(), pluginConfig); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | /** |
| 391 | * Adds from string method for conflict case. |
| 392 | * |
| 393 | * @param newAttrInfo new attribute |
| 394 | * @param pluginConfig plugin configurations |
| 395 | * @throws IOException when fails to do IO operations |
| 396 | */ |
VinodKumarS-Huawei | 9a91b48 | 2016-08-19 23:22:59 +0530 | [diff] [blame] | 397 | private void addFromStringMethod(JavaAttributeInfo newAttrInfo, YangPluginConfig pluginConfig) |
| 398 | throws IOException { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 399 | |
Shankara-Huawei | b756477 | 2016-08-02 18:13:13 +0530 | [diff] [blame] | 400 | JavaQualifiedTypeInfoTranslator qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo, |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 401 | pluginConfig.getConflictResolver()); |
| 402 | /* |
| 403 | * Create a new java attribute info with qualified information of |
| 404 | * wrapper classes. |
| 405 | */ |
| 406 | JavaAttributeInfo fromStringAttributeInfo = getAttributeInfoForTheData(qualifiedInfoOfFromString, |
| 407 | newAttrInfo.getAttributeName(), |
| 408 | newAttrInfo.getAttributeType(), |
| 409 | getIsQualifiedAccessOrAddToImportList(qualifiedInfoOfFromString), false); |
| 410 | |
| 411 | addFromStringMethod(newAttrInfo, fromStringAttributeInfo); |
| 412 | } |
| 413 | |
| 414 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 415 | * Adds type constructor. |
| 416 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 417 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 418 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 419 | * @throws IOException when fails to append to temporary file |
| 420 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 421 | private void addTypeConstructor(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 422 | throws IOException { |
| 423 | appendToFile(getConstructorForTypeTempFileHandle(), getTypeConstructorStringAndJavaDoc(attr, |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 424 | getGeneratedJavaClassName(), pluginConfig) + NEW_LINE); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | /** |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 428 | * Adds type constructor. |
| 429 | * |
| 430 | * @param pluginConfig plugin configurations |
| 431 | * @throws IOException when fails to append to temporary file |
| 432 | */ |
| 433 | private void addTypeConstructor(YangPluginConfig pluginConfig) |
| 434 | throws IOException { |
| 435 | JavaAttributeInfo attr = getIntAttribute(); |
| 436 | if (attr != null) { |
| 437 | attr = getUIntAttribute(); |
| 438 | } |
| 439 | if (attr != null) { |
| 440 | if (attr.isIntConflict()) { |
| 441 | appendToFile(getConstructorForTypeTempFileHandle(), getTypeConstructorStringAndJavaDoc( |
| 442 | getIntAttribute(), |
| 443 | getUIntAttribute(), getGeneratedJavaClassName(), pluginConfig, INT_TYPE_CONFLICT, |
| 444 | getIntIndex() |
| 445 | < getUIntIndex()) + NEW_LINE); |
| 446 | } |
| 447 | } |
| 448 | attr = getLongAttribute(); |
| 449 | if (attr != null) { |
| 450 | attr = getULongAttribute(); |
| 451 | } |
| 452 | if (attr != null) { |
| 453 | if (attr.isLongConflict()) { |
| 454 | appendToFile(getConstructorForTypeTempFileHandle(), getTypeConstructorStringAndJavaDoc( |
| 455 | getLongAttribute(), |
| 456 | getULongAttribute(), getGeneratedJavaClassName(), pluginConfig, LONG_TYPE_CONFLICT, |
| 457 | getLongIndex() |
| 458 | < getULongIndex()) + NEW_LINE); |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | /** |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 464 | * Adds of string for type. |
| 465 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 466 | * @param attr attribute info |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 467 | * @param pluginConfig plugin configurations |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 468 | * @throws IOException when fails to append to temporary file |
| 469 | */ |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 470 | private void addOfStringMethod(JavaAttributeInfo attr, YangPluginConfig pluginConfig) |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 471 | throws IOException { |
| 472 | appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(attr, |
Bharat saraswal | 715d3fc | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 473 | getGeneratedJavaClassName(), pluginConfig) |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 474 | + NEW_LINE); |
| 475 | } |
| 476 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 477 | /** |
| 478 | * Removes all temporary file handles. |
| 479 | * |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 480 | * @param isErrorOccurred flag to tell translator that error has occurred while file generation |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 481 | * @throws IOException when failed to delete the temporary files |
| 482 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 483 | @Override |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 484 | public void freeTemporaryResources(boolean isErrorOccurred) |
| 485 | throws IOException { |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 486 | |
| 487 | if ((getGeneratedJavaFiles() & GENERATE_TYPEDEF_CLASS) != 0) { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 488 | closeFile(getTypedefClassJavaFileHandle(), isErrorOccurred); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | if ((getGeneratedJavaFiles() & GENERATE_UNION_CLASS) != 0) { |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 492 | closeFile(getTypeClassJavaFileHandle(), isErrorOccurred); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | if ((getGeneratedTempFiles() & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { |
| 496 | closeFile(getConstructorForTypeTempFileHandle(), true); |
| 497 | } |
| 498 | if ((getGeneratedTempFiles() & OF_STRING_IMPL_MASK) != 0) { |
| 499 | closeFile(getOfStringImplTempFileHandle(), true); |
| 500 | } |
| 501 | if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { |
| 502 | closeFile(getFromStringImplTempFileHandle(), true); |
| 503 | } |
| 504 | |
| 505 | super.freeTemporaryResources(isErrorOccurred); |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 506 | |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | /** |
| 510 | * Constructs java code exit. |
| 511 | * |
| 512 | * @param fileType generated file type |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 513 | * @param curNode current YANG node |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 514 | * @throws IOException when fails to generate java files |
| 515 | */ |
Bharat saraswal | 250a747 | 2016-05-12 13:16:57 +0530 | [diff] [blame] | 516 | @Override |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 517 | public void generateJavaFile(int fileType, YangNode curNode) |
| 518 | throws IOException { |
| 519 | List<String> imports = new ArrayList<>(); |
| 520 | if (isAttributePresent()) { |
| 521 | imports = getJavaImportData().getImports(); |
| 522 | } |
| 523 | |
| 524 | createPackage(curNode); |
| 525 | |
| 526 | /* |
| 527 | * Creates type def class file. |
| 528 | */ |
| 529 | if ((fileType & GENERATE_TYPEDEF_CLASS) != 0) { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 530 | addImportsToStringAndHasCodeMethods(imports, true); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 531 | setTypedefClassJavaFileHandle(getJavaFileHandle(getJavaClassName(TYPEDEF_CLASS_FILE_NAME_SUFFIX))); |
Gaurav Agrawal | 8a14752 | 2016-08-10 13:43:01 +0530 | [diff] [blame] | 532 | |
| 533 | // In case if data type is binary, MoreObjects is not required and should be removed. |
| 534 | if (curNode instanceof YangTypeHolder) { |
| 535 | YangType yangType = ((YangTypeHolder) curNode).getTypeList().get(0); |
| 536 | if (yangType.getDataType() == YangDataTypes.BINARY) { |
| 537 | imports.remove(getJavaImportData().getImportForToString()); |
| 538 | } |
| 539 | } |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 540 | generateTypeDefClassFile(getTypedefClassJavaFileHandle(), curNode, imports); |
| 541 | } |
| 542 | /* |
| 543 | * Creates type class file. |
| 544 | */ |
| 545 | if ((fileType & GENERATE_UNION_CLASS) != 0) { |
Shankara-Huawei | a1039e5 | 2016-07-14 16:53:09 +0530 | [diff] [blame] | 546 | addImportsToStringAndHasCodeMethods(imports, true); |
VinodKumarS-Huawei | 6266db3 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 547 | setTypeClassJavaFileHandle(getJavaFileHandle(getJavaClassName(UNION_TYPE_CLASS_FILE_NAME_SUFFIX))); |
| 548 | generateUnionClassFile(getTypeClassJavaFileHandle(), curNode, imports); |
| 549 | } |
| 550 | |
| 551 | /* |
| 552 | * Close all the file handles. |
| 553 | */ |
| 554 | freeTemporaryResources(false); |
| 555 | } |
Bharat saraswal | 64e7e23 | 2016-07-14 23:33:55 +0530 | [diff] [blame] | 556 | |
| 557 | /** |
| 558 | * Returns int type index from type list. |
| 559 | * |
| 560 | * @return int type index from type list |
| 561 | */ |
| 562 | public int getIntIndex() { |
| 563 | return intIndex; |
| 564 | } |
| 565 | |
| 566 | /** |
| 567 | * Sets int type index from type list. |
| 568 | * |
| 569 | * @param intIndex int type index from type list. |
| 570 | */ |
| 571 | private void setIntIndex(int intIndex) { |
| 572 | this.intIndex = intIndex; |
| 573 | } |
| 574 | |
| 575 | /** |
| 576 | * Returns uInt type index from type list. |
| 577 | * |
| 578 | * @return uInt type index from type list |
| 579 | */ |
| 580 | public int getUIntIndex() { |
| 581 | return uIntIndex; |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * Sets uInt type index from type list. |
| 586 | * |
| 587 | * @param uIntIndex uInt type index from type list. |
| 588 | */ |
| 589 | private void setUIntIndex(int uIntIndex) { |
| 590 | this.uIntIndex = uIntIndex; |
| 591 | } |
| 592 | |
| 593 | /** |
| 594 | * Returns long type index from type list. |
| 595 | * |
| 596 | * @return long type index from type list |
| 597 | */ |
| 598 | public int getLongIndex() { |
| 599 | return longIndex; |
| 600 | } |
| 601 | |
| 602 | /** |
| 603 | * Sets long type index from type list. |
| 604 | * |
| 605 | * @param longIndex long type index from type list. |
| 606 | */ |
| 607 | private void setLongIndex(int longIndex) { |
| 608 | this.longIndex = longIndex; |
| 609 | } |
| 610 | |
| 611 | /** |
| 612 | * Returns uLong type index from type list. |
| 613 | * |
| 614 | * @return uLong type index from type list |
| 615 | */ |
| 616 | public int getULongIndex() { |
| 617 | return uLongIndex; |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * Sets uLong type index from type list. |
| 622 | * |
| 623 | * @param uLongIndex uLong type index from type list. |
| 624 | */ |
| 625 | private void setULongIndex(int uLongIndex) { |
| 626 | this.uLongIndex = uLongIndex; |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * Validates conflict for int and uInt. |
| 631 | * |
| 632 | * @param typeList type list |
| 633 | * @return true if conflict is there |
| 634 | */ |
| 635 | private boolean validateForConflictingIntTypes(List<YangType<?>> typeList) { |
| 636 | boolean isIntPresent = false; |
| 637 | boolean isUIntPresent = false; |
| 638 | for (YangType type : typeList) { |
| 639 | if (type.getDataType().equals(INT32)) { |
| 640 | setIntIndex(typeList.indexOf(type)); |
| 641 | isIntPresent = true; |
| 642 | } |
| 643 | if (type.getDataType().equals(UINT16)) { |
| 644 | setUIntIndex(typeList.indexOf(type)); |
| 645 | isUIntPresent = true; |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | return isIntPresent && isUIntPresent; |
| 650 | } |
| 651 | |
| 652 | /** |
| 653 | * Validates conflict for long and uLong. |
| 654 | * |
| 655 | * @param typeList type list |
| 656 | * @return true if conflict is there |
| 657 | */ |
| 658 | private boolean validateForConflictingLongTypes(List<YangType<?>> typeList) { |
| 659 | boolean isLongPresent = false; |
| 660 | boolean isULongPresent = false; |
| 661 | for (YangType type : typeList) { |
| 662 | if (type.getDataType().equals(INT64)) { |
| 663 | setLongIndex(typeList.indexOf(type)); |
| 664 | isLongPresent = true; |
| 665 | } |
| 666 | if (type.getDataType().equals(UINT32)) { |
| 667 | setULongIndex(typeList.indexOf(type)); |
| 668 | isULongPresent = true; |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | return isLongPresent && isULongPresent; |
| 673 | } |
| 674 | |
| 675 | /** |
| 676 | * Updates attribute info in case of conflicts. |
| 677 | * |
| 678 | * @param javaAttributeInfo java attribute info |
| 679 | */ |
| 680 | private void updateAttributeCondition(JavaAttributeInfo javaAttributeInfo) { |
| 681 | |
| 682 | if (javaAttributeInfo.isIntConflict()) { |
| 683 | if (javaAttributeInfo.getAttributeType().getDataType() == UINT16) { |
| 684 | setUIntAttribute(javaAttributeInfo); |
| 685 | } else if (javaAttributeInfo.getAttributeType().getDataType() == INT32) { |
| 686 | setIntAttribute(javaAttributeInfo); |
| 687 | } |
| 688 | |
| 689 | } |
| 690 | if (javaAttributeInfo.isLongConflict()) { |
| 691 | if (javaAttributeInfo.getAttributeType().getDataType() == UINT32) { |
| 692 | setULongAttribute(javaAttributeInfo); |
| 693 | } else if (javaAttributeInfo.getAttributeType().getDataType() == INT64) { |
| 694 | setLongAttribute(javaAttributeInfo); |
| 695 | } |
| 696 | |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | /** |
| 701 | * Returns attribute for int. |
| 702 | * |
| 703 | * @return attribute for int |
| 704 | */ |
| 705 | public JavaAttributeInfo getIntAttribute() { |
| 706 | return intAttribute; |
| 707 | } |
| 708 | |
| 709 | /** |
| 710 | * Sets attribute for int. |
| 711 | * |
| 712 | * @param intAttribute attribute for int |
| 713 | */ |
| 714 | private void setIntAttribute(JavaAttributeInfo intAttribute) { |
| 715 | this.intAttribute = intAttribute; |
| 716 | } |
| 717 | |
| 718 | /** |
| 719 | * Returns attribute for long. |
| 720 | * |
| 721 | * @return attribute for long |
| 722 | */ |
| 723 | public JavaAttributeInfo getLongAttribute() { |
| 724 | return longAttribute; |
| 725 | } |
| 726 | |
| 727 | /** |
| 728 | * Sets attribute for long. |
| 729 | * |
| 730 | * @param longAttribute attribute for long |
| 731 | */ |
| 732 | private void setLongAttribute(JavaAttributeInfo longAttribute) { |
| 733 | this.longAttribute = longAttribute; |
| 734 | } |
| 735 | |
| 736 | /** |
| 737 | * Returns attribute for uInt. |
| 738 | * |
| 739 | * @return attribute for uInt |
| 740 | */ |
| 741 | public JavaAttributeInfo getUIntAttribute() { |
| 742 | return uIntAttribute; |
| 743 | } |
| 744 | |
| 745 | /** |
| 746 | * Sets attribute for uInt. |
| 747 | * |
| 748 | * @param uIntAttribute attribute for uInt |
| 749 | */ |
| 750 | private void setUIntAttribute(JavaAttributeInfo uIntAttribute) { |
| 751 | this.uIntAttribute = uIntAttribute; |
| 752 | } |
| 753 | |
| 754 | /** |
| 755 | * Returns attribute for uLong. |
| 756 | * |
| 757 | * @return attribute for uLong |
| 758 | */ |
| 759 | public JavaAttributeInfo getULongAttribute() { |
| 760 | return uLongAttribute; |
| 761 | } |
| 762 | |
| 763 | /** |
| 764 | * Sets attribute for uLong. |
| 765 | * |
| 766 | * @param uLongAttribute attribute for uLong |
| 767 | */ |
| 768 | private void setULongAttribute(JavaAttributeInfo uLongAttribute) { |
| 769 | this.uLongAttribute = uLongAttribute; |
| 770 | } |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 771 | } |