Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

As Available as of Camel 2.14

The barcode data format is based on the zxing library. The goal of this component is to create a barcode image from a String (marshal) and a String from a barcode image (unmarshal). You're free to use all features that zxing offers.

Dependencies

To use Bindy the barcode data format in your camel routes you need to add the a dependency on camel-barcode which implements this data format.

...

Code Block
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-barcode</artifactId>
  <version>x.x.x</version>
</dependency>

...

Using the Java DSL

First you have to initialize the barcode data fomat class. You can use the default constructor, or one of parameterized (see JavaDoc). The default values are:

...

Code Block
// QR-Code default
DataFormat code = new BarcodeDataFormat();

If you want to use zxing hints, you can use the 'addToHintMap' method of your BarcodeDataFormat instance:

Code Block
code.addToHintMap(DecodeHintType.TRY_HARDER, Boolean.true);

For possible hints, please consult the xzing documentation.

Marshalling

Code Block
from("direct://code")
  .marshal(code)
  .to("file://barcode_out");

...

Code Block
from("file://barcode_in?noop=true")
  .unmarshal(code) // for unmarshalling, the instance doesn't matter
  .to("mock:out");

If you'll paste the QR-Code image above into the 'barcode_in' folder, you should find 'This is a testmessage!' inside the mock. You can find the barcode data format as header variable:

NameTypeDescription
BarcodeFormat
StringValue of com.google.zxing.BarcodeFormat.