Package org.marketcetera.util.file
Enum FileType
- java.lang.Object
-
- java.lang.Enum<FileType>
-
- org.marketcetera.util.file.FileType
-
- All Implemented Interfaces:
Serializable,Comparable<FileType>
public enum FileType extends Enum<FileType>
A file type. Files on NTFS are limited to the following types:NONEXISTENT,FILE,DIR(folder), andUNKNOWN(the file may or may not exist, and, if it does, its type cannot be determined). On Linux,LINK_FILEandLINK_DIRalso apply to symbolic links that point to symbolic links (and so on) that eventually point to a file or directory, respectively.- Since:
- 0.5.0
- Version:
- $Id: FileType.java 16154 2012-07-14 16:34:05Z colin $
- Author:
- tlerios@marketcetera.com
-
-
Enum Constant Summary
Enum Constants Enum Constant Description DIRFILELINK_DIRLINK_FILELINK_UNKNOWNNONEXISTENTUNKNOWN
-
Constructor Summary
Constructors Modifier Constructor Description privateFileType()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FileTypeget(File file)Returns the enumerated constant representing the type of the given file.static FileTypeget(String name)Returns the enumerated constant representing the type of the file with the given name.booleanisDirectory()Returns true if the receiver represents a directory (possibly via a symbolic link).booleanisFile()Returns true if the receiver represents a plain file (possibly via a symbolic link).booleanisSymbolicLink()Returns true if the receiver represents a symbolic link.static FileTypevalueOf(String name)Returns the enum constant of this type with the specified name.static FileType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NONEXISTENT
public static final FileType NONEXISTENT
-
LINK_FILE
public static final FileType LINK_FILE
-
FILE
public static final FileType FILE
-
LINK_DIR
public static final FileType LINK_DIR
-
DIR
public static final FileType DIR
-
LINK_UNKNOWN
public static final FileType LINK_UNKNOWN
-
UNKNOWN
public static final FileType UNKNOWN
-
-
Method Detail
-
values
public static FileType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (FileType c : FileType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static FileType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
get
public static final FileType get(File file)
Returns the enumerated constant representing the type of the given file.- Parameters:
file- The file. It may be null, in which caseUNKNOWNis returned.- Returns:
- The enumerated constant.
-
get
public static final FileType get(String name)
Returns the enumerated constant representing the type of the file with the given name.- Parameters:
name- The file name. It may be null, in which caseUNKNOWNis returned.- Returns:
- The enumerated constant.
-
isSymbolicLink
public boolean isSymbolicLink()
Returns true if the receiver represents a symbolic link.- Returns:
- True if so.
-
isDirectory
public boolean isDirectory()
Returns true if the receiver represents a directory (possibly via a symbolic link).- Returns:
- True if so.
-
isFile
public boolean isFile()
Returns true if the receiver represents a plain file (possibly via a symbolic link).- Returns:
- True if so.
-
-