javax.swing.filechooser

Class FileSystemView


public abstract class FileSystemView
extends Object

The base class providing a view of the file system for use by the JFileChooser component.

Method Summary

File
createFileObject(File dir, String filename)
Creates a new file object with the given name in the specified directory.
File
createFileObject(String path)
Creates a new file object from the specified path.
protected File
createFileSystemRoot(File f)
DOCUMENT ME!
abstract File
createNewFolder(File containingDir)
Creates a new folder with a unique name in the specified directory and returns a File object representing the new directory.
File
getChild(File parent, String fileName)
DOCUMENT ME!
File
getDefaultDirectory()
Returns the default directory.
static FileSystemView
getFileSystemView()
Returns a default FileSystemView appropriate for the platform.
File[]
getFiles(File dir, boolean useFileHiding)
Returns an array containing the files in the given directory.
File
getHomeDirectory()
Returns the home directory for the current user.
File
getParentDirectory(File f)
Returns the parent directory for the given file/directory.
File[]
getRoots()
Returns an array containing the file system roots.
String
getSystemDisplayName(File f)
Returns the name of a file as it would be displayed by the underlying system.
Icon
getSystemIcon(File f)
Returns the icon that would be displayed for the given file by the underlying system.
String
getSystemTypeDescription(File f)
Returns the type description of a file that would be displayed by the underlying system.
boolean
isComputerNode(File dir)
DOCUMENT ME!
boolean
isDrive(File dir)
Returns true if the given directory represents a disk drive, and false otherwise.
boolean
isFileSystem(File f)
Returns true if f is a file or directory, and false otherwise.
boolean
isFileSystemRoot(File dir)
Returns true if the given directory is a file system root, and false otherwise.
boolean
isFloppyDrive(File dir)
Returns true if the given directory represents a floppy drive, and false otherwise.
boolean
isHiddenFile(File f)
Returns true if the given file is hidden, and false otherwise.
boolean
isParent(File folder, File file)
Returns true if folder is the parent of file, and false otherwise.
boolean
isRoot(File f)
DOCUMENT ME!
Boolean
isTraversable(File f)
Returns true if the file is traversable, and false otherwise.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

createFileObject

public File createFileObject(File dir,
                             String filename)
Creates a new file object with the given name in the specified directory.
Parameters:
dir - the directory (null permitted).
filename - the file name.
Returns:
A new file object.

createFileObject

public File createFileObject(String path)
Creates a new file object from the specified path.
Parameters:
path - the path.
Returns:
A new file object.

createFileSystemRoot

protected File createFileSystemRoot(File f)
DOCUMENT ME!
Parameters:
f - DOCUMENT ME!
Returns:
DOCUMENT ME!

createNewFolder

public abstract File createNewFolder(File containingDir)
            throws IOException
Creates a new folder with a unique name in the specified directory and returns a File object representing the new directory.
Parameters:
containingDir - the directory to contain the new folder (null not permitted).
Returns:
A File object representing the new directory.
Throws:
IOException - if an exception occurs while creating the new directory.

getChild

public File getChild(File parent,
                     String fileName)
DOCUMENT ME!
Parameters:
parent - DOCUMENT ME!
fileName - DOCUMENT ME!
Returns:
DOCUMENT ME!

getDefaultDirectory

public File getDefaultDirectory()
Returns the default directory.
Returns:
The default directory.

getFileSystemView

public static FileSystemView getFileSystemView()
Returns a default FileSystemView appropriate for the platform.
Returns:
A default FileSystemView appropriate for the platform.

getFiles

public File[] getFiles(File dir,
                       boolean useFileHiding)
Returns an array containing the files in the given directory. The useFileHiding controls whether or not hidden files are included in the result.
Parameters:
dir - the directory (if null
useFileHiding - a flag that controls whether or not hidden files are included in the result (pass in true to exclude hidden files).
Returns:
The files in the given directory (possibly null).

getHomeDirectory

public File getHomeDirectory()
Returns the home directory for the current user.
Returns:
The home directory for the current user.

getParentDirectory

public File getParentDirectory(File f)
Returns the parent directory for the given file/directory.
Parameters:
f - the file/directory.
Returns:
The parent directory (or null if there is no parent directory).

getRoots

public File[] getRoots()
Returns an array containing the file system roots. On Unix-like platforms, this array will contain just a single item ("/"), while other platforms may return multiple roots.

This method is implemented to return null, subclasses must override this method.

Returns:
An array containing the file system roots.

getSystemDisplayName

public String getSystemDisplayName(File f)
Returns the name of a file as it would be displayed by the underlying system.
Parameters:
f - the file.
Returns:
the name of a file as it would be displayed by the underlying system

getSystemIcon

public Icon getSystemIcon(File f)
Returns the icon that would be displayed for the given file by the underlying system. This implementation returns null, subclasses must override.
Parameters:
f - the file.
Returns:
null.

getSystemTypeDescription

public String getSystemTypeDescription(File f)
Returns the type description of a file that would be displayed by the underlying system. This implementation returns null, subclasses must override.
Parameters:
f - the file.
Returns:
null.

isComputerNode

public boolean isComputerNode(File dir)
DOCUMENT ME!
Parameters:
dir - DOCUMENT ME!
Returns:
DOCUMENT ME!

isDrive

public boolean isDrive(File dir)
Returns true if the given directory represents a disk drive, and false otherwise. This default implementation always returns false.
Parameters:
dir - the directory.
Returns:
false.

isFileSystem

public boolean isFileSystem(File f)
Returns true if f is a file or directory, and false otherwise.
Parameters:
f - the file/directory.
Returns:
true if f is a file or directory, and false otherwise.

isFileSystemRoot

public boolean isFileSystemRoot(File dir)
Returns true if the given directory is a file system root, and false otherwise.
Parameters:
dir - the directory.
Returns:
true if the given directory is a file system root, and false otherwise.

isFloppyDrive

public boolean isFloppyDrive(File dir)
Returns true if the given directory represents a floppy drive, and false otherwise. This default implementation always returns false.
Parameters:
dir - the directory.
Returns:
false.

isHiddenFile

public boolean isHiddenFile(File f)
Returns true if the given file is hidden, and false otherwise.
Parameters:
f - the file.
Returns:
true if the given file is hidden, and false otherwise.

isParent

public boolean isParent(File folder,
                        File file)
Returns true if folder is the parent of file, and false otherwise.
Parameters:
folder - the folder (null not permitted).
file - the file (null not permitted).
Returns:
true if folder is the parent of file, and false otherwise.

isRoot

public boolean isRoot(File f)
DOCUMENT ME!
Parameters:
f - DOCUMENT ME!
Returns:
DOCUMENT ME!

isTraversable

public Boolean isTraversable(File f)
Returns true if the file is traversable, and false otherwise. Here, all directories are considered traversable, and files are considered non-traversable.
Parameters:
f - the file or directory (null not permitted).
Returns:
true if the file is traversable, and false otherwise.

FileSystemView.java -- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.