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 NormalGenericFile

java.lang.Object
  extended byjava.io.File
      extended byjavafe.genericfile.NormalGenericFile
All Implemented Interfaces:
java.lang.Comparable, GenericFile, java.io.Serializable

public class NormalGenericFile
extends java.io.File
implements GenericFile

A NormalGenericFile represents a normal file (File) as a GenericFile.

See Also:
Serialized Form

Field Summary
private static long serialVersionUID
           
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
NormalGenericFile(java.io.File underlyingFile)
          Create a NormalGenericFile to represent an existing File.
NormalGenericFile(java.lang.String name)
          Create a NormalGenericFile from a filename.
 
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.
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javafe.genericfile.GenericFile
isDirectory, lastModified
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

NormalGenericFile

public NormalGenericFile(java.io.File underlyingFile)
Create a NormalGenericFile to represent an existing File.


NormalGenericFile

public NormalGenericFile(java.lang.String name)
Create a NormalGenericFile from a filename.

Method Detail

getHumanName

public java.lang.String getHumanName()
Description copied from interface: GenericFile
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
Returns:
a name that uniquely identifies us to the user. Warning: the result may not be a conventional filename or use the system separators.

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
Returns:
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.

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
Returns:
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)

getInputStream

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

Specified by:
getInputStream in interface GenericFile
Throws:
java.io.IOException - May be thrown for many reasons, including no such file and read permission denied.

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
Returns:
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.

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