org.at4j.archive.builder
Interface StreamAddCapableArchiveBuilder<U extends StreamAddCapableArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>

Type Parameters:
U - The archive builder implementation.
V - The type of settings used for the archive builder implementation.
All Superinterfaces:
ArchiveBuilder<U,V>
All Known Implementing Classes:
AbstractStreamAddCapableArchiveBuilder, TarBuilder, ZipBuilder

public interface StreamAddCapableArchiveBuilder<U extends StreamAddCapableArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
extends ArchiveBuilder<U,V>

This interface extends the ArchiveBuilder interface with the capability to add data from InputStream:s to the archive.

Since the size of data in a stream is not known beforehand, this requires that the archive builder has random access to the file it builds since it has to rewind it to write a file entry's size after adding the entry itself. This makes it impossible to write the archive to a stream.

Since:
1.0
Author:
Karl Gustafsson

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.
 
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
 

Method Detail

add

U add(InputStream is,
      AbsoluteLocation entityLocation)
                                                  throws IllegalStateException,
                                                         WrappedIOException,
                                                         ArchiveEntryAddException
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.

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.
ArchiveEntryAddException - If the file cannot be added, for some reason other than an I/O error.

add

U add(InputStream is,
      AbsoluteLocation entityLocation,
      V settings)
                                                  throws IllegalStateException,
                                                         WrappedIOException,
                                                         ArchiveEntryAddException
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.

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.
ArchiveEntryAddException - If the file cannot be added, for some reason other than an I/O error.