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:ddf.security.assertion.impl.SecurityAssertionImpl.java

private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
    objectInputStream.defaultReadObject();
    init();/*w  ww. j  a  va  2 s.c  o m*/
}

From source file:com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.java

/**
 * Re-initializes transient fields when an object of this type is deserialized.
 *//* w  w w.java2 s  . co  m*/
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    initTransientFields();
}

From source file:com.frameworkset.commons.dbcp2.datasources.PerUserPoolDataSource.java

/**
 * Supports Serialization interface.//  w  w  w. j  a v a  2s  .  c o m
 *
 * @param in a <code>java.io.ObjectInputStream</code> value
 * @exception IOException if an error occurs
 * @exception ClassNotFoundException if an error occurs
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    try {
        in.defaultReadObject();
        PerUserPoolDataSource oldDS = (PerUserPoolDataSource) new PerUserPoolDataSourceFactory()
                .getObjectInstance(getReference(), null, null, null);
        this.managers = oldDS.managers;
    } catch (NamingException e) {
        throw new IOException("NamingException: " + e);
    }
}

From source file:msi.gama.outputs.layers.charts.StandardXYItemRenderer.java

/**
 * Provides serialization support./*from  www  . ja v  a  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(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    this.legendLine = SerialUtilities.readShape(stream);
}

From source file:aprofplot.jfreechart.SamplingXYLineAndShapeRenderer.java

/**
 * Provides serialization support./*from  w ww. j  a  v a2  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.lineWidth = stream.readInt();
    this.shapeSize = stream.readInt();
}

From source file:ddf.catalog.data.impl.MetacardImpl.java

/**
 * Deserializes this {@link MetacardImpl}'s instance.
 *
 * @param stream the {@link ObjectInputStream} that contains the bytes of the object
 * @throws IOException/*from w  ww  . ja va2 s. co  m*/
 * @throws ClassNotFoundException
 */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {

    /*
     * defaultReadObject() is invoked for greater flexibility and compatibility. See the
     * *Serialization Note* in MetacardImpl's class Javadoc.
     */
    stream.defaultReadObject();

    map = new HashMap<String, Attribute>();

    wrappedMetacard = null;

    type = (MetacardType) stream.readObject();

    if (type == null) {
        throw new InvalidObjectException(MetacardType.class.getName() + " instance cannot be null.");
    }

    int numElements = stream.readInt();

    for (int i = 0; i < numElements; i++) {

        Attribute attribute = (Attribute) stream.readObject();

        if (attribute != null) {

            AttributeDescriptor attributeDescriptor = getMetacardType()
                    .getAttributeDescriptor(attribute.getName());

            if (attributeDescriptor != null && attribute.getValue() != null) {
                attributeDescriptor.getType().getAttributeFormat();
                attributeDescriptor.getType().getClass();
            }

        }

        setAttribute(attribute);
    }

}

From source file:org.apache.flink.cep.nfa.SharedBuffer.java

private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    DataInputViewStreamWrapper source = new DataInputViewStreamWrapper(ois);
    ArrayList<SharedBufferEntry<K, V>> entryList = new ArrayList<>();
    ois.defaultReadObject();

    this.pages = new HashMap<>();

    int numberPages = ois.readInt();

    for (int i = 0; i < numberPages; i++) {
        // key of the page
        @SuppressWarnings("unchecked")
        K key = (K) ois.readObject();//from   w w  w  .j  a v  a  2  s.  c  om

        SharedBufferPage<K, V> page = new SharedBufferPage<>(key);

        pages.put(key, page);

        int numberEntries = ois.readInt();

        for (int j = 0; j < numberEntries; j++) {
            // restore the SharedBufferEntries for the given page
            V value = valueSerializer.deserialize(source);
            long timestamp = ois.readLong();

            ValueTimeWrapper<V> valueTimeWrapper = new ValueTimeWrapper<>(value, timestamp);
            SharedBufferEntry<K, V> sharedBufferEntry = new SharedBufferEntry<K, V>(valueTimeWrapper, page);

            sharedBufferEntry.referenceCounter = ois.readInt();

            page.entries.put(valueTimeWrapper, sharedBufferEntry);

            entryList.add(sharedBufferEntry);
        }
    }

    // read the edges of the shared buffer entries
    int numberEdges = ois.readInt();

    for (int j = 0; j < numberEdges; j++) {
        int sourceIndex = ois.readInt();
        int targetIndex = ois.readInt();

        if (sourceIndex >= entryList.size() || sourceIndex < 0) {
            throw new RuntimeException("Could not find source entry with index " + sourceIndex
                    + ". This indicates a corrupted state.");
        } else {
            // We've already deserialized the shared buffer entry. Simply read its ID and
            // retrieve the buffer entry from the list of entries
            SharedBufferEntry<K, V> sourceEntry = entryList.get(sourceIndex);

            final DeweyNumber version = (DeweyNumber) ois.readObject();
            final SharedBufferEntry<K, V> target;

            if (targetIndex >= 0) {
                if (targetIndex >= entryList.size()) {
                    throw new RuntimeException("Could not find target entry with index " + targetIndex
                            + ". This indicates a corrupted state.");
                } else {
                    target = entryList.get(targetIndex);
                }
            } else {
                target = null;
            }

            sourceEntry.edges.add(new SharedBufferEdge<K, V>(target, version));
        }
    }
}

From source file:com.cyberway.issue.crawler.frontier.AbstractFrontier.java

private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    liveQueuedUriCount = new AtomicLong(queuedUriCount);
    liveSucceededFetchCount = new AtomicLong(succeededFetchCount);
    liveFailedFetchCount = new AtomicLong(failedFetchCount);
    liveDisregardedUriCount = new AtomicLong(disregardedUriCount);
}

From source file:IntHashMap.java

/**
 * Reconstitute the <tt>HashMap</tt> instance from a stream (i.e.,
 * deserialize it)./*from w w w  . java  2s .  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();

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

    init(); // Give subclass a chance to do its thing.

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

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

From source file:IntHashMap.java

/**
 * Reconstitute the <tt>HashMap</tt> instance from a stream (i.e., deserialize it).
 * //from  w w w.ja  v  a2  s  . co  m
 * @param s
 * @throws IOException
 * @throws ClassNotFoundException
 */
@SuppressWarnings("unchecked")
private 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];

    init(); // Give subclass a chance to do its thing.

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

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