Skip to content

Instantly share code, notes, and snippets.

@pmanvi
Created September 25, 2011 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmanvi/1240845 to your computer and use it in GitHub Desktop.
Save pmanvi/1240845 to your computer and use it in GitHub Desktop.
Class used for implementing the forward compatability of serialized java objects
// A wrapper classes delegating the execution of method into the container that can handle forward compatibility
// This class implements all the methods ObjectInput & moves the cursor
// whenever it sees skippable data from future versions
// WARNING : Currently for POC only 2 methods are implemented
class ObjectInputDecorator{
ObjectInput input;
ObjectInputDecorator(ObjectInput input){
this.input=input;
}
public int readInt() throws IOException {
return new ObjectInputReaderTemplate<Integer>(){
@Override
public Integer get() throws IOException {
return input.readInt();
}
}.execute();
}
public Object readObject()throws IOException {
return new ObjectInputReaderTemplate<Object>(){
@Override
public Object get() throws IOException{
return input.readObject();
}
}.execute();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment