Java 类net.sf.jasperreports.engine.util.JRResourcesUtil 实例源码

项目:jasperreports    文件:JRResourcesFillUtil.java   
@SuppressWarnings("deprecation")
public static void revertResourcesFillContext(ResourcesFillContext context)
{
    if (context.getClassLoader() != null)
    {
        JRResourcesUtil.resetClassLoader();
    }

    if (context.getUrlHandlerFactory() != null)
    {
        JRResourcesUtil.resetThreadURLHandlerFactory();
    }

    if (context.getFileResolver() != null)
    {
        JRResourcesUtil.resetThreadFileResolver();
    }
}
项目:PDFReporter-Studio    文件:ExpressionContextUtils.java   
/**
 * Returns the {@link ResourceBundle} associated to the specified dataset.
 * As fallback solution we look in the main dataset.
 * 
 * @param dataset the dataset to look into
 * @param jconfig the {@link JasperReportsContext} instance
 * @return the {@link ResourceBundle} if any, <code>null</code> otherwise
 */
public static ResourceBundle getResourceBundle(JRDataset dataset, JasperReportsConfiguration jconfig) {
    String baseName = dataset.getResourceBundle();
    ResourceBundle loadedBundle = null;
    if(baseName==null) {
        baseName = jconfig.getJasperDesign().getMainDataset().getResourceBundle();
    }
    if(!Misc.isNullOrEmpty(baseName)) {
        Locale locale = Locale.getDefault();
        Object obj = jconfig.getJRParameters().get(JRParameter.REPORT_LOCALE);
        if (obj instanceof Locale) {
            locale = (Locale) obj;
        }
        try {
            loadedBundle = JRResourcesUtil.loadResourceBundle(baseName, locale, jconfig.getClassLoader());
        }
        catch (MissingResourceException e) {
            JaspersoftStudioPlugin.getInstance().logError(
                    NLS.bind("Unable to get the resource bundle with base name {0}.",baseName), e);
        }
    }
    return loadedBundle;
}
项目:jasperreports    文件:JRFillDataset.java   
/**
 * Loads the resource bundle corresponding to the resource bundle base name and locale.
 */
protected ResourceBundle loadResourceBundle()
{
    ResourceBundle loadedBundle;
    if (resourceBundleBaseName == null)
    {
        loadedBundle = null;
    }
    else
    {
        loadedBundle = JRResourcesUtil.loadResourceBundle(getJasperReportsContext(), resourceBundleBaseName, locale);
    }
    return loadedBundle;
}
项目:jasperreports    文件:JRResourcesFillUtil.java   
@SuppressWarnings("deprecation")
public static ResourcesFillContext setResourcesFillContext(Map<String,Object> parameterValues)
{
    ResourcesFillContext context = new ResourcesFillContext();

    ClassLoader classLoader = (ClassLoader) parameterValues.get(
            JRParameter.REPORT_CLASS_LOADER);
    if (classLoader != null)
    {
        JRResourcesUtil.setThreadClassLoader(classLoader);
        context.setClassLoader(classLoader);
    }

    URLStreamHandlerFactory urlHandlerFactory = (URLStreamHandlerFactory) 
            parameterValues.get(JRParameter.REPORT_URL_HANDLER_FACTORY);
    if (urlHandlerFactory != null)
    {
        JRResourcesUtil.setThreadURLHandlerFactory(urlHandlerFactory);
        context.setUrlHandlerFactory(urlHandlerFactory);
    }

    FileResolver fileResolver = (FileResolver) parameterValues.get(
            JRParameter.REPORT_FILE_RESOLVER);
    if (fileResolver != null)
    {
        JRResourcesUtil.setThreadFileResolver(fileResolver);
        context.setFileResolver(fileResolver);
    }

    return context;
}
项目:jasperreports    文件:DefaultRepositoryService.java   
@Override
public InputStream getInputStream(String uri)
{
    try
    {
        URL url = JRResourcesUtil.createURL(uri, urlHandlerFactory);
        if (url != null)
        {
            return JRLoader.getInputStream(url);
        }

        File file = JRResourcesUtil.resolveFile(uri, fileResolver);
        if (file != null)
        {
            return JRLoader.getInputStream(file);
        }

        url = JRResourcesUtil.findClassLoaderResource(uri, classLoader);
        if (url != null)
        {
            return JRLoader.getInputStream(url);
        }
    }
    catch (JRException e)
    {
        throw new JRRuntimeException(e);
    }

    return null;
}
项目:PDFReporter-Studio    文件:AInterpreter.java   
protected ResourceBundle getResourceBundle() {
    if (rb == null)
        rb = JRResourcesUtil.loadResourceBundle(getBundleName(), getLocale(), jConfig.getClassLoader());
    return rb;
}