org.at4j.archive.builder
Class AbstractStreamAddCapableArchiveBuilder<U extends AbstractStreamAddCapableArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>

java.lang.Object
  extended by org.at4j.archive.builder.AbstractArchiveBuilder<U,V>
      extended by org.at4j.archive.builder.AbstractStreamAddCapableArchiveBuilder<U,V>
Type Parameters:
U - The concrete type of this builder.
V - The type of settings object that this builder uses.
All Implemented Interfaces:
ArchiveBuilder<U,V>, StreamAddCapableArchiveBuilder<U,V>
Direct Known Subclasses:
TarBuilder, ZipBuilder

public abstract class AbstractStreamAddCapableArchiveBuilder<U extends AbstractStreamAddCapableArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
extends AbstractArchiveBuilder<U,V>
implements StreamAddCapableArchiveBuilder<U,V>

This abstract class extends the AbstractArchiveBuilder with the capability to

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
protected AbstractStreamAddCapableArchiveBuilder(V defaultFileEntrySettings, V defaultDirectoryEntrySettings)
          Create a new archive builder.
 
Method Summary
 U add(InputStream is, AbsoluteLocation entityLocation)
          Add a file entry containing all data that can be read from the supplied stream.
 U add(InputStream is, AbsoluteLocation entityLocation, V settings)
          Add a file entry containing all data that can be read from the supplied stream.
protected abstract  void addStreamCallback(AbsoluteLocation location, InputStream is, V effectiveSettings, Date lastModified)
          This callback method is implemented by subclasses to add a file entry containing data read from a stream to the archive.
 
Methods inherited from class org.at4j.archive.builder.AbstractArchiveBuilder
add, add, add, add, add, add, add, add, add, addDirectoryCallback, addFileCallback, addRecursively, addRecursively, addRecursively, addRecursively, addRecursively, addRule, addRules, assertNotClosed, getDefaultDefaultDirectoryEntrySettings, getDefaultDefaultFileEntrySettings, getDefaultDirectoryEntrySettings, getDefaultFileEntrySettings, getEffectiveSettingsForDirectory, getEffectiveSettingsForDirectory, getEffectiveSettingsForFile, getEffectiveSettingsForFile, getRules, getThis, removeRule, setDefaultDirectoryEntrySettings, setDefaultFileEntrySettings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.at4j.archive.builder.ArchiveBuilder
add, add, add, add, add, add, add, add, add, addRecursively, addRecursively, addRecursively, addRecursively, addRecursively, addRule, addRules, close, getDefaultDirectoryEntrySettings, getDefaultFileEntrySettings, getRules, isClosed, removeRule, setDefaultDirectoryEntrySettings, setDefaultFileEntrySettings
 

Constructor Detail

AbstractStreamAddCapableArchiveBuilder

protected AbstractStreamAddCapableArchiveBuilder(V defaultFileEntrySettings,
                                                 V defaultDirectoryEntrySettings)
Create a new archive builder.

Parameters:
defaultFileEntrySettings - Default settings for file entries.
defaultDirectoryEntrySettings - Default settings for directory entries.
Method Detail

addStreamCallback

protected abstract void addStreamCallback(AbsoluteLocation location,
                                          InputStream is,
                                          V effectiveSettings,
                                          Date lastModified)
                                   throws WrappedIOException,
                                          ArchiveEntryAddException
This callback method is implemented by subclasses to add a file entry containing data read from a stream to the archive. The entry is added at the end of the archive file.

Note: If this method throws an exception, it is the method's responsibility to make sure that the archive file is left in a consistent state. This should probably always mean that the failed entry is truncated from the archive file and that the current archive file pointer is restored to where it was before the method was called.

Parameters:
location - The location of the entry in the archive.
is - The stream to read file data from. The method should read up to the end of the stream, but not close the stream.
effectiveSettings - The effective settings for the entry.
lastModified - The time when the file was last modified.
Throws:
WrappedIOException - On I/O errors.
ArchiveEntryAddException - If the entry could not be added to the archive for some other reason than an I/O error.

add

public U add(InputStream is,
             AbsoluteLocation entityLocation,
             V settings)
                                                          throws IllegalStateException,
                                                                 WrappedIOException
Description copied from interface: StreamAddCapableArchiveBuilder
Add a file entry containing all data that can be read from the supplied stream. It is put at the specified location in the archive. The supplied settings is combined with the default file settings and the settings from the global rules that apply to the entry, if any.

Specified by:
add in interface StreamAddCapableArchiveBuilder<U extends AbstractStreamAddCapableArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
is - The stream to read file data from. The stream is not closed by this method.
entityLocation - The location of the file entry in the archive.
settings - The custom settings to use for this entry. The custom settings are combined with the default settings and global rule settings as described above. If this is set to null, only the default settings combined with settings from the global rules that apply to this file are used.
Returns:
this.
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.

add

public U add(InputStream is,
             AbsoluteLocation entityLocation)
                                                          throws IllegalStateException,
                                                                 WrappedIOException
Description copied from interface: StreamAddCapableArchiveBuilder
Add a file entry containing all data that can be read from the supplied stream. It is put at the specified location in the archive. The file is added with the default file settings, combined with settings from the global rules that apply to the file, if any.

Specified by:
add in interface StreamAddCapableArchiveBuilder<U extends AbstractStreamAddCapableArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
is - The stream to read file data from. The stream is not closed by this method.
entityLocation - The location of the file entry in the archive.
Returns:
this.
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.