All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.DirectoryModel

java.lang.Object
   |
   +----com.sun.java.swing.DirectoryModel

public class DirectoryModel
extends Object
Models what goes on in a directory of typed files. Has a notion of its current directory, and provides a notion of file typing. Can be told to "go up". Fakes a meta level above the root file system(s) if it thinks this is a Windows box.


Variable Index

 o changeSupport
 o cleanupTypes
Types to check if none of the general ones match.
 o curDir
Where this chooser is.
 o currentFiles
Cache of the TypedFiles of the local directory
 o currentFilesFresh
True if the currentFiles cache is trustworth, false if it should be refreshed
 o haveCheckedWindows
True if we have executed our hack to see if this is a Windows file system
 o hiddenRule
This type is never assigned to a file.
 o isWindows
Undefined if haveCheckedWindows is false.
 o knownTypes
All types that are known to this file chooser.
 o listenerList
 o overrideTypes
Special tests that must be failed before any general types are assigned.
 o sharedWindowsRootDir
 o shownType
The type that may be shown.

Constructor Index

 o DirectoryModel()
Returns a DirectoryModel whose current directory is the user's home dir
 o DirectoryModel(File)
Returns a DirectoryModel with current directory path

Method Index

 o addKnownFileType(FileType)
 o addPropertyChangeListener(PropertyChangeListener)
 o applyTypeToFile(FileType, TypedFile)
Little convenience used by deduceAndSetTypeOfFile This is the only place TypedFile.setType is called
 o canGoUp()
 o deduceAndSetTypeOfFile(TypedFile)
Search the known types et al for the one that applies to f.
 o enumerateKnownFileTypes()
 o firePropertyChange(String, Object, Object)
 o getCurrentDirectory()
 o getHiddenRule()
 o getKnownFileTypes()
 o getSharedWindowsRootDir()
 o getShownType()
 o getTypedFile(String)
Given a path, return a TypedFile
 o getTypedFile(String, String)
Given a path and a file name, return a TypedFile
 o getTypedFiles()
Convenience, same as this.getTypedFilesForDirectory(this.getCurrentDirectory())
 o getTypedFilesForDirectory(File)
Return a Vector of the files in the given directory, filtered according to knownTypes and hiddenRule.
 o goUp()
 o invalidateCache()
Invalidates the cached copy of the current directory
 o isKnownFileType(FileType)
 o isWindowsFileSystem()
 o lt(TypedFile, TypedFile)
 o makeAbsolute(File)
Convenience method, may return the same object, or a new one if the give was relative.
 o quickSort(Vector, int, int)
This is a generic version of C.A.R Hoare's Quick Sort algorithm.
 o removePropertyChangeListener(PropertyChangeListener)
 o setCurrentDirectory(File)
Change the directory that is the location of this model.
 o setHiddenRule(FileType)
 o setKnownFileTypes(FileType[])
 o setShownType(FileType)
 o sort(Vector)

Variables

 o currentFiles
 protected transient Vector currentFiles
Cache of the TypedFiles of the local directory

 o currentFilesFresh
 protected transient boolean currentFilesFresh
True if the currentFiles cache is trustworth, false if it should be refreshed

 o knownTypes
 protected Vector knownTypes
All types that are known to this file chooser. In an ideal world, this would be system level information.

 o shownType
 protected FileType shownType
The type that may be shown. If null, all types shown.

 o hiddenRule
 protected FileType hiddenRule
This type is never assigned to a file. Rather, it is a general rule to apply after all typing and showing is done. E.g., this is how to hide all files that start with '.', regardless of type.

 o overrideTypes
 protected FileType overrideTypes[]
Special tests that must be failed before any general types are assigned. Devices and such.

 o cleanupTypes
 protected FileType cleanupTypes[]
Types to check if none of the general ones match. Last type in this array must always return true for testFile
 o curDir
 protected File curDir
Where this chooser is. Provides context for unqualified calls to getTypedFile and getTypedFiles, or calls with relative paths.

 o haveCheckedWindows
 protected boolean haveCheckedWindows
True if we have executed our hack to see if this is a Windows file system

 o isWindows
 protected boolean isWindows
Undefined if haveCheckedWindows is false. Otherwise, true if we think this is a windows file system.

 o listenerList
 protected EventListenerList listenerList
 o changeSupport
 protected PropertyChangeSupport changeSupport
 o sharedWindowsRootDir
 protected static DirectoryModel. WindowsRootDir sharedWindowsRootDir

Constructors

 o DirectoryModel
 public DirectoryModel()
Returns a DirectoryModel whose current directory is the user's home dir

 o DirectoryModel
 public DirectoryModel(File path)
Returns a DirectoryModel with current directory path

Methods

 o makeAbsolute
 protected File makeAbsolute(File f)
Convenience method, may return the same object, or a new one if the give was relative. If f instanceof TypedFile, a TypedFile is returned.

 o getCurrentDirectory
 public File getCurrentDirectory()
 o setCurrentDirectory
 public void setCurrentDirectory(File dir)
Change the directory that is the location of this model. Null means go to the user's home directory Emit a ChangeEvent if directory is actually changed.

 o invalidateCache
 protected void invalidateCache()
Invalidates the cached copy of the current directory

 o getTypedFile
 public TypedFile getTypedFile(String path,
                               String name)
Given a path and a file name, return a TypedFile

 o getTypedFile
 public TypedFile getTypedFile(String path)
Given a path, return a TypedFile

 o getTypedFiles
 public Vector getTypedFiles()
Convenience, same as this.getTypedFilesForDirectory(this.getCurrentDirectory())

 o getTypedFilesForDirectory
 public Vector getTypedFilesForDirectory(File dir)
Return a Vector of the files in the given directory, filtered according to knownTypes and hiddenRule. The Vector may be empty. The objects in the Vector are of instances of TypedFile

 o applyTypeToFile
 protected boolean applyTypeToFile(FileType t,
                                   TypedFile f)
Little convenience used by deduceAndSetTypeOfFile This is the only place TypedFile.setType is called

 o deduceAndSetTypeOfFile
 protected void deduceAndSetTypeOfFile(TypedFile f)
Search the known types et al for the one that applies to f. Must be called before f.getType() is ever called. Do not call this twice on the same instance of Typedfile, and do not call f.setType() after this.

 o canGoUp
 public boolean canGoUp()
 o goUp
 public void goUp()
 o setHiddenRule
 public void setHiddenRule(FileType rule)
 o getHiddenRule
 public FileType getHiddenRule()
 o getShownType
 public FileType getShownType()
 o setShownType
 public void setShownType(FileType t)
 o addKnownFileType
 public void addKnownFileType(FileType type)
 o enumerateKnownFileTypes
 public Enumeration enumerateKnownFileTypes()
 o getKnownFileTypes
 public Vector getKnownFileTypes()
 o isKnownFileType
 public boolean isKnownFileType(FileType t)
 o setKnownFileTypes
 public void setKnownFileTypes(FileType types[])
 o firePropertyChange
 protected void firePropertyChange(String propertyName,
                                   Object oldValue,
                                   Object newValue)
 o addPropertyChangeListener
 public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
 o removePropertyChangeListener
 public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
 o isWindowsFileSystem
 protected boolean isWindowsFileSystem()
 o getSharedWindowsRootDir
 public static DirectoryModel. WindowsRootDir getSharedWindowsRootDir()
 o sort
 protected void sort(Vector v)
 o lt
 protected boolean lt(TypedFile a,
                      TypedFile b)
 o quickSort
 protected void quickSort(Vector v,
                          int lo0,
                          int hi0)
This is a generic version of C.A.R Hoare's Quick Sort algorithm. This will handle arrays that are already sorted, and arrays with duplicate keys.
If you think of a one dimensional array as going from the lowest index on the left to the highest index on the right then the parameters to this function are lowest index or left and highest index or right. The first time you call this function it will be with the parameters 0, a.length - 1.

Parameters:
a - an integer array
lo0 - left boundary of array partition
hi0 - right boundary of array partition

All Packages  Class Hierarchy  This Package  Previous  Next  Index