/** * Returns the inputstream for the resource specified by the <strong>absolute</strong> name. * * @param name the name of the resource * @param context the source class * @return the url of the resource or null, if not found. */ public static InputStream getResourceAsStream( final String name, final Class context ) { final URL url = getResource( name, context ); if ( url == null ) { return null; } try { return url.openStream(); } catch ( IOException e ) { return null; } }
/** * Returns the inputstream for the resource specified by the <strong>absolute</strong> name. * * @param name the name of the resource * @param context the source class * @return the url of the resource or null, if not found. */ public static InputStream getResourceAsStream(final String name, final Class context) { final URL url = getResource(name, context); if (url == null) { return null; } try { return url.openStream(); } catch (IOException e) { return null; } }
/** * Returns the URL of a report. * * @param name * the report name. * @return The URL (or <code>null</code>). * @throws java.io.IOException * if there is an I/O problem. */ public URL findReport( final String name ) throws IOException { final URL in = ObjectUtilities.getResource( name, ReportConverter.class ); if ( in != null ) { return in; } final File f = new File( name ); if ( f.canRead() ) { return f.toURL(); } return null; }
/** * Creates a new resource key from the given object and the factory keys. * * @param value * @param factoryKeys * @return the created key. * @throws org.pentaho.reporting.libraries.resourceloader.ResourceKeyCreationException if creating the key failed. */ public ResourceKey createKey( final Object value, final Map factoryKeys ) throws ResourceKeyCreationException { if ( value instanceof String ) { final String valueString = (String) value; if ( valueString.startsWith( RES_PREFIX ) ) { final String resourcePath = valueString.substring( 6 ); if ( ObjectUtilities.getResource( resourcePath, ClassloaderResourceData.class ) != null ) { return new ResourceKey( SCHEMA_NAME, value, factoryKeys ); } } } return null; }
public static void initializeOptionalExpressionsMetaData( final String source ) throws ModuleInitializeException { final URL expressionMetaSource = ObjectUtilities.getResource( source, ElementMetaDataParser.class ); if ( expressionMetaSource == null ) { throw new ModuleInitializeException( "Error: Could not find the expression meta-data description file: " + source ); } try { ExpressionRegistry.getInstance().registerFromXml( expressionMetaSource ); } catch ( Exception e ) { logger.debug( "Failed:", e ); throw new ModuleInitializeException( "Error: Could not parse the expression meta-data description file", e ); } }
public static void initializeOptionalDataFactoryMetaData( final String source ) throws ModuleInitializeException { final URL expressionMetaSource = ObjectUtilities.getResource( source, ElementMetaDataParser.class ); if ( expressionMetaSource == null ) { throw new ModuleInitializeException( "Error: Could not find the datafactory meta-data description file" ); } try { DataFactoryRegistry.getInstance().registerFromXml( expressionMetaSource ); } catch ( Exception e ) { logger.debug( "Failed:", e ); throw new ModuleInitializeException( "Error: Could not parse the datafactory meta-data description file", e ); } } }
public static void initializeOptionalElementMetaData( final String source ) throws ModuleInitializeException { final URL metaDataSource = ObjectUtilities.getResource( source, ElementMetaDataParser.class ); if ( metaDataSource == null ) { throw new ModuleInitializeException( "Error: Could not find the optional element meta-data description file: " + source ); } try { ElementTypeRegistry.getInstance().registerFromXml( metaDataSource ); } catch ( Exception e ) { logger.debug( "Failed:", e ); throw new ModuleInitializeException( "Error: Could not parse the element meta-data description file", e ); } }
public static void initializeOptionalReportPreProcessorMetaData( final String source ) throws ModuleInitializeException { final URL reportPreProcessorMetaSource = ObjectUtilities.getResource( source, ElementMetaDataParser.class ); if ( reportPreProcessorMetaSource == null ) { throw new ModuleInitializeException( "Error: Could not find the core report-preprocessor meta-data description file: " + source ); } try { ReportPreProcessorRegistry.getInstance().registerFromXml( reportPreProcessorMetaSource ); } catch ( Exception e ) { logger.debug( "Failed:", e ); throw new ModuleInitializeException( "Error: Could not parse the report-preprocessor meta-data description file", e ); } }
public static void initializeOptionalReportProcessTaskMetaData( final String source ) throws ModuleInitializeException { final URL reportPreProcessorMetaSource = ObjectUtilities.getResource( source, ElementMetaDataParser.class ); if ( reportPreProcessorMetaSource == null ) { throw new ModuleInitializeException( "Error: Could not find the core report-process-task meta-data description file: " + source ); } try { ReportProcessTaskRegistry.getInstance().registerFromXml( reportPreProcessorMetaSource ); } catch ( Exception e ) { logger.debug( "Failed:", e ); throw new ModuleInitializeException( "Error: Could not parse the report-process-task meta-data description file", e ); } }
url = ObjectUtilities.getResource( iconName, DefaultElementMetaData.class ); url = ObjectUtilities.getResource( fallbackIcon, DefaultElementMetaData.class );
/** * Initializes the simple parser and registers this handler with the parser base module. * * @throws ModuleInitializeException * if initializing the module failes. */ public void performInit() throws ModuleInitializeException { final ParserEntityResolver res = ParserEntityResolver.getDefaultResolver(); final URL urlReportDTD = ObjectUtilities.getResource( "org/pentaho/reporting/engine/classic/core/modules/parser/simple/resources/report-085.dtd", SimpleParserModuleInit.class ); res.setDTDLocation( SimpleParserModuleInit.PUBLIC_ID_SIMPLE, SimpleParserModuleInit.SYSTEM_ID, urlReportDTD ); res.setDTDLocation( SimpleParserModuleInit.PUBLIC_ID_SIMPLE_084, SimpleParserModuleInit.SYSTEM_ID, urlReportDTD ); res.setDeprecatedDTDMessage( SimpleParserModuleInit.PUBLIC_ID_SIMPLE_084, "The given public identifier for the XML document is deprecated. " + "Please use the current document type declaration instead: \n" + " <!DOCTYPE report PUBLIC \n" + " \"-//JFreeReport//DTD report definition//EN//simple/version 0.8.5\"\n" + " \"http://jfreereport.sourceforge.net/report-085.dtd\">" ); } }
/** * Initializes the ext-parser and registers it at the parser base module. * * @throws org.pentaho.reporting.libraries.base.boot.ModuleInitializeException * if an error ocurres. */ public void performInit() throws ModuleInitializeException { final ParserEntityResolver res = ParserEntityResolver.getDefaultResolver(); final URL urlExtReportDTD = ObjectUtilities.getResource( "org/pentaho/reporting/engine/classic/core/modules/parser/ext/resources/extreport-085.dtd", ExtParserModuleInit.class ); res.setDTDLocation( ExtParserModuleInit.PUBLIC_ID_EXTENDED, ExtParserModuleInit.SYSTEM_ID, urlExtReportDTD ); res.setDTDLocation( ExtParserModuleInit.PUBLIC_ID_EXTENDED_084, ExtParserModuleInit.SYSTEM_ID, urlExtReportDTD ); res.setDeprecatedDTDMessage( ExtParserModuleInit.PUBLIC_ID_EXTENDED_084, "The given public identifier for the XML document is deprecated. " + "Please use the current document type declaration instead: \n" + " <!DOCTYPE report PUBLIC \n" + " \"-//JFreeReport//DTD report definition//EN//extended/version 0.8.5\"\n" + " \"http://jfreereport.sourceforge.net/extreport-085.dtd\">" ); } }