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.DataFormatNameDataFormatto create (encode) and read (decode) barcodes. For more info about the available barcodes have a look at:
https://github.com/zxing/zxing
-
-
Constructor Summary
Constructors Constructor Description BarcodeDataFormat()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 customBarcodeFormat.BarcodeDataFormat(BarcodeImageType type)Create instance with customBarcodeImageType.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToHintMap(com.google.zxing.DecodeHintType hintType, Object value)Adds a new hint value to reader (decode) hint map.voidaddToHintMap(com.google.zxing.EncodeHintType hintType, Object value)Adds a new hint value to writer (encode) hint map.protected voiddoStart()protected voiddoStop()StringgetDataFormatName()BarcodeParametersgetParams()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.voidmarshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream)Marshall aStringpayload to a code image.protected voidoptimizeHints()Sets hints optimized for different barcode types.voidremoveFromHintMap(com.google.zxing.DecodeHintType hintType)Removes a hint from reader (decode) hint map.voidremoveFromHintMap(com.google.zxing.EncodeHintType hintType)Removes a hint from writer (encode) hint map.voidsetBarcodeFormat(com.google.zxing.BarcodeFormat format)voidsetBarcodeImageType(BarcodeImageType type)protected voidsetDefaultParameters()Sets the default parameters.voidsetHeight(Integer height)voidsetWidth(Integer width)Objectunmarshal(org.apache.camel.Exchange exchange, InputStream stream)Unmarshall a code image to aStringpayload.-
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
-
-
-
-
Constructor Detail
-
BarcodeDataFormat
public BarcodeDataFormat()
Create instance with default parameters.
-
BarcodeDataFormat
public BarcodeDataFormat(com.google.zxing.BarcodeFormat format)
Create instance with customBarcodeFormat. 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 heightwidth- the image width
-
BarcodeDataFormat
public BarcodeDataFormat(BarcodeImageType type)
Create instance with customBarcodeImageType. 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 heightwidth- the image widthtype- the type (format) of the image. e.g. PNGformat- the barcode format
-
-
Method Detail
-
getDataFormatName
public String getDataFormatName()
- Specified by:
getDataFormatNamein interfaceorg.apache.camel.spi.DataFormatName
-
marshal
public void marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream) throws ExceptionMarshall aStringpayload to a code image.- Specified by:
marshalin interfaceorg.apache.camel.spi.DataFormat- Throws:
Exception
-
unmarshal
public Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
Unmarshall a code image to aStringpayload.- Specified by:
unmarshalin interfaceorg.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:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
-