@Test public void testCreateBarcode4J() { BarcodeGenerator barcodeGen = SimpleBarcodesUtility.createBarcode4J( INCORRECT_TYPE, true, false, BAR_HEIGHT ); assertThat( barcodeGen, is( nullValue() ) ); for ( BarcodeTypeInfo info : barcode4JTypes ) { barcodeGen = SimpleBarcodesUtility.createBarcode4J( info.getType(), true, true, null ); assertThat( barcodeGen, is( instanceOf( info.getClazz() ) ) ); if ( info.isCheckIncorrect() ) { barcodeGen = SimpleBarcodesUtility.createBarcode4J( info.getType(), false, true, BAR_HEIGHT ); assertThat( barcodeGen, is( instanceOf( info.getClazz() ) ) ); assertThat( barcodeGen, is( instanceOf( ConfigurableBarcodeGenerator.class ) ) ); ConfigurableBarcodeGenerator commonGen = (ConfigurableBarcodeGenerator) barcodeGen; assertThat( commonGen.getBean(), is( notNullValue() ) ); assertThat( commonGen.getBean().getMsgPosition(), is( equalTo( HumanReadablePlacement.HRP_NONE ) ) ); double expectedHeight = UnitConv.pt2mm( BAR_HEIGHT ); assertThat( commonGen.getBean().getBarHeight(), is( equalTo( expectedHeight ) ) ); } } }
public static BarcodeGenerator createBarcode4J( final String type, final boolean showText, final boolean checksum, final Number barHeight ) { if ( BARCODE_DATAMATRIX.equals( type ) ) { final DataMatrix dataMatrix = new DataMatrix(); return dataMatrix; } if ( BARCODE_EAN8.equals( type ) ) { final EAN8 dataMatrix = new EAN8(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_EAN128.equals( type ) ) { final EAN128 dataMatrix = new EAN128(); if ( showText == false ) { dataMatrix.getEAN128Bean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getEAN128Bean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getEAN128Bean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_UPCE.equals( type ) ) { final UPCE dataMatrix = new UPCE(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_ROYALMAIL.equals( type ) ) { final RoyalMailCBC dataMatrix = new RoyalMailCBC(); if ( showText == false ) { dataMatrix.getRoyalMailCBCBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getRoyalMailCBCBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getRoyalMailCBCBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_USPSINTELLIGENTMAIL.equals( type ) ) { final USPSIntelligentMail dataMatrix = new USPSIntelligentMail(); if ( showText == false ) { dataMatrix.getUSPSIntelligentMailBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUSPSIntelligentMailBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUSPSIntelligentMailBean() .setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } return null; }
SimpleBarcodesUtility { public static BarcodeGenerator createBarcode4J( final String type, final boolean showText, final boolean checksum, final Number barHeight ) { if ( BARCODE_DATAMATRIX.equals( type ) ) { final DataMatrix dataMatrix = new DataMatrix(); return dataMatrix; } if ( BARCODE_EAN8.equals( type ) ) { final EAN8 dataMatrix = new EAN8(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_EAN128.equals( type ) ) { final EAN128 dataMatrix = new EAN128(); if ( showText == false ) { dataMatrix.getEAN128Bean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getEAN128Bean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getEAN128Bean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_UPCE.equals( type ) ) { final UPCE dataMatrix = new UPCE(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_ROYALMAIL.equals( type ) ) { final RoyalMailCBC dataMatrix = new RoyalMailCBC(); if ( showText == false ) { dataMatrix.getRoyalMailCBCBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getRoyalMailCBCBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getRoyalMailCBCBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_USPSINTELLIGENTMAIL.equals( type ) ) { final USPSIntelligentMail dataMatrix = new USPSIntelligentMail(); if ( showText == false ) { dataMatrix.getUSPSIntelligentMailBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUSPSIntelligentMailBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUSPSIntelligentMailBean() .setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } return null; } }
SimpleBarcodesUtility { public static BarcodeGenerator createBarcode4J( final String type, final boolean showText, final boolean checksum, final Number barHeight ) { if ( BARCODE_DATAMATRIX.equals( type ) ) { final DataMatrix dataMatrix = new DataMatrix(); return dataMatrix; } if ( BARCODE_EAN8.equals( type ) ) { final EAN8 dataMatrix = new EAN8(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_EAN128.equals( type ) ) { final EAN128 dataMatrix = new EAN128(); if ( showText == false ) { dataMatrix.getEAN128Bean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getEAN128Bean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getEAN128Bean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_UPCE.equals( type ) ) { final UPCE dataMatrix = new UPCE(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_ROYALMAIL.equals( type ) ) { final RoyalMailCBC dataMatrix = new RoyalMailCBC(); if ( showText == false ) { dataMatrix.getRoyalMailCBCBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getRoyalMailCBCBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getRoyalMailCBCBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_USPSINTELLIGENTMAIL.equals( type ) ) { final USPSIntelligentMail dataMatrix = new USPSIntelligentMail(); if ( showText == false ) { dataMatrix.getUSPSIntelligentMailBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUSPSIntelligentMailBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUSPSIntelligentMailBean() .setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } return null; } private  SimpleBarcodesUtility(); }
SimpleBarcodesUtility { public static BarcodeGenerator createBarcode4J( final String type, final boolean showText, final boolean checksum, final Number barHeight ) { if ( BARCODE_DATAMATRIX.equals( type ) ) { final DataMatrix dataMatrix = new DataMatrix(); return dataMatrix; } if ( BARCODE_EAN8.equals( type ) ) { final EAN8 dataMatrix = new EAN8(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_EAN128.equals( type ) ) { final EAN128 dataMatrix = new EAN128(); if ( showText == false ) { dataMatrix.getEAN128Bean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getEAN128Bean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getEAN128Bean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_UPCE.equals( type ) ) { final UPCE dataMatrix = new UPCE(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_ROYALMAIL.equals( type ) ) { final RoyalMailCBC dataMatrix = new RoyalMailCBC(); if ( showText == false ) { dataMatrix.getRoyalMailCBCBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getRoyalMailCBCBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getRoyalMailCBCBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_USPSINTELLIGENTMAIL.equals( type ) ) { final USPSIntelligentMail dataMatrix = new USPSIntelligentMail(); if ( showText == false ) { dataMatrix.getUSPSIntelligentMailBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUSPSIntelligentMailBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUSPSIntelligentMailBean() .setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } return null; } private  SimpleBarcodesUtility(); static Barcode createBarcode( final String data, final String type, final boolean checksum ); static BarcodeGenerator createBarcode4J( final String type, final boolean showText, final boolean checksum,
      final Number barHeight ); static String getBarcodeSampleData( final String type ); }
SimpleBarcodesUtility { public static BarcodeGenerator createBarcode4J( final String type, final boolean showText, final boolean checksum, final Number barHeight ) { if ( BARCODE_DATAMATRIX.equals( type ) ) { final DataMatrix dataMatrix = new DataMatrix(); return dataMatrix; } if ( BARCODE_EAN8.equals( type ) ) { final EAN8 dataMatrix = new EAN8(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_EAN128.equals( type ) ) { final EAN128 dataMatrix = new EAN128(); if ( showText == false ) { dataMatrix.getEAN128Bean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getEAN128Bean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getEAN128Bean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_UPCE.equals( type ) ) { final UPCE dataMatrix = new UPCE(); if ( showText == false ) { dataMatrix.getUPCEANBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUPCEANBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUPCEANBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_ROYALMAIL.equals( type ) ) { final RoyalMailCBC dataMatrix = new RoyalMailCBC(); if ( showText == false ) { dataMatrix.getRoyalMailCBCBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getRoyalMailCBCBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getRoyalMailCBCBean().setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } if ( BARCODE_USPSINTELLIGENTMAIL.equals( type ) ) { final USPSIntelligentMail dataMatrix = new USPSIntelligentMail(); if ( showText == false ) { dataMatrix.getUSPSIntelligentMailBean().setMsgPosition( HumanReadablePlacement.HRP_NONE ); } if ( barHeight != null ) { dataMatrix.getUSPSIntelligentMailBean().setBarHeight( UnitConv.pt2mm( barHeight.doubleValue() ) ); } dataMatrix.getUSPSIntelligentMailBean() .setChecksumMode( checksum ? ChecksumMode.CP_AUTO : ChecksumMode.CP_IGNORE ); return dataMatrix; } return null; } private  SimpleBarcodesUtility(); static Barcode createBarcode( final String data, final String type, final boolean checksum ); static BarcodeGenerator createBarcode4J( final String type, final boolean showText, final boolean checksum,
      final Number barHeight ); static String getBarcodeSampleData( final String type ); static final String BARCODE_CODE39; static final String BARCODE_CODE39EXT; static final String BARCODE_CODABAR; static final String BARCODE_CODE128; static final String BARCODE_CODE128A; static final String BARCODE_CODE128B; static final String BARCODE_CODE128C; static final String BARCODE_EAN13; static final String BARCODE_UPCA; static final String BARCODE_ISBN; static final String BARCODE_UCCEAN128; static final String BARCODE_2OF5; static final String BARCODE_2OF5INT; static final String BARCODE_POSTNET; static final String BARCODE_PDF417; static final String BARCODE_EAN8; static final String BARCODE_EAN128; static final String BARCODE_UPCE; static final String BARCODE_DATAMATRIX; static final String BARCODE_ROYALMAIL; static final String BARCODE_USPSINTELLIGENTMAIL; }