net.sf.japaki.io
Interface RestorableIO<T>

All Superinterfaces:
Closeable
All Known Implementing Classes:
ParseReader, ParseWriter, ReaderWithPosition, WriterWithPosition

public interface RestorableIO<T>
extends Closeable

This interface marks classes that contain methods to create a "backup instance" and to restore later from that instance. Despite its name the original object is not restored, but modifications are made to a copy and in case of success are copied to the original. So the typical usage looks like this:

  
   try{
       T copy = original.deepCopy();
       // do something to copy
       original.copyFrom(copy);
   } catch (Exception e){
       // original was not modified
   }
  
 


Method Summary
 void copyFrom(T source)
          Copies all values from the source object After the copy, this object behaves like the source.
 T deepCopy()
          Provides a deep copy of this object.
 
Methods inherited from interface java.io.Closeable
close
 

Method Detail

deepCopy

T deepCopy()
Provides a deep copy of this object.

Returns:
a deep copy of this object

copyFrom

void copyFrom(T source)
              throws IOException
Copies all values from the source object After the copy, this object behaves like the source.

Parameters:
source - the source instance. Compatibility depends on the implementing class. In the standard case it should be the result of a prior call to deepCopy().
Throws:
IOException - if an I/O error occurs
ClassCastException - if the source was not previously copied from this instance.
IllegalStateException - if the source was not previously copied from this instance.
NullPointerException - if the source is null.