/** * DefaultConstructor. Loads the module specification. * * @throws ModuleInitializeException * if an error occured. */ public BeanShellModule() throws ModuleInitializeException { loadModuleInfo(); }
+ Const.CR + " return new " + TransJobDrawable.class.getName() + "(dataRow, " + ( options.getOutputType() == OutputType.PDF ? "true" : "false" ) + ");" + Const.CR + "}"; BSHExpression bshExpression = new BSHExpression(); bshExpression.setExpression( bshCode ); bshExpression.setName( "getImage" ); report.addExpression( bshExpression );
/** * This method tries to create a new and fully initialized BeanShell interpreter. * * @return the interpreter or null, if there was no way to create the interpreter. */ protected Interpreter createInterpreter() { try { final Interpreter interpreter = new Interpreter(); initializeInterpreter( interpreter ); return interpreter; } catch ( Throwable e ) { logger.warn( "Unable to initialize the expression", e ); //$NON-NLS-1$ return null; } }
public void testCreate() throws Exception { assertTrue( DataRow.class.isAssignableFrom( DataRowConnector.class ) ); final BSHExpression ex = new BSHExpression(); ex.setExpression( "" ); final DefaultProcessingContext processingContext = new DefaultProcessingContext(); ex.setRuntime( new DebugExpressionRuntime( new DefaultTableModel(), 0, processingContext ) ); assertNull( ex.getValue() ); // must not crash } }
interpreter = createInterpreter(); if ( interpreter == null ) { invalid = true; interpreter.set( "runtime", getRuntime() ); //$NON-NLS-1$ interpreter.set( "dataRow", getDataRow() ); //$NON-NLS-1$ return interpreter.eval( "getValue ();" ); //$NON-NLS-1$ } catch ( Exception e ) {
/** * 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 ); } }