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
JCache EntryProcessor Example
This post introduces you to JCache EntryProcessor interface. This interface is used to create concrete classes, whose purpose is to modify a cache entry. This is useful when multiple thread are accessing the cache and trying to modify a cache entry at the same time. To avoid threading issues like race condition etc, the thread…… Continue reading JCache EntryProcessor Example
Sorting arrays using Comparator
This post explains how to sort arrays using comparator with an example. The java jdk provides Arrays class, which has a static method named “sort”. This method takes two arguments 1) the array to be sorted 2) Comparator which contains the logic to sort the array Below is the example which sort cards based on…… Continue reading Sorting arrays using Comparator