Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

12.1. Archiving

What you think of as serialization in Java is called archiving in Objective-C; a graph of objects is encoded into a non-human-readable stream of binary data. This architecture-independent data can later be decoded to instantiate an equivalent graph of objects. What Objective-C calls serialization is slightly different and is described later in this chapter.

In Java, the classes largely responsible for serializing objects are java.io.ObjectOutputStream and java.io.ObjectInputStream. These take object references and primitive values and "flatten" them into a serial java.io.OutputStream, or read serialized data from a java.io.InputStream and turn it back into objects. For an object to be included in the stream, it must implement the java.io.Serializable interface. The Java runtime uses introspection to automatically encode the object's instance variables. You can influence this using Java's transient keyword or by customizing the serialization process.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint