Package com.helger.io.resourceprovider
Class FileSystemResourceProvider
java.lang.Object
com.helger.io.resourceprovider.FileSystemResourceProvider
- All Implemented Interfaces:
IReadableResourceProvider,IWritableResourceProvider
@ThreadSafe
public class FileSystemResourceProvider
extends Object
implements IWritableResourceProvider
Simple resource provider that only uses files.
- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor without a base path.FileSystemResourceProvider(@Nullable File aBasePath) Constructor with a base path file.FileSystemResourceProvider(@NonNull String sBasePath) Constructor with a base path string. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal @Nullable File@NonNull IReadableResourcegetReadableResource(@NonNull String sName) Get the resource specified by the given name for reading.@NonNull IWritableResourcegetWritableResource(@NonNull String sName) Get the resource specified by the given name for writing.inthashCode()final booleanfinal @NonNull FileSystemResourceProvidersetCanReadRelativePaths(boolean bCanReadRelativePaths) Enable or disable reading of relative paths.booleansupportsReading(@Nullable String sName) Check if this resource provider can handle the resource with the passed name.booleansupportsWriting(@Nullable String sName) Check if this resource provider can handle the resource with the passed name.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.io.resourceprovider.IReadableResourceProvider
getInputStreamMethods inherited from interface com.helger.io.resourceprovider.IWritableResourceProvider
getOutputStream
-
Constructor Details
-
FileSystemResourceProvider
public FileSystemResourceProvider()Constructor without a base path. -
FileSystemResourceProvider
Constructor with a base path string.- Parameters:
sBasePath- The base path to use. May not benull. Must be an existing directory.
-
FileSystemResourceProvider
Constructor with a base path file.- Parameters:
aBasePath- The base path to use. May benull. If provided, must be an existing directory.
-
-
Method Details
-
getBasePath
- Returns:
- The base path as provided in the constructor. May be
null.
-
isCanReadRelativePaths
public final boolean isCanReadRelativePaths()- Returns:
trueif relative paths can be read,falseif only absolute paths are supported.
-
setCanReadRelativePaths
public final @NonNull FileSystemResourceProvider setCanReadRelativePaths(boolean bCanReadRelativePaths) Enable or disable reading of relative paths.- Parameters:
bCanReadRelativePaths-trueto enable relative path reading,falseto restrict to absolute paths.- Returns:
- this for chaining
-
supportsReading
Check if this resource provider can handle the resource with the passed name. If there is no real check on whether your resource provider can handle it, simply returntrue.- Specified by:
supportsReadingin interfaceIReadableResourceProvider- Parameters:
sName- The name to check. May benull.- Returns:
trueif the name is notnulland can be handled by this provider,falseotherwise.
-
supportsWriting
Check if this resource provider can handle the resource with the passed name. If there is no real check on whether your resource provider can handle it, simply returntrue.- Specified by:
supportsWritingin interfaceIWritableResourceProvider- Parameters:
sName- The name to check. May benull.- Returns:
trueif the name is notnulland can be handled by this provider,falseotherwise.
-
getReadableResource
Get the resource specified by the given name for reading.- Specified by:
getReadableResourcein interfaceIReadableResourceProvider- Parameters:
sName- The name of the resource to resolve.- Returns:
- The readable resource. Never
null.
-
getWritableResource
Get the resource specified by the given name for writing.- Specified by:
getWritableResourcein interfaceIWritableResourceProvider- Parameters:
sName- The name of the resource to resolve.- Returns:
- The writable resource. Never
null.
-
equals
-
hashCode
public int hashCode() -
toString
-