WebObjects 5.2

com.webobjects.eocontrol
Class EOKeyValueUnarchiver

java.lang.Object
  |
  +--com.webobjects.eocontrol.EOKeyValueUnarchiver

public class EOKeyValueUnarchiver
extends Object

EOKeyValueUnarchiver objects are used to re(create) an object graph which was archived into a "property list" with a EOKeyValueArchiver. A typical way to use EOKeyValueArchiver/EOKeyValueUnarchiver is:

  Object objectToArchive = ...;
  EOKeyValueArchiver archiver = new EOKeyValueArchiver();
  archiver.setDelegate(...);
  archiver.encodeObject(objectToArchive, "ArchiveName");
  NSDictionary archive = archiver.dictionary();
 

Afterwards, to recreate the object graph:

  NSDictionary archive = ...;   // for example a dictionary loaded from a file
  EOKeyValueUnarchiver unarchiver = new EOKeyValueUnarchiver(archive);
  unarchiver.setDelegate(...);
  Object archivedObject = unarchiver.decodeObjectForKey("ArchiveName");
  unarchiver.finishInitializationOfObjects();
  unarchiver.awakeObjects();
 

See Also:
EOKeyValueArchiver, EOKeyValueArchiving

Inner Class Summary
static interface EOKeyValueUnarchiver.Delegate
          The EOKeyValueUnarchiver.Delegate interface defines methods which can be used by a delegate object of an EOKeyValueUnarchiver to control the behavior of the unarchiver object.
 
Constructor Summary
EOKeyValueUnarchiver(NSDictionary dictionary)
          Creates a new EOKeyValueUnarchiver to decode the property list dictionary.
 
Method Summary
 void awakeObjects()
          Completes an unarchiving process by sending all unarchived objects which implement the EOKeyValueArchiving.Awaking interface a awakeFromKeyValueUnarchiver method.
 boolean decodeBoolForKey(String key)
          Unarchives a boolean that was archived under the key key.
 int decodeIntForKey(String key)
          Unarchives an integer that was archived under the key key.
 Object decodeObjectForKey(String key)
          Unarchives an object that was archived in place under the key key.
 Object decodeObjectReferenceForKey(String key)
          Unarchives an object that was archived as a reference (placeholder).
 Object delegate()
          Returns the receiver's delegate.
 void ensureObjectAwake(Object object)
          The order that objects an unarchiver sends awakeFromKeyValueUnarchiver to the unarchived objects is not defined.
 void finishInitializationOfObjects()
          Completes an unarchiving process by sending all unarchived objects that implement the EOKeyValueArchiving.FinishInitialization interface a finishInitializationWithKeyValueUnarchiver method.
 Object parent()
          Returns the parent object for the currently unarchived object.
 void setDelegate(Object delegate)
          Sets the receiver's delegate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EOKeyValueUnarchiver

public EOKeyValueUnarchiver(NSDictionary dictionary)
Creates a new EOKeyValueUnarchiver to decode the property list dictionary.
Parameters:
dictionary - the property list to be decoded
Method Detail

awakeObjects

public void awakeObjects()
Completes an unarchiving process by sending all unarchived objects which implement the EOKeyValueArchiving.Awaking interface a awakeFromKeyValueUnarchiver method. This methods needs to be invoked at the end of the unarchiving process, after invoking finishInitializationOfObjects.
See Also:
ensureObjectAwake(Object), finishInitializationOfObjects()

decodeBoolForKey

public boolean decodeBoolForKey(String key)
Unarchives a boolean that was archived under the key key.
Parameters:
key - the key under which the boolean to be unarchived is stored
Returns:
the unarchived boolean

decodeIntForKey

public int decodeIntForKey(String key)
Unarchives an integer that was archived under the key key.
Parameters:
key - the key under which the integer to be unarchived is stored
Returns:
the unarchived integer

decodeObjectForKey

public Object decodeObjectForKey(String key)
Unarchives an object that was archived in place under the key key. The object to unarchive needs to be an instance of the NSArray or NSDictionary class, implement the EOKeyValueArchiving interface, or have a Support object registered with EOKeyValueArchiving.
Parameters:
key - the key under which the object to be unarchived is stored
Returns:
the unarchived object
See Also:
EOKeyValueArchiving, EOKeyValueArchiving.Support

decodeObjectReferenceForKey

public Object decodeObjectReferenceForKey(String key)
Unarchives an object that was archived as a reference (placeholder). The object to be used instead of the placeholder is determined by asking the receiver's delegate with the unarchiverObjectForReference method.
Parameters:
key - the key under which the object to be unarchived is stored

delegate

public Object delegate()
Returns the receiver's delegate.
Returns:
the delegate

ensureObjectAwake

public void ensureObjectAwake(Object object)
The order that objects an unarchiver sends awakeFromKeyValueUnarchiver to the unarchived objects is not defined. However, if in its implementation of awakeFromKeyValueUnarchiver an object depends a related object already being awake, it can call ensureObjectAwake passing the related object.
Parameters:
object - the object which needs to be awaken
See Also:
awakeObjects()

finishInitializationOfObjects

public void finishInitializationOfObjects()
Completes an unarchiving process by sending all unarchived objects that implement the EOKeyValueArchiving.FinishInitialization interface a finishInitializationWithKeyValueUnarchiver method. This methods needs to be invoked at the end of the unarchiving process, but before invoking awakeObjects.
See Also:
awakeObjects()

parent

public Object parent()
Returns the parent object for the currently unarchived object. This method can be called by an object while unarchived to retrieve the parent object that is unarchiving it. For example, if an EOAttribute calls this while an EOModel is loaded from an archive, it will get its EOEntity.

setDelegate

public void setDelegate(Object delegate)
Sets the receiver's delegate.
Parameters:
delegate - the delegate

Last updated Fri Feb 21 13:15:00 PST 2003.

Copyright © 2003 Apple Computer, Inc.