Committed by
Gerrit Code Review
[ONOS-3908] Implemetation of YANG container translator.
Change-Id: I9ffcfc4b370edb801dfc90c5394cef787c77641d
Showing
23 changed files
with
283 additions
and
85 deletions
| ... | @@ -21,6 +21,7 @@ import java.util.List; | ... | @@ -21,6 +21,7 @@ import java.util.List; |
| 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
| 23 | import org.onosproject.yangutils.parser.ParsableDataType; | 23 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 24 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 24 | 25 | ||
| 25 | /*- | 26 | /*- |
| 26 | * Reference RFC 6020. | 27 | * Reference RFC 6020. |
| ... | @@ -342,4 +343,16 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo | ... | @@ -342,4 +343,16 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo |
| 342 | // TODO Auto-generated method stub | 343 | // TODO Auto-generated method stub |
| 343 | 344 | ||
| 344 | } | 345 | } |
| 346 | + | ||
| 347 | + @Override | ||
| 348 | + public CachedFileHandle getFileHandle() { | ||
| 349 | + // TODO Auto-generated method stub | ||
| 350 | + return null; | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + @Override | ||
| 354 | + public void setFileHandle(CachedFileHandle fileHandle) { | ||
| 355 | + // TODO Auto-generated method stub | ||
| 356 | + | ||
| 357 | + } | ||
| 345 | } | 358 | } | ... | ... |
| ... | @@ -21,6 +21,7 @@ import java.util.List; | ... | @@ -21,6 +21,7 @@ import java.util.List; |
| 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
| 23 | import org.onosproject.yangutils.parser.ParsableDataType; | 23 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 24 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 24 | 25 | ||
| 25 | /*- | 26 | /*- |
| 26 | * Reference RFC 6020. | 27 | * Reference RFC 6020. |
| ... | @@ -336,4 +337,16 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn | ... | @@ -336,4 +337,16 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn |
| 336 | // TODO Auto-generated method stub | 337 | // TODO Auto-generated method stub |
| 337 | 338 | ||
| 338 | } | 339 | } |
| 340 | + | ||
| 341 | + @Override | ||
| 342 | + public CachedFileHandle getFileHandle() { | ||
| 343 | + // TODO Auto-generated method stub | ||
| 344 | + return null; | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + @Override | ||
| 348 | + public void setFileHandle(CachedFileHandle fileHandle) { | ||
| 349 | + // TODO Auto-generated method stub | ||
| 350 | + | ||
| 351 | + } | ||
| 339 | } | 352 | } | ... | ... |
| ... | @@ -21,6 +21,7 @@ import java.util.List; | ... | @@ -21,6 +21,7 @@ import java.util.List; |
| 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
| 23 | import org.onosproject.yangutils.parser.ParsableDataType; | 23 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 24 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 24 | 25 | ||
| 25 | /*- | 26 | /*- |
| 26 | * Reference RFC 6020. | 27 | * Reference RFC 6020. |
| ... | @@ -252,6 +253,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -252,6 +253,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 252 | * | 253 | * |
| 253 | * @return the description. | 254 | * @return the description. |
| 254 | */ | 255 | */ |
| 256 | + @Override | ||
| 255 | public String getDescription() { | 257 | public String getDescription() { |
| 256 | return description; | 258 | return description; |
| 257 | } | 259 | } |
| ... | @@ -261,6 +263,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -261,6 +263,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 261 | * | 263 | * |
| 262 | * @param description set the description. | 264 | * @param description set the description. |
| 263 | */ | 265 | */ |
| 266 | + @Override | ||
| 264 | public void setDescription(String description) { | 267 | public void setDescription(String description) { |
| 265 | this.description = description; | 268 | this.description = description; |
| 266 | } | 269 | } |
| ... | @@ -270,6 +273,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -270,6 +273,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 270 | * | 273 | * |
| 271 | * @return the reference. | 274 | * @return the reference. |
| 272 | */ | 275 | */ |
| 276 | + @Override | ||
| 273 | public String getReference() { | 277 | public String getReference() { |
| 274 | return reference; | 278 | return reference; |
| 275 | } | 279 | } |
| ... | @@ -279,6 +283,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -279,6 +283,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 279 | * | 283 | * |
| 280 | * @param reference the reference to set. | 284 | * @param reference the reference to set. |
| 281 | */ | 285 | */ |
| 286 | + @Override | ||
| 282 | public void setReference(String reference) { | 287 | public void setReference(String reference) { |
| 283 | this.reference = reference; | 288 | this.reference = reference; |
| 284 | } | 289 | } |
| ... | @@ -288,6 +293,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -288,6 +293,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 288 | * | 293 | * |
| 289 | * @return the status. | 294 | * @return the status. |
| 290 | */ | 295 | */ |
| 296 | + @Override | ||
| 291 | public YangStatusType getStatus() { | 297 | public YangStatusType getStatus() { |
| 292 | return status; | 298 | return status; |
| 293 | } | 299 | } |
| ... | @@ -297,6 +303,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -297,6 +303,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 297 | * | 303 | * |
| 298 | * @param status the status to set. | 304 | * @param status the status to set. |
| 299 | */ | 305 | */ |
| 306 | + @Override | ||
| 300 | public void setStatus(YangStatusType status) { | 307 | public void setStatus(YangStatusType status) { |
| 301 | this.status = status; | 308 | this.status = status; |
| 302 | } | 309 | } |
| ... | @@ -306,6 +313,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -306,6 +313,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 306 | * | 313 | * |
| 307 | * @return returns CHOICE_DATA | 314 | * @return returns CHOICE_DATA |
| 308 | */ | 315 | */ |
| 316 | + @Override | ||
| 309 | public ParsableDataType getParsableDataType() { | 317 | public ParsableDataType getParsableDataType() { |
| 310 | return ParsableDataType.CHOICE_DATA; | 318 | return ParsableDataType.CHOICE_DATA; |
| 311 | } | 319 | } |
| ... | @@ -315,6 +323,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -315,6 +323,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 315 | * | 323 | * |
| 316 | * @throws DataModelException a violation of data model rules. | 324 | * @throws DataModelException a violation of data model rules. |
| 317 | */ | 325 | */ |
| 326 | + @Override | ||
| 318 | public void validateDataOnEntry() throws DataModelException { | 327 | public void validateDataOnEntry() throws DataModelException { |
| 319 | // TODO auto-generated method stub, to be implemented by parser | 328 | // TODO auto-generated method stub, to be implemented by parser |
| 320 | } | 329 | } |
| ... | @@ -324,6 +333,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -324,6 +333,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 324 | * | 333 | * |
| 325 | * @throws DataModelException a violation of data model rules. | 334 | * @throws DataModelException a violation of data model rules. |
| 326 | */ | 335 | */ |
| 336 | + @Override | ||
| 327 | public void validateDataOnExit() throws DataModelException { | 337 | public void validateDataOnExit() throws DataModelException { |
| 328 | // TODO auto-generated method stub, to be implemented by parser | 338 | // TODO auto-generated method stub, to be implemented by parser |
| 329 | } | 339 | } |
| ... | @@ -349,6 +359,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -349,6 +359,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 349 | /* (non-Javadoc) | 359 | /* (non-Javadoc) |
| 350 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | 360 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() |
| 351 | */ | 361 | */ |
| 362 | + @Override | ||
| 352 | public void generateJavaCodeEntry() { | 363 | public void generateJavaCodeEntry() { |
| 353 | // TODO Auto-generated method stub | 364 | // TODO Auto-generated method stub |
| 354 | 365 | ||
| ... | @@ -357,8 +368,21 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -357,8 +368,21 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable { |
| 357 | /* (non-Javadoc) | 368 | /* (non-Javadoc) |
| 358 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | 369 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() |
| 359 | */ | 370 | */ |
| 371 | + @Override | ||
| 360 | public void generateJavaCodeExit() { | 372 | public void generateJavaCodeExit() { |
| 361 | // TODO Auto-generated method stub | 373 | // TODO Auto-generated method stub |
| 362 | 374 | ||
| 363 | } | 375 | } |
| 376 | + | ||
| 377 | + @Override | ||
| 378 | + public CachedFileHandle getFileHandle() { | ||
| 379 | + // TODO Auto-generated method stub | ||
| 380 | + return null; | ||
| 381 | + } | ||
| 382 | + | ||
| 383 | + @Override | ||
| 384 | + public void setFileHandle(CachedFileHandle fileHandle) { | ||
| 385 | + // TODO Auto-generated method stub | ||
| 386 | + | ||
| 387 | + } | ||
| 364 | } | 388 | } | ... | ... |
| ... | @@ -133,7 +133,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -133,7 +133,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
| 133 | private YangStatusType status; | 133 | private YangStatusType status; |
| 134 | 134 | ||
| 135 | /** | 135 | /** |
| 136 | - * package of the generated java code. | 136 | + * Package of the generated java code. |
| 137 | */ | 137 | */ |
| 138 | private String pkg; | 138 | private String pkg; |
| 139 | 139 | ||
| ... | @@ -332,6 +332,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -332,6 +332,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
| 332 | * | 332 | * |
| 333 | * @return the fileHandle | 333 | * @return the fileHandle |
| 334 | */ | 334 | */ |
| 335 | + @Override | ||
| 335 | public CachedFileHandle getFileHandle() { | 336 | public CachedFileHandle getFileHandle() { |
| 336 | return fileHandle; | 337 | return fileHandle; |
| 337 | } | 338 | } |
| ... | @@ -341,6 +342,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -341,6 +342,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
| 341 | * | 342 | * |
| 342 | * @param handle the fileHandle to set | 343 | * @param handle the fileHandle to set |
| 343 | */ | 344 | */ |
| 345 | + @Override | ||
| 344 | public void setFileHandle(CachedFileHandle handle) { | 346 | public void setFileHandle(CachedFileHandle handle) { |
| 345 | fileHandle = handle; | 347 | fileHandle = handle; |
| 346 | } | 348 | } |
| ... | @@ -395,11 +397,6 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -395,11 +397,6 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
| 395 | pkg = pcg; | 397 | pkg = pcg; |
| 396 | } | 398 | } |
| 397 | 399 | ||
| 398 | - /** | ||
| 399 | - * Generate the java code corresponding to YANG container. | ||
| 400 | - * | ||
| 401 | - * @throws IOException when fails to generate the source files. | ||
| 402 | - */ | ||
| 403 | @Override | 400 | @Override |
| 404 | public void generateJavaCodeEntry() throws IOException { | 401 | public void generateJavaCodeEntry() throws IOException { |
| 405 | YangNode parent = getParent(); | 402 | YangNode parent = getParent(); |
| ... | @@ -414,14 +411,33 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -414,14 +411,33 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
| 414 | throw new IOException("Failed to create the source files."); | 411 | throw new IOException("Failed to create the source files."); |
| 415 | } | 412 | } |
| 416 | setFileHandle(handle); | 413 | setFileHandle(handle); |
| 417 | - addLavesAttributes(); | 414 | + addAttributeInParent(); |
| 415 | + } | ||
| 416 | + | ||
| 417 | + /** | ||
| 418 | + * Adds current node attribute to parent file. | ||
| 419 | + * | ||
| 420 | + * @param pkg java file package path | ||
| 421 | + */ | ||
| 422 | + private void addAttributeInParent() { | ||
| 423 | + if (getParent() != null) { | ||
| 424 | + getParent().getFileHandle().setChildsPackage(getPackage()); | ||
| 425 | + getParent().getFileHandle().addAttributeInfo(null, getName(), false); | ||
| 426 | + } | ||
| 427 | + } | ||
| 428 | + | ||
| 429 | + @Override | ||
| 430 | + public void generateJavaCodeExit() throws IOException { | ||
| 431 | + addLeavesAttributes(); | ||
| 418 | addLeafListAttributes(); | 432 | addLeafListAttributes(); |
| 433 | + getFileHandle().close(); | ||
| 434 | + return; | ||
| 419 | } | 435 | } |
| 420 | 436 | ||
| 421 | /** | 437 | /** |
| 422 | * Adds leaf attributes in generated files. | 438 | * Adds leaf attributes in generated files. |
| 423 | */ | 439 | */ |
| 424 | - private void addLavesAttributes() { | 440 | + private void addLeavesAttributes() { |
| 425 | 441 | ||
| 426 | List<YangLeaf<?>> leaves = getListOfLeaf(); | 442 | List<YangLeaf<?>> leaves = getListOfLeaf(); |
| 427 | if (leaves != null) { | 443 | if (leaves != null) { |
| ... | @@ -442,17 +458,5 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom | ... | @@ -442,17 +458,5 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom |
| 442 | } | 458 | } |
| 443 | } | 459 | } |
| 444 | return; | 460 | return; |
| 445 | - | ||
| 446 | - } | ||
| 447 | - | ||
| 448 | - /** | ||
| 449 | - * Free resources used to generate code. | ||
| 450 | - * | ||
| 451 | - * @throws IOException when fails to generate source files. | ||
| 452 | - */ | ||
| 453 | - @Override | ||
| 454 | - public void generateJavaCodeExit() throws IOException { | ||
| 455 | - getFileHandle().close(); | ||
| 456 | - return; | ||
| 457 | } | 461 | } |
| 458 | } | 462 | } | ... | ... |
| ... | @@ -22,6 +22,7 @@ import java.util.Set; | ... | @@ -22,6 +22,7 @@ import java.util.Set; |
| 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 23 | import org.onosproject.yangutils.parser.Parsable; | 23 | import org.onosproject.yangutils.parser.Parsable; |
| 24 | import org.onosproject.yangutils.parser.ParsableDataType; | 24 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 25 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 25 | 26 | ||
| 26 | /* | 27 | /* |
| 27 | * The enumeration built-in type represents values from a set of | 28 | * The enumeration built-in type represents values from a set of |
| ... | @@ -79,6 +80,7 @@ public class YangEnumeration extends YangNode implements Parsable { | ... | @@ -79,6 +80,7 @@ public class YangEnumeration extends YangNode implements Parsable { |
| 79 | * | 80 | * |
| 80 | * @return returns ENUMERATION_DATA | 81 | * @return returns ENUMERATION_DATA |
| 81 | */ | 82 | */ |
| 83 | + @Override | ||
| 82 | public ParsableDataType getParsableDataType() { | 84 | public ParsableDataType getParsableDataType() { |
| 83 | return ParsableDataType.ENUMERATION_DATA; | 85 | return ParsableDataType.ENUMERATION_DATA; |
| 84 | } | 86 | } |
| ... | @@ -88,6 +90,7 @@ public class YangEnumeration extends YangNode implements Parsable { | ... | @@ -88,6 +90,7 @@ public class YangEnumeration extends YangNode implements Parsable { |
| 88 | * | 90 | * |
| 89 | * @throws DataModelException a violation of data model rules. | 91 | * @throws DataModelException a violation of data model rules. |
| 90 | */ | 92 | */ |
| 93 | + @Override | ||
| 91 | public void validateDataOnEntry() throws DataModelException { | 94 | public void validateDataOnEntry() throws DataModelException { |
| 92 | // TODO auto-generated method stub, to be implemented by parser | 95 | // TODO auto-generated method stub, to be implemented by parser |
| 93 | } | 96 | } |
| ... | @@ -97,6 +100,7 @@ public class YangEnumeration extends YangNode implements Parsable { | ... | @@ -97,6 +100,7 @@ public class YangEnumeration extends YangNode implements Parsable { |
| 97 | * | 100 | * |
| 98 | * @throws DataModelException a violation of data model rules. | 101 | * @throws DataModelException a violation of data model rules. |
| 99 | */ | 102 | */ |
| 103 | + @Override | ||
| 100 | public void validateDataOnExit() throws DataModelException { | 104 | public void validateDataOnExit() throws DataModelException { |
| 101 | // TODO auto-generated method stub, to be implemented by parser | 105 | // TODO auto-generated method stub, to be implemented by parser |
| 102 | } | 106 | } |
| ... | @@ -140,6 +144,7 @@ public class YangEnumeration extends YangNode implements Parsable { | ... | @@ -140,6 +144,7 @@ public class YangEnumeration extends YangNode implements Parsable { |
| 140 | /* (non-Javadoc) | 144 | /* (non-Javadoc) |
| 141 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | 145 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() |
| 142 | */ | 146 | */ |
| 147 | + @Override | ||
| 143 | public void generateJavaCodeEntry() { | 148 | public void generateJavaCodeEntry() { |
| 144 | // TODO Auto-generated method stub | 149 | // TODO Auto-generated method stub |
| 145 | 150 | ||
| ... | @@ -148,8 +153,21 @@ public class YangEnumeration extends YangNode implements Parsable { | ... | @@ -148,8 +153,21 @@ public class YangEnumeration extends YangNode implements Parsable { |
| 148 | /* (non-Javadoc) | 153 | /* (non-Javadoc) |
| 149 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | 154 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() |
| 150 | */ | 155 | */ |
| 156 | + @Override | ||
| 151 | public void generateJavaCodeExit() { | 157 | public void generateJavaCodeExit() { |
| 152 | // TODO Auto-generated method stub | 158 | // TODO Auto-generated method stub |
| 153 | 159 | ||
| 154 | } | 160 | } |
| 161 | + | ||
| 162 | + @Override | ||
| 163 | + public CachedFileHandle getFileHandle() { | ||
| 164 | + // TODO Auto-generated method stub | ||
| 165 | + return null; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + @Override | ||
| 169 | + public void setFileHandle(CachedFileHandle fileHandle) { | ||
| 170 | + // TODO Auto-generated method stub | ||
| 171 | + | ||
| 172 | + } | ||
| 155 | } | 173 | } | ... | ... |
| ... | @@ -21,6 +21,7 @@ import java.util.List; | ... | @@ -21,6 +21,7 @@ import java.util.List; |
| 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
| 23 | import org.onosproject.yangutils.parser.ParsableDataType; | 23 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 24 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 24 | 25 | ||
| 25 | /*- | 26 | /*- |
| 26 | * Reference RFC 6020. | 27 | * Reference RFC 6020. |
| ... | @@ -321,4 +322,16 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm | ... | @@ -321,4 +322,16 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm |
| 321 | // TODO Auto-generated method stub | 322 | // TODO Auto-generated method stub |
| 322 | 323 | ||
| 323 | } | 324 | } |
| 325 | + | ||
| 326 | + @Override | ||
| 327 | + public CachedFileHandle getFileHandle() { | ||
| 328 | + // TODO Auto-generated method stub | ||
| 329 | + return null; | ||
| 330 | + } | ||
| 331 | + | ||
| 332 | + @Override | ||
| 333 | + public void setFileHandle(CachedFileHandle fileHandle) { | ||
| 334 | + // TODO Auto-generated method stub | ||
| 335 | + | ||
| 336 | + } | ||
| 324 | } | 337 | } | ... | ... |
| ... | @@ -22,6 +22,7 @@ import java.util.List; | ... | @@ -22,6 +22,7 @@ import java.util.List; |
| 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 23 | import org.onosproject.yangutils.parser.Parsable; | 23 | import org.onosproject.yangutils.parser.Parsable; |
| 24 | import org.onosproject.yangutils.parser.ParsableDataType; | 24 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 25 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 25 | 26 | ||
| 26 | /*- | 27 | /*- |
| 27 | * The "list" statement is used to define an interior data node in the | 28 | * The "list" statement is used to define an interior data node in the |
| ... | @@ -459,4 +460,16 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn | ... | @@ -459,4 +460,16 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn |
| 459 | // TODO Auto-generated method stub | 460 | // TODO Auto-generated method stub |
| 460 | 461 | ||
| 461 | } | 462 | } |
| 463 | + | ||
| 464 | + @Override | ||
| 465 | + public CachedFileHandle getFileHandle() { | ||
| 466 | + // TODO Auto-generated method stub | ||
| 467 | + return null; | ||
| 468 | + } | ||
| 469 | + | ||
| 470 | + @Override | ||
| 471 | + public void setFileHandle(CachedFileHandle fileHandle) { | ||
| 472 | + // TODO Auto-generated method stub | ||
| 473 | + | ||
| 474 | + } | ||
| 462 | } | 475 | } | ... | ... |
| ... | @@ -155,7 +155,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, | ... | @@ -155,7 +155,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, |
| 155 | private byte version; | 155 | private byte version; |
| 156 | 156 | ||
| 157 | /** | 157 | /** |
| 158 | - * package of the generated java code. | 158 | + * Package of the generated java code. |
| 159 | */ | 159 | */ |
| 160 | private String pkg; | 160 | private String pkg; |
| 161 | 161 | ||
| ... | @@ -493,6 +493,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, | ... | @@ -493,6 +493,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, |
| 493 | * | 493 | * |
| 494 | * @return the fileHandle | 494 | * @return the fileHandle |
| 495 | */ | 495 | */ |
| 496 | + @Override | ||
| 496 | public CachedFileHandle getFileHandle() { | 497 | public CachedFileHandle getFileHandle() { |
| 497 | return fileHandle; | 498 | return fileHandle; |
| 498 | } | 499 | } |
| ... | @@ -502,6 +503,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, | ... | @@ -502,6 +503,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, |
| 502 | * | 503 | * |
| 503 | * @param handle the fileHandle to set | 504 | * @param handle the fileHandle to set |
| 504 | */ | 505 | */ |
| 506 | + @Override | ||
| 505 | public void setFileHandle(CachedFileHandle handle) { | 507 | public void setFileHandle(CachedFileHandle handle) { |
| 506 | fileHandle = handle; | 508 | fileHandle = handle; |
| 507 | } | 509 | } |
| ... | @@ -555,14 +557,20 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, | ... | @@ -555,14 +557,20 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, |
| 555 | throw new IOException("Failed to create the source files."); | 557 | throw new IOException("Failed to create the source files."); |
| 556 | } | 558 | } |
| 557 | setFileHandle(handle); | 559 | setFileHandle(handle); |
| 558 | - addLavesAttributes(); | 560 | + } |
| 561 | + | ||
| 562 | + @Override | ||
| 563 | + public void generateJavaCodeExit() throws IOException { | ||
| 564 | + addLeavesAttributes(); | ||
| 559 | addLeafListAttributes(); | 565 | addLeafListAttributes(); |
| 566 | + getFileHandle().close(); | ||
| 567 | + return; | ||
| 560 | } | 568 | } |
| 561 | 569 | ||
| 562 | /** | 570 | /** |
| 563 | * Adds leaf attributes in generated files. | 571 | * Adds leaf attributes in generated files. |
| 564 | */ | 572 | */ |
| 565 | - private void addLavesAttributes() { | 573 | + private void addLeavesAttributes() { |
| 566 | 574 | ||
| 567 | List<YangLeaf<?>> leaves = getListOfLeaf(); | 575 | List<YangLeaf<?>> leaves = getListOfLeaf(); |
| 568 | if (leaves != null) { | 576 | if (leaves != null) { |
| ... | @@ -584,15 +592,4 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, | ... | @@ -584,15 +592,4 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, |
| 584 | } | 592 | } |
| 585 | } | 593 | } |
| 586 | 594 | ||
| 587 | - /** | ||
| 588 | - * Free resources used to generate code. | ||
| 589 | - * | ||
| 590 | - * @throws IOException when fails to generate source files. | ||
| 591 | - */ | ||
| 592 | - @Override | ||
| 593 | - public void generateJavaCodeExit() throws IOException { | ||
| 594 | - getFileHandle().close(); | ||
| 595 | - return; | ||
| 596 | - } | ||
| 597 | - | ||
| 598 | } | 595 | } | ... | ... |
| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | package org.onosproject.yangutils.datamodel; | 16 | package org.onosproject.yangutils.datamodel; |
| 17 | 17 | ||
| 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 19 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 19 | import org.onosproject.yangutils.translator.CodeGenerator; | 20 | import org.onosproject.yangutils.translator.CodeGenerator; |
| 20 | 21 | ||
| 21 | /** | 22 | /** |
| ... | @@ -253,4 +254,18 @@ public abstract class YangNode implements CodeGenerator { | ... | @@ -253,4 +254,18 @@ public abstract class YangNode implements CodeGenerator { |
| 253 | */ | 254 | */ |
| 254 | public abstract void setPackage(String pkg); | 255 | public abstract void setPackage(String pkg); |
| 255 | 256 | ||
| 257 | + /** | ||
| 258 | + * Get the mapped java file handler. | ||
| 259 | + * | ||
| 260 | + * @return the file handle. | ||
| 261 | + */ | ||
| 262 | + public abstract CachedFileHandle getFileHandle(); | ||
| 263 | + | ||
| 264 | + /** | ||
| 265 | + * Set the mapped java file handle. | ||
| 266 | + * | ||
| 267 | + * @param fileHandle the file handle to set of current node. | ||
| 268 | + */ | ||
| 269 | + public abstract void setFileHandle(CachedFileHandle fileHandle); | ||
| 270 | + | ||
| 256 | } | 271 | } | ... | ... |
| ... | @@ -21,6 +21,7 @@ import java.util.List; | ... | @@ -21,6 +21,7 @@ import java.util.List; |
| 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.parser.Parsable; | 22 | import org.onosproject.yangutils.parser.Parsable; |
| 23 | import org.onosproject.yangutils.parser.ParsableDataType; | 23 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 24 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 24 | 25 | ||
| 25 | /* | 26 | /* |
| 26 | * Reference RFC 6020. | 27 | * Reference RFC 6020. |
| ... | @@ -491,4 +492,16 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes | ... | @@ -491,4 +492,16 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes |
| 491 | // TODO Auto-generated method stub | 492 | // TODO Auto-generated method stub |
| 492 | 493 | ||
| 493 | } | 494 | } |
| 495 | + | ||
| 496 | + @Override | ||
| 497 | + public CachedFileHandle getFileHandle() { | ||
| 498 | + // TODO Auto-generated method stub | ||
| 499 | + return null; | ||
| 500 | + } | ||
| 501 | + | ||
| 502 | + @Override | ||
| 503 | + public void setFileHandle(CachedFileHandle fileHandle) { | ||
| 504 | + // TODO Auto-generated method stub | ||
| 505 | + | ||
| 506 | + } | ||
| 494 | } | 507 | } | ... | ... |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -18,6 +18,7 @@ package org.onosproject.yangutils.datamodel; |
| 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 19 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
| 20 | import org.onosproject.yangutils.parser.ParsableDataType; | 20 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 21 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 21 | 22 | ||
| 22 | /*- | 23 | /*- |
| 23 | * Reference RFC 6020. | 24 | * Reference RFC 6020. |
| ... | @@ -138,6 +139,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -138,6 +139,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 138 | * | 139 | * |
| 139 | * @return the description. | 140 | * @return the description. |
| 140 | */ | 141 | */ |
| 142 | + @Override | ||
| 141 | public String getDescription() { | 143 | public String getDescription() { |
| 142 | return description; | 144 | return description; |
| 143 | } | 145 | } |
| ... | @@ -147,6 +149,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -147,6 +149,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 147 | * | 149 | * |
| 148 | * @param description set the description. | 150 | * @param description set the description. |
| 149 | */ | 151 | */ |
| 152 | + @Override | ||
| 150 | public void setDescription(String description) { | 153 | public void setDescription(String description) { |
| 151 | this.description = description; | 154 | this.description = description; |
| 152 | } | 155 | } |
| ... | @@ -156,6 +159,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -156,6 +159,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 156 | * | 159 | * |
| 157 | * @return the reference. | 160 | * @return the reference. |
| 158 | */ | 161 | */ |
| 162 | + @Override | ||
| 159 | public String getReference() { | 163 | public String getReference() { |
| 160 | return reference; | 164 | return reference; |
| 161 | } | 165 | } |
| ... | @@ -165,6 +169,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -165,6 +169,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 165 | * | 169 | * |
| 166 | * @param reference the reference to set. | 170 | * @param reference the reference to set. |
| 167 | */ | 171 | */ |
| 172 | + @Override | ||
| 168 | public void setReference(String reference) { | 173 | public void setReference(String reference) { |
| 169 | this.reference = reference; | 174 | this.reference = reference; |
| 170 | } | 175 | } |
| ... | @@ -174,6 +179,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -174,6 +179,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 174 | * | 179 | * |
| 175 | * @return the status. | 180 | * @return the status. |
| 176 | */ | 181 | */ |
| 182 | + @Override | ||
| 177 | public YangStatusType getStatus() { | 183 | public YangStatusType getStatus() { |
| 178 | return status; | 184 | return status; |
| 179 | } | 185 | } |
| ... | @@ -183,6 +189,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -183,6 +189,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 183 | * | 189 | * |
| 184 | * @param status the status to set. | 190 | * @param status the status to set. |
| 185 | */ | 191 | */ |
| 192 | + @Override | ||
| 186 | public void setStatus(YangStatusType status) { | 193 | public void setStatus(YangStatusType status) { |
| 187 | this.status = status; | 194 | this.status = status; |
| 188 | } | 195 | } |
| ... | @@ -230,6 +237,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -230,6 +237,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 230 | * | 237 | * |
| 231 | * @return returns TYPEDEF_DATA | 238 | * @return returns TYPEDEF_DATA |
| 232 | */ | 239 | */ |
| 240 | + @Override | ||
| 233 | public ParsableDataType getParsableDataType() { | 241 | public ParsableDataType getParsableDataType() { |
| 234 | return ParsableDataType.TYPEDEF_DATA; | 242 | return ParsableDataType.TYPEDEF_DATA; |
| 235 | } | 243 | } |
| ... | @@ -239,6 +247,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -239,6 +247,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 239 | * | 247 | * |
| 240 | * @throws DataModelException a violation of data model rules. | 248 | * @throws DataModelException a violation of data model rules. |
| 241 | */ | 249 | */ |
| 250 | + @Override | ||
| 242 | public void validateDataOnEntry() throws DataModelException { | 251 | public void validateDataOnEntry() throws DataModelException { |
| 243 | // TODO auto-generated method stub, to be implemented by parser | 252 | // TODO auto-generated method stub, to be implemented by parser |
| 244 | } | 253 | } |
| ... | @@ -248,6 +257,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -248,6 +257,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 248 | * | 257 | * |
| 249 | * @throws DataModelException a violation of data model rules. | 258 | * @throws DataModelException a violation of data model rules. |
| 250 | */ | 259 | */ |
| 260 | + @Override | ||
| 251 | public void validateDataOnExit() throws DataModelException { | 261 | public void validateDataOnExit() throws DataModelException { |
| 252 | // TODO auto-generated method stub, to be implemented by parser | 262 | // TODO auto-generated method stub, to be implemented by parser |
| 253 | } | 263 | } |
| ... | @@ -273,6 +283,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -273,6 +283,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 273 | /* (non-Javadoc) | 283 | /* (non-Javadoc) |
| 274 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | 284 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() |
| 275 | */ | 285 | */ |
| 286 | + @Override | ||
| 276 | public void generateJavaCodeEntry() { | 287 | public void generateJavaCodeEntry() { |
| 277 | // TODO Auto-generated method stub | 288 | // TODO Auto-generated method stub |
| 278 | 289 | ||
| ... | @@ -281,6 +292,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -281,6 +292,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 281 | /* (non-Javadoc) | 292 | /* (non-Javadoc) |
| 282 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | 293 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() |
| 283 | */ | 294 | */ |
| 295 | + @Override | ||
| 284 | public void generateJavaCodeExit() { | 296 | public void generateJavaCodeExit() { |
| 285 | // TODO Auto-generated method stub | 297 | // TODO Auto-generated method stub |
| 286 | 298 | ||
| ... | @@ -303,4 +315,16 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -303,4 +315,16 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable { |
| 303 | // TODO Auto-generated method stub | 315 | // TODO Auto-generated method stub |
| 304 | 316 | ||
| 305 | } | 317 | } |
| 318 | + | ||
| 319 | + @Override | ||
| 320 | + public CachedFileHandle getFileHandle() { | ||
| 321 | + // TODO Auto-generated method stub | ||
| 322 | + return null; | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + @Override | ||
| 326 | + public void setFileHandle(CachedFileHandle fileHandle) { | ||
| 327 | + // TODO Auto-generated method stub | ||
| 328 | + | ||
| 329 | + } | ||
| 306 | } | 330 | } | ... | ... |
| ... | @@ -18,6 +18,7 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -18,6 +18,7 @@ package org.onosproject.yangutils.datamodel; |
| 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 19 | import org.onosproject.yangutils.parser.Parsable; | 19 | import org.onosproject.yangutils.parser.Parsable; |
| 20 | import org.onosproject.yangutils.parser.ParsableDataType; | 20 | import org.onosproject.yangutils.parser.ParsableDataType; |
| 21 | +import org.onosproject.yangutils.translator.CachedFileHandle; | ||
| 21 | 22 | ||
| 22 | /*- | 23 | /*- |
| 23 | * Reference RFC 6020. | 24 | * Reference RFC 6020. |
| ... | @@ -127,6 +128,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -127,6 +128,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 127 | * | 128 | * |
| 128 | * @return the description. | 129 | * @return the description. |
| 129 | */ | 130 | */ |
| 131 | + @Override | ||
| 130 | public String getDescription() { | 132 | public String getDescription() { |
| 131 | return description; | 133 | return description; |
| 132 | } | 134 | } |
| ... | @@ -136,6 +138,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -136,6 +138,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 136 | * | 138 | * |
| 137 | * @param description set the description. | 139 | * @param description set the description. |
| 138 | */ | 140 | */ |
| 141 | + @Override | ||
| 139 | public void setDescription(String description) { | 142 | public void setDescription(String description) { |
| 140 | this.description = description; | 143 | this.description = description; |
| 141 | } | 144 | } |
| ... | @@ -145,6 +148,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -145,6 +148,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 145 | * | 148 | * |
| 146 | * @return the reference. | 149 | * @return the reference. |
| 147 | */ | 150 | */ |
| 151 | + @Override | ||
| 148 | public String getReference() { | 152 | public String getReference() { |
| 149 | return reference; | 153 | return reference; |
| 150 | } | 154 | } |
| ... | @@ -154,6 +158,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -154,6 +158,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 154 | * | 158 | * |
| 155 | * @param reference the reference to set. | 159 | * @param reference the reference to set. |
| 156 | */ | 160 | */ |
| 161 | + @Override | ||
| 157 | public void setReference(String reference) { | 162 | public void setReference(String reference) { |
| 158 | this.reference = reference; | 163 | this.reference = reference; |
| 159 | } | 164 | } |
| ... | @@ -163,6 +168,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -163,6 +168,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 163 | * | 168 | * |
| 164 | * @return the status. | 169 | * @return the status. |
| 165 | */ | 170 | */ |
| 171 | + @Override | ||
| 166 | public YangStatusType getStatus() { | 172 | public YangStatusType getStatus() { |
| 167 | return status; | 173 | return status; |
| 168 | } | 174 | } |
| ... | @@ -172,6 +178,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -172,6 +178,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 172 | * | 178 | * |
| 173 | * @param status the status to set. | 179 | * @param status the status to set. |
| 174 | */ | 180 | */ |
| 181 | + @Override | ||
| 175 | public void setStatus(YangStatusType status) { | 182 | public void setStatus(YangStatusType status) { |
| 176 | this.status = status; | 183 | this.status = status; |
| 177 | } | 184 | } |
| ... | @@ -181,6 +188,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -181,6 +188,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 181 | * | 188 | * |
| 182 | * @return returns USES_DATA. | 189 | * @return returns USES_DATA. |
| 183 | */ | 190 | */ |
| 191 | + @Override | ||
| 184 | public ParsableDataType getParsableDataType() { | 192 | public ParsableDataType getParsableDataType() { |
| 185 | return ParsableDataType.USES_DATA; | 193 | return ParsableDataType.USES_DATA; |
| 186 | } | 194 | } |
| ... | @@ -190,6 +198,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -190,6 +198,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 190 | * | 198 | * |
| 191 | * @throws DataModelException a violation of data model rules. | 199 | * @throws DataModelException a violation of data model rules. |
| 192 | */ | 200 | */ |
| 201 | + @Override | ||
| 193 | public void validateDataOnEntry() throws DataModelException { | 202 | public void validateDataOnEntry() throws DataModelException { |
| 194 | // TODO auto-generated method stub, to be implemented by parser | 203 | // TODO auto-generated method stub, to be implemented by parser |
| 195 | } | 204 | } |
| ... | @@ -199,6 +208,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -199,6 +208,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 199 | * | 208 | * |
| 200 | * @throws DataModelException a violation of data model rules. | 209 | * @throws DataModelException a violation of data model rules. |
| 201 | */ | 210 | */ |
| 211 | + @Override | ||
| 202 | public void validateDataOnExit() throws DataModelException { | 212 | public void validateDataOnExit() throws DataModelException { |
| 203 | // TODO auto-generated method stub, to be implemented by parser | 213 | // TODO auto-generated method stub, to be implemented by parser |
| 204 | } | 214 | } |
| ... | @@ -224,6 +234,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -224,6 +234,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 224 | /* (non-Javadoc) | 234 | /* (non-Javadoc) |
| 225 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() | 235 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry() |
| 226 | */ | 236 | */ |
| 237 | + @Override | ||
| 227 | public void generateJavaCodeEntry() { | 238 | public void generateJavaCodeEntry() { |
| 228 | // TODO Auto-generated method stub | 239 | // TODO Auto-generated method stub |
| 229 | 240 | ||
| ... | @@ -232,6 +243,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -232,6 +243,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 232 | /* (non-Javadoc) | 243 | /* (non-Javadoc) |
| 233 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() | 244 | * @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit() |
| 234 | */ | 245 | */ |
| 246 | + @Override | ||
| 235 | public void generateJavaCodeExit() { | 247 | public void generateJavaCodeExit() { |
| 236 | // TODO Auto-generated method stub | 248 | // TODO Auto-generated method stub |
| 237 | 249 | ||
| ... | @@ -254,4 +266,16 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { | ... | @@ -254,4 +266,16 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable { |
| 254 | // TODO Auto-generated method stub | 266 | // TODO Auto-generated method stub |
| 255 | 267 | ||
| 256 | } | 268 | } |
| 269 | + | ||
| 270 | + @Override | ||
| 271 | + public CachedFileHandle getFileHandle() { | ||
| 272 | + // TODO Auto-generated method stub | ||
| 273 | + return null; | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + @Override | ||
| 277 | + public void setFileHandle(CachedFileHandle fileHandle) { | ||
| 278 | + // TODO Auto-generated method stub | ||
| 279 | + | ||
| 280 | + } | ||
| 257 | } | 281 | } | ... | ... |
| ... | @@ -42,4 +42,11 @@ public interface CachedFileHandle { | ... | @@ -42,4 +42,11 @@ public interface CachedFileHandle { |
| 42 | * @throws IOException when failes to generated java files. | 42 | * @throws IOException when failes to generated java files. |
| 43 | */ | 43 | */ |
| 44 | void close() throws IOException; | 44 | void close() throws IOException; |
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * Sets child package path for import. | ||
| 48 | + * | ||
| 49 | + * @param pkg child's package path | ||
| 50 | + */ | ||
| 51 | + void setChildsPackage(String pkg); | ||
| 45 | } | 52 | } | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -42,18 +42,19 @@ public final class JavaCodeGenerator { | ... | @@ -42,18 +42,19 @@ public final class JavaCodeGenerator { |
| 42 | TraversalType curTraversal = TraversalType.ROOT; | 42 | TraversalType curTraversal = TraversalType.ROOT; |
| 43 | 43 | ||
| 44 | while (!(curNode == null)) { | 44 | while (!(curNode == null)) { |
| 45 | - if (curTraversal != TraversalType.PARENT) { | 45 | + if (curTraversal != TraversalType.PARENT || curTraversal == TraversalType.SIBILING) { |
| 46 | curNode.generateJavaCodeEntry(); | 46 | curNode.generateJavaCodeEntry(); |
| 47 | } | 47 | } |
| 48 | if (curTraversal != TraversalType.PARENT && !(curNode.getChild() == null)) { | 48 | if (curTraversal != TraversalType.PARENT && !(curNode.getChild() == null)) { |
| 49 | curTraversal = TraversalType.CHILD; | 49 | curTraversal = TraversalType.CHILD; |
| 50 | curNode = curNode.getChild(); | 50 | curNode = curNode.getChild(); |
| 51 | - } else if (!(curNode.getNextSibling() == null)) { | 51 | + } else if (curTraversal == TraversalType.PARENT && !(curNode.getNextSibling() == null)) { |
| 52 | + curNode.generateJavaCodeExit(); | ||
| 52 | curTraversal = TraversalType.SIBILING; | 53 | curTraversal = TraversalType.SIBILING; |
| 53 | curNode = curNode.getNextSibling(); | 54 | curNode = curNode.getNextSibling(); |
| 54 | } else { | 55 | } else { |
| 55 | - curTraversal = TraversalType.PARENT; | ||
| 56 | curNode.generateJavaCodeExit(); | 56 | curNode.generateJavaCodeExit(); |
| 57 | + curTraversal = TraversalType.PARENT; | ||
| 57 | curNode = curNode.getParent(); | 58 | curNode = curNode.getParent(); |
| 58 | } | 59 | } |
| 59 | } | 60 | } | ... | ... |
| ... | @@ -16,9 +16,6 @@ | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.yangutils.translator.tojava.utils; | 17 | package org.onosproject.yangutils.translator.tojava.utils; |
| 18 | 18 | ||
| 19 | -import java.util.List; | ||
| 20 | -import java.util.SortedSet; | ||
| 21 | - | ||
| 22 | import org.onosproject.yangutils.datamodel.YangType; | 19 | import org.onosproject.yangutils.datamodel.YangType; |
| 23 | import org.onosproject.yangutils.translator.GeneratedFileType; | 20 | import org.onosproject.yangutils.translator.GeneratedFileType; |
| 24 | import org.onosproject.yangutils.translator.tojava.GeneratedMethodTypes; | 21 | import org.onosproject.yangutils.translator.tojava.GeneratedMethodTypes; |
| ... | @@ -50,29 +47,15 @@ public final class JavaCodeSnippetGen { | ... | @@ -50,29 +47,15 @@ public final class JavaCodeSnippetGen { |
| 50 | } | 47 | } |
| 51 | 48 | ||
| 52 | /** | 49 | /** |
| 53 | - * reorder the import list based on the ONOS import rules. | ||
| 54 | - * | ||
| 55 | - * @param importInfo the set of classes/interfaces to be imported. | ||
| 56 | - * @return string of import info. | ||
| 57 | - */ | ||
| 58 | - public List<ImportInfo> sortImportOrder(SortedSet<ImportInfo> importInfo) { | ||
| 59 | - /* TODO: reorder the import list based on the ONOS import rules. */ | ||
| 60 | - return null; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - /** | ||
| 64 | * Get the textual java code information corresponding to the import list. | 50 | * Get the textual java code information corresponding to the import list. |
| 65 | * | 51 | * |
| 66 | - * @param importInfo sorted list of import info. | 52 | + * @param importInfo import info. |
| 67 | * @return the textual java code information corresponding to the import | 53 | * @return the textual java code information corresponding to the import |
| 68 | * list. | 54 | * list. |
| 69 | */ | 55 | */ |
| 70 | - public static String getImportText(List<ImportInfo> importInfo) { | 56 | + public static String getImportText(ImportInfo importInfo) { |
| 71 | - /* | 57 | + return UtilConstants.IMPORT + importInfo.getPkgInfo() + UtilConstants.PERIOD + importInfo.getClassInfo() |
| 72 | - * TODO: get the textual java code information corresponding to the | 58 | + + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE; |
| 73 | - * import list | ||
| 74 | - */ | ||
| 75 | - return null; | ||
| 76 | } | 59 | } |
| 77 | 60 | ||
| 78 | /** | 61 | /** |
| ... | @@ -101,8 +84,22 @@ public final class JavaCodeSnippetGen { | ... | @@ -101,8 +84,22 @@ public final class JavaCodeSnippetGen { |
| 101 | */ | 84 | */ |
| 102 | public static String getJavaAttributeInfo(GeneratedFileType genFileTypes, String yangName, YangType<?> type) { | 85 | public static String getJavaAttributeInfo(GeneratedFileType genFileTypes, String yangName, YangType<?> type) { |
| 103 | yangName = JavaIdentifierSyntax.getCamelCase(yangName); | 86 | yangName = JavaIdentifierSyntax.getCamelCase(yangName); |
| 104 | - return UtilConstants.PRIVATE + UtilConstants.SPACE + type.getDataTypeName() + UtilConstants.SPACE + yangName | 87 | + if (type != null) { |
| 105 | - + UtilConstants.SEMI_COLAN; | 88 | + return UtilConstants.PRIVATE + UtilConstants.SPACE + type.getDataTypeName() + UtilConstants.SPACE + yangName |
| 89 | + + UtilConstants.SEMI_COLAN; | ||
| 90 | + } | ||
| 91 | + return UtilConstants.PRIVATE + UtilConstants.SPACE + JavaIdentifierSyntax.getCaptialCase(yangName) | ||
| 92 | + + UtilConstants.SPACE + yangName + UtilConstants.SEMI_COLAN; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + /** | ||
| 96 | + * Returns list attribute string. | ||
| 97 | + * | ||
| 98 | + * @param type attribute type | ||
| 99 | + * @return list attribute string | ||
| 100 | + */ | ||
| 101 | + public static String getListAttribute(String type) { | ||
| 102 | + return UtilConstants.LIST + UtilConstants.DIAMOND_OPEN_BRACKET + type + UtilConstants.DIAMOND_CLOSE_BRACKET; | ||
| 106 | } | 103 | } |
| 107 | 104 | ||
| 108 | /** | 105 | /** | ... | ... |
| ... | @@ -163,4 +163,14 @@ public final class JavaIdentifierSyntax { | ... | @@ -163,4 +163,14 @@ public final class JavaIdentifierSyntax { |
| 163 | } | 163 | } |
| 164 | return camelCase; | 164 | return camelCase; |
| 165 | } | 165 | } |
| 166 | + | ||
| 167 | + /** | ||
| 168 | + * Translate the YANG identifier name to java identifier with first letter in caps. | ||
| 169 | + * | ||
| 170 | + * @param yangIdentifier identifier in YANG file. | ||
| 171 | + * @return corresponding java identifier | ||
| 172 | + */ | ||
| 173 | + public static String getCaptialCase(String yangIdentifier) { | ||
| 174 | + return yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1); | ||
| 175 | + } | ||
| 166 | } | 176 | } | ... | ... |
| ... | @@ -112,6 +112,13 @@ public final class MethodsGenerator { | ... | @@ -112,6 +112,13 @@ public final class MethodsGenerator { |
| 112 | public static String constructMethodInfo(GeneratedFileType genFileTypes, String yangName, | 112 | public static String constructMethodInfo(GeneratedFileType genFileTypes, String yangName, |
| 113 | GeneratedMethodTypes methodTypes, YangType<?> returnType) { | 113 | GeneratedMethodTypes methodTypes, YangType<?> returnType) { |
| 114 | 114 | ||
| 115 | + if (returnType == null) { | ||
| 116 | + @SuppressWarnings("rawtypes") | ||
| 117 | + YangType<?> type = new YangType(); | ||
| 118 | + type.setDataTypeName(yangName); | ||
| 119 | + returnType = type; | ||
| 120 | + } | ||
| 121 | + | ||
| 115 | if (genFileTypes.equals(GeneratedFileType.INTERFACE)) { | 122 | if (genFileTypes.equals(GeneratedFileType.INTERFACE)) { |
| 116 | 123 | ||
| 117 | /** | 124 | /** |
| ... | @@ -177,12 +184,10 @@ public final class MethodsGenerator { | ... | @@ -177,12 +184,10 @@ public final class MethodsGenerator { |
| 177 | 184 | ||
| 178 | String overrideString = UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.OVERRIDE | 185 | String overrideString = UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.OVERRIDE |
| 179 | + UtilConstants.NEW_LINE; | 186 | + UtilConstants.NEW_LINE; |
| 180 | - | ||
| 181 | String getterString = JavaCodeSnippetGen.getJavaMethodInfo(GeneratedFileType.BUILDER_CLASS, | 187 | String getterString = JavaCodeSnippetGen.getJavaMethodInfo(GeneratedFileType.BUILDER_CLASS, |
| 182 | attr.getAttributeName(), GeneratedMethodTypes.GETTER, attr.getAttributeType()); | 188 | attr.getAttributeName(), GeneratedMethodTypes.GETTER, attr.getAttributeType()); |
| 183 | String setterString = JavaCodeSnippetGen.getJavaMethodInfo(GeneratedFileType.BUILDER_CLASS, | 189 | String setterString = JavaCodeSnippetGen.getJavaMethodInfo(GeneratedFileType.BUILDER_CLASS, |
| 184 | attr.getAttributeName(), GeneratedMethodTypes.SETTER, attr.getAttributeType()); | 190 | attr.getAttributeName(), GeneratedMethodTypes.SETTER, attr.getAttributeType()); |
| 185 | - | ||
| 186 | return overrideString + getterString + UtilConstants.NEW_LINE + overrideString + setterString | 191 | return overrideString + getterString + UtilConstants.NEW_LINE + overrideString + setterString |
| 187 | + UtilConstants.NEW_LINE; | 192 | + UtilConstants.NEW_LINE; |
| 188 | } | 193 | } |
| ... | @@ -299,7 +304,8 @@ public final class MethodsGenerator { | ... | @@ -299,7 +304,8 @@ public final class MethodsGenerator { |
| 299 | private static String getGetterForClass(String yangName, YangType<?> returnType) { | 304 | private static String getGetterForClass(String yangName, YangType<?> returnType) { |
| 300 | 305 | ||
| 301 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE | 306 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE |
| 302 | - + returnType.getDataTypeName() + UtilConstants.SPACE + UtilConstants.GET_METHOD_PREFIX + yangName | 307 | + + JavaIdentifierSyntax.getCaptialCase(returnType.getDataTypeName()) + UtilConstants.SPACE |
| 308 | + + UtilConstants.GET_METHOD_PREFIX + JavaIdentifierSyntax.getCaptialCase(yangName) | ||
| 303 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE | 309 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE |
| 304 | + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION | 310 | + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION |
| 305 | + UtilConstants.RETURN + UtilConstants.SPACE + yangName + UtilConstants.SEMI_COLAN | 311 | + UtilConstants.RETURN + UtilConstants.SPACE + yangName + UtilConstants.SEMI_COLAN |
| ... | @@ -316,13 +322,14 @@ public final class MethodsGenerator { | ... | @@ -316,13 +322,14 @@ public final class MethodsGenerator { |
| 316 | private static String getSetterForClass(String yangName, YangType<?> returnType) { | 322 | private static String getSetterForClass(String yangName, YangType<?> returnType) { |
| 317 | 323 | ||
| 318 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE + getBuilderClassName() | 324 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE + getBuilderClassName() |
| 319 | - + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX + yangName + UtilConstants.OPEN_PARENTHESIS | 325 | + + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX + JavaIdentifierSyntax.getCaptialCase(yangName) |
| 320 | - + returnType.getDataTypeName() + UtilConstants.SPACE + yangName + UtilConstants.CLOSE_PARENTHESIS | 326 | + + UtilConstants.OPEN_PARENTHESIS + JavaIdentifierSyntax.getCaptialCase(returnType.getDataTypeName()) |
| 321 | - + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE | 327 | + + UtilConstants.SPACE + yangName + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE |
| 322 | - + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS + UtilConstants.PERIOD + yangName | 328 | + + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION |
| 323 | - + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE + yangName + UtilConstants.SEMI_COLAN | 329 | + + UtilConstants.THIS + UtilConstants.PERIOD + yangName + UtilConstants.SPACE + UtilConstants.EQUAL |
| 324 | - + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN | 330 | + + UtilConstants.SPACE + yangName + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE |
| 325 | - + UtilConstants.SPACE + UtilConstants.THIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE | 331 | + + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN + UtilConstants.SPACE |
| 332 | + + UtilConstants.THIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE | ||
| 326 | + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET; | 333 | + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET; |
| 327 | } | 334 | } |
| 328 | 335 | ||
| ... | @@ -335,9 +342,9 @@ public final class MethodsGenerator { | ... | @@ -335,9 +342,9 @@ public final class MethodsGenerator { |
| 335 | */ | 342 | */ |
| 336 | private static String getGetterForInterface(String yangName, YangType<?> returnType) { | 343 | private static String getGetterForInterface(String yangName, YangType<?> returnType) { |
| 337 | returnType.setDataTypeName(returnType.getDataTypeName().replace("\"", "")); | 344 | returnType.setDataTypeName(returnType.getDataTypeName().replace("\"", "")); |
| 338 | - return UtilConstants.FOUR_SPACE_INDENTATION + returnType.getDataTypeName() + UtilConstants.SPACE | 345 | + return UtilConstants.FOUR_SPACE_INDENTATION + JavaIdentifierSyntax.getCaptialCase(returnType.getDataTypeName()) |
| 339 | - + UtilConstants.GET_METHOD_PREFIX + yangName + UtilConstants.OPEN_PARENTHESIS | 346 | + + UtilConstants.SPACE + UtilConstants.GET_METHOD_PREFIX + JavaIdentifierSyntax.getCaptialCase(yangName) |
| 340 | - + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN; | 347 | + + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN; |
| 341 | } | 348 | } |
| 342 | 349 | ||
| 343 | /** | 350 | /** |
| ... | @@ -349,9 +356,9 @@ public final class MethodsGenerator { | ... | @@ -349,9 +356,9 @@ public final class MethodsGenerator { |
| 349 | */ | 356 | */ |
| 350 | private static String getSetterForInterface(String yangName, YangType<?> returnType) { | 357 | private static String getSetterForInterface(String yangName, YangType<?> returnType) { |
| 351 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.BUILDER + UtilConstants.SPACE | 358 | return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.BUILDER + UtilConstants.SPACE |
| 352 | - + UtilConstants.SET_METHOD_PREFIX + yangName + UtilConstants.OPEN_PARENTHESIS | 359 | + + UtilConstants.SET_METHOD_PREFIX + JavaIdentifierSyntax.getCaptialCase(yangName) |
| 353 | - + returnType.getDataTypeName() + UtilConstants.SPACE + yangName + UtilConstants.CLOSE_PARENTHESIS | 360 | + + UtilConstants.OPEN_PARENTHESIS + JavaIdentifierSyntax.getCaptialCase(returnType.getDataTypeName()) |
| 354 | - + UtilConstants.SEMI_COLAN; | 361 | + + UtilConstants.SPACE + yangName + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN; |
| 355 | } | 362 | } |
| 356 | 363 | ||
| 357 | /** | 364 | /** |
| ... | @@ -387,7 +394,8 @@ public final class MethodsGenerator { | ... | @@ -387,7 +394,8 @@ public final class MethodsGenerator { |
| 387 | constructor = constructor + UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.THIS | 394 | constructor = constructor + UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.THIS |
| 388 | + UtilConstants.PERIOD + attribute.getAttributeName() + UtilConstants.SPACE | 395 | + UtilConstants.PERIOD + attribute.getAttributeName() + UtilConstants.SPACE |
| 389 | + UtilConstants.EQUAL + UtilConstants.SPACE + builderAttribute + UtilConstants.OBJECT | 396 | + UtilConstants.EQUAL + UtilConstants.SPACE + builderAttribute + UtilConstants.OBJECT |
| 390 | - + UtilConstants.PERIOD + UtilConstants.GET_METHOD_PREFIX + attribute.getAttributeName() | 397 | + + UtilConstants.PERIOD + UtilConstants.GET_METHOD_PREFIX |
| 398 | + + JavaIdentifierSyntax.getCaptialCase(attribute.getAttributeName()) | ||
| 391 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN | 399 | + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN |
| 392 | + UtilConstants.NEW_LINE; | 400 | + UtilConstants.NEW_LINE; |
| 393 | } | 401 | } | ... | ... |
| ... | @@ -129,7 +129,7 @@ public final class UtilConstants { | ... | @@ -129,7 +129,7 @@ public final class UtilConstants { |
| 129 | public static final String STATIC = "static"; | 129 | public static final String STATIC = "static"; |
| 130 | public static final String FINAL = "final"; | 130 | public static final String FINAL = "final"; |
| 131 | public static final String PACKAGE = "package"; | 131 | public static final String PACKAGE = "package"; |
| 132 | - public static final String IMPORT = "import"; | 132 | + public static final String IMPORT = "import "; |
| 133 | public static final String NULL = "null"; | 133 | public static final String NULL = "null"; |
| 134 | public static final String RETURN = "return"; | 134 | public static final String RETURN = "return"; |
| 135 | public static final String NEW = "new"; | 135 | public static final String NEW = "new"; |
| ... | @@ -144,6 +144,7 @@ public final class UtilConstants { | ... | @@ -144,6 +144,7 @@ public final class UtilConstants { |
| 144 | /** | 144 | /** |
| 145 | * For collections. | 145 | * For collections. |
| 146 | */ | 146 | */ |
| 147 | + public static final String COLLECTION_IMPORTS = "import java.util."; | ||
| 147 | public static final String ABSTRACT_COLLECTION = "AbstractCollection"; | 148 | public static final String ABSTRACT_COLLECTION = "AbstractCollection"; |
| 148 | 149 | ||
| 149 | public static final String LIST = "List"; | 150 | public static final String LIST = "List"; | ... | ... |
| ... | @@ -62,8 +62,7 @@ public final class FileSystemUtil { | ... | @@ -62,8 +62,7 @@ public final class FileSystemUtil { |
| 62 | public static void createPackage(String pkg, String pkgInfo) throws IOException { | 62 | public static void createPackage(String pkg, String pkgInfo) throws IOException { |
| 63 | if (!doesPackageExist(new File(pkg))) { | 63 | if (!doesPackageExist(new File(pkg))) { |
| 64 | try { | 64 | try { |
| 65 | - File pack = YangIoUtils | 65 | + File pack = YangIoUtils.createDirectories(pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH)); |
| 66 | - .createDirectories(pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH)); | ||
| 67 | YangIoUtils.addPackageInfo(pack, pkgInfo, pkg); | 66 | YangIoUtils.addPackageInfo(pack, pkgInfo, pkg); |
| 68 | } catch (IOException e) { | 67 | } catch (IOException e) { |
| 69 | throw new IOException("failed to create package-info file"); | 68 | throw new IOException("failed to create package-info file"); | ... | ... |
| ... | @@ -226,8 +226,8 @@ public final class JavaDocGen { | ... | @@ -226,8 +226,8 @@ public final class JavaDocGen { |
| 226 | */ | 226 | */ |
| 227 | private static String generateForConstructors(String className) { | 227 | private static String generateForConstructors(String className) { |
| 228 | return (UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.FOUR_SPACE_INDENTATION | 228 | return (UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.FOUR_SPACE_INDENTATION |
| 229 | - + UtilConstants.JAVA_DOC_SETTERS + className + UtilConstants.PERIOD + UtilConstants.NEW_LINE | 229 | + + UtilConstants.JAVA_DOC_CONSTRUCTOR + className + UtilConstants.IMPL + UtilConstants.PERIOD |
| 230 | - + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.NEW_LINE_ESTRIC | 230 | + + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.NEW_LINE_ESTRIC |
| 231 | + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_PARAM | 231 | + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_PARAM |
| 232 | + (className.substring(0, 1).toLowerCase() + className.substring(1)) + UtilConstants.OBJECT | 232 | + (className.substring(0, 1).toLowerCase() + className.substring(1)) + UtilConstants.OBJECT |
| 233 | + UtilConstants.SPACE + UtilConstants.BUILDER_OBJECT + UtilConstants.SPACE + className | 233 | + UtilConstants.SPACE + UtilConstants.BUILDER_OBJECT + UtilConstants.SPACE + className | ... | ... |
| ... | @@ -27,6 +27,7 @@ import java.io.ObjectInputStream; | ... | @@ -27,6 +27,7 @@ import java.io.ObjectInputStream; |
| 27 | import java.io.ObjectOutput; | 27 | import java.io.ObjectOutput; |
| 28 | import java.io.ObjectOutputStream; | 28 | import java.io.ObjectOutputStream; |
| 29 | import java.io.OutputStream; | 29 | import java.io.OutputStream; |
| 30 | +import java.util.ArrayList; | ||
| 30 | import java.util.List; | 31 | import java.util.List; |
| 31 | 32 | ||
| 32 | /** | 33 | /** |
| ... | @@ -165,7 +166,6 @@ public final class SerializedDataStore { | ... | @@ -165,7 +166,6 @@ public final class SerializedDataStore { |
| 165 | * @throws IOException when fails to read from the file. | 166 | * @throws IOException when fails to read from the file. |
| 166 | * @throws ClassNotFoundException when file is missing. | 167 | * @throws ClassNotFoundException when file is missing. |
| 167 | */ | 168 | */ |
| 168 | - @SuppressWarnings("unchecked") | ||
| 169 | public static List<String> getSerializeData(SerializedDataStoreType type) | 169 | public static List<String> getSerializeData(SerializedDataStoreType type) |
| 170 | throws IOException, ClassNotFoundException { | 170 | throws IOException, ClassNotFoundException { |
| 171 | 171 | ||
| ... | @@ -191,10 +191,13 @@ public final class SerializedDataStore { | ... | @@ -191,10 +191,13 @@ public final class SerializedDataStore { |
| 191 | InputStream buffer = new BufferedInputStream(file); | 191 | InputStream buffer = new BufferedInputStream(file); |
| 192 | ObjectInput input = new ObjectInputStream(buffer); | 192 | ObjectInput input = new ObjectInputStream(buffer); |
| 193 | try { | 193 | try { |
| 194 | - List<String> recoveredData = (List<String>) input.readObject(); | 194 | + String data = (String) input.readObject(); |
| 195 | + List<String> recoveredData = new ArrayList<>(); | ||
| 196 | + recoveredData.add(data); | ||
| 195 | return recoveredData; | 197 | return recoveredData; |
| 196 | } finally { | 198 | } finally { |
| 197 | input.close(); | 199 | input.close(); |
| 200 | + file.close(); | ||
| 198 | } | 201 | } |
| 199 | } catch (ClassNotFoundException ex) { | 202 | } catch (ClassNotFoundException ex) { |
| 200 | throw new ClassNotFoundException("failed to fetch the serialized data file."); | 203 | throw new ClassNotFoundException("failed to fetch the serialized data file."); | ... | ... |
| ... | @@ -27,6 +27,7 @@ import org.apache.maven.project.MavenProject; | ... | @@ -27,6 +27,7 @@ import org.apache.maven.project.MavenProject; |
| 27 | import org.apache.maven.model.Resource; | 27 | import org.apache.maven.model.Resource; |
| 28 | 28 | ||
| 29 | import org.onosproject.yangutils.utils.UtilConstants; | 29 | import org.onosproject.yangutils.utils.UtilConstants; |
| 30 | +import org.apache.commons.io.FileUtils; | ||
| 30 | 31 | ||
| 31 | import static org.slf4j.LoggerFactory.getLogger; | 32 | import static org.slf4j.LoggerFactory.getLogger; |
| 32 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
| ... | @@ -102,10 +103,10 @@ public final class YangIoUtils { | ... | @@ -102,10 +103,10 @@ public final class YangIoUtils { |
| 102 | File currentFile = new File(file); | 103 | File currentFile = new File(file); |
| 103 | currentFile.delete(); | 104 | currentFile.delete(); |
| 104 | } | 105 | } |
| 106 | + FileUtils.deleteDirectory(generatedDirectory); | ||
| 105 | } catch (IOException e) { | 107 | } catch (IOException e) { |
| 106 | log.info("Failed to delete the generated files in " + generatedDirectory + " directory"); | 108 | log.info("Failed to delete the generated files in " + generatedDirectory + " directory"); |
| 107 | } | 109 | } |
| 108 | - generatedDirectory.delete(); | ||
| 109 | } | 110 | } |
| 110 | } | 111 | } |
| 111 | 112 | ... | ... |
-
Please register or login to post a comment