com.alachisoft.ncache.serialization.standard.io.surrogates.InternalCompactSerializableSurrogate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-serialization Show documentation
Show all versions of nc-serialization Show documentation
Internal package of Alachisoft.
/*
* 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);
}
}
}