Package com.helger.io.resource.inmemory
Class AbstractMemoryReadableResource
java.lang.Object
com.helger.io.resource.inmemory.AbstractMemoryReadableResource
- All Implemented Interfaces:
com.helger.base.io.iface.IHasInputStream,com.helger.base.io.iface.IHasInputStreamAndReader,IMemoryReadableResource,IReadableResource,IResourceBase
- Direct Known Subclasses:
ReadableResourceByteArray,ReadableResourceInputStream
public abstract class AbstractMemoryReadableResource
extends Object
implements IMemoryReadableResource
Abstract base class for an
IReadableResource that is not really a resource but where the
API does not offer alternatives. These resources cannot be converted to a file or to a URL.- Author:
- Philip Helger
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMemoryReadableResource(@NonNull @Nonempty String sResourceID) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexists()@Nullable File@Nullable URLgetAsURL()@NonNull StringgetPath()@NonNull IReadableResourcegetReadableCloneForPath(@NonNull String sPath) Get a new resource of the same implementation type as this object but for a different path.final @NonNull @Nonempty StringvoidSet the path of this in-memory resource.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.base.io.iface.IHasInputStream
getBufferedInputStream, getInputStream, isReadMultiple, withBufferedInputStreamDo, withInputStreamDoMethods inherited from interface com.helger.base.io.iface.IHasInputStreamAndReader
getBufferedReader, getReader
-
Constructor Details
-
AbstractMemoryReadableResource
Constructor.- Parameters:
sResourceID- The mandatory resource ID, used as the cache key. May neither benullnor empty.
-
-
Method Details
-
getResourceID
- Specified by:
getResourceIDin interfaceIResourceBase- Returns:
- The resource ID as provided in the constructor. Neither
nullnor empty.
-
getPath
- Specified by:
getPathin interfaceIResourceBase- Returns:
- The requested path. Never
null
-
setPath
Set the path of this in-memory resource.- Parameters:
sPath- The path to set. May not benull.
-
getAsURL
- Specified by:
getAsURLin interfaceIResourceBase- Returns:
- Always
nullsince in-memory resources cannot be represented as a URL.
-
getAsFile
- Specified by:
getAsFilein interfaceIResourceBase- Returns:
- Always
nullsince in-memory resources cannot be represented as a file.
-
exists
public boolean exists()- Specified by:
existsin interfaceIResourceBase- Returns:
- Always
truesince in-memory resources always exist.
-
getReadableCloneForPath
@UnsupportedOperation public @NonNull IReadableResource getReadableCloneForPath(@NonNull String sPath) Get a new resource of the same implementation type as this object but for a different path.- Specified by:
getReadableCloneForPathin interfaceIReadableResource- Parameters:
sPath- The new path to use. May not benull.- Returns:
- The resource of the same implementation but a different path. May
not be
null.
-
toString
-