com.alachisoft.ncache.serialization.standard.io.surrogates.XExternalizableSerializationSurrogate 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.
/*
* @(#)XExternalizableSerializationSurrogate.java 1.0
*
* Created on September 18, 2008, 12:59 PM
*
* Copyright 2008 NeXtreme Innovations, Inc. All rights reserved.
* "NeXtreme Innovations" PROPRIETARY/CONFIDENTIAL. Use is subject
* to license terms.
*/
package com.alachisoft.ncache.serialization.standard.io.surrogates;
import com.alachisoft.ncache.serialization.core.io.ICompactSerializable;
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 java.io.IOException;
/**
* XExternalizableSerializationSurrogate is responsible for writing and reading
* instances of class that implement the Externalizable interface.
*
* @version 1.0, September 18, 2008
*/
public class XExternalizableSerializationSurrogate
extends SerializationSurrogateImpl
implements BuiltinSerializationSurrogate {
/**
* Creates a new instance of XExternalizableSerializationSurrogate
*/
public XExternalizableSerializationSurrogate(Class type) {
super(type);
}
public Object readDirect(NCacheObjectInput input, Object graph)
throws NCacheInstantiationException, NCacheIOException {
try {
((ICompactSerializable) graph).deserialize(input);
} catch (ClassNotFoundException ex) {
throw new NCacheInstantiationException(ex);
} catch (IOException ex) {
throw new NCacheIOException(ex);
}
return graph;
}
public void writeDirect(NCacheObjectOutput output, Object graph)
throws NCacheIOException {
try {
((ICompactSerializable) graph).serialize(output);
} catch (IOException ex) {
throw new NCacheIOException(ex);
}
}
@Override
public void skipDirect(NCacheObjectInput input, Object graph) throws NCacheInstantiationException, NCacheIOException {
try {
((ICompactSerializable) graph).deserialize(input);
} catch (ClassNotFoundException ex) {
throw new NCacheInstantiationException(ex);
} catch (IOException ex) {
throw new NCacheIOException(ex);
}
}
}