PATH |
- Inherits from:
- Object
- Package:
- com.webobjects.foundation
NSCoder is an abstract class that declares the API used by concrete subclasses to transfer objects and other data items between memory and some other format. This capability provides the basis for archiving (where objects and data items are stored on disk) and distribution (where objects and data items are copied between different processes or threads).
You should never need to subclass NSCoder. Rather, WebObjects provides private concrete subclasses that it uses by default. However, you might interact with a coder object if you create a class that implements the NSCoding interface.
NSCoder operates on scalars (booleans, bytes, and integers, for example), and any other types of object. A coder object stores object type information along with an object's data, so an object decoded from a stream of bytes is normally of the same class as the object that was originally encoded into the stream.
To encode or decode an object or data item, you must first create a coder object, then send it a message defined by NSCoder or by a concrete subclass to actually encode or decode the item. NSCoder itself defines no particular method for creating a coder; this typically varies with the subclass.
To encode an object or data item, use any of the encode... methods. To decode an object or data item, simply use the decode... method corresponding to the original encode... method. Matching these is important, as the method originally used determines the format of the encoded data.
NSCoder's interface is quite general. Concrete subclasses aren't required to properly implement all of NSCoder's methods, and may explicitly restrict themselves to certain types of operations.
Objects frequently contain references to other objects, which may in turn contain references to other objects. When analyzed, a group of objects may contain circular references or one object may be referred to by several other objects. In these cases, the objects form an object graph and require special handling to preserve the graph structure. NSCoder's encodeObject method preserves the graph structure.
- Encoding data
- encodeBoolean
- encodeByte
- encodeBytes
- encodeChar
- encodeClass
- encodeDouble
- encodeFloat
- encodeInt
- encodeLong
- encodeObject
- encodeObjects
- encodeShort
- Decoding data
- decodeBoolean
- decodeByte
- decodeBytes
- decodeChar
- decodeClass
- decodeDouble
- decodeFloat
- decodeInt
- decodeLong
- decodeObject
- decodeObjects
- decodeShort
- All methods
- finishCoding
- prepareForReading
- prepareForWriting
public NSCoder()
public abstract boolean decodeBoolean()
public abstract byte decodeByte()
public abstract byte[] decodeBytes()
public abstract char decodeChar()
public abstract Class decodeClass()
public abstract double decodeDouble()
public abstract float decodeFloat()
public abstract int decodeInt()
public abstract long decodeLong()
public abstract Object decodeObject()
public abstract Object[] decodeObjects()
public abstract short decodeShort()
public abstract void encodeBoolean(boolean aBoolean)
public abstract void encodeByte(byte aByte)
public abstract void encodeBytes(byte[] bytes[])
public abstract void encodeChar(char aChar)
public abstract void encodeClass(Class aClass)
public abstract void encodeDouble(double aDouble)
public abstract void encodeFloat(float aFloat)
public abstract void encodeInt(int anInt)
public abstract void encodeLong(long aLong)
public abstract void encodeObject(Object anObject)
public abstract void encodeObjects(Object[] anObject[])
public abstract void encodeShort(short aShort)
public void finishCoding()
public void prepareForReading(java.io.InputStream inputStream)
public void prepareForWriting(java.io.OutputStream outputStream)
© 2001 Apple Computer, Inc. (Last Published April 17, 2001)