Class BarcodeDataFormat

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.dataformat.barcode.BarcodeDataFormat
All Implemented Interfaces:
AutoCloseable, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@Dataformat("barcode") public class BarcodeDataFormat extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.spi.DataFormat, org.apache.camel.spi.DataFormatName
DataFormat to create (encode) and read (decode) barcodes. For more info about the available barcodes have a look at:

https://github.com/zxing/zxing

  • Field Summary

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create instance with default parameters.
    BarcodeDataFormat(int width, int height)
    Create instance with custom height and width.
    BarcodeDataFormat(int width, int height, BarcodeImageType type, com.google.zxing.BarcodeFormat format)
    Create instance with custom height, width and image type.
    BarcodeDataFormat(com.google.zxing.BarcodeFormat format)
    Create instance with custom BarcodeFormat.
    Create instance with custom BarcodeImageType.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    addToHintMap(com.google.zxing.DecodeHintType hintType, Object value)
    Adds a new hint value to reader (decode) hint map.
    final void
    addToHintMap(com.google.zxing.EncodeHintType hintType, Object value)
    Adds a new hint value to writer (encode) hint map.
    protected void
     
    protected void
     
     
    The (default) parameters.
    final Map<com.google.zxing.DecodeHintType,Object>
    The reader (decode) hint map.
    final Map<com.google.zxing.EncodeHintType,Object>
    The writer (encode) hint map.
    void
    marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream)
    Marshall a String payload to a code image.
    protected final void
    Sets hints optimized for different barcode types.
    final void
    removeFromHintMap(com.google.zxing.DecodeHintType hintType)
    Removes a hint from reader (decode) hint map.
    final void
    removeFromHintMap(com.google.zxing.EncodeHintType hintType)
    Removes a hint from writer (encode) hint map.
    void
    setBarcodeFormat(com.google.zxing.BarcodeFormat format)
     
    void
     
    protected final void
    Sets the default parameters.
    void
     
    void
     
    unmarshal(org.apache.camel.Exchange exchange, InputStream stream)
    Unmarshall a code image to a String payload.

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Constructor Details

    • BarcodeDataFormat

      public BarcodeDataFormat()
      Create instance with default parameters.
    • BarcodeDataFormat

      public BarcodeDataFormat(com.google.zxing.BarcodeFormat format)
      Create instance with custom BarcodeFormat. The other values are default.
      Parameters:
      format - the barcode format
    • BarcodeDataFormat

      public BarcodeDataFormat(int width, int height)
      Create instance with custom height and width. The other values are default.
      Parameters:
      width - the image width
      height - the image height
    • BarcodeDataFormat

      public BarcodeDataFormat(BarcodeImageType type)
      Create instance with custom BarcodeImageType. The other values are default.
      Parameters:
      type - the type (format) of the image. e.g. PNG
    • BarcodeDataFormat

      public BarcodeDataFormat(int width, int height, BarcodeImageType type, com.google.zxing.BarcodeFormat format)
      Create instance with custom height, width and image type. The other values are default.
      Parameters:
      width - the image width
      height - the image height
      type - the type (format) of the image. e.g. PNG
      format - the barcode format
  • Method Details

    • getDataFormatName

      public String getDataFormatName()
      Specified by:
      getDataFormatName in interface org.apache.camel.spi.DataFormatName
    • marshal

      public void marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream) throws Exception
      Marshall a String payload to a code image.
      Specified by:
      marshal in interface org.apache.camel.spi.DataFormat
      Throws:
      Exception
    • unmarshal

      public Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
      Unmarshall a code image to a String payload.
      Specified by:
      unmarshal in interface org.apache.camel.spi.DataFormat
      Throws:
      Exception
    • setDefaultParameters

      protected final void setDefaultParameters()
      Sets the default parameters.
    • optimizeHints

      protected final void optimizeHints()
      Sets hints optimized for different barcode types.
    • addToHintMap

      public final void addToHintMap(com.google.zxing.EncodeHintType hintType, Object value)
      Adds a new hint value to writer (encode) hint map.
    • addToHintMap

      public final void addToHintMap(com.google.zxing.DecodeHintType hintType, Object value)
      Adds a new hint value to reader (decode) hint map.
    • removeFromHintMap

      public final void removeFromHintMap(com.google.zxing.EncodeHintType hintType)
      Removes a hint from writer (encode) hint map.
    • removeFromHintMap

      public final void removeFromHintMap(com.google.zxing.DecodeHintType hintType)
      Removes a hint from reader (decode) hint map.
    • getParams

      public final BarcodeParameters getParams()
      The (default) parameters.
    • getWriterHintMap

      public final Map<com.google.zxing.EncodeHintType,Object> getWriterHintMap()
      The writer (encode) hint map.
    • getReaderHintMap

      public final Map<com.google.zxing.DecodeHintType,Object> getReaderHintMap()
      The reader (decode) hint map.
    • setBarcodeImageType

      public void setBarcodeImageType(BarcodeImageType type)
    • setBarcodeFormat

      public void setBarcodeFormat(com.google.zxing.BarcodeFormat format)
    • setWidth

      public void setWidth(Integer width)
    • setHeight

      public void setHeight(Integer height)
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception