001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.model.dataformat;
018
019import javax.xml.bind.annotation.XmlAccessType;
020import javax.xml.bind.annotation.XmlAccessorType;
021import javax.xml.bind.annotation.XmlAttribute;
022import javax.xml.bind.annotation.XmlRootElement;
023
024import org.apache.camel.CamelContext;
025import org.apache.camel.model.DataFormatDefinition;
026import org.apache.camel.spi.DataFormat;
027import org.apache.camel.spi.Metadata;
028
029/**
030 * The Barcode data format is used for creating barccode images (such as QR-Code)
031 *
032 * @version 
033 */
034@Metadata(firstVersion = "2.14.0", label = "dataformat,transformation", title = "Barcode")
035@XmlRootElement(name = "barcode")
036@XmlAccessorType(XmlAccessType.FIELD)
037public class BarcodeDataFormat extends DataFormatDefinition {
038    @XmlAttribute
039    private Integer width;
040    @XmlAttribute
041    private Integer height;
042    @XmlAttribute
043    private String imageType;
044    @XmlAttribute
045    private String barcodeFormat;
046    
047    public BarcodeDataFormat() {
048        super("barcode");
049    }
050    
051    @Override
052    protected void configureDataFormat(DataFormat dataFormat, CamelContext camelContext) {
053        if (width != null) {
054            setProperty(camelContext, dataFormat, "width", width);
055        }
056
057        if (height != null) {
058            setProperty(camelContext, dataFormat, "height", height);
059        } 
060        
061        if (imageType != null) {
062            setProperty(camelContext, dataFormat, "barcodeImageType", imageType);
063        }
064
065        if (barcodeFormat != null) {
066            setProperty(camelContext, dataFormat, "barcodeFormat", barcodeFormat);
067        }
068    }
069    
070    public Integer getWidth() {
071        return width;
072    }
073
074    /**
075     * Width of the barcode
076     */
077    public void setWidth(Integer width) {
078        this.width = width;
079    }
080
081    public Integer getHeight() {
082        return height;
083    }
084
085    /**
086     * Height of the barcode
087     */
088    public void setHeight(Integer height) {
089        this.height = height;
090    }
091
092    public String getImageType() {
093        return imageType;
094    }
095
096    /**
097     * Image type of the barcode such as png
098     */
099    public void setImageType(String imageType) {
100        this.imageType = imageType;
101    }
102
103    public String getBarcodeFormat() {
104        return barcodeFormat;
105    }
106
107    /**
108     * Barcode format such as QR-Code
109     */
110    public void setBarcodeFormat(String barcodeFormat) {
111        this.barcodeFormat = barcodeFormat;
112    }
113
114}