Class Unarchiver
All Packages Class Hierarchy This Package Previous Next Index
Class Unarchiver
public class netscape.util.Unarchiver
extends java.lang.Object
implements netscape.util.Decoder
{
/* Constructors
*/
public Unarchiver(Archive);
/* Methods
*/
public static Object readObject(InputStream);
public Archive archive();
protected Class classForName(String);
public boolean decodeBoolean(String);
public boolean[] decodeBooleanArray(String);
public byte decodeByte(String);
public byte[] decodeByteArray(String);
public char decodeChar(String);
public char[] decodeCharArray(String);
public double decodeDouble(String);
public double[] decodeDoubleArray(String);
public float decodeFloat(String);
public float[] decodeFloatArray(String);
public int decodeInt(String);
public int[] decodeIntArray(String);
public long decodeLong(String);
public long[] decodeLongArray(String);
public Object decodeObject(String);
public Object[] decodeObjectArray(String);
public short decodeShort(String);
public short[] decodeShortArray(String);
public String decodeString(String);
public String[] decodeStringArray(String);
public void replaceObject(Object);
public Object unarchiveIdentifier(int);
public int versionForClassName(String);
}
Object subclass implementing the Decoder interface to decode a graph of
objects from an Archive. The following example demonstrates how to use
an Unarchiver to retrieve the first root object from an Archive read from
System.in:
archive = new Archive();
archive.readASCII(System.in)
rootIdentifiers = archive.rootIdentifiers();
unarchiver = new Unarchiver(archive);
rootObject = unarchiver.unarchiveIdentifier(rootIdentifiers[0]);
- See Also:
- Decoder, Archive, Archiver
Constructors
Unarchiver
public Unarchiver(Archive archive)
- Primitive constructor creating an Unarchiver that retrieves objects
from archive. Do not mutate the Archive while using the
Unarchiver.
Methods
archive
public Archive archive()
- Returns the archive from which the Unarchiver decodes objects.
readObject
public static Object readObject(InputStream inputStream) throws IOException, CodingException
- A convenience method for reading an object from a stream.
Equivilent to the code:
archive = new Archive();
archive.read(in);
unarchiver = new Unarchiver(archive);
rootIds = archive.rootIdentifiers();
if (rootIds == null || rootIds.length == 0)
return null;
return unarchiver.unarchiveIdentifier(rootIds[0]);
unarchiveIdentifier
public Object unarchiveIdentifier(int identifier) throws CodingException
- Unarchives a graph of objects starting from the object identified by
identifier in an archive. That object, and all objects it
references, will be reconstructed by calling their empty constructor
followed by decode().
- See Also:
- rootIdentifiers, Codable, Decoder
classForName
protected Class classForName(String className) throws CodingException
- Called to look up a class from the Archive by name.
versionForClassName
public int versionForClassName(String className) throws CodingException
- Decoder interface method that returns the version information for the
class named className. Objects can use this information to
bring forward old encodings at runtime.
decodeBoolean
public boolean decodeBoolean(String key) throws CodingException
- Decoder interface method that decodes the boolean value associated
with the string key.
decodeBooleanArray
public boolean[] decodeBooleanArray(String key) throws CodingException
- Decoder interface method that decodes the boolean array associated
with the string key.
decodeChar
public char decodeChar(String key) throws CodingException
- Decoder interface method that decodes the character value associated
with the string key.
decodeCharArray
public char[] decodeCharArray(String key) throws CodingException
- Decoder interface method that decodes the character array associated
with the string key.
decodeByte
public byte decodeByte(String key) throws CodingException
- Decoder interface method that decodes the byte value associated with
the string key.
decodeByteArray
public byte[] decodeByteArray(String key) throws CodingException
- Decoder interface method that decodes the byte array associated with
the string key.
decodeShort
public short decodeShort(String key) throws CodingException
- Decoder interface method that decodes the short value associated with
the string key.
decodeShortArray
public short[] decodeShortArray(String key) throws CodingException
- Decoder interface method that decodes the short array associated with
the string key.
decodeInt
public int decodeInt(String key) throws CodingException
- Decoder interface method that decodes the integer value associated
with the string key.
decodeIntArray
public int[] decodeIntArray(String key) throws CodingException
- Decoder interface method that decodes the integer array associated
with the string key.
decodeLong
public long decodeLong(String key) throws CodingException
- Decoder interface method that decodes the long value associated with
the string key.
decodeLongArray
public long[] decodeLongArray(String key) throws CodingException
- Decoder interface method that decodes the long array value associated
with the string key.
decodeFloat
public float decodeFloat(String key) throws CodingException
- Decoder interface method that decodes the float value associated with
the string key.
decodeFloatArray
public float[] decodeFloatArray(String key) throws CodingException
- Decoder interface method that decodes the float array associated with
the string key.
decodeDouble
public double decodeDouble(String key) throws CodingException
- Decoder interface method that decodes the double value associated with
the string key.
decodeDoubleArray
public double[] decodeDoubleArray(String key) throws CodingException
- Decoder interface method that decodes the double array associated with
the string key.
decodeString
public String decodeString(String key) throws CodingException
- Decoder interface method that decodes the string value associated with
the string key.
decodeStringArray
public String[] decodeStringArray(String key) throws CodingException
- Decoder interface method that decodes the string array associated with
the string key.
decodeObject
public Object decodeObject(String key) throws CodingException
- Decoder interface method that decodes a reference to another Codable
object.
decodeObjectArray
public Object[] decodeObjectArray(String key) throws CodingException
- Decoder interface method that decodes an array of Codable objects. The
references to the Codable objects are shared, but the reference to the
array is not.
replaceObject
public void replaceObject(Object replacement) throws CodingException
- Decoder interface method that replaces references to the object
currently being decoded with replacement. This method throws a
CodingException when an attempt is made to replace an object which has
already been seen by other objects. For maximum safety, this method
should only be called from leaves of the object graph.
All Packages Class Hierarchy This Package Previous Next Index