Class 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addToHintMap​(com.google.zxing.DecodeHintType hintType, Object value)
      Adds a new hint value to reader (decode) hint map.
      void addToHintMap​(com.google.zxing.EncodeHintType hintType, Object value)
      Adds a new hint value to writer (encode) hint map.
      protected void doStart()  
      protected void doStop()  
      String getDataFormatName()  
      BarcodeParameters getParams()
      The (default) parameters.
      Map<com.google.zxing.DecodeHintType,​Object> getReaderHintMap()
      The reader (decode) hint map.
      Map<com.google.zxing.EncodeHintType,​Object> getWriterHintMap()
      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 void optimizeHints()
      Sets hints optimized for different barcode types.
      void removeFromHintMap​(com.google.zxing.DecodeHintType hintType)
      Removes a hint from reader (decode) hint map.
      void removeFromHintMap​(com.google.zxing.EncodeHintType hintType)
      Removes a hint from writer (encode) hint map.
      void setBarcodeFormat​(com.google.zxing.BarcodeFormat format)  
      void setBarcodeImageType​(BarcodeImageType type)  
      protected void setDefaultParameters()
      Sets the default parameters.
      void setHeight​(Integer height)  
      void setWidth​(Integer width)  
      Object 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 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 Detail

      • 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:
        height - the image height
        width - the image width
      • 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:
        height - the image height
        width - the image width
        type - the type (format) of the image. e.g. PNG
        format - the barcode format
    • Method Detail

      • 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.
      • 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