Package com.helger.commons.io.file
Enum EFileIOErrorCode
- java.lang.Object
-
- java.lang.Enum<EFileIOErrorCode>
-
- com.helger.commons.io.file.EFileIOErrorCode
-
- All Implemented Interfaces:
IHasIntID,ISuccessIndicator,Serializable,Comparable<EFileIOErrorCode>
public enum EFileIOErrorCode extends Enum<EFileIOErrorCode> implements ISuccessIndicator, IHasIntID
Represents a set of predefined error codes that can occur in file operations.- Author:
- Philip Helger
-
-
Enum Constant Summary
Enum Constants Enum Constant Description IO_ERRORGeneric IO code: an IOException occurred.NO_ERRORGeneric error code: no error.OBJECT_CANNOT_BE_HANDLEDWe stumble across an object that is neither a file nor a directory.OBJECT_HAS_NO_PARENTAn object's parent could not be retrieved.OPERATION_FAILEDGeneric error code: operation failed but we don't know why.SECURITY_ERRORGeneric error code: a SecurityException occurred.SOURCE_DOES_NOT_EXISTA source file or directory does not exist.SOURCE_EQUALS_TARGETSource and destination object are identical.SOURCE_NOT_READABLEThe source object cannot be read.SOURCE_PARENT_NOT_WRITABLEThe source parent object is read-only (not writable).TARGET_ALREADY_EXISTSA destination file or directory already exists.TARGET_IS_CHILD_OF_SOURCEAvoid recursive dependencies.TARGET_PARENT_NOT_WRITABLEThe target parent object is read-only (not writable).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FileIOErrorgetAsIOError(EFileIOOperation eOperation, File aFile)Use this error code to create a newFileIOErrorinstance.FileIOErrorgetAsIOError(EFileIOOperation eOperation, File aFile1, File aFile2)Use this error code to create a newFileIOErrorinstance.static FileIOErrorgetAsIOError(EFileIOOperation eOperation, IOException ex)Static method to create aFileIOErrorfor anIOException.static FileIOErrorgetAsIOError(EFileIOOperation eOperation, UncheckedIOException ex)Static method to create aFileIOErrorfor anUncheckedIOException.FileIOErrorgetAsIOError(EFileIOOperation eOperation, Path aPath)Use this error code to create a newFileIOErrorinstance.FileIOErrorgetAsIOError(EFileIOOperation eOperation, Path aFile1, Path aFile2)Use this error code to create a newFileIOErrorinstance.static EFileIOErrorCodegetFromIDOrNull(int nID)intgetID()An internal ID for easier referencing.static FileIOErrorgetSecurityAsIOError(EFileIOOperation eOperation, SecurityException ex)Static method to create aFileIOErrorfor aSecurityException.booleanisSuccess()static EFileIOErrorCodevalueOf(String name)Returns the enum constant of this type with the specified name.static EFileIOErrorCode[]values()Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface com.helger.commons.state.ISuccessIndicator
and, isFailure, or
-
-
-
-
Enum Constant Detail
-
NO_ERROR
public static final EFileIOErrorCode NO_ERROR
Generic error code: no error.
-
OPERATION_FAILED
public static final EFileIOErrorCode OPERATION_FAILED
Generic error code: operation failed but we don't know why.
-
SECURITY_ERROR
public static final EFileIOErrorCode SECURITY_ERROR
Generic error code: a SecurityException occurred.
-
SOURCE_DOES_NOT_EXIST
public static final EFileIOErrorCode SOURCE_DOES_NOT_EXIST
A source file or directory does not exist.
-
TARGET_ALREADY_EXISTS
public static final EFileIOErrorCode TARGET_ALREADY_EXISTS
A destination file or directory already exists.
-
SOURCE_EQUALS_TARGET
public static final EFileIOErrorCode SOURCE_EQUALS_TARGET
Source and destination object are identical.
-
TARGET_IS_CHILD_OF_SOURCE
public static final EFileIOErrorCode TARGET_IS_CHILD_OF_SOURCE
Avoid recursive dependencies.
-
OBJECT_CANNOT_BE_HANDLED
public static final EFileIOErrorCode OBJECT_CANNOT_BE_HANDLED
We stumble across an object that is neither a file nor a directory.
-
OBJECT_HAS_NO_PARENT
public static final EFileIOErrorCode OBJECT_HAS_NO_PARENT
An object's parent could not be retrieved.
-
SOURCE_NOT_READABLE
public static final EFileIOErrorCode SOURCE_NOT_READABLE
The source object cannot be read.
-
SOURCE_PARENT_NOT_WRITABLE
public static final EFileIOErrorCode SOURCE_PARENT_NOT_WRITABLE
The source parent object is read-only (not writable).
-
TARGET_PARENT_NOT_WRITABLE
public static final EFileIOErrorCode TARGET_PARENT_NOT_WRITABLE
The target parent object is read-only (not writable).
-
IO_ERROR
public static final EFileIOErrorCode IO_ERROR
Generic IO code: an IOException occurred.
-
-
Method Detail
-
values
public static EFileIOErrorCode[] 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 (EFileIOErrorCode c : EFileIOErrorCode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static EFileIOErrorCode 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
-
getID
@Nonnegative public int getID()
An internal ID for easier referencing.NO_ERRORhas ID 0. All errors have positive numbers.
-
getAsIOError
@Nonnull public FileIOError getAsIOError(@Nonnull EFileIOOperation eOperation, @Nonnull File aFile)
Use this error code to create a newFileIOErrorinstance.- Parameters:
eOperation- The operation carried out. May not benull.aFile- The file on which operation was carried out. May not benull.- Returns:
- The new
FileIOErrorand nevernull.
-
getAsIOError
@Nonnull public FileIOError getAsIOError(@Nonnull EFileIOOperation eOperation, @Nonnull Path aPath)
Use this error code to create a newFileIOErrorinstance.- Parameters:
eOperation- The operation carried out. May not benull.aPath- The path on which operation was carried out. May not benull.- Returns:
- The new
FileIOErrorand nevernull.
-
getAsIOError
@Nonnull public FileIOError getAsIOError(@Nonnull EFileIOOperation eOperation, @Nonnull File aFile1, @Nonnull File aFile2)
Use this error code to create a newFileIOErrorinstance.- Parameters:
eOperation- The operation carried out. May not benull.aFile1- The first file on which operation was carried out. May not benull.aFile2- The second file on which operation was carried out. May not benull.- Returns:
- The new
FileIOErrorand nevernull.
-
getAsIOError
@Nonnull public FileIOError getAsIOError(@Nonnull EFileIOOperation eOperation, @Nonnull Path aFile1, @Nonnull Path aFile2)
Use this error code to create a newFileIOErrorinstance.- Parameters:
eOperation- The operation carried out. May not benull.aFile1- The first file on which operation was carried out. May not benull.aFile2- The second file on which operation was carried out. May not benull.- Returns:
- The new
FileIOErrorand nevernull.
-
isSuccess
public boolean isSuccess()
- Specified by:
isSuccessin interfaceISuccessIndicator- Returns:
trueif this isNO_ERROR,falseotherwise.
-
getSecurityAsIOError
@Nonnull public static FileIOError getSecurityAsIOError(@Nonnull EFileIOOperation eOperation, @Nonnull SecurityException ex)
Static method to create aFileIOErrorfor aSecurityException.- Parameters:
eOperation- The performed operation. May not benull.ex- The occurredSecurityException. Nevernull.- Returns:
- The non-
nullFileIOError.
-
getAsIOError
@Nonnull public static FileIOError getAsIOError(@Nonnull EFileIOOperation eOperation, @Nonnull IOException ex)
Static method to create aFileIOErrorfor anIOException.- Parameters:
eOperation- The performed operation. May not benull.ex- The occurredIOException. Nevernull.- Returns:
- The non-
nullFileIOError.
-
getAsIOError
@Nonnull public static FileIOError getAsIOError(@Nonnull EFileIOOperation eOperation, @Nonnull UncheckedIOException ex)
Static method to create aFileIOErrorfor anUncheckedIOException.- Parameters:
eOperation- The performed operation. May not benull.ex- The occurredUncheckedIOException. Nevernull.- Returns:
- The non-
nullFileIOError.
-
getFromIDOrNull
@Nullable public static EFileIOErrorCode getFromIDOrNull(int nID)
-
-