com.mucommander.file
Class ArchiveEntry

java.lang.Object
  extended by com.mucommander.file.SimpleFileAttributes
      extended by com.mucommander.file.ArchiveEntry
All Implemented Interfaces:
FileAttributes

public class ArchiveEntry
extends SimpleFileAttributes

This class represents a generic archive entry. It provides getters and setters for common archive entry attributes and allows to encapsulate the entry object of a 3rd party library.

Important: the path of archive entries must use the '/' character as a path delimiter, and be relative to the archive's root, i.e. must not start with a leading '/'.

Author:
Maxence Bernard

Field Summary
protected  java.lang.Object entryObject
          Encapsulated entry object
 
Constructor Summary
ArchiveEntry()
          Creates a new ArchiveEntry with all attributes set to their default value.
ArchiveEntry(java.lang.String path, boolean directory)
          Creates a new ArchiveEntry using the supplied path and directory attributes.
ArchiveEntry(java.lang.String path, boolean directory, long date, long size)
          Creates a new ArchiveEntry using the values of the supplied attributes.
 
Method Summary
 int getDepth()
          Returns the depth of this entry based on the number of path delimiters ('/') its path contains.
static int getDepth(java.lang.String entryPath)
          Returns the depth of the specified entry path, based on the number of path delimiters ('/') it contains.
 java.lang.Object getEntryObject()
          Returns an archive format-dependent object providing extra information about this entry, typically an object from a 3rd party library ; null if this entry has none.
 java.lang.String getName()
          Extracts this entry's filename from its path and returns it.
 FilePermissions getPermissions()
          Returns the file permissions of this entry.
 void setEntryObject(java.lang.Object entryObject)
          Sets an archive format-dependent object providing extra information about this entry, typically an object from a 3rd party library ; null for none.
 
Methods inherited from class com.mucommander.file.SimpleFileAttributes
getDate, getExists, getGroup, getOwner, getPath, getSize, isDirectory, setDate, setDirectory, setExists, setGroup, setOwner, setPath, setPermissions, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entryObject

protected java.lang.Object entryObject
Encapsulated entry object

Constructor Detail

ArchiveEntry

public ArchiveEntry()
Creates a new ArchiveEntry with all attributes set to their default value.


ArchiveEntry

public ArchiveEntry(java.lang.String path,
                    boolean directory)
Creates a new ArchiveEntry using the supplied path and directory attributes.

Parameters:
path - the entry's path
directory - true if the entry is a directory

ArchiveEntry

public ArchiveEntry(java.lang.String path,
                    boolean directory,
                    long date,
                    long size)
Creates a new ArchiveEntry using the values of the supplied attributes.

Parameters:
path - the entry's path
directory - true if the entry is a directory
date - the entry's date
size - the entry's size
Method Detail

getDepth

public int getDepth()
Returns the depth of this entry based on the number of path delimiters ('/') its path contains. Top-level entries have a depth of 0 (minimum depth).

Returns:
the depth of this entry

getDepth

public static int getDepth(java.lang.String entryPath)
Returns the depth of the specified entry path, based on the number of path delimiters ('/') it contains. Top-level entries have a depth of 0 (minimum depth).

Parameters:
entryPath - the path for which to calculate the depth
Returns:
the depth of the given entry path

getName

public java.lang.String getName()
Extracts this entry's filename from its path and returns it.

Returns:
this entry's filename

getEntryObject

public java.lang.Object getEntryObject()
Returns an archive format-dependent object providing extra information about this entry, typically an object from a 3rd party library ; null if this entry has none.

Returns:
an object providing extra information about this entry, null if this entry has none

setEntryObject

public void setEntryObject(java.lang.Object entryObject)
Sets an archive format-dependent object providing extra information about this entry, typically an object from a 3rd party library ; null for none.

Parameters:
entryObject - an object providing extra information about this entry, null for none

getPermissions

public FilePermissions getPermissions()
Returns the file permissions of this entry. This method is overridden to return default permissions (FilePermissions.DEFAULT_DIRECTORY_PERMISSIONS for directories, FilePermissions.DEFAULT_FILE_PERMISSIONS for regular files), when none have been set.

Specified by:
getPermissions in interface FileAttributes
Overrides:
getPermissions in class SimpleFileAttributes
Returns:
the file permissions of this entry


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard