In this post I will explain how to parse a YAML file using Jackson framework. We need the following jars in our classpath 1) jackson-dataformat-yaml-2.9.6.jar 2) snakeyaml-1.18.jar 3) jackson-annotations-2.9.0.jar 4) jackson-core-2.9.6.jar 5) jackson-databind-2.9.6.jar First we need to create an instance of YAMLFactory class. It is factory class used to create instance of YAMLParser (reader) and…… Continue reading Parsing a YAML file
Selecting particular element using ID selector
In this post of JQuery, I will introduce you to id selector. The syntax of id selector is particular element’ attribute id value prepended by ‘#’ symbol, for eg #button. It is used to select one particular element whose id matches the id given in the $ method. Below is an example 1 <html> 2…… Continue reading Selecting particular element using ID selector
Universal Selector *
In this post of JQuery, I will introduce you to universal selector, represented by * symbol. It is used to select all the elements in the html page. Below is an example 1 <html> 2 <head> 3 https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js 4 </head> 5 <body> 6 7 function selectAll() { 8 var $all = $(‘*’); 9 alert($all); 10…… Continue reading Universal Selector *
Writting to multiple files using MultiResourceItemWriter
In this post of Spring Batch, I will explain how to write the records read, to multiple files instead of one. We take the help of MultiResourceItemWriter, it writes to multiple file and suffixes the output fileNames with an index. For example if the file name to be created, is DemoData.txt and two files are…… Continue reading Writting to multiple files using MultiResourceItemWriter
Filtering items using ItemProcessor
In Spring Batch, items are read from the source using reader and written to destination using a writer. Sometimes, we need to add business logic between the reader and writer for the following purpose1) Filtering an item2) Converting an item read from one format to another before written to the destination3) Modify the item read…… Continue reading Filtering items using ItemProcessor
Sorting a section of an array
In this post I will explain how to sort a section of an array. The java Arrays class provides a static method named “sort” which takes the below three arguments 1) the array 2) fromIndex 3) toIndex This method sorts a section of the array. The section to be sorted is indicated by fromIndex (position…… Continue reading Sorting a section of an array
Combining two or more Consumer Functional Interface
In this post I will explain how to combine two or more Consumer Functional interface implementations. Consumer Functional interface has a default method “andThen”, which combines two Consumer Functional interface implementations. The method signature is as shown below default Consumer andThen(Consumer after) The way two Consumer implementations are combined using “andThen” method is as shown…… Continue reading Combining two or more Consumer Functional Interface
Map with Composite key
In Maps we always use one key object to uniquely identify an entry. We never combined a collection of keys to create one composite key and use it to uniquely identify an entry. But with help of MultiKey class available in Apache Common Collections framework, we can create a composite key to uniquely identify an…… Continue reading Map with Composite key
Parsing xml document with SAX API
In this post I will explain how to parse an xml document in java using the SAX API. SAX api is event based java api. The SAX compliant parser which reads the xml document sequentially, generates events whenever the parser encounters an xml element. The parser reads the document sequentially and doesn’t load the entire…… Continue reading Parsing xml document with SAX API
Verifying the exact number of method invocations
This post explains how to verify that a method is executed desired number of times using Mockito framework. Below is the code of the class to be tested. Class1 code package package14; import java.util.List; public class Class1 { private List list; public void method1() { for(int i = 0; i < 10 ;i++) { list.add(i);…… Continue reading Verifying the exact number of method invocations