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;
023import javax.xml.bind.annotation.XmlTransient;
024
025import org.apache.camel.model.DataFormatDefinition;
026import org.apache.camel.spi.Metadata;
027
028/**
029 * CBOR data format is used for unmarshal a CBOR payload to POJO or to marshal
030 * POJO back to CBOR payload.
031 */
032@Metadata(firstVersion = "3.0.0", label = "dataformat,transformation,json", title = "CBOR")
033@XmlRootElement(name = "cbor")
034@XmlAccessorType(XmlAccessType.FIELD)
035public class CBORDataFormat extends DataFormatDefinition {
036    @XmlAttribute
037    private String objectMapper;
038    @XmlAttribute
039    @Metadata(defaultValue = "true", javaType = "java.lang.Boolean")
040    private String useDefaultObjectMapper;
041    @XmlAttribute
042    private String unmarshalTypeName;
043    @XmlTransient
044    private Class<?> unmarshalType;
045    @XmlAttribute
046    private String collectionTypeName;
047    @XmlTransient
048    private Class<?> collectionType;
049    @XmlAttribute
050    @Metadata(defaultValue = "false", javaType = "java.lang.Boolean")
051    private String useList;
052    @XmlAttribute
053    @Metadata(defaultValue = "false", javaType = "java.lang.Boolean")
054    private String allowUnmarshallType;
055    @XmlAttribute
056    @Metadata(defaultValue = "false", javaType = "java.lang.Boolean")
057    private String prettyPrint;
058    @XmlAttribute
059    @Metadata(defaultValue = "false", javaType = "java.lang.Boolean")
060    private String allowJmsType;
061    @XmlAttribute
062    private String enableFeatures;
063    @XmlAttribute
064    private String disableFeatures;
065
066    public CBORDataFormat() {
067        super("cbor");
068    }
069
070    public String getObjectMapper() {
071        return objectMapper;
072    }
073
074    /**
075     * Lookup and use the existing CBOR ObjectMapper with the given id when
076     * using Jackson.
077     */
078    public void setObjectMapper(String objectMapper) {
079        this.objectMapper = objectMapper;
080    }
081
082    public String getUseDefaultObjectMapper() {
083        return useDefaultObjectMapper;
084    }
085
086    /**
087     * Whether to lookup and use default Jackson CBOR ObjectMapper from the
088     * registry.
089     */
090    public void setUseDefaultObjectMapper(String useDefaultObjectMapper) {
091        this.useDefaultObjectMapper = useDefaultObjectMapper;
092    }
093
094    public String getUnmarshalTypeName() {
095        return unmarshalTypeName;
096    }
097
098    /**
099     * Class name of the java type to use when unarmshalling
100     */
101    public void setUnmarshalTypeName(String unmarshalTypeName) {
102        this.unmarshalTypeName = unmarshalTypeName;
103    }
104
105    public Class<?> getUnmarshalType() {
106        return unmarshalType;
107    }
108
109    public String getPrettyPrint() {
110        return prettyPrint;
111    }
112
113    /**
114     * To enable pretty printing output nicely formatted.
115     * <p/>
116     * Is by default false.
117     */
118    public void setPrettyPrint(String prettyPrint) {
119        this.prettyPrint = prettyPrint;
120    }
121
122    public String getAllowJmsType() {
123        return allowJmsType;
124    }
125
126    /**
127     * Used for JMS users to allow the JMSType header from the JMS spec to
128     * specify a FQN classname to use to unmarshal to.
129     */
130    public void setAllowJmsType(String allowJmsType) {
131        this.allowJmsType = allowJmsType;
132    }
133
134    /**
135     * Class of the java type to use when unarmshalling
136     */
137    public void setUnmarshalType(Class<?> unmarshalType) {
138        this.unmarshalType = unmarshalType;
139    }
140
141    public String getCollectionTypeName() {
142        return collectionTypeName;
143    }
144
145    /**
146     * Refers to a custom collection type to lookup in the registry to use. This
147     * option should rarely be used, but allows to use different collection
148     * types than java.util.Collection based as default.
149     */
150    public void setCollectionTypeName(String collectionTypeName) {
151        this.collectionTypeName = collectionTypeName;
152    }
153
154    public Class<?> getCollectionType() {
155        return collectionType;
156    }
157
158    public void setCollectionType(Class<?> collectionType) {
159        this.collectionType = collectionType;
160    }
161
162    public String getUseList() {
163        return useList;
164    }
165
166    /**
167     * To unarmshal to a List of Map or a List of Pojo.
168     */
169    public void setUseList(String useList) {
170        this.useList = useList;
171    }
172
173    public String getAllowUnmarshallType() {
174        return allowUnmarshallType;
175    }
176
177    /**
178     * If enabled then Jackson CBOR is allowed to attempt to use the
179     * CamelCBORUnmarshalType header during the unmarshalling.
180     * <p/>
181     * This should only be enabled when desired to be used.
182     */
183    public void setAllowUnmarshallType(String allowUnmarshallType) {
184        this.allowUnmarshallType = allowUnmarshallType;
185    }
186
187    public String getEnableFeatures() {
188        return enableFeatures;
189    }
190
191    /**
192     * Set of features to enable on the Jackson
193     * <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
194     * <p/>
195     * The features should be a name that matches a enum from
196     * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
197     * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
198     * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
199     * <p/>
200     * Multiple features can be separated by comma
201     */
202    public void setEnableFeatures(String enableFeatures) {
203        this.enableFeatures = enableFeatures;
204    }
205
206    public String getDisableFeatures() {
207        return disableFeatures;
208    }
209
210    /**
211     * Set of features to disable on the Jackson
212     * <tt>com.fasterxml.jackson.databind.ObjectMapper</tt>.
213     * <p/>
214     * The features should be a name that matches a enum from
215     * <tt>com.fasterxml.jackson.databind.SerializationFeature</tt>,
216     * <tt>com.fasterxml.jackson.databind.DeserializationFeature</tt>, or
217     * <tt>com.fasterxml.jackson.databind.MapperFeature</tt>
218     * <p/>
219     * Multiple features can be separated by comma
220     */
221    public void setDisableFeatures(String disableFeatures) {
222        this.disableFeatures = disableFeatures;
223    }
224
225}