Class ObjectPlusFilesInputStream
java.lang.Object
java.io.InputStream
java.io.ObjectInputStream
org.archive.io.ObjectPlusFilesInputStream
- All Implemented Interfaces:
Closeable,DataInput,ObjectInput,ObjectStreamConstants,AutoCloseable
Enhanced ObjectOutputStream with support for restoring
files that had been saved, in parallel with object
serialization.
- Author:
- gojomo
-
Nested Class Summary
Nested classes/interfaces inherited from class java.io.ObjectInputStream
ObjectInputStream.GetField -
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionObjectPlusFilesInputStream(InputStream in, File storeDir) Instantiate over the given stream and using the supplied auxiliary storage directory. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()In addition to default, do any registered cleanup tasks.Return the top auxiliary directory, from which saved files are restored.voidDiscard the top auxiliary directory.voidPush another default storage directory for use until popped.voidregisterFinishTask(Runnable task) Register a task to be done when the ObjectPlusFilesInputStream is closed.voidrestoreFile(File destination) Restore a file from storage, using the name and length info on the serialization stream and the file from the current auxiliary directory, to the given File.voidrestoreFileTo(File directory) Restore a file from storage, using the name and length info on the serialization stream and the file from the current auxiliary directory, to the given File.Methods inherited from class java.io.ObjectInputStream
available, defaultReadObject, enableResolveObject, read, read, readBoolean, readByte, readChar, readClassDescriptor, readDouble, readFields, readFloat, readFully, readFully, readInt, readLine, readLong, readObject, readObjectOverride, readShort, readStreamHeader, readUnshared, readUnsignedByte, readUnsignedShort, readUTF, registerValidation, resolveClass, resolveObject, resolveProxyClass, skipBytesMethods inherited from class java.io.InputStream
mark, markSupported, read, reset, skipMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.io.ObjectInput
read, skip
-
Field Details
-
auxiliaryDirectoryStack
-
postRestoreTasks
-
-
Constructor Details
-
ObjectPlusFilesInputStream
Instantiate over the given stream and using the supplied auxiliary storage directory.- Parameters:
in-storeDir-- Throws:
IOException
-
-
Method Details
-
pushAuxiliaryDirectory
Push another default storage directory for use until popped.- Parameters:
dir-
-
popAuxiliaryDirectory
public void popAuxiliaryDirectory()Discard the top auxiliary directory. -
getAuxiliaryDirectory
Return the top auxiliary directory, from which saved files are restored.- Returns:
- Auxillary directory.
-
restoreFile
Restore a file from storage, using the name and length info on the serialization stream and the file from the current auxiliary directory, to the given File.- Parameters:
destination-- Throws:
IOException
-
restoreFileTo
Restore a file from storage, using the name and length info on the serialization stream and the file from the current auxiliary directory, to the given File.- Parameters:
directory-- Throws:
IOException
-
registerFinishTask
Register a task to be done when the ObjectPlusFilesInputStream is closed.- Parameters:
task-
-
close
In addition to default, do any registered cleanup tasks.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceObjectInput- Overrides:
closein classObjectInputStream- Throws:
IOException- See Also:
-