public void load( final String resourceName ) { if ( resourceName == null ) { throw new NullPointerException(); } final InputStream in = ObjectUtilities.getResourceRelativeAsStream( resourceName, PrinterDriver.class ); if ( in == null ) { PrinterSpecificationManager.logger.error( "Printer definition is missing: " + resourceName ); return; } try { try { load( in ); } finally { in.close(); } } catch ( IOException e ) { PrinterSpecificationManager.logger.error( "Unable to load printer definition file " + resourceName, e ); } }
/** * Loads the properties stored in the given file. This method does nothing if the file does not exist or is * unreadable. Appends the contents of the loaded properties to the already stored contents. * * @param resourceName the file name of the stored properties. * @param resourceSource the class to which relative resource paths are resolved. */ public void load( final String resourceName, final Class resourceSource ) { final InputStream in = ObjectUtilities.getResourceRelativeAsStream ( resourceName, resourceSource ); if ( in != null ) { try { load( in ); } finally { try { in.close(); } catch ( IOException e ) { // ignore } } } else { LOGGER.debug( "Configuration file not found in the classpath: " + resourceName ); } }
/** * Loads the default module description from the file "module.properties". This file must be in the same package as * the implementing class. * * @throws ModuleInitializeException if an error occurs. */ protected void loadModuleInfo() throws ModuleInitializeException { final InputStream in = ObjectUtilities.getResourceRelativeAsStream( "module.properties", getClass() ); if ( in == null ) { throw new ModuleInitializeException ( "File 'module.properties' not found in module package." ); } loadModuleInfo( in ); }
this.targetDirectory = targetDirectory; final InputStream propIn = ObjectUtilities.getResourceRelativeAsStream ( "encodings.properties", EncodingGenerator.class ); propertySet = new DefaultConfiguration();
final InputStream in = ObjectUtilities.getResourceRelativeAsStream (resourceName, resourceSource); if (in != null)
/** * Loads the default module description from the file "module.properties". This file * must be in the same package as the implementing class. * * @throws ModuleInitializeException if an error occurs. */ protected void loadModuleInfo() throws ModuleInitializeException { final InputStream in = ObjectUtilities.getResourceRelativeAsStream("module.properties", getClass()); if (in == null) { throw new ModuleInitializeException ("File 'module.properties' not found in module package."); } loadModuleInfo(in); }
/** * Creates a new module definition based on the 'coremodule.properties' file of this package. * * @throws ModuleInitializeException * if the file could not be loaded. */ public ClassicEngineCoreModule() throws ModuleInitializeException { final InputStream in = ObjectUtilities.getResourceRelativeAsStream( "coremodule.properties", ClassicEngineCoreModule.class ); if ( in == null ) { throw new ModuleInitializeException( "File 'coremodule.properties' not found in JFreeReport package." ); } loadModuleInfo( in ); }
/** * Configures the module by loading the configuration properties and adding them to the package configuration. * * @param subSystem the subsystem. */ public void configure( final SubSystem subSystem ) { final InputStream in = ObjectUtilities.getResourceRelativeAsStream( "configuration.properties", getClass() ); if ( in == null ) { return; } try { subSystem.getPackageManager().getPackageConfiguration().load( in ); } finally { try { in.close(); } catch ( IOException e ) { // can be ignored ... } } }
/** * Initializes the bean-shell interpreter by executing the code in the BSHExpressionHeader.txt file. * * @param interpreter * the interpreter that should be initialized. * @throws EvalError * if an BeanShell-Error occured. * @throws IOException * if the beanshell file could not be read. */ protected void initializeInterpreter( final Interpreter interpreter ) throws EvalError, IOException { final InputStream in = ObjectUtilities.getResourceRelativeAsStream( "BSHExpressionHeader.txt", BSHExpression.class ); //$NON-NLS-1$ // read the header, creates a skeleton final Reader r = new InputStreamReader( new BufferedInputStream( in ) ); try { interpreter.eval( r ); } finally { r.close(); } // now add the userdefined expression // the expression is given in form of a function with the signature of: // // Object getValue () // if ( getExpression() != null ) { interpreter.eval( expression ); } }
/** * Configures the module by loading the configuration properties and * adding them to the package configuration. * * @param subSystem the subsystem. */ public void configure(final SubSystem subSystem) { final InputStream in = ObjectUtilities.getResourceRelativeAsStream("configuration.properties", getClass()); if (in == null) { return; } try { subSystem.getPackageManager().getPackageConfiguration().load(in); } finally { try { in.close(); } catch (IOException e) { // can be ignored ... } } }
protected void compareLineByLine( final String sourceFile, final String resultText ) throws IOException { final BufferedReader resultReader = new BufferedReader( new StringReader( resultText ) ); final InputStream stream = ObjectUtilities.getResourceRelativeAsStream( sourceFile, getClass() ); if ( stream == null ) { throw new NullPointerException( "Cannot locate resource '" + sourceFile + "' with context " + getClass() ); } final BufferedReader compareReader = new BufferedReader( new InputStreamReader( stream, "UTF-8" ) ); try { int line = 1; String lineResult = resultReader.readLine(); String lineSource = compareReader.readLine(); while ( lineResult != null && lineSource != null ) { assertEquals( "Failure in line " + line + " (file: " + sourceFile + ")", lineSource, lineResult ); line += 1; lineResult = resultReader.readLine(); lineSource = compareReader.readLine(); } assertNull( "Extra lines encountered in live-result " + line + " (file: " + sourceFile + ")", lineResult ); assertNull( "Extra lines encountered in recorded result " + line + " (file: " + sourceFile + ")", lineSource ); } finally { resultReader.close(); compareReader.close(); } }