org.at4j.zip.builder
Class ZipEntrySettings

java.lang.Object
  extended by org.at4j.zip.builder.ZipEntrySettings
All Implemented Interfaces:
Cloneable, ArchiveEntrySettings<ZipEntrySettings>

public class ZipEntrySettings
extends Object
implements ArchiveEntrySettings<ZipEntrySettings>

This object contains the settings for Zip entries. It is used by the ZipBuilder.

The properties and methods of this object works as is described in the ArchiveEntrySettings documentation.

Since:
1.0
Author:
Karl Gustafsson
See Also:
ZipBuilder

Constructor Summary
ZipEntrySettings()
          Create a new read/write Zip entry settings object.
ZipEntrySettings(ZipEntrySettings template)
          Create a new read/write Zip entry settings object using the supplied object as a template.
 
Method Summary
 ZipEntrySettings addExtraFieldFactory(ZipEntryExtraFieldFactory f)
          Add a ZipEntryExtraFieldFactory that creates a Zip entry extra field for each Zip entry configured by this settings object.
 ZipEntrySettings clone()
          Clone this settings object.
 ZipEntrySettings combineWith(ZipEntrySettings zes)
          Combine this settings object with the supplied object.
 String getComment()
          Get the Zip entry comment.
 ZipEntryCompressionMethod getCompressionMethod()
          Get the Zip entry compression method.
 ZipExternalFileAttributesFactory getExternalFileAttributesFactory()
          Get the external file attributes factory for this Zip entry.
 List<ZipEntryExtraFieldFactory> getExtraFieldFactories()
          Get the factories for creating extra fields for Zip entries.
 ZipEntrySettings setComment(String comment)
          Set the Zip entry comment.
 ZipEntrySettings setCompressionMethod(ZipEntryCompressionMethod cm)
          Set the compression method to use.
 ZipEntrySettings setExternalFileAttributesFactory(ZipExternalFileAttributesFactory f)
          Set a factory object for creating the external file attributes.
 ZipEntrySettings setReadOnly()
          Set this settings object to be read only to prevent accidental modification.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipEntrySettings

public ZipEntrySettings()
Create a new read/write Zip entry settings object.


ZipEntrySettings

public ZipEntrySettings(ZipEntrySettings template)
Create a new read/write Zip entry settings object using the supplied object as a template.

The properties from the template object is copied to this object.

Parameters:
template - The template object.
Since:
1.0.2
Method Detail

setReadOnly

public ZipEntrySettings setReadOnly()
Description copied from interface: ArchiveEntrySettings
Set this settings object to be read only to prevent accidental modification.

After calling this method, a call to any of the object's setter methods will result in an IllegalStateException.

This method can safely be called several times.

Specified by:
setReadOnly in interface ArchiveEntrySettings<ZipEntrySettings>
Returns:
this.

setCompressionMethod

public ZipEntrySettings setCompressionMethod(ZipEntryCompressionMethod cm)
                                      throws IllegalStateException
Set the compression method to use.

Parameters:
cm - The compression method to use, or null if this property should not be set in this settings object.
Returns:
this
Throws:
IllegalStateException - If this configuration object is read only.

getCompressionMethod

public ZipEntryCompressionMethod getCompressionMethod()
Get the Zip entry compression method.

Returns:
The Zip entry compression method, or null if it is not set.
See Also:
setCompressionMethod(ZipEntryCompressionMethod)

setExternalFileAttributesFactory

public ZipEntrySettings setExternalFileAttributesFactory(ZipExternalFileAttributesFactory f)
                                                  throws IllegalStateException
Set a factory object for creating the external file attributes.

Parameters:
f - The external file attributes factory, or null if that should not be set.
Returns:
this
Throws:
IllegalStateException - If this configuration object is read only.

getExternalFileAttributesFactory

public ZipExternalFileAttributesFactory getExternalFileAttributesFactory()
Get the external file attributes factory for this Zip entry.

Returns:
The external file attributes factory for this Zip entry, or null if it is not set.
See Also:
setExternalFileAttributesFactory(ZipExternalFileAttributesFactory)

setComment

public ZipEntrySettings setComment(String comment)
                            throws IllegalStateException
Set the Zip entry comment.

Parameters:
comment - The Zip entry comment or null if that should not be set.
Returns:
this
Throws:
IllegalStateException - If this configuration object is read only.

getComment

public String getComment()
Get the Zip entry comment.

Returns:
The Zip entry comment, or null if that is not set.
See Also:
setComment(String)

addExtraFieldFactory

public ZipEntrySettings addExtraFieldFactory(ZipEntryExtraFieldFactory f)
                                      throws IllegalStateException
Add a ZipEntryExtraFieldFactory that creates a Zip entry extra field for each Zip entry configured by this settings object.

If this object is combined with another settings object, that settings object's list of extra field factories is appended to this object's list.

Parameters:
f - The factory.
Returns:
this.
Throws:
IllegalStateException - If this configuration object is read only.

getExtraFieldFactories

public List<ZipEntryExtraFieldFactory> getExtraFieldFactories()
Get the factories for creating extra fields for Zip entries.

Returns:
The returned list is read only.
See Also:
addExtraFieldFactory(ZipEntryExtraFieldFactory)

combineWith

public ZipEntrySettings combineWith(ZipEntrySettings zes)
Combine this settings object with the supplied object. The two objects are combined by first cloning this object and then overwriting the properties in the new object with the properties that are set in the supplied settings object. In other words, the properties that are set in the supplied object take precedence over the properties in this object.

If a property is not set in either of this or the supplied object, it will be set to null in the new object.

The created object will have a list of extra field factories that first contains the factories of this object and then the factories of the supplied object.

None of this or the supplied settings objects are modified by this method.

Specified by:
combineWith in interface ArchiveEntrySettings<ZipEntrySettings>
Parameters:
zes - The settings object to combine this object's properties with.
Returns:
A new settings object containing the combined properties of this object and the supplied object.

clone

public ZipEntrySettings clone()
Description copied from interface: ArchiveEntrySettings
Clone this settings object.

Specified by:
clone in interface ArchiveEntrySettings<ZipEntrySettings>
Overrides:
clone in class Object
Returns:
A clone of this settings object.