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
<?xmlversion="1.0"encoding="UTF-8"?> <blog> <postid="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</author> <date>07/06/2012</date> <url>http://techiesinsight.blogspot.in/2012/06…

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 SyntaxAn annotation is defined by an annotation interface: 

public @interfaceAnnotationName
 //element declarations 
typeelementName(); 
typeelementName()defaultvalue; 
 . . . 
}  One of the followingtypecan be used for annotation fields:
All primitives (boolean, char, short, int, long, double)StringClassEnumArray of any of above typesMeta-AnnotationsMeta annotations are annotations that are used to annotate annotations. There are four meta-annotation types that come standard with Java 5:  @Documented:is a marker annotation. Annotation declaration (of the @documented annotation type) will be included in the documentati…

Serializable vs Externizable

Serialization vs Externalization

SerializableExternizableSerializable 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 overheadUser 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 invokedA default construtor definition is not mandatory when parameterized constructor(s) are definedAn explicit default constructor definition is mandatory, w…