APIdia Launch Partner
Top Inners Fields Constructors Methods
sun.awt.shell

public abstract Class ShellFolder

extends File
Class Inheritance
Known Direct Subclasses
sun.awt.shell.DefaultShellFolder
Annotations
@SuppressWarnings:serial
Imports
java.awt.Image, .Toolkit, java.io.File, .FileNotFoundException, .IOException, .Serial, java.nio.file.Files, .LinkOption, .Paths, java.util.ArrayList, .Comparator, .Date, .List, java.util.concurrent.Callable, javax.swing.SwingConstants, sun.awt.OSInfo

Author
Michael Martak
Since
1.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ShellFolder.Invoker

Interface allowing to invoke tasks in different environments on different platforms.

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
private static final Comparator<Object>
DEFAULT_COMPARATOR

Provides a default comparator for the default column set

private static final Comparator<File>
private static final ShellFolder.Invoker
protected ShellFolder
private static final ShellFolderManager
Inherited from java.io.File:
pathSeparatorpathSeparatorCharseparatorseparatorChar

Constructor Summary

AccessConstructor and Description
pack-priv
ShellFolder(ShellFolder parent, String pathname)

Create a file system shell folder from a file

Method Summary

Modifier and TypeMethod and Description
public boolean
canRead()

Overrides java.io.File.canRead.

Tests whether the application can read the file located by this abstract pathname.

public boolean
canWrite()

Overrides java.io.File.canWrite.

Returns true if folder allows creation of children.

public int
compareTo(File file2)

Overrides java.io.File.compareTo.

Implements java.lang.Comparable.compareTo.

Compares this ShellFolder with the specified ShellFolder for order.

public boolean
createNewFile()

Overrides java.io.File.createNewFile.

Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.

public boolean
delete()

Overrides java.io.File.delete.

Deletes the file or directory located by this abstract pathname.

public void
deleteOnExit()

Overrides java.io.File.deleteOnExit.

Requests that the file or directory located by this abstract pathname be deleted when the virtual machine terminates.

public boolean
exists()

Overrides java.io.File.exists.

Tests whether the file or directory located by this abstract pathname exists.

public static Object
get(String
a String
key
)

Returns: An Object matching the string key.

public File
getAbsoluteFile()

Overrides java.io.File.getAbsoluteFile.

Returns the absolute form of this abstract pathname.

public abstract String
getDisplayName()

Returns: The name used to display this shell folder

public abstract String
getExecutableType()

Returns: The executable type as a string

public static ShellFolderColumnInfo[]
public ShellFolderColumnInfo[]
public static Object
getFolderColumnValue(File file, int column)

public Object
public abstract String
getFolderType()

Returns: The type of shell folder as a string

public Image
getIcon(boolean
whether to return large icon (ignored in base implementation)
getLargeIcon
)

Returns: The icon used to display this shell folder

public Image

Returns:

The icon of the specified size used to display this shell folder
getIcon
(int
width of the icon > 0
width
,
int
height of the icon > 0
height
)

Returns the icon of the specified size used to display this shell folder.

public abstract ShellFolder
getLinkLocation()

Returns: The shell folder linked to by this shell folder, or null if this shell folder is not a link

public static File
getNormalizedFile(File f)

Canonicalizes files that don't have symbolic links in their path.

public String

Returns:

the path as a String for this object's parent, or null if this object does not name a parent folder
getParent
()

Overrides java.io.File.getParent.

Returns the path for this object's parent, or null if this object does not name a parent folder.

public File

Returns:

a File object representing this object's parent, or null if this object does not name a parent folder
getParentFile
()

Overrides java.io.File.getParentFile.

Returns a File object representing this object's parent, or null if this object does not name a parent folder.

public static ShellFolder
getShellFolder(File file)

Return a shell folder from a file object

public static <T> T
invoke(Callable<T> task)

Invokes the task which doesn't throw checked exceptions from its call method.

public static <T, E extends Throwable> T
invoke(Callable<T> task, Class<E> exceptionClass)

Invokes the task which throws checked exceptions from its call method.

public boolean
isAbsolute()

Overrides java.io.File.isAbsolute.

Tests whether this abstract pathname is absolute.

public static boolean
isComputerNode(File dir)

Does dir represent a "computer" such as a node on the network, or "My Computer" on the desktop.

public boolean
isDirectory()

Overrides java.io.File.isDirectory.

Tests whether the file located by this abstract pathname is a directory.

public boolean
isFile()

Overrides java.io.File.isFile.

Tests whether the file located by this abstract pathname is a normal file.

public boolean
isFileSystem()

Returns: Whether this is a file system shell folder

public static boolean
isFileSystemRoot(File dir)

Returns: Whether this is a file system root directory

public long
lastModified()

Overrides java.io.File.lastModified.

Returns the time that the file located by this abstract pathname was last modified.

public long
length()

Overrides java.io.File.length.

Returns the length of the file located by this abstract pathname.

public File[]
listFiles()

Overrides java.io.File.listFiles.

Returns an array of abstract pathnames locating the files in the directory located by this abstract pathname.

public File[]
listFiles(boolean includeHiddenFiles)

public boolean
mkdir()

Overrides java.io.File.mkdir.

Creates the directory named by this abstract pathname.

public boolean
mkdirs()

Overrides java.io.File.mkdirs.

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.

public boolean
renameTo(File dest)

Overrides java.io.File.renameTo.

Renames the file located by this abstract pathname.

public boolean
setLastModified(long time)

Overrides java.io.File.setLastModified.

Sets the last-modified time of the file or directory located by this abstract pathname.

public boolean
setReadOnly()

Overrides java.io.File.setReadOnly.

Marks the file or directory located by this abstract pathname so that only read operations are allowed.

public static void
sort(final List<? extends File> files)

public void
sortChildren(final List<? extends File> files)

public String
toString()

Overrides java.io.File.toString.

Returns the pathname string of this abstract pathname.

protected abstract Object

Returns:

a java.io.File replacement object, or null if no suitable replacement can be found.
writeReplace
()

This method must be implemented to make sure that no instances of ShellFolder are ever serialized.

Inherited from java.io.File:
canExecutecreateTempFilecreateTempFileequalsgetAbsolutePathgetCanonicalFilegetCanonicalPathgetFreeSpacegetNamegetPathgetTotalSpacegetUsableSpacehashCodeisHiddenlistlistlistFileslistFileslistRootssetExecutablesetExecutablesetReadablesetReadablesetWritablesetWritabletoPathtoURItoURL

Field Detail

COLUMN_DATEback to summary
public static final String COLUMN_DATE
COLUMN_NAMEback to summary
public static final String COLUMN_NAME
COLUMN_SIZEback to summary
public static final String COLUMN_SIZE
DEFAULT_COMPARATORback to summary
private static final Comparator<Object> DEFAULT_COMPARATOR

Provides a default comparator for the default column set

FILE_COMPARATORback to summary
private static final Comparator<File> FILE_COMPARATOR
invokerback to summary
private static final ShellFolder.Invoker invoker
parentback to summary
protected ShellFolder parent
shellFolderManagerback to summary
private static final ShellFolderManager shellFolderManager

Constructor Detail

ShellFolderback to summary
pack-priv ShellFolder(ShellFolder parent, String pathname)

Create a file system shell folder from a file

Method Detail

canReadback to summary
public boolean canRead()

Overrides java.io.File.canRead.

Doc from java.io.File.canRead.

Tests whether the application can read the file located by this abstract pathname. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to read files that are marked as unreadable. Consequently, this method may return true even though the file does not have read permissions.

canWriteback to summary
public boolean canWrite()

Overrides java.io.File.canWrite.

Returns true if folder allows creation of children. True for the "Desktop" folder, but false for the "My Computer" folder.

compareToback to summary
public int compareTo(File file2)

Overrides java.io.File.compareTo.

Implements java.lang.Comparable.compareTo.

Compares this ShellFolder with the specified ShellFolder for order.

See Also
compareTo(Object)
createNewFileback to summary
public boolean createNewFile() throws IOException

Overrides java.io.File.createNewFile.

Doc from java.io.File.createNewFile.

Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file.

Note

this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The FileLock facility should be used instead.

Exceptions
IOException:
If an I/O error occurred
deleteback to summary
public boolean delete()

Overrides java.io.File.delete.

Doc from java.io.File.delete.

Deletes the file or directory located by this abstract pathname. If this pathname locates a directory, then the directory must be empty in order to be deleted. If this pathname locates a symbolic link, then the link itself, not its target, will be deleted.

Note that the java.nio.file.Files class defines the delete method to throw an IOException when a file cannot be deleted. This is useful for error reporting and to diagnose why a file cannot be deleted.

deleteOnExitback to summary
public void deleteOnExit()

Overrides java.io.File.deleteOnExit.

Doc from java.io.File.deleteOnExit.

Requests that the file or directory located by this abstract pathname be deleted when the virtual machine terminates. If this pathname locates a symbolic link, then the link itself, not its target, will be deleted. Files (or directories) are deleted in the reverse order that they are registered. Invoking this method to delete a file or directory that is already registered for deletion has no effect. Deletion will be attempted only for normal termination of the virtual machine, as defined by the Java Language Specification.

Once deletion has been requested, it is not possible to cancel the request. This method should therefore be used with care.

Note

this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The FileLock facility should be used instead.

existsback to summary
public boolean exists()

Overrides java.io.File.exists.

Doc from java.io.File.exists.

Tests whether the file or directory located by this abstract pathname exists.

getback to summary
public static Object get(String key)
Parameters
key:String

a String

Returns:Object

An Object matching the string key.

See Also
ShellFolderManager#get(String)
getAbsoluteFileback to summary
public File getAbsoluteFile()

Overrides java.io.File.getAbsoluteFile.

Doc from java.io.File.getAbsoluteFile.

Returns the absolute form of this abstract pathname. Equivalent to new File(this.getAbsolutePath).

getDisplayNameback to summary
public abstract String getDisplayName()
Returns:String

The name used to display this shell folder

getExecutableTypeback to summary
public abstract String getExecutableType()
Returns:String

The executable type as a string

getFolderColumnsback to summary
public static ShellFolderColumnInfo[] getFolderColumns(File dir)
getFolderColumnsback to summary
public ShellFolderColumnInfo[] getFolderColumns()
getFolderColumnValueback to summary
public static Object getFolderColumnValue(File file, int column)
getFolderColumnValueback to summary
public Object getFolderColumnValue(int column)
getFolderTypeback to summary
public abstract String getFolderType()
Returns:String

The type of shell folder as a string

getIconback to summary
public Image getIcon(boolean getLargeIcon)
Parameters
getLargeIcon:boolean

whether to return large icon (ignored in base implementation)

Returns:Image

The icon used to display this shell folder

getIconback to summary
public Image getIcon(int width, int height)

Returns the icon of the specified size used to display this shell folder.

Parameters
width:int

width of the icon > 0

height:int

height of the icon > 0

Returns:Image

The icon of the specified size used to display this shell folder

getLinkLocationback to summary
public abstract ShellFolder getLinkLocation() throws FileNotFoundException
Returns:ShellFolder

The shell folder linked to by this shell folder, or null if this shell folder is not a link

getNormalizedFileback to summary
public static File getNormalizedFile(File f) throws IOException

Canonicalizes files that don't have symbolic links in their path. Normalizes files that do, preserving symbolic links from being resolved.

getParentback to summary
public String getParent()

Overrides java.io.File.getParent.

Returns the path for this object's parent, or null if this object does not name a parent folder.

Returns:String

the path as a String for this object's parent, or null if this object does not name a parent folder

Since
1.4
See Also
java.io.File#getParent()
getParentFileback to summary
public File getParentFile()

Overrides java.io.File.getParentFile.

Returns a File object representing this object's parent, or null if this object does not name a parent folder.

Returns:File

a File object representing this object's parent, or null if this object does not name a parent folder

Since
1.4
See Also
java.io.File#getParentFile()
getShellFolderback to summary
public static ShellFolder getShellFolder(File file) throws FileNotFoundException

Return a shell folder from a file object

Exceptions
FileNotFoundException:
if file does not exist
invokeback to summary
public static <T> T invoke(Callable<T> task)

Invokes the task which doesn't throw checked exceptions from its call method. If invocation is interrupted then Thread.currentThread().isInterrupted() will be set and result will be null

invokeback to summary
public static <T, E extends Throwable> T invoke(Callable<T> task, Class<E> exceptionClass) throws InterruptedException, Class-:E

Invokes the task which throws checked exceptions from its call method. If invocation is interrupted then Thread.currentThread().isInterrupted() will be set and InterruptedException will be thrown as well.

isAbsoluteback to summary
public boolean isAbsolute()

Overrides java.io.File.isAbsolute.

Doc from java.io.File.isAbsolute.

Tests whether this abstract pathname is absolute. The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is "/". On Microsoft Windows systems, a pathname is absolute if its prefix is a drive specifier followed by "\\", or if its prefix is "\\\\".

isComputerNodeback to summary
public static boolean isComputerNode(File dir)

Does dir represent a "computer" such as a node on the network, or "My Computer" on the desktop.

isDirectoryback to summary
public boolean isDirectory()

Overrides java.io.File.isDirectory.

Doc from java.io.File.isDirectory.

Tests whether the file located by this abstract pathname is a directory.

Where it is required to distinguish an I/O exception from the case that the file is not a directory, or where several attributes of the same file are required at the same time, then the Files.readAttributes method may be used.

isFileback to summary
public boolean isFile()

Overrides java.io.File.isFile.

Doc from java.io.File.isFile.

Tests whether the file located by this abstract pathname is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.

Where it is required to distinguish an I/O exception from the case that the file is not a normal file, or where several attributes of the same file are required at the same time, then the Files.readAttributes method may be used.

isFileSystemback to summary
public boolean isFileSystem()
Returns:boolean

Whether this is a file system shell folder

isFileSystemRootback to summary
public static boolean isFileSystemRoot(File dir)
Returns:boolean

Whether this is a file system root directory

lastModifiedback to summary
public long lastModified()

Overrides java.io.File.lastModified.

Doc from java.io.File.lastModified.

Returns the time that the file located by this abstract pathname was last modified.

lengthback to summary
public long length()

Overrides java.io.File.length.

Doc from java.io.File.length.

Returns the length of the file located by this abstract pathname. The return value is unspecified if this pathname locates a directory.

Where it is required to distinguish an I/O exception from the case that 0L is returned, or where several attributes of the same file are required at the same time, then the Files.readAttributes method may be used.

listFilesback to summary
public File[] listFiles()

Overrides java.io.File.listFiles.

Doc from java.io.File.listFiles.

Returns an array of abstract pathnames locating the files in the directory located by this abstract pathname.

If this abstract pathname does not locate a directory, then this method returns null. Otherwise an array of File objects is returned, one for each file or directory in the directory. Pathnames locating the directory itself and the directory's parent directory are not included in the result. Each resulting abstract pathname is constructed from this abstract pathname using the File(File, String) constructor. Therefore if this pathname is absolute then each resulting pathname is absolute; if this pathname is relative then each resulting pathname will be relative to the same directory.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Note that the java.nio.file.Files class defines the newDirectoryStream method to open a directory and iterate over the names of the files in the directory. This may use less resources when working with very large directories.

listFilesback to summary
public File[] listFiles(boolean includeHiddenFiles)
mkdirback to summary
public boolean mkdir()

Overrides java.io.File.mkdir.

Doc from java.io.File.mkdir.

Creates the directory named by this abstract pathname.

mkdirsback to summary
public boolean mkdirs()

Overrides java.io.File.mkdirs.

Doc from java.io.File.mkdirs.

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

renameToback to summary
public boolean renameTo(File dest)

Overrides java.io.File.renameTo.

Doc from java.io.File.renameTo.

Renames the file located by this abstract pathname. If this pathname locates a symbolic link, then the link itself, not its target, will be renamed.

Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists. The return value should always be checked to make sure that the rename operation was successful. As instances of File are immutable, this File object is not changed to name the destination file or directory.

Note that the java.nio.file.Files class defines the move method to move or rename a file in a platform independent manner.

setLastModifiedback to summary
public boolean setLastModified(long time)

Overrides java.io.File.setLastModified.

Doc from java.io.File.setLastModified.

Sets the last-modified time of the file or directory located by this abstract pathname.

All platforms support file-modification times to the nearest second, but some provide more precision. The argument will be truncated to fit the supported precision. If the operation succeeds and no intervening operations on the file take place, then the next invocation of the lastModified method will return the (possibly truncated) time argument that was passed to this method.

setReadOnlyback to summary
public boolean setReadOnly()

Overrides java.io.File.setReadOnly.

Doc from java.io.File.setReadOnly.

Marks the file or directory located by this abstract pathname so that only read operations are allowed. After invoking this method the file or directory will not change until it is either deleted or marked to allow write access. On some platforms it may be possible to start the Java virtual machine with special privileges that allow it to modify files that are marked read-only. Whether or not a read-only file or directory may be deleted depends upon the underlying system.

sortback to summary
public static void sort(final List<? extends File> files)
sortChildrenback to summary
public void sortChildren(final List<? extends File> files)
toStringback to summary
public String toString()

Overrides java.io.File.toString.

Doc from java.io.File.toString.

Returns the pathname string of this abstract pathname. This is just the string returned by the getPath method.

writeReplaceback to summary
protected abstract Object writeReplace() throws ObjectStreamException

This method must be implemented to make sure that no instances of ShellFolder are ever serialized. If isFileSystem() returns true, then the object should be representable with an instance of java.io.File instead. If not, then the object is most likely depending on some internal (native) state and cannot be serialized.

Returns:Object

a java.io.File replacement object, or null if no suitable replacement can be found.

Annotations
@Serial
sun.awt.shell back to summary

public Interface ShellFolder.Invoker

Known Direct Implementers
sun.awt.shell.ShellFolderManager.DirectInvoker

Interface allowing to invoke tasks in different environments on different platforms.

Method Summary

Modifier and TypeMethod and Description
public <T> T

Returns:

the result of task's invocation
invoke
(Callable<T>
a task to invoke
task
)

Invokes a callable task.

Method Detail

invokeback to summary
public <T> T invoke(Callable<T> task) throws Exception

Invokes a callable task.

Parameters
task:Callable<T>

a task to invoke

Returns:T

the result of task's invocation

Exceptions
Exception:
InterruptedException or an exception that was thrown from the task