@Test public void testGetValue() { SimpleBarcodesExpression expression = spy( new SimpleBarcodesExpression() ); Object obj = expression.getValue(); assertThat( obj, is( nullValue() ) ); DataRow dataRow = mock( DataRow.class ); doReturn( dataRow ).when( expression ).getDataRow(); doReturn( null ).when( dataRow ).get( RAW_PARAM ); expression.setRawDataField( RAW_PARAM ); obj = expression.getValue(); assertThat( obj, is( nullValue() ) ); doReturn( "test" ).when( dataRow ).get( RAW_PARAM ); obj = expression.getValue(); assertThat( obj, is( nullValue() ) ); expression.setType( SimpleBarcodesUtility.BARCODE_DATAMATRIX ); obj = expression.getValue(); assertThat( obj, is( instanceOf( BarcodeDrawable.class ) ) ); expression.setType( "incorrect_type" ); obj = expression.getValue(); assertThat( obj, is( nullValue() ) ); expression.setType( SimpleBarcodesUtility.BARCODE_PDF417 ); expression.setShowText( true ); expression.setBarWidth( 10 ); expression.setBarHeight( 20 ); obj = expression.getValue(); assertThat( obj, is( instanceOf( BarcodeWrapper.class ) ) ); BarcodeWrapper bar = (BarcodeWrapper) obj; assertThat( bar.getBarcode(), is( notNullValue() ) ); }
public Object getValue() { final String data = getData(); if ( data == null ) { logger.info( "No data supplied to barcode element." ); return null; } String ltype; if ( type == null ) { ltype = computeRawType(); } else { ltype = type; } if ( ltype == null ) { logger.info( "No type supplied to barcode element." ); return null; } try { final BarcodeGenerator generator = SimpleBarcodesUtility.createBarcode4J( type, showText, checksum, Integer.valueOf( barHeight ) ); if ( generator != null ) { return new BarcodeDrawable( generator, data ); } } catch ( Exception e ) { if ( logger.isInfoEnabled() ) { logger.info( "Error creating barcode, falling back to null value", e ); } return null; } final Barcode barcode = SimpleBarcodesUtility.createBarcode( data, ltype, checksum ); if ( barcode == null ) { return null; } barcode.setDrawingText( showText ); barcode.setBarWidth( barWidth ); barcode.setBarHeight( barHeight ); return new BarcodeWrapper( barcode ); }
SimpleBarcodesExpression extends AbstractExpression { public Object getValue() { final String data = getData(); if ( data == null ) { logger.info( "No data supplied to barcode element." ); return null; } String ltype; if ( type == null ) { ltype = computeRawType(); } else { ltype = type; } if ( ltype == null ) { logger.info( "No type supplied to barcode element." ); return null; } try { final BarcodeGenerator generator = SimpleBarcodesUtility.createBarcode4J( type, showText, checksum, Integer.valueOf( barHeight ) ); if ( generator != null ) { return new BarcodeDrawable( generator, data ); } } catch ( Exception e ) { if ( logger.isInfoEnabled() ) { logger.info( "Error creating barcode, falling back to null value", e ); } return null; } final Barcode barcode = SimpleBarcodesUtility.createBarcode( data, ltype, checksum ); if ( barcode == null ) { return null; } barcode.setDrawingText( showText ); barcode.setBarWidth( barWidth ); barcode.setBarHeight( barHeight ); return new BarcodeWrapper( barcode ); } }
SimpleBarcodesExpression extends AbstractExpression { public Object getValue() { final String data = getData(); if ( data == null ) { logger.info( "No data supplied to barcode element." ); return null; } String ltype; if ( type == null ) { ltype = computeRawType(); } else { ltype = type; } if ( ltype == null ) { logger.info( "No type supplied to barcode element." ); return null; } try { final BarcodeGenerator generator = SimpleBarcodesUtility.createBarcode4J( type, showText, checksum, Integer.valueOf( barHeight ) ); if ( generator != null ) { return new BarcodeDrawable( generator, data ); } } catch ( Exception e ) { if ( logger.isInfoEnabled() ) { logger.info( "Error creating barcode, falling back to null value", e ); } return null; } final Barcode barcode = SimpleBarcodesUtility.createBarcode( data, ltype, checksum ); if ( barcode == null ) { return null; } barcode.setDrawingText( showText ); barcode.setBarWidth( barWidth ); barcode.setBarHeight( barHeight ); return new BarcodeWrapper( barcode ); } SimpleBarcodesExpression(); }
SimpleBarcodesExpression extends AbstractExpression { public Object getValue() { final String data = getData(); if ( data == null ) { logger.info( "No data supplied to barcode element." ); return null; } String ltype; if ( type == null ) { ltype = computeRawType(); } else { ltype = type; } if ( ltype == null ) { logger.info( "No type supplied to barcode element." ); return null; } try { final BarcodeGenerator generator = SimpleBarcodesUtility.createBarcode4J( type, showText, checksum, Integer.valueOf( barHeight ) ); if ( generator != null ) { return new BarcodeDrawable( generator, data ); } } catch ( Exception e ) { if ( logger.isInfoEnabled() ) { logger.info( "Error creating barcode, falling back to null value", e ); } return null; } final Barcode barcode = SimpleBarcodesUtility.createBarcode( data, ltype, checksum ); if ( barcode == null ) { return null; } barcode.setDrawingText( showText ); barcode.setBarWidth( barWidth ); barcode.setBarHeight( barHeight ); return new BarcodeWrapper( barcode ); } SimpleBarcodesExpression(); Object getValue(); String getType(); void setType( final String type ); int getBarHeight(); void setBarHeight( final int barHeight ); int getBarWidth(); void setBarWidth( final int barWidth ); boolean isChecksum(); void setChecksum( final boolean checksum ); boolean isShowText(); void setShowText( final boolean showText ); String getRawDataField(); void setRawDataField( final String rawDataField ); String getRawTypeField(); void setRawTypeField( String rawTypeField ); }
SimpleBarcodesExpression extends AbstractExpression { public Object getValue() { final String data = getData(); if ( data == null ) { logger.info( "No data supplied to barcode element." ); return null; } String ltype; if ( type == null ) { ltype = computeRawType(); } else { ltype = type; } if ( ltype == null ) { logger.info( "No type supplied to barcode element." ); return null; } try { final BarcodeGenerator generator = SimpleBarcodesUtility.createBarcode4J( type, showText, checksum, Integer.valueOf( barHeight ) ); if ( generator != null ) { return new BarcodeDrawable( generator, data ); } } catch ( Exception e ) { if ( logger.isInfoEnabled() ) { logger.info( "Error creating barcode, falling back to null value", e ); } return null; } final Barcode barcode = SimpleBarcodesUtility.createBarcode( data, ltype, checksum ); if ( barcode == null ) { return null; } barcode.setDrawingText( showText ); barcode.setBarWidth( barWidth ); barcode.setBarHeight( barHeight ); return new BarcodeWrapper( barcode ); } SimpleBarcodesExpression(); Object getValue(); String getType(); void setType( final String type ); int getBarHeight(); void setBarHeight( final int barHeight ); int getBarWidth(); void setBarWidth( final int barWidth ); boolean isChecksum(); void setChecksum( final boolean checksum ); boolean isShowText(); void setShowText( final boolean showText ); String getRawDataField(); void setRawDataField( final String rawDataField ); String getRawTypeField(); void setRawTypeField( String rawTypeField );  }