Package com.pd4ml

Class ResourceProvider


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

      Fields 
      Modifier and Type Field Description
      java.lang.String mime  
      java.net.URL redirected  
      • Fields inherited from class com.pd4ml.util.Base

        LOG_ALL, LOG_CACHE, LOG_CSS, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_FONTS, LOG_INFO, LOG_MINIMAL, LOG_PARSE, LOG_TRACE, LOG_USAGE, LOG_VERBOSE, LOG_WARN, NO_LOG, PD4ML_LOG_LEVEL
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract boolean canLoad​(java.lang.String resource, com.pd4ml.cache.FileCache cache)  
      abstract void closeResourceStream()
      method closes the resource stream
      boolean dontCache()  
      java.lang.String getEncoding()  
      java.lang.String getMime()  
      byte[] getResourceAsBytes​(java.lang.String resource, com.pd4ml.cache.FileCache cache)
      The default implementation reads fully input stream returned by getResourceAsStream() and returns it as a byte array.
      abstract java.io.BufferedInputStream getResourceAsStream​(java.lang.String resource, com.pd4ml.cache.FileCache cache)  
      boolean isDirectory()  
      abstract java.io.File localFile()  
      • Methods inherited from class com.pd4ml.util.Base

        log, printLog
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • mime

        public java.lang.String mime
      • redirected

        public java.net.URL redirected
    • Constructor Detail

      • ResourceProvider

        public ResourceProvider()
    • Method Detail

      • getResourceAsStream

        public abstract java.io.BufferedInputStream getResourceAsStream​(java.lang.String resource,
                                                                        com.pd4ml.cache.FileCache cache)
                                                                 throws java.io.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:
        java.io.IOException - general IO exception
      • canLoad

        public abstract boolean canLoad​(java.lang.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 java.io.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​(java.lang.String resource,
                                         com.pd4ml.cache.FileCache cache)
                                  throws java.io.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:
        java.io.IOException - general IO exception
      • getMime

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

        public java.lang.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