Friday, September 5, 2014

New and Updated JSRs in JEE 7

Java EE 7 contains 14 new and updated JSRs. Java specifications are available at
  • JSR236:ConcurrencyUtilitiesforJavaEE1.0
  • JSR 338: Java Persistence API 2.1
  • JSR339:JavaAPIforRESTfulWebServices2.0
  • JSR 340: Java Servlet 3.1
  • JSR 341: Expression Language 3.0
  • JSR342:JavaPlatform,EnterpriseEdition7
  • JSR 343: Java Message Service 2.0
  • JSR 344: JavaServer Faces 2.2
  • JSR 345: Enterprise JavaBeans 3.2
  • JSR346:ContextsandDependencyInjectionforJavaEE1.1
  • JSR 349: Bean Validation 1.1
  • JSR352:BatchApplicationsfortheJavaPlatform1.0
  • JSR353:JavaAPIforJSONProcessing1.0
  • JSR356:JavaAPIforWebSocket1.0 

Thursday, March 27, 2014

Regular Expressions Reference Card

Title Reference Explanation Example Matches
Letters Inside Square Brackets [Ww] W or w [Ww]oodwork Woodwork, woodwork

[1234567890] Any digit

Letters outside square brackets ame Matches exact sequence ame -> amersohail794 matches ame

Ranges [0-9] 0 to 9 [0-2] -> amersohail794 matches 794

[a-z] all characters from a to z [a-z] -> amersohail794 matches amersohail

[A-Z] all characters from A to A [a-z] -> amersohail794 matches nothing

[ ] matches space [] -> amer sohail matches space only

Not [^a-z] Not characters from a-z [^a-z] matches 794

[^a-aA-Z] Not characters from a-z and from A-Z [^a-zA-Z] -> amersohail794 matches 794

Beginning of line ^ carret outside the square bracket shows that following character should be matched beginning of the line ^o -> oooohhhh OOOOhhh oooOOOOHHHH will match to first character only and that is "o"

End of line $ $ will match end of the line

Pipe Symbol | for or. A|a is same as [aA] W|w matches W or w

Special Characters *  0 or more occurences of previous character o*O*h*  matches oohhh, ooooooooohhhhh,OOOOOhhhhhh,oooOOOOOhhhhh

+ 1 or more occurences of previous character

? 0 or 1 occurrence of previous character

. Any character

\ is used as escape character [\.] -> This is sample sentence. will match the . In the line

Tuesday, January 28, 2014

Java Programming Terms

 Functional Interface

Its new term in JavaSE 8 for interfaces having just one method e.g. Runnable, ActionListener, Comparator, all are the examples of functional interfaces. Previous name was Single Abstract Method Type (SAM).

Anonymous Inner Classes

Its on the spot implementation of interface without explicitly requiring a name. Usually implementation of interfaces is done by classes and each class does have name but anonymous inner class does not have any name

Lambda Expressions

Short hand or concise notation for implementing functional interfaces than anonymous inner classes.

Immutable and Mutable Objects

Immutable objects are those objects which can not be changed after its creation. String is most famous example of immutable object. There are many pros of immutable objects like they can not be corrupted by multiple threads in concurrent application, least overhead for GC

Guarded Blocks

Its a code block waiting for a certain condition to be true for its execution. It happens in multi threading programs when different threads do different task and they coordinate each other by setting certain conditions / variables.

Generic Type

Generic Type is a generic class or interface that is parametrized over types.

Generic Type Declaration

 Definition of a class with type variables is know as Generic Type Declaration. This type variable can be used anywhere within a class.

The Diamond

In Java SE 7, we can replace the type arguments required to invoke a generic class, with empty set of type arguments (<>) as long as the compiler can determine or infer the type arguments from the content. This pair of angle brackets is known as "the diamond".

Box integerBox = new Box<>();
Raw Type
A Generic Class or interface without type arguments is known as raw type. e.g. List is a generic type but simple List is a raw type. We can assign generic types to raw types but assignment of raw type to generic type will give warnings and will be checked at runtime.