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 UnopenableFile

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

public class UnopenableFile
extends java.lang.Object
implements GenericFile

Instances of UnopenableFile are GenericFiles that cannot be opened.

Their value lies solely in their associated naming, etc., info.

Example: CorrelatedReader's keeps an open InputStream and an associated GenericFile. In the case of unreopenable streams like stdin, the associated GenericFile is an UnopenableFile with the name "stdin".


Field Summary
(package private)  java.lang.String humanName
          * Instance variables: * *
(package private)  boolean isDir
           
 
Constructor Summary
UnopenableFile(java.lang.String name)
          Create a ordinary (aka, non-directory) UnopenableFile with human-name name.
UnopenableFile(java.lang.String name, boolean isDir)
          Create an UnopenableFile with human-name name that is a directory iff isDir.
 
Method Summary
 java.lang.String getCanonicalID()
          Return a String that canonically represents the identity of our underlying file.
 java.lang.String getHumanName()
          * GenericFile interface implementation: * *
 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

humanName

java.lang.String humanName
* Instance variables: * *


isDir

boolean isDir
Constructor Detail

UnopenableFile

public UnopenableFile(java.lang.String name)
Create a ordinary (aka, non-directory) UnopenableFile with human-name name. The resulting file has no modification date available and a local name of "".


UnopenableFile

public UnopenableFile(java.lang.String name,
                      boolean isDir)
Create an UnopenableFile with human-name name that is a directory iff isDir. The resulting file has no modification date available and a local name of "".

Method Detail

getHumanName

public java.lang.String getHumanName()
* GenericFile interface implementation: * *

Specified by:
getHumanName in interface GenericFile

getCanonicalID

public java.lang.String getCanonicalID()
Description copied from interface: GenericFile
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()
Description copied from interface: GenericFile
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()
Description copied from interface: GenericFile
Do we represent a directory?

Specified by:
isDirectory in interface GenericFile

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: GenericFile
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()
Description copied from interface: GenericFile
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)
Description copied from interface: GenericFile
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