All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.serialization.standard.io.surrogates.InternalCompactSerializableSurrogate Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.alachisoft.ncache.serialization.standard.io.surrogates;

import com.alachisoft.ncache.serialization.core.io.InternalCompactSerializable;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectInput;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectOutput;
import com.alachisoft.ncache.serialization.core.io.surrogates.BuiltinSerializationSurrogate;
import com.alachisoft.ncache.serialization.core.io.surrogates.NCacheIOException;
import com.alachisoft.ncache.serialization.core.io.surrogates.NCacheInstantiationException;
import com.alachisoft.ncache.serialization.core.io.surrogates.SerializationSurrogateImpl;
import com.alachisoft.ncache.serialization.standard.io.CompactReader;
import com.alachisoft.ncache.serialization.standard.io.CompactWriter;
import com.alachisoft.ncache.serialization.standard.io.ObjectInputStream;
import com.alachisoft.ncache.serialization.standard.io.ObjectOutputStream;

import java.io.IOException;

/**
 * @author taimoor_haider
 */
public class InternalCompactSerializableSurrogate extends SerializationSurrogateImpl
        implements BuiltinSerializationSurrogate {

    /**
     * Creates a new instance of ExternalizableSerializationSurrogate
     */
    public InternalCompactSerializableSurrogate(Class type) {
        super(type);
    }

    public Object readDirect(NCacheObjectInput input, Object graph)
            throws NCacheInstantiationException, NCacheIOException {
        try {
            CompactReader reader = new CompactReader((ObjectInputStream) input);
            ((InternalCompactSerializable) graph).Deserialize(reader);
            return graph;
        } catch (IOException ex) {
            throw new NCacheIOException(ex);
        } catch (ClassNotFoundException ex) {
            throw new NCacheInstantiationException(ex);
        }
    }

    public void writeDirect(NCacheObjectOutput output, Object graph)
            throws NCacheIOException {
        try {
            CompactWriter writer = new CompactWriter((ObjectOutputStream) output);
            ((InternalCompactSerializable) graph).Serialize(writer);
        } catch (IOException ex) {
            throw new NCacheIOException(ex);
        }
    }

    @Override
    public void skipDirect(NCacheObjectInput input, Object graph) throws NCacheInstantiationException, NCacheIOException {
        try {
            CompactReader reader = new CompactReader((ObjectInputStream) input);
            ((InternalCompactSerializable) graph).Deserialize(reader);
        } catch (IOException ex) {
            throw new NCacheIOException(ex);
        } catch (ClassNotFoundException ex) {
            throw new NCacheInstantiationException(ex);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy