TrueZIP Kernel 7.0-rc2

de.schlichtherle.truezip.fs.archive
Class FsMultiplexedArchiveOutputShop<AE extends FsArchiveEntry>

java.lang.Object
  extended by de.schlichtherle.truezip.entry.DecoratingEntryContainer<E,O>
      extended by de.schlichtherle.truezip.socket.DecoratingOutputShop<AE,OutputShop<AE>>
          extended by de.schlichtherle.truezip.fs.archive.FsMultiplexedArchiveOutputShop<AE>
Type Parameters:
AE - The type of the archive entries.
All Implemented Interfaces:
EntryContainer<AE>, OutputService<AE>, OutputShop<AE>, Closeable, Iterable<AE>

@NotThreadSafe
@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public class FsMultiplexedArchiveOutputShop<AE extends FsArchiveEntry>
extends DecoratingOutputShop<AE,OutputShop<AE>>

Decorates an OutputShop in order to support a virtually unlimited number of entries which may be written concurrently while actually at most one entry is written concurrently to the output archive output. If there is more than one entry to be written concurrently, the additional entries are actually written to temp files and copied to the output output archive upon a call to their OutputStream.close() method. Note that this implies that the close() method may fail with an IOException.

Author:
Christian Schlichtherle

Nested Class Summary
private  class FsMultiplexedArchiveOutputShop.EntryOutputStream
          This entry output stream writes directly to the output archive.
private  class FsMultiplexedArchiveOutputShop.TempEntriesIterator
           
private  class FsMultiplexedArchiveOutputShop.TempEntryOutputStream
          This entry output stream writes the archive entry to a temporary file.
 
Field Summary
private  boolean busy
           
private  IOPool<?> pool
           
private  Map<String,FsMultiplexedArchiveOutputShop.TempEntryOutputStream> temps
          The map of temporary archive entries which have not yet been written to the output output archive.
 
Fields inherited from class de.schlichtherle.truezip.entry.DecoratingEntryContainer
delegate
 
Constructor Summary
FsMultiplexedArchiveOutputShop(OutputShop<AE> output, IOPool<?> pool)
          Constructs a new FsMultiplexedArchiveOutputShop.
 
Method Summary
 void close()
           
 AE getEntry(String name)
          Returns the entry for the given name or null if no entry with this name exists in this container.
 OutputSocket<? extends AE> getOutputSocket(AE entry)
          Returns an output socket for write access to the given entry.
 int getSize()
          Returns the number of entries in this container.
 boolean isBusy()
          Returns whether the container output archive is busy writing an archive entry or not.
 Iterator<AE> iterator()
          Returns a new iterator over all entries in this container.
private  void storeTemps()
           
 
Methods inherited from class de.schlichtherle.truezip.entry.DecoratingEntryContainer
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pool

private final IOPool<?> pool

temps

private final Map<String,FsMultiplexedArchiveOutputShop.TempEntryOutputStream> temps
The map of temporary archive entries which have not yet been written to the output output archive.


busy

private boolean busy
See Also:
isBusy()
Constructor Detail

FsMultiplexedArchiveOutputShop

public FsMultiplexedArchiveOutputShop(OutputShop<AE> output,
                                      IOPool<?> pool)
Constructs a new FsMultiplexedArchiveOutputShop.

Parameters:
output - the decorated output archive.
Throws:
NullPointerException - iff output is null.
Method Detail

getSize

public int getSize()
Description copied from interface: EntryContainer
Returns the number of entries in this container.

Specified by:
getSize in interface EntryContainer<AE extends FsArchiveEntry>
Overrides:
getSize in class DecoratingEntryContainer<AE extends FsArchiveEntry,OutputShop<AE extends FsArchiveEntry>>

iterator

public Iterator<AE> iterator()
Description copied from interface: EntryContainer
Returns a new iterator over all entries in this container.

First, the iteration must be consistent: Multiple iterators must iterate the same entries in the same order again unless the set of entries has changed.

Next, the iteration should also reflect the natural order of the entries in this container. For example, if this container represents an archive file, the iteration should reflect the natural order of the entries in the archive file.

Specified by:
iterator in interface EntryContainer<AE extends FsArchiveEntry>
Specified by:
iterator in interface Iterable<AE extends FsArchiveEntry>
Overrides:
iterator in class DecoratingEntryContainer<AE extends FsArchiveEntry,OutputShop<AE extends FsArchiveEntry>>
Returns:
A new non-null iterator over all entries in this container.

getEntry

@CheckForNull
public AE getEntry(String name)
Description copied from interface: EntryContainer
Returns the entry for the given name or null if no entry with this name exists in this container.

Specified by:
getEntry in interface EntryContainer<AE extends FsArchiveEntry>
Overrides:
getEntry in class DecoratingEntryContainer<AE extends FsArchiveEntry,OutputShop<AE extends FsArchiveEntry>>
Parameters:
name - an entry name.
Returns:
The entry for the given name or null if no entry with this name exists in this container.

getOutputSocket

public OutputSocket<? extends AE> getOutputSocket(AE entry)
Description copied from interface: OutputService
Returns an output socket for write access to the given entry.

Specified by:
getOutputSocket in interface OutputService<AE extends FsArchiveEntry>
Overrides:
getOutputSocket in class DecoratingOutputShop<AE extends FsArchiveEntry,OutputShop<AE extends FsArchiveEntry>>
Parameters:
entry - the non-null local target.
Returns:
An output socket for writing to the local target.

isBusy

public boolean isBusy()
Returns whether the container output archive is busy writing an archive entry or not.


close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class DecoratingOutputShop<AE extends FsArchiveEntry,OutputShop<AE extends FsArchiveEntry>>
Throws:
IOException

storeTemps

private void storeTemps()
                 throws IOException
Throws:
IOException

TrueZIP Kernel 7.0-rc2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.