Example usage for java.io ObjectInputStream defaultReadObject

List of usage examples for java.io ObjectInputStream defaultReadObject

Introduction

In this page you can find the example usage for java.io ObjectInputStream defaultReadObject.

Prototype

public void defaultReadObject() throws IOException, ClassNotFoundException 

Source Link

Document

Read the non-static and non-transient fields of the current class from this stream.

Usage

From source file:CopyOnWriteArrayList.java

/**
 * Reconstitute the list from a stream (i.e., deserialize it).
 * @param s the stream//from  w  w w . ja v  a 2 s  .c o  m
 */
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {

    // Read in size, and any hidden stuff
    s.defaultReadObject();

    // Read in array length and allocate array
    int len = s.readInt();
    Object[] elements = new Object[len];

    // Read in all elements in the proper order.
    for (int i = 0; i < len; i++)
        elements[i] = s.readObject();
    setArray(elements);

}

From source file:edu.stanford.muse.email.AddressBook.java

private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    // the no-arg constructor to do the needed setup when an address book is initialized thru deserialization
}

From source file:CopyOnWriteArrayList.java

/**
 * Reconstitute the list from a stream (i.e., deserialize it).
 * @param s //from  w ww . ja v a  2  s  .  co m
 * @throws java.io.IOException 
 * @throws ClassNotFoundException 
 */
private synchronized void readObject(java.io.ObjectInputStream s)
        throws java.io.IOException, ClassNotFoundException {
    // Read in size, and any hidden stuff
    s.defaultReadObject();

    // Read in array length and allocate array
    int arrayLength = s.readInt();
    Object[] elementData = new Object[arrayLength];

    // Read in all elements in the proper order.
    for (int i = 0; i < elementData.length; i++)
        elementData[i] = s.readObject();
    array_ = elementData;
}

From source file:KIDLYRenderer.java

/**
 * Provides serialization support./* w ww .  java  2s . c om*/
 *
 * @param stream  the input stream.
 *
 * @throws IOException  if there is an I/O error.
 * @throws ClassNotFoundException  if there is a classpath problem.
 */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    this.shadowPaint = SerialUtilities.readPaint(stream);
}

From source file:edu.dlnu.liuwenpeng.render.XYLineAndShapeRenderer.java

/**    
 * Provides serialization support.    //from w ww .  j a  v  a  2  s. c  o m
 *    
 * @param stream  the input stream.    
 *    
 * @throws IOException  if there is an I/O error.    
 * @throws ClassNotFoundException  if there is a classpath problem.    
 */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    this.legendLine = SerialUtilities.readShape(stream);
}

From source file:ConcurrentReaderHashMap.java

/**
 * Reconstitute the <tt>ConcurrentReaderHashMap</tt> 
 * instance from a stream (i.e.,// w w  w  . ja v a 2s.  c o m
 * deserialize it).
 */
private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
    // Read in the threshold, loadfactor, and any hidden stuff
    s.defaultReadObject();

    // Read in number of buckets and allocate the bucket array;
    int numBuckets = s.readInt();
    table = new Entry[numBuckets];

    // Read in size (number of Mappings)
    int size = s.readInt();

    // Read the keys and values, and put the mappings in the table
    for (int i = 0; i < size; i++) {
        Object key = s.readObject();
        Object value = s.readObject();
        put(key, value);
    }
}

From source file:ConcurrentHashMap.java

/**
 * Reconstitute the <tt>ConcurrentHashMap</tt> instance from a stream
 * (i.e., deserialize it).//from  ww w.jav a2  s . c o m
 * @param s 
 * @throws IOException 
 * @throws ClassNotFoundException 
 */
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
    // Read in the threshold, loadfactor, and any hidden stuff
    s.defaultReadObject();

    int cap = s.readInt();
    table = newTable(cap);
    for (int i = 0; i < segments.length; ++i) {
        segments[i] = new Segment();
    }

    // Read the keys and values, and put the mappings in the table
    for (;;) {
        Object key = s.readObject();
        Object value = s.readObject();
        if (key == null) {
            break;
        }
        put(key, value);
    }
}

From source file:com.cyberway.issue.crawler.datamodel.CrawlURI.java

/**
 * Custom deserialization recreating empty HashSet from null in 'outLinks'
 * slot. /* w ww. ja v a 2  s. c  o  m*/
 * 
 * @param stream
 * @throws IOException
 * @throws ClassNotFoundException
 */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    @SuppressWarnings("unchecked")
    HashSet<Object> ol = (HashSet<Object>) stream.readObject();
    outLinks = (ol == null) ? new HashSet<Object>() : ol;
}

From source file:LinkedTransferQueue.java

/**
 * Reconstitutes the Queue instance from a stream (that is,
 * deserializes it).//from  www  . ja v  a  2 s  .c  om
 *
 * @param s the stream
 */
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
    s.defaultReadObject();
    for (;;) {
        @SuppressWarnings("unchecked")
        E item = (E) s.readObject();
        if (item == null)
            break;
        else
            offer(item);
    }
}

From source file:bin.spider.frame.uri.CrawlURI.java

/**
 * Custom deserialization recreating empty HashSet from null in 'outLinks'
 * slot. /*from  w  w w .  j  a  va  2s. c  o  m*/
 * 
 * @param stream
 * @throws IOException
 * @throws ClassNotFoundException
 */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    @SuppressWarnings("unchecked")
    Collection<Object> ol = (Collection<Object>) stream.readObject();
    outLinks = (ol == null) ? new ArrayList<Object>() : ol;
}