Class CachingResourceData
- java.lang.Object
-
- org.pentaho.reporting.libraries.resourceloader.cache.CachingResourceData
-
- All Implemented Interfaces:
Serializable
,ResourceData
public class CachingResourceData extends Object implements ResourceData, Serializable
A very simple implementation which is suitable for smaller objects. The complete data is read into memory.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.pentaho.reporting.libraries.resourceloader.ResourceData
CONTENT_LENGTH, CONTENT_TYPE, FILENAME
-
-
Constructor Summary
Constructors Constructor Description CachingResourceData(ResourceData data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ResourceData
createCached(ResourceData data)
Object
getAttribute(String key)
ResourceKey
getKey()
long
getLength()
byte[]
getResource(ResourceManager caller)
This is dangerous, especially if the resource is large.int
getResource(ResourceManager caller, byte[] target, long offset, int length)
Tries to read data into the given byte-array.InputStream
getResourceAsStream(ResourceManager caller)
long
getVersion(ResourceManager caller)
-
-
-
Constructor Detail
-
CachingResourceData
public CachingResourceData(ResourceData data)
-
-
Method Detail
-
getResourceAsStream
public InputStream getResourceAsStream(ResourceManager caller) throws ResourceLoadingException
- Specified by:
getResourceAsStream
in interfaceResourceData
- Throws:
ResourceLoadingException
-
getLength
public long getLength()
- Specified by:
getLength
in interfaceResourceData
-
getResource
public byte[] getResource(ResourceManager caller) throws ResourceLoadingException
Description copied from interface:ResourceData
This is dangerous, especially if the resource is large.- Specified by:
getResource
in interfaceResourceData
- Returns:
- Throws:
ResourceLoadingException
-
getResource
public int getResource(ResourceManager caller, byte[] target, long offset, int length) throws ResourceLoadingException
Description copied from interface:ResourceData
Tries to read data into the given byte-array.- Specified by:
getResource
in interfaceResourceData
- Returns:
- the number of bytes read or -1 if no more data can be read.
- Throws:
ResourceLoadingException
-
getAttribute
public Object getAttribute(String key)
- Specified by:
getAttribute
in interfaceResourceData
-
getKey
public ResourceKey getKey()
- Specified by:
getKey
in interfaceResourceData
-
getVersion
public long getVersion(ResourceManager caller) throws ResourceLoadingException
- Specified by:
getVersion
in interfaceResourceData
- Throws:
ResourceLoadingException
-
createCached
public static ResourceData createCached(ResourceData data)
-
-