net.sf.jasperreports.engine.util
Class JRLoader

java.lang.Object
  extended by net.sf.jasperreports.engine.util.JRLoader

public final class JRLoader
extends Object

Version:
$Id: JRLoader.java 5180 2012-03-29 13:23:12Z teodord $
Author:
Teodor Danciu (teodord@users.sourceforge.net)

Method Summary
protected static void collectResources(String resourceName, ClassLoader classLoader, Map<URL,ClassLoaderResource> resources)
           
protected static void collectResources(String resourceName, ClassLoader classLoader, Set<URL> resources)
           
static List<ClassLoaderResource> getClassLoaderResources(String resource)
          Scans the context classloader and the classloader of this class for all resources that have a specified name, and returns a list of ClassLoaderResource objects for the found resources.
static InputStream getFileInputStream(String filename)
          Tries to open a file for reading.
static InputStream getInputStream(File file)
           
static InputStream getInputStream(URL url)
           
static InputStream getInputStreamFromLocation(String location)
          Deprecated. Replaced by RepositoryUtil.getInputStream(String).
static InputStream getInputStreamFromLocation(String location, ClassLoader classLoader, URLStreamHandlerFactory urlHandlerFactory, FileResolver fileResolver)
          Deprecated. Replaced by RepositoryUtil.getInputStream(String).
static InputStream getLocationInputStream(String location)
          Tries to open an input stream for a location.
static URL getResource(String resource)
          Returns the resource URL for a specified resource name.
static InputStream getResourceInputStream(String resource)
          Tries to open an input stream for a resource.
static List<URL> getResources(String resource)
          Scans the context classloader and the classloader of this class for all resources that have a specified name, and returns a list of URLs for the found resources.
static InputStream getURLInputStream(String spec)
          Tries to open an input stream for an URL.
static byte[] loadBytes(File file)
           
static byte[] loadBytes(InputStream is)
           
static byte[] loadBytes(URL url)
           
static byte[] loadBytesFromLocation(String location)
          Deprecated. Replaced by RepositoryUtil.getBytes(String).
static byte[] loadBytesFromLocation(String location, ClassLoader classLoader)
          Deprecated. Replaced by RepositoryUtil.getBytes(String).
static byte[] loadBytesFromLocation(String location, ClassLoader classLoader, URLStreamHandlerFactory urlHandlerFactory)
          Deprecated. Replaced by RepositoryUtil.getBytes(String).
static byte[] loadBytesFromLocation(String location, ClassLoader classLoader, URLStreamHandlerFactory urlHandlerFactory, FileResolver fileResolver)
          Deprecated. Replaced by RepositoryUtil.getBytes(String).
static byte[] loadBytesFromResource(String resourceName)
           
static byte[] loadBytesFromResource(String resourceName, ClassLoader classLoader)
           
static JasperPrint loadJasperPrint(File file, JRVirtualizer virtualizer)
          Loads a JasperPrint object from a file, optionally using a virtualizer for the object.
static JasperPrint loadJasperPrint(InputStream is, JRVirtualizer virtualizer)
          Loads a JasperPrint object from a stream, optionally using a virtualizer for the object.
static JasperPrint loadJasperPrint(URL url, JRVirtualizer virtualizer)
          Loads a JasperPrint object from a URL, optionally using a virtualizer for the object.
static JasperPrint loadJasperPrintFromFile(String fileName, JRVirtualizer virtualizer)
          Loads a JasperPrint object from a file, optionally using a virtualizer for the object.
static Object loadObject(File file)
           
static Object loadObject(InputStream is)
           
static Object loadObject(String fileName)
          Deprecated. Replaced by loadObjectFromFile(String).
static Object loadObject(URL url)
           
static Object loadObjectFromFile(String fileName)
           
static Object loadObjectFromLocation(String location)
          Deprecated. Replaced by RepositoryUtil.getResource(String, Class).
static Object loadObjectFromLocation(String location, ClassLoader classLoader)
          Deprecated. Replaced by RepositoryUtil.getResource(String, Class).
static Object loadObjectFromLocation(String location, ClassLoader classLoader, URLStreamHandlerFactory urlHandlerFactory, FileResolver fileResolver)
          Deprecated. Replaced by RepositoryUtil.getResource(String, Class).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadObject

public static Object loadObject(String fileName)
                         throws JRException
Deprecated. Replaced by loadObjectFromFile(String).

Throws:
JRException

loadObjectFromFile

public static Object loadObjectFromFile(String fileName)
                                 throws JRException
Throws:
JRException

loadObject

public static Object loadObject(File file)
                         throws JRException
Throws:
JRException

loadObject

public static Object loadObject(URL url)
                         throws JRException
Throws:
JRException

loadObject

public static Object loadObject(InputStream is)
                         throws JRException
Throws:
JRException

loadObjectFromLocation

public static Object loadObjectFromLocation(String location)
                                     throws JRException
Deprecated. Replaced by RepositoryUtil.getResource(String, Class).

Throws:
JRException

loadObjectFromLocation

public static Object loadObjectFromLocation(String location,
                                            ClassLoader classLoader)
                                     throws JRException
Deprecated. Replaced by RepositoryUtil.getResource(String, Class).

Throws:
JRException

loadObjectFromLocation

public static Object loadObjectFromLocation(String location,
                                            ClassLoader classLoader,
                                            URLStreamHandlerFactory urlHandlerFactory,
                                            FileResolver fileResolver)
                                     throws JRException
Deprecated. Replaced by RepositoryUtil.getResource(String, Class).

Throws:
JRException

getInputStream

public static InputStream getInputStream(File file)
                                  throws JRException
Throws:
JRException

getInputStream

public static InputStream getInputStream(URL url)
                                  throws JRException
Throws:
JRException

getInputStreamFromLocation

public static InputStream getInputStreamFromLocation(String location)
                                              throws JRException
Deprecated. Replaced by RepositoryUtil.getInputStream(String).

Throws:
JRException

getInputStreamFromLocation

public static InputStream getInputStreamFromLocation(String location,
                                                     ClassLoader classLoader,
                                                     URLStreamHandlerFactory urlHandlerFactory,
                                                     FileResolver fileResolver)
                                              throws JRException
Deprecated. Replaced by RepositoryUtil.getInputStream(String).

Throws:
JRException

loadBytes

public static byte[] loadBytes(File file)
                        throws JRException
Throws:
JRException

loadBytes

public static byte[] loadBytes(URL url)
                        throws JRException
Throws:
JRException

loadBytes

public static byte[] loadBytes(InputStream is)
                        throws JRException
Throws:
JRException

loadBytesFromResource

public static byte[] loadBytesFromResource(String resourceName)
                                    throws JRException
Throws:
JRException

loadBytesFromResource

public static byte[] loadBytesFromResource(String resourceName,
                                           ClassLoader classLoader)
                                    throws JRException
Throws:
JRException

loadBytesFromLocation

public static byte[] loadBytesFromLocation(String location)
                                    throws JRException
Deprecated. Replaced by RepositoryUtil.getBytes(String).

Throws:
JRException

loadBytesFromLocation

public static byte[] loadBytesFromLocation(String location,
                                           ClassLoader classLoader)
                                    throws JRException
Deprecated. Replaced by RepositoryUtil.getBytes(String).

Throws:
JRException

loadBytesFromLocation

public static byte[] loadBytesFromLocation(String location,
                                           ClassLoader classLoader,
                                           URLStreamHandlerFactory urlHandlerFactory)
                                    throws JRException
Deprecated. Replaced by RepositoryUtil.getBytes(String).

Throws:
JRException

loadBytesFromLocation

public static byte[] loadBytesFromLocation(String location,
                                           ClassLoader classLoader,
                                           URLStreamHandlerFactory urlHandlerFactory,
                                           FileResolver fileResolver)
                                    throws JRException
Deprecated. Replaced by RepositoryUtil.getBytes(String).

Throws:
JRException

getLocationInputStream

public static InputStream getLocationInputStream(String location)
                                          throws JRException
Tries to open an input stream for a location.

The method tries to interpret the location as a file name, a resource name or an URL. If any of these succeed, an input stream is created and returned.

Parameters:
location - the location
Returns:
an input stream if the location is an existing file name, a resource name on the classpath or an URL or null otherwise.
Throws:
JRException

getFileInputStream

public static InputStream getFileInputStream(String filename)
                                      throws JRException
Tries to open a file for reading.

Parameters:
filename - the file name
Returns:
an input stream for the file or null if the file was not found
Throws:
JRException

getResourceInputStream

public static InputStream getResourceInputStream(String resource)
Tries to open an input stream for a resource.

Parameters:
resource - the resource name
Returns:
an input stream for the resource or null if the resource was not found

getResources

public static List<URL> getResources(String resource)
Scans the context classloader and the classloader of this class for all resources that have a specified name, and returns a list of URLs for the found resources.

Parameters:
resource - the resource names
Returns:
a list of URLs of resources with the specified name; the list is empty if no resources have been found for the name
See Also:
ClassLoader.getResources(String)

collectResources

protected static void collectResources(String resourceName,
                                       ClassLoader classLoader,
                                       Set<URL> resources)

getClassLoaderResources

public static List<ClassLoaderResource> getClassLoaderResources(String resource)
Scans the context classloader and the classloader of this class for all resources that have a specified name, and returns a list of ClassLoaderResource objects for the found resources.

The returned list contains the URLs of the resources, and for each resource the highest classloader in the classloader hierarchy on which the resource was found.

Parameters:
resource - the resource names
Returns:
a list of resources with the specified name; the list is empty if no resources have been found for the name
See Also:
ClassLoader.getResources(String)

collectResources

protected static void collectResources(String resourceName,
                                       ClassLoader classLoader,
                                       Map<URL,ClassLoaderResource> resources)

getResource

public static URL getResource(String resource)
Returns the resource URL for a specified resource name.

Parameters:
resource - the resource name
Returns:
the URL of the resource having the specified name, or null if none found
See Also:
ClassLoader.getResource(String)

getURLInputStream

public static InputStream getURLInputStream(String spec)
                                     throws JRException
Tries to open an input stream for an URL.

Parameters:
spec - the string to parse as an URL
Returns:
an input stream for the URL or null if spec is not a valid URL
Throws:
JRException

loadJasperPrintFromFile

public static JasperPrint loadJasperPrintFromFile(String fileName,
                                                  JRVirtualizer virtualizer)
                                           throws JRException
Loads a JasperPrint object from a file, optionally using a virtualizer for the object.

Parameters:
fileName - the file name
virtualizer - the virtualizer
Returns:
a JasperPrint object
Throws:
JRException
See Also:
JRVirtualizationHelper.setThreadVirtualizer(JRVirtualizer)

loadJasperPrint

public static JasperPrint loadJasperPrint(File file,
                                          JRVirtualizer virtualizer)
                                   throws JRException
Loads a JasperPrint object from a file, optionally using a virtualizer for the object.

Parameters:
file - the file
virtualizer - the virtualizer
Returns:
a JasperPrint object
Throws:
JRException
See Also:
JRVirtualizationHelper.setThreadVirtualizer(JRVirtualizer)

loadJasperPrint

public static JasperPrint loadJasperPrint(URL url,
                                          JRVirtualizer virtualizer)
                                   throws JRException
Loads a JasperPrint object from a URL, optionally using a virtualizer for the object.

Parameters:
url - the URL
virtualizer - the virtualizer
Returns:
a JasperPrint object
Throws:
JRException
See Also:
JRVirtualizationHelper.setThreadVirtualizer(JRVirtualizer)

loadJasperPrint

public static JasperPrint loadJasperPrint(InputStream is,
                                          JRVirtualizer virtualizer)
                                   throws JRException
Loads a JasperPrint object from a stream, optionally using a virtualizer for the object.

Parameters:
is - the stream
virtualizer - the virtualizer
Returns:
a JasperPrint object
Throws:
JRException
See Also:
JRVirtualizationHelper.setThreadVirtualizer(JRVirtualizer)


Copyright © 2012. All Rights Reserved.