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:lirmm.inria.fr.math.OpenLongToDoubleHashMap.java

/**
 * Read a serialized object./*  ww  w. j a  v  a  2s.c  o m*/
 *
 * @param stream input stream
 * @throws IOException if object cannot be read
 * @throws ClassNotFoundException if the class corresponding to the
 * serialized object cannot be found
 */
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    count = 0;
}

From source file:org.pentaho.reporting.engine.classic.core.MasterReport.java

/**
 * A helper method that deserializes a object from the given stream.
 *
 * @param stream//from   ww  w.  j  a  v  a2 s .  c  om
 *          the stream from which to read the object data.
 * @throws IOException
 *           if an IO error occured.
 * @throws ClassNotFoundException
 *           if an referenced class cannot be found.
 */
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();

    updateResourceBundleFactoryInternal();

    reportConfiguration.reconnectConfiguration(ClassicEngineBoot.getInstance().getGlobalConfig());
    addReportModelListener(new DocumentBundleChangeHandler());

    try {
        final String bundleType = (String) stream.readObject();

        final byte[] bundleRawZip = (byte[]) stream.readObject();
        final ResourceManager mgr = getResourceManager();
        final Resource bundleResource = mgr.createDirectly(bundleRawZip, DocumentBundle.class);
        final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();

        final MemoryDocumentBundle mem = new MemoryDocumentBundle(getContentBase());
        BundleUtilities.copyStickyInto(mem, bundle);
        BundleUtilities.copyInto(mem, bundle, LegacyBundleResourceRegistry.getInstance().getRegisteredFiles(),
                true);
        BundleUtilities.copyMetaData(mem, bundle);
        mem.getWriteableDocumentMetaData().setBundleType(bundleType);
        setBundle(mem);
    } catch (ResourceException e) {
        throw new IOException(e);
    }
}

From source file:com.softwarementors.extjs.djn.router.processor.standard.form.upload.DiskFileItem2.java

/**
 * Reads the state of this object during deserialization.
 *
 * @param in The stream from which the state should be read.
 *
 * @throws IOException if an error occurs.
 * @throws ClassNotFoundException if class cannot be found.
 */// ww w  . java 2 s.  c om
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    // read values
    in.defaultReadObject();

    OutputStream output = getOutputStream();
    if (cachedContent != null) {
        output.write(cachedContent);
    } else {
        FileInputStream input = new FileInputStream(dfosFile);

        IOUtils.copy(input, output);
        dfosFile.delete();
        dfosFile = null;
    }
    output.close();

    cachedContent = null;
}

From source file:it.unimi.di.big.mg4j.document.SimpleCompressedDocumentCollection.java

private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();
    loadOffsets(basename, false);/*  www  .  ja  va2 s  .c o  m*/
    initMappings(basename, false);
    initFiles(basename, false);
    termsFrequencyKeeper = new FrequencyCodec();
    if (exact)
        nonTermsFrequencyKeeper = new FrequencyCodec();
}

From source file:com.masscustsoft.service.inner.DiskTempItem.java

/**
 * Reads the state of this object during deserialization.
 *
 * @param in The stream from which the state should be read.
 *
 * @throws IOException if an error occurs.
 * @throws ClassNotFoundException if class cannot be found.
 *//*from   w  w  w  .ja  v  a 2  s . c  o m*/
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    // read values
    in.defaultReadObject();

    OutputStream output = getOutputStream();
    if (cachedContent != null) {
        output.write(cachedContent);
    } else {
        InputStream input = dfosFile.getInputStream();

        IOUtils.copy(input, output);
        dfosFile.delete();
        dfosFile = null;
    }
    output.close();

    cachedContent = null;
}

From source file:edu.cmu.tetrad.data.CovarianceMatrixOnTheFly.java

/**
 * Adds semantic checks to the default deserialization method. This method
 * must have the standard signature for a readObject method, and the body of
 * the method must begin with "s.defaultReadObject();". Other than that, any
 * semantic checks can be specified and do not need to stay the same from
 * version to version. A readObject method of this form may be added to any
 * class, even if Tetrad sessions were previously saved out using a version
 * of the class that didn't include it. (That's what the
 * "s.defaultReadObject();" is for. See J. Bloch, Effective Java, for help.
 *
 * @throws java.io.IOException/*  w w  w  .j  av  a 2  s  .c  o  m*/
 * @throws ClassNotFoundException
 */
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();

    if (getVariables() == null) {
        throw new NullPointerException();
    }

    if (matrixC != null) {
        matrix = new TetradMatrix(matrixC.toArray());
        matrixC = null;
    }

    if (knowledge == null) {
        throw new NullPointerException();
    }

    if (sampleSize < -1) {
        throw new IllegalStateException();
    }

    if (selectedVariables == null) {
        selectedVariables = new HashSet<Node>();
    }
}

From source file:org.objectweb.proactive.core.remoteobject.RemoteObjectSet.java

/**
 * Update the protocol order from the new ProActive Runtime
 * when the remote remote object is reified
 *//* w  w  w .j av a  2  s  .c  om*/
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    int size = in.readInt();
    ReentrantReadWriteLock.WriteLock wl = rwlock.writeLock();
    wl.lock();
    this.rros = new LinkedHashMap<URI, RemoteRemoteObject>(size);
    this.sortedrros = new ArrayList<URI>();
    this.lastBenchmarkResults = new ConcurrentHashMap<URI, Integer>();

    // read protocols
    for (int i = 0; i < size; i++) {
        Map.Entry<URI, RemoteRemoteObject> entry = readProtocol(in);
        if (entry != null) {
            URI uri = entry.getKey();
            RemoteRemoteObject rro = entry.getValue();
            if (i == 0) {
                // default protocol is the first one
                this.defaultURI = uri;
                this.defaultRO = rro;
            }
            this.rros.put(uri, rro);
            sortedrros.add(uri);
            lastBenchmarkResults.put(uri, size - i);
        }
    }
    wl.unlock();
    sortProtocolsInternal();

    if (LOGGER_RO.isDebugEnabled()) {
        LOGGER_RO.debug("[ROAdapter] read RemoteObjectSet " + sortedrros);
    }

    VMID testLocal = ProActiveRuntimeImpl.getProActiveRuntime().getVMInformation().getVMID();
    if (!vmid.equals(testLocal)) {
        this.vmid = testLocal;
        this.startBenchmark();
    }
}

From source file:edu.cmu.tetrad.data.CovarianceMatrix.java

/**
 * Adds semantic checks to the default deserialization method. This method
 * must have the standard signature for a readObject method, and the body of
 * the method must begin with "s.defaultReadObject();". Other than that, any
 * semantic checks can be specified and do not need to stay the same from
 * version to version. A readObject method of this form may be added to any
 * class, even if Tetrad sessions were previously saved out using a version
 * of the class that didn't include it. (That's what the
 * "s.defaultReadObject();" is for. See J. Bloch, Effective Java, for help.
 *
 * @throws java.io.IOException// ww  w .j  a va  2 s.  co  m
 * @throws ClassNotFoundException
 */
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();

    if (getVariables() == null) {
        throw new NullPointerException();
    }

    //        if (matrixC != null) {
    //            matrix = new TetradMatrix(matrixC.toArray());
    //            matrixC = null;
    //        }

    if (knowledge == null) {
        throw new NullPointerException();
    }

    if (sampleSize < -1) {
        throw new IllegalStateException();
    }

    if (selectedVariables == null) {
        selectedVariables = new HashSet<>();
    }
}

From source file:org.seasar.mayaa.impl.builder.TemplateBuilderImpl.java

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();

    _chain = new DefaultInjectionChain();
}

From source file:org.seasar.mayaa.impl.engine.processor.JspProcessor.java

private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
    in.defaultReadObject();
    _variableInfo = new TLDScriptingVariableInfo();
}