Java Doc for ObjectInputStream.java in  » Science » Cougaar12_4 » java » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Cougaar12_4 » java.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.io.InputStream
      java.io.ObjectInputStream

All known Subclasses:   org.cougaar.core.persist.PersistenceInputStream,
ObjectInputStream
public class ObjectInputStream extends InputStream implements ObjectInput,ObjectStreamConstants(Code)
An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream.

ObjectOutputStream and ObjectInputStream can provide an application with persistent storage for graphs of objects when used with a FileOutputStream and FileInputStream respectively. ObjectInputStream is used to recover those objects previously serialized. Other uses include passing objects between hosts using a socket stream or for marshaling and unmarshaling arguments and parameters in a remote communication system.

ObjectInputStream ensures that the types of all objects in the graph created from the stream match the classes present in the Java Virtual Machine. Classes are loaded as required using the standard mechanisms.

Only objects that support the java.io.Serializable or java.io.Externalizable interface can be read from streams.

The method readObject is used to read an object from the stream. Java's safe casting should be used to get the desired type. In Java, strings and arrays are objects and are treated as objects during serialization. When read they need to be cast to the expected type.

Primitive data types can be read from the stream using the appropriate method on DataInput.

The default deserialization mechanism for objects restores the contents of each field to the value and type it had when it was written. Fields declared as transient or static are ignored by the deserialization process. References to other objects cause those objects to be read from the stream as necessary. Graphs of objects are restored correctly using a reference sharing mechanism. New objects are always allocated when deserializing, which prevents existing objects from being overwritten.

Reading an object is analogous to running the constructors of a new object. Memory is allocated for the object and initialized to zero (NULL). No-arg constructors are invoked for the non-serializable classes and then the fields of the serializable classes are restored from the stream starting with the serializable class closest to java.lang.object and finishing with the object's most specific class.

For example to read from a stream as written by the example in ObjectOutputStream:

 FileInputStream fis = new FileInputStream("t.tmp");
 ObjectInputStream ois = new ObjectInputStream(fis);
 int i = ois.readInt();
 String today = (String) ois.readObject();
 Date date = (Date) ois.readObject();
 ois.close();
 

Classes control how they are serialized by implementing either the java.io.Serializable or java.io.Externalizable interfaces.

Implementing the Serializable interface allows object serialization to save and restore the entire state of the object and it allows classes to evolve between the time the stream is written and the time it is read. It automatically traverses references between objects, saving and restoring entire graphs.

Serializable classes that require special handling during the serialization and deserialization process should implement the following methods:

 private void writeObject(java.io.ObjectOutputStream stream)
 throws IOException;
 private void readObject(java.io.ObjectInputStream stream)
 throws IOException, ClassNotFoundException; 
 private void readObjectNoData() 
 throws ObjectStreamException;
 

The readObject method is responsible for reading and restoring the state of the object for its particular class using data written to the stream by the corresponding writeObject method. The method does not need to concern itself with the state belonging to its superclasses or subclasses. State is restored by reading data from the ObjectInputStream for the individual fields and making assignments to the appropriate fields of the object. Reading primitive data types is supported by DataInput.

Any attempt to read object data which exceeds the boundaries of the custom data written by the corresponding writeObject method will cause an OptionalDataException to be thrown with an eof field value of true. Non-object reads which exceed the end of the allotted data will reflect the end of data in the same way that they would indicate the end of the stream: bytewise reads will return -1 as the byte read or number of bytes read, and primitive reads will throw EOFExceptions. If there is no corresponding writeObject method, then the end of default serialized data marks the end of the allotted data.

Primitive and object read calls issued from within a readExternal method behave in the same manner--if the stream is already positioned at the end of data written by the corresponding writeExternal method, object reads will throw OptionalDataExceptions with eof set to true, bytewise reads will return -1, and primitive reads will throw EOFExceptions. Note that this behavior does not hold for streams written with the old ObjectStreamConstants.PROTOCOL_VERSION_1 protocol, in which the end of data written by writeExternal methods is not demarcated, and hence cannot be detected.

The readObjectNoData method is responsible for initializing the state of the object for its particular class in the event that the serialization stream does not list the given class as a superclass of the object being deserialized. This may occur in cases where the receiving party uses a different version of the deserialized instance's class than the sending party, and the receiver's version extends classes that are not extended by the sender's version. This may also occur if the serialization stream has been tampered; hence, readObjectNoData is useful for initializing deserialized objects properly despite a "hostile" or incomplete source stream.

Serialization does not read or assign values to the fields of any object that does not implement the java.io.Serializable interface. Subclasses of Objects that are not serializable can be serializable. In this case the non-serializable class must have a no-arg constructor to allow its fields to be initialized. In this case it is the responsibility of the subclass to save and restore the state of the non-serializable class. It is frequently the case that the fields of that class are accessible (public, package, or protected) or that there are get and set methods that can be used to restore the state.

Any exception that occurs while deserializing an object will be caught by the ObjectInputStream and abort the reading process.

Implementing the Externalizable interface allows the object to assume complete control over the contents and format of the object's serialized form. The methods of the Externalizable interface, writeExternal and readExternal, are called to save and restore the objects state. When implemented by a class they can write and read their own state using all of the methods of ObjectOutput and ObjectInput. It is the responsibility of the objects to handle any versioning that occurs.

Enum constants are deserialized differently than ordinary serializable or externalizable objects. The serialized form of an enum constant consists solely of its name; field values of the constant are not transmitted. To deserialize an enum constant, ObjectInputStream reads the constant name from the stream; the deserialized constant is then obtained by calling the static method Enum.valueOf(Class, String) with the enum constant's base type and the received constant name as arguments. Like other serializable or externalizable objects, enum constants can function as the targets of back references appearing subsequently in the serialization stream. The process by which enum constants are deserialized cannot be customized: any class-specific readObject, readObjectNoData, and readResolve methods defined by enum types are ignored during deserialization. Similarly, any serialPersistentFields or serialVersionUID field declarations are also ignored--all enum types have a fixed serialVersionUID of 0L.
author:
   Mike Warres
author:
   Roger Riggs
version:
   1.155, 04/05/28
See Also:   java.io.DataInput
See Also:   java.io.ObjectOutputStream
See Also:   java.io.Serializable
See Also:    Object Serialization Specification, Section 3, Object Input Classes
since:
   JDK1.1


Inner Class :abstract public static class GetField


Constructor Summary
public  ObjectInputStream(InputStream in)
     Creates an ObjectInputStream that reads from the specified InputStream.
protected  ObjectInputStream()
     Provide a way for subclasses that are completely reimplementing ObjectInputStream to not have to allocate private data just used by this implementation of ObjectInputStream.

Method Summary
public  intavailable()
     Returns the number of bytes that can be read without blocking.
public  voidclose()
     Closes the input stream.
public  voiddefaultReadObject()
     Read the non-static and non-transient fields of the current class from this stream.
protected  booleanenableResolveObject(boolean enable)
     Enable the stream to allow objects read from the stream to be replaced.
protected  ObjectnewInstanceFromDesc(ObjectStreamClass desc)
    
public  intread()
     Reads a byte of data.
public  intread(byte[] buf, int off, int len)
     Reads into an array of bytes.
public  booleanreadBoolean()
     Reads in a boolean.
public  bytereadByte()
     Reads an 8 bit byte.
public  charreadChar()
     Reads a 16 bit char. the 16 bit char read.
protected  ObjectStreamClassreadClassDescriptor()
     Read a class descriptor from the serialization stream.
public  doublereadDouble()
     Reads a 64 bit double.
public  ObjectInputStream.GetFieldreadFields()
     Reads the persistent fields from the stream and makes them available by name.
public  floatreadFloat()
     Reads a 32 bit float.
public  voidreadFully(byte[] buf)
     Reads bytes, blocking until all bytes are read.
public  voidreadFully(byte[] buf, int off, int len)
     Reads bytes, blocking until all bytes are read.
public  intreadInt()
     Reads a 32 bit int.
public  StringreadLine()
     Reads in a line that has been terminated by a \n, \r, \r\n or EOF.
public  longreadLong()
     Reads a 64 bit long.
final public  ObjectreadObject()
     Read an object from the ObjectInputStream.
protected  ObjectreadObjectOverride()
     This method is called by trusted subclasses of ObjectOutputStream that constructed ObjectOutputStream using the protected no-arg constructor.
public  shortreadShort()
     Reads a 16 bit short.
protected  voidreadStreamHeader()
     The readStreamHeader method is provided to allow subclasses to read and verify their own stream headers.
 StringreadTypeString()
     Reads string without allowing it to be replaced in stream.
public  StringreadUTF()
     Reads a String in modified UTF-8 format.
public  ObjectreadUnshared()
     Reads an "unshared" object from the ObjectInputStream.
public  intreadUnsignedByte()
     Reads an unsigned 8 bit byte.
public  intreadUnsignedShort()
     Reads an unsigned 16 bit short.
final protected  Objectreal_newInstanceFromDesc(ObjectStreamClass desc)
    
public  voidregisterValidation(ObjectInputValidation obj, int prio)
     Register an object to be validated before the graph is returned.
protected  ClassresolveClass(ObjectStreamClass desc)
     Load the local class equivalent of the specified stream class description.
protected  ObjectresolveObject(Object obj)
     This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization.
protected  ClassresolveProxyClass(String[] interfaces)
     Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.

This method is called exactly once for each unique proxy class descriptor in the stream.

The corresponding method in ObjectOutputStream is annotateProxyClass.

public  intskipBytes(int len)
     Skips bytes, block until all bytes are skipped.


Constructor Detail
ObjectInputStream
public ObjectInputStream(InputStream in) throws IOException(Code)
Creates an ObjectInputStream that reads from the specified InputStream. A serialization stream header is read from the stream and verified. This constructor will block until the corresponding ObjectOutputStream has written and flushed the header.

If a security manager is installed, this constructor will check for the "enableSubclassImplementation" SerializablePermission when invoked directly or indirectly by the constructor of a subclass which overrides the ObjectInputStream.readFields or ObjectInputStream.readUnshared methods.
Parameters:
  in - input stream to read from
throws:
  StreamCorruptedException - if the stream header is incorrect
throws:
  IOException - if an I/O error occurs while reading stream header
throws:
  SecurityException - if untrusted subclass illegally overridessecurity-sensitive methods
throws:
  NullPointerException - if in is null
See Also:   ObjectInputStream.ObjectInputStream
See Also:   ObjectInputStream.readFields
See Also:   ObjectOutputStream.ObjectOutputStream(OutputStream)




ObjectInputStream
protected ObjectInputStream() throws IOException, SecurityException(Code)
Provide a way for subclasses that are completely reimplementing ObjectInputStream to not have to allocate private data just used by this implementation of ObjectInputStream.

If there is a security manager installed, this method first calls the security manager's checkPermission method with the SerializablePermission("enableSubclassImplementation") permission to ensure it's ok to enable subclassing.
throws:
  SecurityException - if a security manager exists and itscheckPermission method denies enablingsubclassing.
See Also:   SecurityManager.checkPermission
See Also:   java.io.SerializablePermission





Method Detail
available
public int available() throws IOException(Code)
Returns the number of bytes that can be read without blocking. the number of available bytes.
throws:
  IOException - if there are I/O errors while reading from theunderlying InputStream



close
public void close() throws IOException(Code)
Closes the input stream. Must be called to release any resources associated with the stream.
throws:
  IOException - If an I/O error has occurred.



defaultReadObject
public void defaultReadObject() throws IOException, ClassNotFoundException(Code)
Read the non-static and non-transient fields of the current class from this stream. This may only be called from the readObject method of the class being deserialized. It will throw the NotActiveException if it is called otherwise.
throws:
  ClassNotFoundException - if the class of a serialized objectcould not be found.
throws:
  IOException - if an I/O error occurs.
throws:
  NotActiveException - if the stream is not currently readingobjects.



enableResolveObject
protected boolean enableResolveObject(boolean enable) throws SecurityException(Code)
Enable the stream to allow objects read from the stream to be replaced. When enabled, the resolveObject method is called for every object being deserialized.

If enable is true, and there is a security manager installed, this method first calls the security manager's checkPermission method with the SerializablePermission("enableSubstitution") permission to ensure it's ok to enable the stream to allow objects read from the stream to be replaced.
Parameters:
  enable - true for enabling use of resolveObject forevery object being deserialized the previous setting before this method was invoked
throws:
  SecurityException - if a security manager exists and itscheckPermission method denies enabling the streamto allow objects read from the stream to be replaced.
See Also:   SecurityManager.checkPermission
See Also:   java.io.SerializablePermission




newInstanceFromDesc
protected Object newInstanceFromDesc(ObjectStreamClass desc) throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException(Code)



read
public int read() throws IOException(Code)
Reads a byte of data. This method will block if no input is available. the byte read, or -1 if the end of the stream is reached.
throws:
  IOException - If an I/O error has occurred.



read
public int read(byte[] buf, int off, int len) throws IOException(Code)
Reads into an array of bytes. This method will block until some input is available. Consider using java.io.DataInputStream.readFully to read exactly 'length' bytes.
Parameters:
  buf - the buffer into which the data is read
Parameters:
  off - the start offset of the data
Parameters:
  len - the maximum number of bytes read the actual number of bytes read, -1 is returned when the end ofthe stream is reached.
throws:
  IOException - If an I/O error has occurred.
See Also:   java.io.DataInputStream.readFully(byte[]intint)



readBoolean
public boolean readBoolean() throws IOException(Code)
Reads in a boolean. the boolean read.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readByte
public byte readByte() throws IOException(Code)
Reads an 8 bit byte. the 8 bit byte read.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readChar
public char readChar() throws IOException(Code)
Reads a 16 bit char. the 16 bit char read.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readClassDescriptor
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException(Code)
Read a class descriptor from the serialization stream. This method is called when the ObjectInputStream expects a class descriptor as the next item in the serialization stream. Subclasses of ObjectInputStream may override this method to read in class descriptors that have been written in non-standard formats (by subclasses of ObjectOutputStream which have overridden the writeClassDescriptor method). By default, this method reads class descriptors according to the format defined in the Object Serialization specification. the class descriptor read
throws:
  IOException - If an I/O error has occurred.
throws:
  ClassNotFoundException - If the Class of a serialized object usedin the class descriptor representation cannot be found
See Also:   java.io.ObjectOutputStream.writeClassDescriptor(java.io.ObjectStreamClass)
since:
   1.3



readDouble
public double readDouble() throws IOException(Code)
Reads a 64 bit double. the 64 bit double read.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readFields
public ObjectInputStream.GetField readFields() throws IOException, ClassNotFoundException(Code)
Reads the persistent fields from the stream and makes them available by name. the GetField object representing the persistentfields of the object being deserialized
throws:
  ClassNotFoundException - if the class of a serialized objectcould not be found.
throws:
  IOException - if an I/O error occurs.
throws:
  NotActiveException - if the stream is not currently readingobjects.
since:
   1.2



readFloat
public float readFloat() throws IOException(Code)
Reads a 32 bit float. the 32 bit float read.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readFully
public void readFully(byte[] buf) throws IOException(Code)
Reads bytes, blocking until all bytes are read.
Parameters:
  buf - the buffer into which the data is read
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readFully
public void readFully(byte[] buf, int off, int len) throws IOException(Code)
Reads bytes, blocking until all bytes are read.
Parameters:
  buf - the buffer into which the data is read
Parameters:
  off - the start offset of the data
Parameters:
  len - the maximum number of bytes to read
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readInt
public int readInt() throws IOException(Code)
Reads a 32 bit int. the 32 bit integer read.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readLine
public String readLine() throws IOException(Code)
Reads in a line that has been terminated by a \n, \r, \r\n or EOF. a String copy of the line.
throws:
  IOException - if there are I/O errors while reading from theunderlying InputStream



readLong
public long readLong() throws IOException(Code)
Reads a 64 bit long. the read 64 bit long.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readObject
final public Object readObject() throws IOException, ClassNotFoundException(Code)
Read an object from the ObjectInputStream. The class of the object, the signature of the class, and the values of the non-transient and non-static fields of the class and all of its supertypes are read. Default deserializing for a class can be overriden using the writeObject and readObject methods. Objects referenced by this object are read transitively so that a complete equivalent graph of objects is reconstructed by readObject.

The root object is completely restored when all of its fields and the objects it references are completely restored. At this point the object validation callbacks are executed in order based on their registered priorities. The callbacks are registered by objects (in the readObject special methods) as they are individually restored.

Exceptions are thrown for problems with the InputStream and for classes that should not be deserialized. All exceptions are fatal to the InputStream and leave it in an indeterminate state; it is up to the caller to ignore or recover the stream state.
throws:
  ClassNotFoundException - Class of a serialized object cannot befound.
throws:
  InvalidClassException - Something is wrong with a class used byserialization.
throws:
  StreamCorruptedException - Control information in thestream is inconsistent.
throws:
  OptionalDataException - Primitive data was found in the stream instead of objects.
throws:
  IOException - Any of the usual Input/Output related exceptions.




readObjectOverride
protected Object readObjectOverride() throws IOException, ClassNotFoundException(Code)
This method is called by trusted subclasses of ObjectOutputStream that constructed ObjectOutputStream using the protected no-arg constructor. The subclass is expected to provide an override method with the modifier "final". the Object read from the stream.
throws:
  ClassNotFoundException - Class definition of a serialized objectcannot be found.
throws:
  OptionalDataException - Primitive data was found in the streaminstead of objects.
throws:
  IOException - if I/O errors occurred while reading from theunderlying stream
See Also:   ObjectInputStream.ObjectInputStream()
See Also:   ObjectInputStream.readObject()
since:
   1.2



readShort
public short readShort() throws IOException(Code)
Reads a 16 bit short. the 16 bit short read.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readStreamHeader
protected void readStreamHeader() throws IOException, StreamCorruptedException(Code)
The readStreamHeader method is provided to allow subclasses to read and verify their own stream headers. It reads and verifies the magic number and version number.
throws:
  IOException - if there are I/O errors while reading from theunderlying InputStream
throws:
  StreamCorruptedException - if control information in the streamis inconsistent



readTypeString
String readTypeString() throws IOException(Code)
Reads string without allowing it to be replaced in stream. Called from within ObjectStreamClass.read().



readUTF
public String readUTF() throws IOException(Code)
Reads a String in modified UTF-8 format. the String.
throws:
  IOException - if there are I/O errors while reading from theunderlying InputStream
throws:
  UTFDataFormatException - if read bytes do not represent a validmodified UTF-8 encoding of a string



readUnshared
public Object readUnshared() throws IOException, ClassNotFoundException(Code)
Reads an "unshared" object from the ObjectInputStream. This method is identical to readObject, except that it prevents subsequent calls to readObject and readUnshared from returning additional references to the deserialized instance obtained via this call. Specifically:
  • If readUnshared is called to deserialize a back-reference (the stream representation of an object which has been written previously to the stream), an ObjectStreamException will be thrown.
  • If readUnshared returns successfully, then any subsequent attempts to deserialize back-references to the stream handle deserialized by readUnshared will cause an ObjectStreamException to be thrown.
Deserializing an object via readUnshared invalidates the stream handle associated with the returned object. Note that this in itself does not always guarantee that the reference returned by readUnshared is unique; the deserialized object may define a readResolve method which returns an object visible to other parties, or readUnshared may return a Class object or enum constant obtainable elsewhere in the stream or through external means.

However, for objects which are not enum constants or instances of java.lang.Class and do not define readResolve methods, readUnshared guarantees that the returned object reference is unique and cannot be obtained a second time from the ObjectInputStream that created it, even if the underlying data stream has been manipulated. This guarantee applies only to the base-level object returned by readUnshared, and not to any transitively referenced sub-objects in the returned object graph.

ObjectInputStream subclasses which override this method can only be constructed in security contexts possessing the "enableSubclassImplementation" SerializablePermission; any attempt to instantiate such a subclass without this permission will cause a SecurityException to be thrown. reference to deserialized object
throws:
  ClassNotFoundException - if class of an object to deserializecannot be found
throws:
  StreamCorruptedException - if control information in the streamis inconsistent
throws:
  ObjectStreamException - if object to deserialize has alreadyappeared in stream
throws:
  OptionalDataException - if primitive data is next in stream
throws:
  IOException - if an I/O error occurs during deserialization




readUnsignedByte
public int readUnsignedByte() throws IOException(Code)
Reads an unsigned 8 bit byte. the 8 bit byte read.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



readUnsignedShort
public int readUnsignedShort() throws IOException(Code)
Reads an unsigned 16 bit short. the 16 bit short read.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



real_newInstanceFromDesc
final protected Object real_newInstanceFromDesc(ObjectStreamClass desc) throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException(Code)



registerValidation
public void registerValidation(ObjectInputValidation obj, int prio) throws NotActiveException, InvalidObjectException(Code)
Register an object to be validated before the graph is returned. While similar to resolveObject these validations are called after the entire graph has been reconstituted. Typically, a readObject method will register the object with the stream so that when all of the objects are restored a final set of validations can be performed.
Parameters:
  obj - the object to receive the validation callback.
Parameters:
  prio - controls the order of callbacks;zero is a good default.Use higher numbers to be called back earlier, lower numbers forlater callbacks. Within a priority, callbacks are processed inno particular order.
throws:
  NotActiveException - The stream is not currently reading objectsso it is invalid to register a callback.
throws:
  InvalidObjectException - The validation object is null.



resolveClass
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException(Code)
Load the local class equivalent of the specified stream class description. Subclasses may implement this method to allow classes to be fetched from an alternate source.

The corresponding method in ObjectOutputStream is annotateClass. This method will be invoked only once for each unique class in the stream. This method can be implemented by subclasses to use an alternate loading mechanism but must return a Class object. Once returned, the serialVersionUID of the class is compared to the serialVersionUID of the serialized class. If there is a mismatch, the deserialization fails and an exception is raised.

By default the class name is resolved relative to the class that called readObject.
Parameters:
  desc - an instance of class ObjectStreamClass a Class object corresponding to desc
throws:
  IOException - any of the usual input/output exceptions
throws:
  ClassNotFoundException - if class of a serialized object cannotbe found




resolveObject
protected Object resolveObject(Object obj) throws IOException(Code)
This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization. Replacing objects is disabled until enableResolveObject is called. The enableResolveObject method checks that the stream requesting to resolve object can be trusted. Every reference to serializable objects is passed to resolveObject. To insure that the private state of objects is not unintentionally exposed only trusted streams may use resolveObject.

This method is called after an object has been read but before it is returned from readObject. The default resolveObject method just returns the same object.

When a subclass is replacing objects it must insure that the substituted object is compatible with every field where the reference will be stored. Objects whose type is not a subclass of the type of the field or array element abort the serialization by raising an exception and the object is not be stored.

This method is called only once when each object is first encountered. All subsequent references to the object will be redirected to the new object.
Parameters:
  obj - object to be substituted the substituted object
throws:
  IOException - Any of the usual Input/Output exceptions.




resolveProxyClass
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException(Code)
Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.

This method is called exactly once for each unique proxy class descriptor in the stream.

The corresponding method in ObjectOutputStream is annotateProxyClass. For a given subclass of ObjectInputStream that overrides this method, the annotateProxyClass method in the corresponding subclass of ObjectOutputStream must write any data or objects read by this method.

The default implementation of this method in ObjectInputStream returns the result of calling Proxy.getProxyClass with the list of Class objects for the interfaces that are named in the interfaces parameter. The Class object for each interface name i is the value returned by calling

 Class.forName(i, false, loader)
 
where loader is that of the first non-null class loader up the execution stack, or null if no non-null class loaders are on the stack (the same class loader choice used by the resolveClass method). Unless any of the resolved interfaces are non-public, this same value of loader is also the class loader passed to Proxy.getProxyClass; if non-public interfaces are present, their class loader is passed instead (if more than one non-public interface class loader is encountered, an IllegalAccessError is thrown). If Proxy.getProxyClass throws an IllegalArgumentException, resolveProxyClass will throw a ClassNotFoundException containing the IllegalArgumentException.
Parameters:
  interfaces - the list of interface names that weredeserialized in the proxy class descriptor a proxy class for the specified interfaces
throws:
  IOException - any exception thrown by the underlyingInputStream
throws:
  ClassNotFoundException - if the proxy class or any of thenamed interfaces could not be found
See Also:   ObjectOutputStream.annotateProxyClass(Class)
since:
   1.3



skipBytes
public int skipBytes(int len) throws IOException(Code)
Skips bytes, block until all bytes are skipped.
Parameters:
  len - the number of bytes to be skipped the actual number of bytes skipped.
throws:
  EOFException - If end of file is reached.
throws:
  IOException - If other I/O error has occurred.



Methods inherited from java.io.InputStream
public int available() throws IOException(Code)(Java Doc)
public void close() throws IOException(Code)(Java Doc)
public synchronized void mark(int readlimit)(Code)(Java Doc)
public boolean markSupported()(Code)(Java Doc)
abstract public int read() throws IOException(Code)(Java Doc)
public int read(byte b) throws IOException(Code)(Java Doc)
public int read(byte b, int off, int len) throws IOException(Code)(Java Doc)
public synchronized void reset() throws IOException(Code)(Java Doc)
public long skip(long n) throws IOException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.