org.at4j.tar.builder
Class TarEntrySettings

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

public class TarEntrySettings
extends Object
implements ArchiveEntrySettings<TarEntrySettings>

This object contains settings for a Tar entry that is to be added to a tar archive by a TarBuilder.

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

In addition to the regular properties of this object, it also has a Map<String, String> for storing named properties in. Those properties are currently not used for anything, but they may be used by clients to pass data to, for instance, custom PaxVariableProvider implementations. When this settings object is combined with another settings object, the properties of this object is copied to the new object, and then the properties of the other object is copied to the new object. If both this and the other object contains properties with the same names, the properties of the other object takes precedence.

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
TarEntrySettings()
           
 
Method Summary
 TarEntrySettings addProperty(String name, String value)
          Add a custom, named property.
 TarEntrySettings clone()
          Clone this settings object.
 TarEntrySettings combineWith(TarEntrySettings settings)
          Create a new settings object that contains this object's settings combined with the settings from the supplied object.
 UnixEntityMode getEntityMode()
          Get the Unix entity permissions mode.
 Integer getOwnerGid()
          Get the owner group id.
 String getOwnerGroupName()
          Get the owner group name.
 Integer getOwnerUid()
          Get the owner user id.
 String getOwnerUserName()
          Get the owner user name.
 Map<String,String> getProperties()
          Get the properties for this settings object.
 String removeProperty(String name)
          Remove a named property.
 TarEntrySettings setEntityMode(UnixEntityMode mode)
          Set the entry's Unix entity permission mode.
 TarEntrySettings setOwnerGid(Integer gid)
          Set the owner group id.
 TarEntrySettings setOwnerGroupName(String n)
          Set the owner group name.
 TarEntrySettings setOwnerUid(Integer uid)
          Set the owner user id.
 TarEntrySettings setOwnerUserName(String n)
          Set the owner user name.
 TarEntrySettings 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

TarEntrySettings

public TarEntrySettings()
Method Detail

setReadOnly

public TarEntrySettings 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<TarEntrySettings>
Returns:
this.

setEntityMode

public TarEntrySettings setEntityMode(UnixEntityMode mode)
                               throws IllegalStateException
Set the entry's Unix entity permission mode.

Parameters:
mode - The permission mode, or null if this property should not be set.
Returns:
this
Throws:
IllegalStateException - If this object has been set read only.

getEntityMode

public UnixEntityMode getEntityMode()
Get the Unix entity permissions mode.

Returns:
The Unix entity permissions mode, or null if this property is not set.
See Also:
setEntityMode(UnixEntityMode)

setOwnerUid

public TarEntrySettings setOwnerUid(Integer uid)
                             throws IllegalArgumentException,
                                    IllegalStateException
Set the owner user id.

Parameters:
uid - The owner user id. This must be a value between 0 and 2097151 (inclusive), or null if this property should not be set.
Returns:
this
Throws:
IllegalArgumentException - If the UID is not in the permitted range.
IllegalStateException - If this object has been set read only.

getOwnerUid

public Integer getOwnerUid()
Get the owner user id.

Returns:
The owner user id, or null if this property is not set.
See Also:
setOwnerUid(Integer)

setOwnerGid

public TarEntrySettings setOwnerGid(Integer gid)
                             throws IllegalArgumentException,
                                    IllegalStateException
Set the owner group id.

Parameters:
gid - The owner group id. This must be a value between 0 and 2097151 (inclusive), or null if this property should not be set.
Returns:
this
Throws:
IllegalArgumentException - If the GID is not in the permitted range.
IllegalStateException - If this object has been set read only.

getOwnerGid

public Integer getOwnerGid()
Get the owner group id.

Returns:
The owner group id, or null if this property is not set.
See Also:
setOwnerGid(Integer)

setOwnerUserName

public TarEntrySettings setOwnerUserName(String n)
                                  throws IllegalStateException
Set the owner user name.

Parameters:
n - The owner user name, or null if this property should not be set.
Returns:
this
Throws:
IllegalStateException - If this object has been set read only.

getOwnerUserName

public String getOwnerUserName()
Get the owner user name.

Returns:
The owner user name, or null if this property is not set.
See Also:
setOwnerUserName(String)

setOwnerGroupName

public TarEntrySettings setOwnerGroupName(String n)
                                   throws IllegalStateException
Set the owner group name.

Parameters:
n - The owner group name, or null if this property should not be set.
Returns:
this
Throws:
IllegalStateException - If this object has been set read only.

getOwnerGroupName

public String getOwnerGroupName()
Get the owner group name.

Returns:
The owner group name, or null if this property is not set.
See Also:
setOwnerGroupName(String)

addProperty

public TarEntrySettings addProperty(String name,
                                    String value)
                             throws IllegalStateException
Add a custom, named property.

Parameters:
name - The name of the property.
value - The property value.
Returns:
this
Throws:
IllegalStateException - If this object has been set read only.

removeProperty

public String removeProperty(String name)
                      throws IllegalStateException
Remove a named property.

Parameters:
name - The name of the property to remove.
Returns:
The property's value, or null if there was no property with the supplied name (or if it had the value null).
Throws:
IllegalStateException - If this object has been set read only.

getProperties

public Map<String,String> getProperties()
Get the properties for this settings object. The returned map is read only.

Returns:
Properties for this settings object, read only.

combineWith

public TarEntrySettings combineWith(TarEntrySettings settings)
Description copied from interface: ArchiveEntrySettings
Create a new settings object that contains this object's settings combined with the settings from the supplied object.

The returned object is created by first cloning this object, and then by replacing all the property values for properties that are set in the supplied object with the values from that object. In other words, properties from the supplied object take precedence over properties from this object.

Specified by:
combineWith in interface ArchiveEntrySettings<TarEntrySettings>
Parameters:
settings - The other settings object.
Returns:
A new settings object with the settings from this object combined with the settings from the supplied object.

clone

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

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