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

java.lang.Object
  extended by org.at4j.archive.builder.AbstractArchiveBuilder<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>
Direct Known Subclasses:
AbstractStreamAddCapableArchiveBuilder, TarStreamBuilder

public abstract class AbstractArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
extends Object
implements ArchiveBuilder<U,V>

This is an abstract base implementation of an archive builder that implements most of the methods in the ArchiveBuilder interface. It can be extended by objects that build specific types of archives.

Since:
1.0
Author:
Karl Gustafsson
See Also:
ArchiveBuilder

Constructor Summary
protected AbstractArchiveBuilder(V defaultFileEntrySettings, V defaultDirectoryEntrySettings)
          Create a new archive builder.
 
Method Summary
 U add(DirectoryView d)
          Add a directory entry to the archive's root directory.
 U add(DirectoryView d, AbsoluteLocation parentDirLocation)
          Add the directory entry to the specified parent directory in the archive.
 U add(DirectoryView d, AbsoluteLocation parentDirLocation, V settings)
          Add a directory entry to the specified parent directory in the archive.
 U add(File f)
          Add a file or directory entry to the archive's root directory.
 U add(File f, AbsoluteLocation parentDirLocation)
          Add a file or directory entry to the specified parent directory in the archive.
 U add(File f, AbsoluteLocation parentDirLocation, V settings)
          Add a file or directory entry to the specified parent directory in the archive.
 U add(NamedReadableFile f)
          Add a file entry to the archive's root directory.
 U add(NamedReadableFile f, AbsoluteLocation parentDirLocation)
          Add a file entry to the specified parent directory in the archive.
 U add(NamedReadableFile f, AbsoluteLocation parentDirLocation, V settings)
          Add a file entry to the specified parent directory in the archive.
protected abstract  void addDirectoryCallback(AbsoluteLocation location, Object d, V effectiveSettings, Date lastModified)
          This callback method is implemented by subclasses to add a directory entry to the archive.
protected abstract  void addFileCallback(AbsoluteLocation location, ReadableFile f, V effectiveSettings, Date lastModified)
          This callback method is implemented by subclasses to add a file entry to the archive.
 U addRecursively(DirectoryView d, AbsoluteLocation rootDirLocation)
          Add the supplied directory recursively to the specified position in the archive.
 U addRecursively(DirectoryView d, AbsoluteLocation rootDirLocation, Filter<? super EntityView> filter)
          Add the supplied directory recursively to the specified position in the archive.
 U addRecursively(DirectoryView d, AbsoluteLocation rootDirLocation, Filter<? super EntityView> filter, ArchiveEntrySettingsRule<? extends V>... rules)
          Add the supplied directory recursively to the specified position in the archive.
 U addRecursively(File f, AbsoluteLocation rootDirLocation)
          Add the supplied file or directory recursively to the specified position in the archive.
 U addRecursively(File f, AbsoluteLocation rootDirLocation, ArchiveEntrySettingsRule<? extends V>... rules)
          Add the supplied file or directory recursively to the specified position in the archive.
 U addRule(ArchiveEntrySettingsRule<? extends V> rule)
          Append an entry settings rule to the end of the rule list.
 U addRules(Collection<? extends ArchiveEntrySettingsRule<? extends V>> rules)
          Append a list of entry settings rules to the end of the rule list.
protected abstract  void assertNotClosed()
          Subclasses implement this method to throw an IllegalStateException if it is called after the archive builder has been closed.
protected abstract  V getDefaultDefaultDirectoryEntrySettings()
          Subclasses implement this method to return a default settings object for directory entries if the client does not specify one when creating the archive builder object.
protected abstract  V getDefaultDefaultFileEntrySettings()
          Subclasses implement this method to return a default settings object for file entries if the client does not specify one when creating the archive builder object.
 V getDefaultDirectoryEntrySettings()
          Get (a copy of) the default settings for the directory entries added to this archive builder.
 V getDefaultFileEntrySettings()
          Get (a copy of) the default settings for the file entries added to this archive builder.
protected  V getEffectiveSettingsForDirectory(Object entity, AbsoluteLocation location, ArchiveEntrySettingsRule<? extends V>[] rules)
          Get the effective settings for a directory entry that is about to be added to the archive.
protected  V getEffectiveSettingsForDirectory(Object entity, AbsoluteLocation location, V entrySettings)
          Get the effective settings for a directory entry that is about to be added to the archive.
protected  V getEffectiveSettingsForFile(Object entity, AbsoluteLocation location, ArchiveEntrySettingsRule<? extends V>[] rules)
          Get the effective settings for a file entry that is about to be added to the archive.
protected  V getEffectiveSettingsForFile(Object entity, AbsoluteLocation location, V entrySettings)
          Get the effective settings for a file entry that is about to be added to the archive.
 List<ArchiveEntrySettingsRule<? extends V>> getRules()
          Get a copy of the list of rules that are used to determine the entry settings for entries added to this archive.
protected  U getThis()
          Get this object cast to its actual type.
 boolean removeRule(ArchiveEntrySettingsRule<? extends V> rule)
          Remove an entry settings rule from the rule list.
 U setDefaultDirectoryEntrySettings(V s)
          Set the default settings for directory entries that are added to the archive from now on.
 U setDefaultFileEntrySettings(V s)
          Set the default settings for file entries that are added to the archive from now on.
 
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
close, isClosed
 

Constructor Detail

AbstractArchiveBuilder

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

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

assertNotClosed

protected abstract void assertNotClosed()
                                 throws IllegalStateException
Subclasses implement this method to throw an IllegalStateException if it is called after the archive builder has been closed.

Throws:
IllegalStateException - If the archive builder has been closed.

getDefaultDefaultFileEntrySettings

protected abstract V getDefaultDefaultFileEntrySettings()
Subclasses implement this method to return a default settings object for file entries if the client does not specify one when creating the archive builder object.

Returns:
The default settings object for file entries if none is specified by the client.

getDefaultDefaultDirectoryEntrySettings

protected abstract V getDefaultDefaultDirectoryEntrySettings()
Subclasses implement this method to return a default settings object for directory entries if the client does not specify one when creating the archive builder object.

Returns:
The default settings object for directory entries if none is specified by the client.

getThis

protected U getThis()
Get this object cast to its actual type.

Returns:
this.

setDefaultFileEntrySettings

public U setDefaultFileEntrySettings(V s)
                                                                  throws IllegalStateException
Description copied from interface: ArchiveBuilder
Set the default settings for file entries that are added to the archive from now on.

The supplied object is combined with the default default file entry settings object using the ArchiveEntrySettings.combineWith(ArchiveEntrySettings) method. This means that the client does not have to specify values for the properties where the default values should be used.

The actual settings that are used for entries that are added to the archive is determined using the algorithm described in the interface documentation above.

Specified by:
setDefaultFileEntrySettings in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
s - The new default file entry settings.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
See Also:
ArchiveBuilder.setDefaultDirectoryEntrySettings(ArchiveEntrySettings)

getDefaultFileEntrySettings

public V getDefaultFileEntrySettings()
                                                              throws IllegalStateException
Description copied from interface: ArchiveBuilder
Get (a copy of) the default settings for the file entries added to this archive builder.

The actual settings that are used for entries that are added to the archive is determined using the algorithm described in the interface documentation above.

Specified by:
getDefaultFileEntrySettings in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Returns:
The default settings used for file entries added to the archive builder.
Throws:
IllegalStateException - If the archive builder is closed.
See Also:
ArchiveBuilder.getDefaultDirectoryEntrySettings(), ArchiveBuilder.setDefaultFileEntrySettings(ArchiveEntrySettings)

setDefaultDirectoryEntrySettings

public U setDefaultDirectoryEntrySettings(V s)
                                                                       throws IllegalStateException
Description copied from interface: ArchiveBuilder
Set the default settings for directory entries that are added to the archive from now on.

The supplied object is combined with the default default directory entry settings object using the ArchiveEntrySettings.combineWith(ArchiveEntrySettings) method. This means that the client does not have to specify values for the properties where the default values should be used.

The actual settings that are used for entries that are added to the archive is determined using the algorithm described in the interface documentation above.

Specified by:
setDefaultDirectoryEntrySettings in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
s - The new default directory entry settings.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
See Also:
ArchiveBuilder.setDefaultFileEntrySettings(ArchiveEntrySettings)

getDefaultDirectoryEntrySettings

public V getDefaultDirectoryEntrySettings()
                                                                   throws IllegalStateException
Description copied from interface: ArchiveBuilder
Get (a copy of) the default settings for the directory entries added to this archive builder.

The actual settings that are used for entries that are added to the archive is determined using the algorithm described in the interface documentation above.

Specified by:
getDefaultDirectoryEntrySettings in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Returns:
The default settings used for directory entries added to the archive builder
Throws:
IllegalStateException - If the archive builder is closed.
See Also:
ArchiveBuilder.getDefaultFileEntrySettings(), ArchiveBuilder.setDefaultDirectoryEntrySettings(ArchiveEntrySettings)

addRule

public U addRule(ArchiveEntrySettingsRule<? extends V> rule)
                                              throws IllegalStateException
Description copied from interface: ArchiveBuilder
Append an entry settings rule to the end of the rule list. This rule will be used for entries added to the archive after this method has been called.

The rule list is used when determining the settings that an entry added to the archive should have. The actual settings that are used for entries that are added to the archive is determined using the algorithm described in the interface documentation above.

Specified by:
addRule in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
rule - The rule to append to the end of the rule list.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
See Also:
ArchiveBuilder.addRules(Collection), ArchiveBuilder.removeRule(ArchiveEntrySettingsRule), ArchiveBuilder.getRules()

addRules

public U addRules(Collection<? extends ArchiveEntrySettingsRule<? extends V>> rules)
                                               throws IllegalStateException
Description copied from interface: ArchiveBuilder
Append a list of entry settings rules to the end of the rule list. The rules are appended in the order that they are returned when iterating over the supplied collection.

The rules will be used for entries added to the archive after this method has been called.

The rule list is used when determining the settings that an entry added to the archive should have. The actual settings that are used for entries that are added to the archive is determined using the algorithm described in the interface documentation above.

Specified by:
addRules in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
rules - The rules to append to the end of the rule list.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
See Also:
ArchiveBuilder.addRule(ArchiveEntrySettingsRule), ArchiveBuilder.removeRule(ArchiveEntrySettingsRule), ArchiveBuilder.getRules()

removeRule

public boolean removeRule(ArchiveEntrySettingsRule<? extends V> rule)
                   throws IllegalStateException
Description copied from interface: ArchiveBuilder
Remove an entry settings rule from the rule list. This rule will not be used for the entries added to the archive after this method has been called.

The rule list is used when determining the settings that an entry added to the archive should have. The actual settings that are used for entries that are added to the archive is determined using the algorithm described in the interface documentation above.

Specified by:
removeRule in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
rule - The rule to remove from the list.
Returns:
true if a rule was removed from the list, false if not. If no rule was removed from the list, that means that the supplied rule was not present in the list to begin with.
Throws:
IllegalStateException - If the archive builder is closed.
See Also:
ArchiveBuilder.addRule(ArchiveEntrySettingsRule), ArchiveBuilder.getRules()

getRules

public List<ArchiveEntrySettingsRule<? extends V>> getRules()
                                                                                     throws IllegalStateException
Description copied from interface: ArchiveBuilder
Get a copy of the list of rules that are used to determine the entry settings for entries added to this archive.

The actual settings that are used for entries that are added to the archive is determined using the algorithm described in the interface documentation above.

Specified by:
getRules in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Returns:
A copy of the list of rules that are used to determine the entry settings for entries added to this archive.
Throws:
IllegalStateException - If the archive builder is closed.
See Also:
ArchiveBuilder.addRule(ArchiveEntrySettingsRule), ArchiveBuilder.removeRule(ArchiveEntrySettingsRule)

getEffectiveSettingsForFile

protected V getEffectiveSettingsForFile(Object entity,
                                        AbsoluteLocation location,
                                        V entrySettings)
Get the effective settings for a file entry that is about to be added to the archive.

The effective settings are created by combining first the default file entry settings with all global rules that apply to the file entry, and then by combining the resulting settings with the supplied settings object (if the supplied object is not null).

Parameters:
entity - The file entity to add to the archive. This may be a ReadableFile or an InputStream.
location - The absolute location where the entry should be put in the archive.
entrySettings - The settings that the default settings and settings from global rules should be combined with. This may be null.
Returns:
The effective settings.

getEffectiveSettingsForFile

protected V getEffectiveSettingsForFile(Object entity,
                                        AbsoluteLocation location,
                                        ArchiveEntrySettingsRule<? extends V>[] rules)
Get the effective settings for a file entry that is about to be added to the archive.

The effective settings are created by combining first the default file entry settings with all global rules that apply to the file entry, and then by combining the resulting settings with the settings objects for all of the supplied rules that apply to the file entry.

Parameters:
entity - The file entity to add to the archive. This may be a ReadableFile or an InputStream.
location - The absolute location where the entry should be put in the archive.
rules - The rules to evaluate for the file entry. This may be null.
Returns:
The effective settings

getEffectiveSettingsForDirectory

protected V getEffectiveSettingsForDirectory(Object entity,
                                             AbsoluteLocation location,
                                             V entrySettings)
Get the effective settings for a directory entry that is about to be added to the archive.

The effective settings are created by combining first the default directory entry settings with all global rules that apply to the directory entry, and then by combining the resulting settings with the supplied settings object (if the supplied object is not null).

Parameters:
entity - The directory entity to add to the archive. This may be a DirectoryView or a File.
location - The absolute location where the entry should be put in the archive.
entrySettings - The settings that the default settings and settings from global rules should be combined with. This may be null.
Returns:
The effective settings.

getEffectiveSettingsForDirectory

protected V getEffectiveSettingsForDirectory(Object entity,
                                             AbsoluteLocation location,
                                             ArchiveEntrySettingsRule<? extends V>[] rules)
Get the effective settings for a directory entry that is about to be added to the archive.

The effective settings are created by combining first the default directory entry settings with all global rules that apply to the directory entry, and then by combining the resulting settings with the settings objects for all of the supplied rules that apply to the directory entry.

Parameters:
entity - The directory entity to add to the archive. This may be a DirectoryView or a File.
location - The absolute location where the entry should be put in the archive.
rules - The rules to evaluate for the directory entry. This may be null.
Returns:
The effective settings

addDirectoryCallback

protected abstract void addDirectoryCallback(AbsoluteLocation location,
                                             Object d,
                                             V effectiveSettings,
                                             Date lastModified)
                                      throws WrappedIOException,
                                             ArchiveEntryAddException
This callback method is implemented by subclasses to add a directory entry 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.
d - The directory. This may be a DirectoryView or a File.
effectiveSettings - The effective settings for the entry.
lastModified - The time when the directory 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.

addFileCallback

protected abstract void addFileCallback(AbsoluteLocation location,
                                        ReadableFile f,
                                        V effectiveSettings,
                                        Date lastModified)
                                 throws WrappedIOException,
                                        ArchiveEntryAddException
This callback method is implemented by subclasses to add a file entry 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.
f - The file.
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(NamedReadableFile f)
                                          throws IllegalStateException,
                                                 WrappedIOException
Description copied from interface: ArchiveBuilder
Add a file entry to the archive's root directory. The file is added with the default file settings, combined with settings from the global rules that apply to the file, if any.

If the file is in a locking FileSystem, it is temporarily locked for reading by this method.

The name of the added file entry will be the name of the added file. If you want another name, use a NamedReadableFileAdapter.

Specified by:
add in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
f - The file to add to the archive.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.

add

public U add(NamedReadableFile f,
             AbsoluteLocation parentDirLocation)
                                          throws IllegalStateException,
                                                 WrappedIOException
Description copied from interface: ArchiveBuilder
Add a file entry to the specified parent directory 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.

If the file is in a locking FileSystem, it is temporarily locked for reading by this method.

The name of the added file entry will be the name of the added file. If you want another name, use a NamedReadableFileAdapter.

Specified by:
add in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
f - The file to add to the archive.
parentDirLocation - The location of the parent directory. It is not required that this directory is present in the archive.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.

add

public U add(NamedReadableFile f,
             AbsoluteLocation parentDirLocation,
             V settings)
                                          throws IllegalStateException,
                                                 WrappedIOException
Description copied from interface: ArchiveBuilder
Add a file entry to the specified parent directory in the archive. The supplied settings is combined with the default file settings and the settings from the global rules that apply to the file, if any.

If the file is in a locking FileSystem, it is temporarily locked for reading by this method.

The name of the added file entry will be the name of the added file. If you want another name, use a NamedReadableFileAdapter.

Specified by:
add in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
f - The file to add to the archive.
parentDirLocation - The location of the parent directory. It is not required that this directory is present in the archive.
settings - The custom settings to use for this file. 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 file 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(DirectoryView d)
                                          throws IllegalStateException,
                                                 WrappedIOException
Description copied from interface: ArchiveBuilder
Add a directory entry to the archive's root directory. The directory is added with the default directory settings, combined with settings from the global rules that apply to the directory, if any.

If the directory is in a locking FileSystem, it is temporarily locked for reading by this method.

The name of the directory entry will be the name of the added directory.

Specified by:
add in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
d - The directory to add to the archive.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.

add

public U add(DirectoryView d,
             AbsoluteLocation parentDirLocation)
                                          throws IllegalStateException,
                                                 WrappedIOException
Description copied from interface: ArchiveBuilder
Add the directory entry to the specified parent directory in the archive. The directory is added with the default directory settings, combined with settings from the global rules that apply to the directory, if any.

If the directory is in a locking FileSystem, it is temporarily locked for reading by this method.

The name of the directory entry will be the name of the added directory.

Specified by:
add in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
d - The directory to add to the archive.
parentDirLocation - The location of the parent directory. It is not required that this directory is present in the archive.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.

add

public U add(DirectoryView d,
             AbsoluteLocation parentDirLocation,
             V settings)
                                          throws IllegalStateException,
                                                 WrappedIOException
Description copied from interface: ArchiveBuilder
Add a directory entry to the specified parent directory in the archive. The supplied settings is combined with the default directory settings and the settings from the global rules that apply to the directory, if any.

If the directory is in a locking FileSystem, it is temporarily locked for reading by this method.

The name of the directory entry will be the name of the added directory.

Specified by:
add in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
d - The directory to add to the archive.
parentDirLocation - The location of the parent directory. It is not required that this directory is present in the archive.
settings - The custom settings to use for this directory. 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 directory settings combined with settings from the global rules that apply to this directory are used.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.

add

public U add(File f)
                                          throws IllegalStateException,
                                                 WrappedIOException,
                                                 EntityNotFoundException
Description copied from interface: ArchiveBuilder
Add a file or directory entry to the archive's root directory. The entry is added with the default settings for its entity type (file or directory), combined with settings from the global rules that apply to the entry, if any.

The name of the file entry will be the name of the added file. If you want another name for the entry, wrap the file in a FileReadableFile and then in a NamedReadableFileAdapter.

Specified by:
add in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
f - The file or directory to add to the archive.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.
EntityNotFoundException - If the File object does not reference an existing file or directory.

add

public U add(File f,
             AbsoluteLocation parentDirLocation)
                                          throws IllegalStateException,
                                                 WrappedIOException,
                                                 EntityNotFoundException
Description copied from interface: ArchiveBuilder
Add a file or directory entry to the specified parent directory in the archive. The entry is added with the default settings for its entity type (file or directory), combined with settings from the global rules that apply to the entry, if any.

The name of the file entry will be the name of the added file. If you want another name for the entry, wrap the file in a FileReadableFile and then in a NamedReadableFileAdapter.

Specified by:
add in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
f - The file or directory to add to the archive.
parentDirLocation - The location of the parent directory. It is not required that this directory is present in the archive.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.
EntityNotFoundException - If the File object does not reference an existing file or directory.

add

public U add(File f,
             AbsoluteLocation parentDirLocation,
             V settings)
                                          throws IllegalStateException,
                                                 WrappedIOException,
                                                 EntityNotFoundException
Description copied from interface: ArchiveBuilder
Add a file or directory entry to the specified parent directory in the archive. The supplied settings is combined with the default settings for its entity type (file or directory) and the settings from the global rules that apply to the entry, if any.

The name of the file entry will be the name of the added file. If you want another name for the entry, wrap the file in a FileReadableFile and then in a NamedReadableFileAdapter.

Specified by:
add in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
f - The file or directory to add to the archive.
parentDirLocation - The location of the parent directory. It is not required that this directory is present 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 entry are used.
Returns:
this
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.
EntityNotFoundException - If the File object does not reference an existing file or directory.

addRecursively

public U addRecursively(DirectoryView d,
                        AbsoluteLocation rootDirLocation)
                                                     throws IllegalStateException,
                                                            WrappedIOException
Description copied from interface: ArchiveBuilder
Add the supplied directory recursively to the specified position in the archive. Each entry is added with the default settings for its entity type (file or directory), combined with settings from the global rules that apply to the entry, if any.

If the added directory is in a locking FileSystem, all added entities are temporarily locked by this method as they are being added to the archive.

If an error occurs when adding an entry, the recursive add operation terminates and the rest of the entries that were to be added are ignored. The archive file will then contain all entries that had been added before the error occurred.

Specified by:
addRecursively in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
d - The directory to add recursively to the archive.
rootDirLocation - The location where to put the root of the added directory tree. If this is the root directory (/), the contents of d are added directly to the archive's root directory.
Returns:
this.
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.

addRecursively

public U addRecursively(DirectoryView d,
                        AbsoluteLocation rootDirLocation,
                        Filter<? super EntityView> filter)
                                                     throws IllegalStateException,
                                                            WrappedIOException
Description copied from interface: ArchiveBuilder
Add the supplied directory recursively to the specified position in the archive. An entity is only added if it passes the supplied filter. Each added entry is added with the default settings for its entity type (file or directory), combined with settings from the global rules that apply to the entry, if any.

If the added directory is in a locking FileSystem, all added entities are temporarily locked by this method as they are being added to the archive.

If an error occurs when adding an entry, the recursive add operation terminates and the rest of the entries that were to be added are ignored. The archive file will then contain all entries that had been added before the error occurred.

Specified by:
addRecursively in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
d - The directory to add recursively to the archive.
rootDirLocation - The location where to put the root of the added directory tree. If this is the root directory (/), the contents of d are added directly to the archive's root directory.
filter - The filter that is used to decide if an entity is to be added to the archive or not. This filter does not affect how the method traverses the directory tree in any way.
Returns:
this.
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.

addRecursively

public U addRecursively(File f,
                        AbsoluteLocation rootDirLocation)
                                                     throws IllegalStateException,
                                                            WrappedIOException,
                                                            EntityNotFoundException
Description copied from interface: ArchiveBuilder
Add the supplied file or directory recursively to the specified position in the archive. Each entry is added with the default settings for its entity type (file or directory), combined with settings from the global rules that apply to the entry, if any.

If an error occurs when adding an entry, the recursive add operation terminates and the rest of the entries that were to be added are ignored. The archive file will then contain all entries that had been added before the error occurred.

Specified by:
addRecursively in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
f - The file or directory to add recursively to the archive.
rootDirLocation - The location where to put the root of the added directory tree. If this is the root directory (/), the contents of f (if it is a directory) are added directly to the archive's root directory.
Returns:
this.
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.
EntityNotFoundException - If the File object does not reference an existing file or directory.

addRecursively

public U addRecursively(DirectoryView d,
                        AbsoluteLocation rootDirLocation,
                        Filter<? super EntityView> filter,
                        ArchiveEntrySettingsRule<? extends V>... rules)
                                                     throws IllegalStateException,
                                                            WrappedIOException
Description copied from interface: ArchiveBuilder
Add the supplied directory recursively to the specified position in the archive. An entity is only added if it passes the supplied filter. Each added entry is added with the default settings for its entity type (file or directory), combined with settings from the global rules that apply to the entry, combined with the settings from the supplied rules that apply to the entry.

If the added directory is in a locking FileSystem, all added entities are temporarily locked by this method as they are being added to the archive.

If an error occurs when adding an entry, the recursive add operation terminates and the rest of the entries that were to be added are ignored. The archive file will then contain all entries that had been added before the error occurred.

Specified by:
addRecursively in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
d - The directory to add recursively to the archive.
rootDirLocation - The location where to put the root of the added directory tree. If this is the root directory (/), the contents of d are added directly to the archive's root directory.
filter - The filter that is used to decide if an entity is to be added to the archive or not. This filter does not affect how the method traverses the directory tree in any way.
rules - Settings rules for this add operation.
Returns:
this.
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.

addRecursively

public U addRecursively(File f,
                        AbsoluteLocation rootDirLocation,
                        ArchiveEntrySettingsRule<? extends V>... rules)
                                                     throws IllegalStateException,
                                                            WrappedIOException,
                                                            EntityNotFoundException
Description copied from interface: ArchiveBuilder
Add the supplied file or directory recursively to the specified position in the archive. Each entry is added with the default settings for its entity type (file or directory), combined with settings from the global rules that apply to the entry, combined with settings from the supplied rules that apply to the entry.

If an error occurs when adding an entry, the recursive add operation terminates and the rest of the entries that were to be added are ignored. The archive file will then contain all entries that had been added before the error occurred.

Specified by:
addRecursively in interface ArchiveBuilder<U extends AbstractArchiveBuilder<U,V>,V extends ArchiveEntrySettings<V>>
Parameters:
f - The file or directory to add recursively to the archive.
rootDirLocation - The location where to put the root of the added directory tree. If this is the root directory (/), the contents of f (if it is a directory) are added directly to the archive's root directory.
rules - Settings rules for this add operation.
Returns:
this.
Throws:
IllegalStateException - If the archive builder is closed.
WrappedIOException - On I/O errors.
EntityNotFoundException - If the File object does not reference an existing file or directory.