public GenericExpressionRuntime( final TableModel data, final int currentRow, final ProcessingContext processingContext ) { this( new StaticDataRow(), data, currentRow, processingContext ); }
public StaticDataRow( final String[] names, final Object[] values ) { setData( names, values ); }
public boolean equals( final Object o ) { if ( this == o ) { return true; } if ( !( o instanceof StaticDataRow ) ) { return false; } final StaticDataRow that = (StaticDataRow) o; if ( !Arrays.equals( names, that.names ) ) { return false; } if ( !equalsMap( that.values ) ) { return false; } return true; }
@Test( expected = IllegalArgumentException.class ) public void testUpdateDataException() { String[] names = new String[]{ "name_0" }; Object[] values = new Object[]{ "value_0" }; StaticDataRow dataRow = new StaticDataRow( names, values ); Object[] newValues = new Object[]{ "new_value_0", "new_value_1" }; dataRow.updateData( newValues ); }
@Test public void testUpdateData() { String[] names = new String[]{ "name_0" }; Object[] values = new Object[]{ "value_0" }; StaticDataRow dataRow = new StaticDataRow( names, values ); Object[] newValues = new Object[]{ "new_value_0" }; dataRow.updateData( newValues ); assertThat( dataRow.getColumnNames(), is( equalTo( new String[]{ "name_0" } ) ) ); assertThat( (String) dataRow.get( "name_0" ), is( equalTo( "new_value_0" ) ) ); }
@Test public void testEquals() { StaticDataRow dataRow = new StaticDataRow(); assertThat( dataRow.equals( dataRow ), is( equalTo( true ) ) ); assertThat( dataRow.equals( "incorrect" ), is( equalTo( false ) ) ); String[] names = new String[]{ "name_0" }; Object[] values = new Object[]{ "value_0" }; StaticDataRow newDataRow = new StaticDataRow( names, values ); assertThat( dataRow.equals( newDataRow ), is( equalTo( false ) ) ); dataRow.setData( names, new Object[]{ "test_val" } ); assertThat( dataRow.equals( newDataRow ), is( equalTo( false ) ) ); dataRow.setData( names, values ); assertThat( dataRow.equals( newDataRow ), is( equalTo( true ) ) ); } }
@Test public void testCreation() { StaticDataRow dataRow = new StaticDataRow(); assertThat( dataRow.getColumnNames(), is( equalTo( new String[]{ } ) ) ); StaticDataRow staticDataRowParam = mock( StaticDataRow.class ); dataRow = new StaticDataRow( staticDataRowParam ); assertThat( dataRow.getColumnNames(), is( equalTo( new String[]{ } ) ) ); DataRow dataRowParam = mock( DataRow.class ); doReturn( new String[]{ "test_name" } ).when( dataRowParam ).getColumnNames(); doReturn( "test_val" ).when( dataRowParam ).get( "test_name" ); dataRow = new StaticDataRow( dataRowParam ); assertThat( dataRow.getColumnNames(), is( equalTo( new String[]{ "test_name" } ) ) ); assertThat( (String) dataRow.get( "test_name" ), is( equalTo( "test_val" ) ) ); String[] names = new String[]{ "name_0", "name_1" }; Object[] values = new Object[]{ "value_0" }; dataRow = new StaticDataRow( names, values ); assertThat( dataRow.getColumnNames(), is( equalTo( new String[]{ "name_0" } ) ) ); assertThat( (String) dataRow.get( "name_0" ), is( equalTo( "value_0" ) ) ); Map<String, Object> parameterValues = new HashMap<String, Object>(); parameterValues.put( "name_0", "value_0" ); dataRow = new StaticDataRow( parameterValues ); assertThat( dataRow.getColumnNames(), is( equalTo( new String[]{ "name_0" } ) ) ); assertThat( (String) dataRow.get( "name_0" ), is( equalTo( "value_0" ) ) ); }
@Test public void testIsChanged() { StaticDataRow dataRow = new StaticDataRow(); assertThat( dataRow.isChanged( "test" ), is( equalTo( false ) ) ); }
public int hashCode() { int result = hashCodeMap(); for ( int i = 0; i < names.length; i++ ) { final String name = names[i]; if ( name != null ) { result = 31 * result + name.hashCode(); } else { result = 31 * result; } } return result; }
/** * Translates the given string and resolves the embedded property references. * * @param value * the raw value, * @return the fully translated string. */ public String translateAndLookup( final String value ) { return translateAndLookup( value, new StaticDataRow() ); }
public StaticDataRow( final Map<String, Object> parameterValues ) { final String[] names = parameterValues.keySet().toArray( new String[parameterValues.size()] ); setData( names, parameterValues.values().toArray() ); }
protected DataRow computeData( Band band, ExpressionRuntime runtime ) { if ( band.getComputedStyle().getBooleanStyleProperty( ElementStyleKeys.VISIBLE ) == false ) { return new StaticDataRow(); } this.values.clear(); compute( band, runtime ); return new StaticDataRow( values ); }
final StaticDataRow params = new StaticDataRow( parameters ); final TableModel dataFromQuery; switch ( queryStyle ) {
@Test( expected = NullPointerException.class ) public void testCreationWithoutNames() { new StaticDataRow( null, null ); }
@Test( expected = NullPointerException.class ) public void testCreationWithoutStaticDataRowParam() { StaticDataRow dataRow = null; new StaticDataRow( dataRow ); }
@Test( expected = NullPointerException.class ) public void testCreationWithoutDataRowParam() { DataRow dataRow = null; new StaticDataRow( dataRow ); }
@Test( expected = NullPointerException.class ) public void testCreationWithoutValues() { new StaticDataRow( new String[]{ }, null ); }
public void setup( final ParameterDefinitionEntry parameter, final DataAttributes globalAttributes, final ReportEnvironment reportEnvironment, final ResourceManager resourceManager ) throws ReportDataFactoryException { if ( globalAttributes == null ) { throw new NullPointerException(); } if ( parameter == null ) { throw new NullPointerException(); } this.globalAttributes = globalAttributes; this.entry = parameter; this.parameterContext = new DefaultParameterContext( new CompoundDataFactory(), new StaticDataRow(), ClassicEngineBoot.getInstance() .getGlobalConfig(), new DefaultResourceBundleFactory(), resourceManager, null, reportEnvironment ); }
public DataFactory getDataFactoryForQuery( final String queryName, final boolean freeform ) { final DataRow dr = new StaticDataRow(); for ( int i = 0; i < size(); i++ ) { final DataFactory df = dataFactories.get( i ); if ( df instanceof CompoundDataFactorySupport ) { final CompoundDataFactorySupport cdf = (CompoundDataFactorySupport) df; final DataFactory r = cdf.getDataFactoryForQuery( queryName, freeform ); if ( r != null ) { return r; } } if ( ( isFreeFormQueryDataFactory( df ) == freeform ) && df.isQueryExecutable( queryName, dr ) ) { return df; } } return null; }
public GenericExpressionRuntime( final ExpressionRuntime runtime ) { this( new StaticDataRow( runtime.getDataRow() ), runtime.getData(), runtime.getCurrentRow(), runtime .getProcessingContext() ); }