Package com.pd4ml
Class ResourceProvider
- java.lang.Object
-
- com.pd4ml.util.Base
-
- com.pd4ml.ResourceProvider
-
public abstract class ResourceProvider extends com.pd4ml.util.BaseBase class for customer resource reader implementations
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.Stringmimejava.net.URLredirected
-
Constructor Summary
Constructors Constructor Description ResourceProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleancanLoad(java.lang.String resource, com.pd4ml.cache.FileCache cache)abstract voidcloseResourceStream()method closes the resource streambooleandontCache()java.lang.StringgetEncoding()java.lang.StringgetMime()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.BufferedInputStreamgetResourceAsStream(java.lang.String resource, com.pd4ml.cache.FileCache cache)booleanisDirectory()abstract java.io.FilelocalFile()
-
-
-
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.IOExceptionThe 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
-
-