Package com.helger.io.resourceprovider
Class WritableResourceProviderChain
java.lang.Object
com.helger.io.resourceprovider.ReadableResourceProviderChain
com.helger.io.resourceprovider.WritableResourceProviderChain
- All Implemented Interfaces:
IReadableResourceProvider,IWritableResourceProvider
- Direct Known Subclasses:
DefaultResourceProvider
@Immutable
public class WritableResourceProviderChain
extends ReadableResourceProviderChain
implements IWritableResourceProvider
A resource provider chain implementation of
IWritableResourceProvider .- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.helger.collection.commons.ICommonsList<IWritableResourceProvider> -
Constructor Summary
ConstructorsConstructorDescriptionWritableResourceProviderChain(@NonNull IReadableResourceProvider... aResProviders) Constructor with a varargs array of resource providers.WritableResourceProviderChain(@NonNull Iterable<? extends IReadableResourceProvider> aResProviders) Constructor with an iterable of resource providers. -
Method Summary
Modifier and TypeMethodDescriptionboolean@NonNull @Nonempty com.helger.collection.commons.ICommonsList<IWritableResourceProvider> @Nullable OutputStreamgetOutputStream(@NonNull String sName, @NonNull com.helger.base.io.EAppend eAppend) Get theOutputStreamspecified by the given name for reading.@NonNull IWritableResourcegetWritableResource(@NonNull String sName) Get the resource specified by the given name for writing.@Nullable IWritableResourcegetWritableResourceIf(@NonNull String sName, @NonNull Predicate<? super IWritableResource> aReturnFilter) Get a writable resource matching the name and filter.inthashCode()final booleansupportsWriting(@Nullable String sName) Check if this resource provider can handle the resource with the passed name.toString()Methods inherited from class com.helger.io.resourceprovider.ReadableResourceProviderChain
getAllContainedReadingResourceProviders, getInputStream, getReadableResource, getReadableResourceIf, readingResourceProviders, supportsReadingMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.io.resourceprovider.IReadableResourceProvider
getInputStream, getReadableResource, supportsReading
-
Field Details
-
m_aWritableResourceProviders
protected final com.helger.collection.commons.ICommonsList<IWritableResourceProvider> m_aWritableResourceProviders
-
-
Constructor Details
-
WritableResourceProviderChain
Constructor with a varargs array of resource providers.- Parameters:
aResProviders- The resource providers to use. May neither benullnor empty. At least one must implementIWritableResourceProvider.
-
WritableResourceProviderChain
public WritableResourceProviderChain(@NonNull Iterable<? extends IReadableResourceProvider> aResProviders) Constructor with an iterable of resource providers.- Parameters:
aResProviders- The resource providers to use. May neither benullnor empty. At least one must implementIWritableResourceProvider.
-
-
Method Details
-
getAllContainedWritingResourceProviders
@Nonempty @ReturnsMutableCopy public @NonNull @Nonempty com.helger.collection.commons.ICommonsList<IWritableResourceProvider> getAllContainedWritingResourceProviders()- Returns:
- A copy of all contained writable resource providers. Never
null.
-
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.
-
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.
-
getWritableResourceIf
public @Nullable IWritableResource getWritableResourceIf(@NonNull String sName, @NonNull Predicate<? super IWritableResource> aReturnFilter) Get a writable resource matching the name and filter.- Parameters:
sName- The name of the resource to resolve. May not benull.aReturnFilter- The filter to apply on found resources. May not benull.- Returns:
nullif no matching resource was found.
-
getOutputStream
public @Nullable OutputStream getOutputStream(@NonNull String sName, @NonNull com.helger.base.io.EAppend eAppend) Description copied from interface:IWritableResourceProviderGet theOutputStreamspecified by the given name for reading. This method may be called without prior call toIWritableResourceProvider.supportsWriting(String).- Specified by:
getOutputStreamin interfaceIWritableResourceProvider- Parameters:
sName- The name of the resource to resolve.eAppend- Appending mode. May not benull.- Returns:
- The
OutputStream. May benullif the underlying resource does not exist and cannot be created or ifIWritableResourceProvider.supportsWriting(String)returnsfalse.
-
equals
- Overrides:
equalsin classReadableResourceProviderChain
-
hashCode
public int hashCode()- Overrides:
hashCodein classReadableResourceProviderChain
-
toString
- Overrides:
toStringin classReadableResourceProviderChain
-