TrueZIP 6.8

de.schlichtherle.io.archive.spi
Interface ArchiveEntry

All Known Implementing Classes:
JarEntry, RfsEntry, TarEntry, Zip32Entry, ZipEntry

public interface ArchiveEntry

A simple interface for entries in an archive. Drivers need to implement this interface in order to allow TrueZIP to read and write entries for the supported archive types.

Implementations do not need to be thread safe: Multithreading is addressed in the package de.schlichtherle.io.

Requirements for Archive Entry Names

TrueZIP 6 has the following requirements for archive entry names:

  1. An entry name is a list of directory or file names whichs elements are separated by single separators (SEPARATOR).
  2. An empty string (""), a dot ("."), or a dot-dot ("..") is not permissible as a directory or file name.
  3. If an entry name starts with a separator, it's said to be absolute. Absolute entries are not accessible by client applications, but are retained if the archive is updated.
  4. If an entry name ends with a separator, it denotes a directory and vice versa.
For example, "foo/bar" denotes a valid entry name for a file, but "./abc/../foo/./def/./../bar/." would not, although both refer to the same entry.

As another example, "dir/" denotes a valid entry name for a directory, but "dir" would not.

If an archive driver is to be written for an archive type which does not support these requirements, an adapter for the entry name must be implemented.

For example, the ZIP and TAR file formats conform to all but the second requirement. So the driver implementations for the archive types use Paths.normalize(String, char) to remove any redundant elements from the path.

It's hoped that these requirements can be relaxed, but this would imply some minor changes in the service provider interface for archive drivers, so it's not going to happen in this major version number.

Since:
TrueZIP 6.0
Version:
$Id: ArchiveEntry.java,v 1.5 2010/08/22 13:08:39 christian_schlichtherle Exp $
Author:
Christian Schlichtherle
See Also:
A utility method to remove empty and dot and dot-dot elements from an archive entry name

Field Summary
static String SEPARATOR
          The entry name separator as a string.
static char SEPARATOR_CHAR
          The entry name separator as a character.
static byte UNKNOWN
          The unknown value for numeric properties.
 
Method Summary
 Icon getClosedIcon()
          Returns the icon that FileSystemView and FileTreeCellRenderer should display for this entry if it is closed/collapsed in the view.
 ArchiveEntryMetaData getMetaData()
          Returns the meta data for this archive entry.
 String getName()
          Returns the archive entry name.
 Icon getOpenIcon()
          Returns the icon that FileTreeCellRenderer should display for this entry if it is open/expanded in the view.
 long getSize()
          Returns the (uncompressed) size of the archive entry in bytes, or UNKNOWN if not specified.
 long getTime()
          Returns the last modification time of this archive entry since the epoch, or UNKNOWN if not specified.
 boolean isDirectory()
          Returns true if and only if this entry represents a directory.
 void setMetaData(ArchiveEntryMetaData metaData)
          Sets the meta data for this archive entry.
 void setTime(long time)
          Sets the last modification time of this archive entry.
 

Field Detail

SEPARATOR

static final String SEPARATOR
The entry name separator as a string.

Since:
TrueZIP 6.5
See Also:
SEPARATOR_CHAR, Constant Field Values

SEPARATOR_CHAR

static final char SEPARATOR_CHAR
The entry name separator as a character.

Since:
TrueZIP 6.5
See Also:
SEPARATOR, Constant Field Values

UNKNOWN

static final byte UNKNOWN
The unknown value for numeric properties.

See Also:
Constant Field Values
Method Detail

getName

String getName()
Returns the archive entry name.

Returns:
A valid archive entry name.
See Also:
Requirements for Archive Entry Names

isDirectory

boolean isDirectory()
Returns true if and only if this entry represents a directory.


getSize

long getSize()
Returns the (uncompressed) size of the archive entry in bytes, or UNKNOWN if not specified. This method is not meaningful for directory entries.


getTime

long getTime()
Returns the last modification time of this archive entry since the epoch, or UNKNOWN if not specified.

See Also:
setTime(long)

setTime

void setTime(long time)
Sets the last modification time of this archive entry.

Parameters:
time - The last modification time of this archive entry in milliseconds since the epoch.
See Also:
getTime()

getOpenIcon

Icon getOpenIcon()
Returns the icon that FileTreeCellRenderer should display for this entry if it is open/expanded in the view. If null is returned, a default icon will be used, depending on the type of this entry and its state in the view.


getClosedIcon

Icon getClosedIcon()
Returns the icon that FileSystemView and FileTreeCellRenderer should display for this entry if it is closed/collapsed in the view. If null is returned, a default icon will be used, depending on the type of this entry and its state in the view.


getMetaData

ArchiveEntryMetaData getMetaData()
Returns the meta data for this archive entry. The default value is null.


setMetaData

void setMetaData(ArchiveEntryMetaData metaData)
Sets the meta data for this archive entry.

Parameters:
metaData - The meta data - may not be null.

TrueZIP 6.8

Copyright © 2005-2010 Schlichtherle IT Services. All Rights Reserved.