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 Details

    • AbstractMemoryReadableResource

      protected AbstractMemoryReadableResource(@Nonempty @NonNull @Nonempty String sResourceID)
      Constructor.
      Parameters:
      sResourceID - The mandatory resource ID, used as the cache key. May neither be null nor empty.
  • Method Details

    • getResourceID

      @Nonempty public final @NonNull @Nonempty String getResourceID()
      Specified by:
      getResourceID in interface IResourceBase
      Returns:
      The resource ID as provided in the constructor. Neither null nor empty.
    • getPath

      public @NonNull String getPath()
      Specified by:
      getPath in interface IResourceBase
      Returns:
      The requested path. Never null
    • setPath

      public void setPath(@NonNull String sPath)
      Set the path of this in-memory resource.
      Parameters:
      sPath - The path to set. May not be null.
    • getAsURL

      public @Nullable URL getAsURL()
      Specified by:
      getAsURL in interface IResourceBase
      Returns:
      Always null since in-memory resources cannot be represented as a URL.
    • getAsFile

      public @Nullable File getAsFile()
      Specified by:
      getAsFile in interface IResourceBase
      Returns:
      Always null since in-memory resources cannot be represented as a file.
    • exists

      public boolean exists()
      Specified by:
      exists in interface IResourceBase
      Returns:
      Always true since 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:
      getReadableCloneForPath in interface IReadableResource
      Parameters:
      sPath - The new path to use. May not be null.
      Returns:
      The resource of the same implementation but a different path. May not be null.
    • toString

      public String toString()
      Overrides:
      toString in class Object