Package com.pd4ml

Class ResourceProvider


  • public abstract class ResourceProvider
    extends com.pd4ml.util.Base
    Base class for customer resource reader implementations
    • Field Detail

      • redirected

        public URL redirected
    • Constructor Detail

      • ResourceProvider

        public ResourceProvider()
    • Method Detail

      • getResourceAsStream

        public abstract BufferedInputStream getResourceAsStream​(String resource,
                                                                com.pd4ml.cache.FileCache cache)
                                                         throws IOException
        Parameters:
        resource - resource address or some kind of resource identifier (notation is implementation dependent)
        cache - current file cache instance. Used by PD4ML native resource loaders to get various context info and logging level
        Returns:
        the requested resource as an input stream
        Throws:
        IOException - general IO exception
      • canLoad

        public abstract boolean canLoad​(String resource,
                                        com.pd4ml.cache.FileCache cache)
        Parameters:
        resource - resource address or some kind of resource identifier (notation is implementation dependent)
        cache - current file cache instance. Used by PD4ML native resource loaders to get various context info and logging level
        Returns:
        "true" if the resource loader "understands" the resource identifier notation and is capable to load the resource
      • dontCache

        public boolean dontCache()
        Returns:
        "true" if the loaded resources should not be cached. Default implementation returns "false"
      • localFile

        public abstract File localFile()
        Returns:
        local file reference if the resource exists as a local (temp) file. Otherwise it should return null
      • closeResourceStream

        public abstract void closeResourceStream()
        method closes the resource stream
      • getResourceAsBytes

        public byte[] getResourceAsBytes​(String resource,
                                         com.pd4ml.cache.FileCache cache)
                                  throws IOException
        The default implementation reads fully input stream returned by getResourceAsStream() and returns it as a byte array. No need to override in most cases.
        Parameters:
        resource - resource address or some kind of resource identifier (notation is implementation dependent)
        cache - current file cache instance. Used by PD4ML native resource loaders to get various context info and logging level
        Returns:
        the requested resource as a byte array
        Throws:
        IOException - general IO exception
      • getMime

        public String getMime()
        Returns:
        MIME of the loaded resource or null
      • getEncoding

        public String getEncoding()
        Returns:
        encoding of the loaded resource or null
      • isDirectory

        public boolean isDirectory()
        Returns:
        "true" if the requested resource address points not to a file, but a folder/directory