Posts

Showing posts from July, 2012

An introduction to XML

What is XML? XML, or eXtensible Markup Language was created by the World Wide Web Consortium (W3C) to overcome the limitations of HTML. While the HTML tags tell a browser how to display this information, the tags don't tell the browser what the information is . With XML, you can assign some meaning to the tags in the document, which can be processed by the machine. A simple XML File <? xml version = "1.0" encoding = "UTF-8" ?> <blog> <post id = "1" value = "post1" > <title> Serialization in Java </title> <author> Dev </author> <date> 05/06/2012 </date> <url> http://techiesinsight.blogspot.in/2012/06/serialization-in-java.html </url> </post> <post  id = "2" value = "post2" > <title> serialVersionUId in Java Object Serialization </title> <author> Dev </aut

Annotations in Java

Annotations are the tags that can be inserted into a Java programs so that they can be processed by the tools. In the Java programming language, an annotation is used like a modifier, and it is placed before the annotated item, without a semicolon. The name of each annotation is preceded by an @ symbol.  For Example: @Override   public boolean equals(Object obj){  ...  }  Annotation Syntax An annotation is defined by an annotation interface:  public  @interface AnnotationName {   //element declarations    type elementName () ;    type   elementName () default value ;   . . .  }  One of the following   type can be used for annotation fields: All primitives (boolean, char, short, int, long, double) String Class Enum Array of any of above types Meta-Annotations Meta annotations are annotations that are used to annotate annotations. There are four meta-annotation types that come standard with Java 5:  @Documented:   is a mar

Serializable vs Externizable

Serialization vs Externalization Serializable Externizable Serializable is a marker interface (an interface with no methods) Unlike Serializable, Externizable is a standard interface with two methods defined to be implemented by the implementing class. Serailization is a recursive process, all non-transient variables and super classes in the object hierarchy will be serialized causing an unnecessary overhead User defines what should be serialized and what should not. Hence it is more optimized. Should be preferred for "Fat Objects"  Serialization uses reflection mechanism for marshalling and un marshalling the objects.  Marshalling/Unmarshalling process is user defined. During de-serialization no constructor is called, hence initialization done in constructor will be skipped.  During de-serialization default constructor is invoked A default construtor definition