org.archive.io
Class ObjectPlusFilesOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ObjectOutputStream
          extended by org.archive.io.ObjectPlusFilesOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.io.ObjectOutput, java.io.ObjectStreamConstants

public class ObjectPlusFilesOutputStream
extends java.io.ObjectOutputStream

Enhanced ObjectOutputStream which maintains (a stack of) auxiliary directories and offers convenience methods for serialized objects to save their related disk files alongside their serialized version.

Author:
gojomo

Nested Class Summary
 
Nested classes/interfaces inherited from class java.io.ObjectOutputStream
java.io.ObjectOutputStream.PutField
 
Field Summary
(package private)  java.util.LinkedList<java.io.File> auxiliaryDirectoryStack
           
 
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
 
Constructor Summary
ObjectPlusFilesOutputStream(java.io.OutputStream out, java.io.File topDirectory)
          Constructor
 
Method Summary
 java.io.File getAuxiliaryDirectory()
          Return the current auxiliary directory for storing files associated with serialized objects.
 void popAuxiliaryDirectory()
          Remove the top subdirectory.
 void pushAuxiliaryDirectory(java.lang.String dir)
          Add another subdirectory for any file-capture needs during the current serialization.
 void snapshotAppendOnlyFile(java.io.File file)
          Store a snapshot of an object's supporting file to the current auxiliary directory.
 
Methods inherited from class java.io.ObjectOutputStream
annotateClass, annotateProxyClass, close, defaultWriteObject, drain, enableReplaceObject, flush, putFields, replaceObject, reset, useProtocolVersion, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeClassDescriptor, writeDouble, writeFields, writeFloat, writeInt, writeLong, writeObject, writeObjectOverride, writeShort, writeStreamHeader, writeUnshared, writeUTF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

auxiliaryDirectoryStack

java.util.LinkedList<java.io.File> auxiliaryDirectoryStack
Constructor Detail

ObjectPlusFilesOutputStream

public ObjectPlusFilesOutputStream(java.io.OutputStream out,
                                   java.io.File topDirectory)
                            throws java.io.IOException
Constructor

Parameters:
out -
topDirectory -
Throws:
java.io.IOException
Method Detail

pushAuxiliaryDirectory

public void pushAuxiliaryDirectory(java.lang.String dir)
Add another subdirectory for any file-capture needs during the current serialization.

Parameters:
dir -

popAuxiliaryDirectory

public void popAuxiliaryDirectory()
Remove the top subdirectory.


getAuxiliaryDirectory

public java.io.File getAuxiliaryDirectory()
Return the current auxiliary directory for storing files associated with serialized objects.

Returns:
Auxillary directory.

snapshotAppendOnlyFile

public void snapshotAppendOnlyFile(java.io.File file)
                            throws java.io.IOException
Store a snapshot of an object's supporting file to the current auxiliary directory. Should only be used for files which are strictly appended-to, because it tries to use a "hard link" where possible (meaning that future edits to the original file's contents will also affect the snapshot). Remembers current file extent to allow a future restore to ignore subsequent appended data.

Parameters:
file -
Throws:
java.io.IOException


Copyright © 2003-2011 Internet Archive. All Rights Reserved.