Created
September 25, 2011 17:04
-
-
Save pmanvi/1240845 to your computer and use it in GitHub Desktop.
Class used for implementing the forward compatability of serialized java objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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