WebObjects 5.4.2

com.webobjects.foundation
Class NSCoding.Support

java.lang.Object
  extended by com.webobjects.foundation.NSCoding.Support
Enclosing interface:
NSCoding

public abstract static class NSCoding.Support
extends Object

NSCoding.Support is an abstract class that defines a mechanism for one class to provide NSCoding behavior on behalf of another class. Subclasses of NSCoding.Support encode and decode objects of a different class. Subclasses of NSCoding.Support are needed to provide coding for classes whose code you don't own and that don't implement NSCoding.

For example, consider Java Client WebObjects applications that use NSCoding to distribute objects between client and server. Not all objects that Java Client distributes implement NSCoding (java.lang.String, for example). To encode and decode non-NSCoding objects, Java Client uses specialized (private) subclasses of NSCoding.Support.

A subclass of NSCoding.Support should implement the methods encodeWithCoder and decodeObject to encode and decode objects of a specific non-NSCoding class. NSCoding.Support's default implementations of these methods do nothing.

NSCoding.Support manages a registry of Support classes for classes that don't implement NSCoding. The methods setSupportForClass and supportForClass are used to register and access the NSCoding.Support classes for performing coding on non-NSCoding objects. There is pre-register list of NSCoding.Support classes for the following types:

See Also:
NSCoding.encodeWithCoder(NSCoder coder), NSCoding.Support.decodeObject(NSCoder aCoder), NSCoding.Support.setSupportForClass(NSCoding.Support supportClass, Class aClass), NSCoding.Support.supportForClass(Class aClass), NSCoding

Constructor Summary
NSCoding.Support()
           
 
Method Summary
 Class classForCoder(Object receiver)
          NSCoding.Support's default implementation simply returns receiver's actual class.
abstract  Object decodeObject(NSCoder coder)
          Implemented by subclasses to decode an object of a specific type from the data in coder.
abstract  void encodeWithCoder(Object receiver, NSCoder coder)
          Implemented by subclasses to encode an object receiver of a specific type using NSCoder coder.
static void setSupportForClass(NSCoding.Support support, Class aClass)
          Sets support as the NSCoding.Support class to use for encoding and decoding instances of aClass.
static NSCoding.Support supportForClass(Class aClass)
          Gets the registered NSCoding.Support class to encode and decode instances of aClass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NSCoding.Support

public NSCoding.Support()
Method Detail

supportForClass

public static NSCoding.Support supportForClass(Class aClass)
Gets the registered NSCoding.Support class to encode and decode instances of aClass.

Parameters:
aClass - class whose instances are to be encoded or decoded
Returns:
the NSCoding.Support class if such a class is registered for aClass or null otherwise

setSupportForClass

public static void setSupportForClass(NSCoding.Support support,
                                      Class aClass)
Sets support as the NSCoding.Support class to use for encoding and decoding instances of aClass.

Parameters:
support - the NSCoding.Support class to be registered for aClass
aClass - class whose instances are to be encoded or decoded

classForCoder

public Class classForCoder(Object receiver)
NSCoding.Support's default implementation simply returns receiver's actual class.

Parameters:
receiver - the object being encoded
Returns:
the class a coder should record as the class for receiver when receiver is encoded.
See Also:
NSCoding.classForCoder()

encodeWithCoder

public abstract void encodeWithCoder(Object receiver,
                                     NSCoder coder)
Implemented by subclasses to encode an object receiver of a specific type using NSCoder coder.

Parameters:
receiver - the object being encoded
coder - an NSCoder object that will be used to encode receiver
See Also:
NSCoding.encodeWithCoder(NSCoder coder)

decodeObject

public abstract Object decodeObject(NSCoder coder)
Implemented by subclasses to decode an object of a specific type from the data in coder.

Parameters:
coder - an NSCoder object that will be used to decode an object out of its data
Returns:
the decoded object
See Also:
NSCoding

Last updated June 2008

Copyright © 2000-2008 Apple Inc.