com.alachisoft.ncache.serialization.standard.io.surrogates.ExternalizableSerializationSurrogate 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.
/*
* @(#)ExternalizableSerializationSurrogate.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.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.Externalizable;
import java.io.IOException;
/**
* ExternalizableSerializationSurrogate is responsible for writing and reading
* instances of class that implement the Externalizable interface.
*
* @version 1.0, September 18, 2008
*/
public class ExternalizableSerializationSurrogate
extends SerializationSurrogateImpl
implements BuiltinSerializationSurrogate {
/**
* Creates a new instance of ExternalizableSerializationSurrogate
*/
public ExternalizableSerializationSurrogate(Class type) {
super(type);
}
public Object readDirect(NCacheObjectInput input, Object graph)
throws NCacheInstantiationException, NCacheIOException {
try {
((Externalizable) graph).readExternal(input);
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 {
((Externalizable) graph).writeExternal(output);
} catch (IOException ex) {
throw new NCacheIOException(ex);
}
}
@Override
public void skipDirect(NCacheObjectInput input, Object graph) throws NCacheInstantiationException, NCacheIOException {
try {
((Externalizable) graph).readExternal(input);
} catch (IOException ex) {
throw new NCacheIOException(ex);
} catch (ClassNotFoundException ex) {
throw new NCacheInstantiationException(ex);
}
}
}