ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

javafe.genericfile
Class ZipGenericFile

java.lang.Object
  extended byjavafe.genericfile.ZipGenericFile
All Implemented Interfaces:
GenericFile

public class ZipGenericFile
extends java.lang.Object
implements GenericFile

A ZipGenericFile represents a zipfile-entry file (java.util.zip.ZipEntry) as a GenericFile. WARNING: ZipEntry's (but not ZipFile's) always use "/" as their separator.


Field Summary
 java.util.zip.ZipEntry underlyingZipEntry
           
 java.util.zip.ZipFile underlyingZipFile
           
 
Constructor Summary
ZipGenericFile(java.util.zip.ZipFile file, java.util.zip.ZipEntry entry)
          Create a generic file representing a ZipEntry in a ZipFile:
 
Method Summary
 java.lang.String getCanonicalID()
          Return a String that canonically represents the identity of our underlying file.
 java.lang.String getHumanName()
          Return a name that uniquely identifies us to the user.
 java.io.InputStream getInputStream()
          Open the file we represent as an InputStream.
 java.lang.String getLocalName()
          Return our local name, the name that distinguishes us within the directory that contains us.
 GenericFile getSibling(java.lang.String n)
          Attempt to return a GenericFile that describes the file in the same "directory" as us that has the local name n.
 boolean isDirectory()
          Do we represent a directory?
 long lastModified()
          Returns the time that the file represented by us was last modified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

underlyingZipFile

public java.util.zip.ZipFile underlyingZipFile

underlyingZipEntry

public java.util.zip.ZipEntry underlyingZipEntry
Constructor Detail

ZipGenericFile

public ZipGenericFile(java.util.zip.ZipFile file,
                      java.util.zip.ZipEntry entry)
Create a generic file representing a ZipEntry in a ZipFile:

Method Detail

getHumanName

public java.lang.String getHumanName()
Return a name that uniquely identifies us to the user. Warning: the result may not be a conventional filename or use the system separators.

Specified by:
getHumanName in interface GenericFile

getCanonicalID

public java.lang.String getCanonicalID()
Return a String that canonically represents the identity of our underlying file. This function must be defined such that if two GenericFiles return non-null canonical ID's then the IDs are the same (modulo .equals) => the GenericFiles represent the same underlying file. Ideally, under normal circumstances, the => is actually a <=>. This function should only return null in exceptional cases, such as when an I/O error in the underlying storage media prevents construction of a canonical ID. Convention: Canonical IDs start with where X is the fully-qualified name of the class that mediates I/O to the underlying file. E.g., java.io.File for a normal disk file.

Specified by:
getCanonicalID in interface GenericFile

getLocalName

public java.lang.String getLocalName()
Return our local name, the name that distinguishes us within the directory that contains us. E.g., "/a/b/c" has local name "c", "/e/r/" has local name "r", and "/" has local name "". (assuming "/" is the separator char)

Specified by:
getLocalName in interface GenericFile

isDirectory

public boolean isDirectory()
Do we represent a directory?

Specified by:
isDirectory in interface GenericFile

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Open the file we represent as an InputStream.

java.io.IOEXception may be thrown for many reasons, including no such file and read permission denied.

Specified by:
getInputStream in interface GenericFile
Throws:
java.io.IOException

lastModified

public long lastModified()
Returns the time that the file represented by us was last modified.

The return value is system dependent and should only be used to compare with other values returned by last modified. It should not be interpreted as an absolute time.

If a last-modified time is not available (e.g., underlying file doesn't exist, no time specified in a zipentry, etc.), then 0L is returned.

Specified by:
lastModified in interface GenericFile

getSibling

public GenericFile getSibling(java.lang.String n)
Attempt to return a GenericFile that describes the file in the same "directory" as us that has the local name n.

No attempt is made to verify whether or not that file exists.

In cases where the notion of "containing directory" makes no sense (e.g., streams or root directories), null is returned.

Specified by:
getSibling in interface GenericFile

ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

The ESC/Java2 Project Homepage