WebObjects 5.2

com.webobjects.eocontrol
Class EOKeyValueArchiver

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

public class EOKeyValueArchiver
extends Object

EOKeyValueArchiver objects are used to archive a graph of objects into a "property list" with a key-value mechanism. To (re)create the object graph, EOKeyValueUnarchiver objects are used. 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:
EOKeyValueUnarchiver, EOKeyValueArchiving

Inner Class Summary
static interface EOKeyValueArchiver.Delegate
          The EOKeyValueArchiver.Delegate interface defines methods which can be used by a delegate object of an EOKeyValueArchiver to control the behavior of the archiver object.
 
Constructor Summary
EOKeyValueArchiver()
          Creates a new EOKeyValueArchiver.
 
Method Summary
 Object delegate()
          Returns the receiver's delegate.
 NSDictionary dictionary()
          Returns the property list which represents the object archive.
 void encodeBool(boolean value, String key)
          Archives the boolean value under the key key.
 void encodeInt(int value, String key)
          Archives the integer value under the key key.
 void encodeObject(Object object, String key)
          Archives the object object in place under the key key.
 void encodeReferenceToObject(Object object, String key)
          Archives the object object with a special reference (placeholder) under the key key.
 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

EOKeyValueArchiver

public EOKeyValueArchiver()
Creates a new EOKeyValueArchiver.
Method Detail

delegate

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

dictionary

public NSDictionary dictionary()
Returns the property list which represents the object archive.
Returns:
the object archive (property list)

encodeBool

public void encodeBool(boolean value,
                       String key)
Archives the boolean value under the key key.
Parameters:
value - the boolean to be archived
key - the key under which it is stored
See Also:
EOKeyValueArchiving

encodeInt

public void encodeInt(int value,
                      String key)
Archives the integer value under the key key.
Parameters:
value - the integer to be archived
key - the key under which it is stored
See Also:
EOKeyValueArchiving

encodeObject

public void encodeObject(Object object,
                         String key)
Archives the object object in place under the key key. The object either needs to be an instance of the NSArray or NSDictionary class, implement the EOKeyValueArchiving interface, or have a Support object registered with EOKeyValueArchiving. For objects that implement EOKeyValueArchiving, this method calls object with encodeWithKeyValueArchiver.
Parameters:
object - the object to be archived
key - the key under which it is stored
See Also:
EOKeyValueArchiving, EOKeyValueArchiving.Support

encodeReferenceToObject

public void encodeReferenceToObject(Object object,
                                    String key)
Archives the object object with a special reference (placeholder) under the key key. The reference object is determined by asking the receiver's delegate with the referenceToEncodeForObject method.
Parameters:
object - the object to be archived as a reference
key - the key under which it is stored
See Also:
EOKeyValueArchiver.Delegate, EOKeyValueArchiving

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.