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 */
017 package org.apache.camel.model.dataformat;
018
019 import java.util.HashMap;
020 import java.util.List;
021 import java.util.Map;
022
023 import javax.xml.bind.annotation.XmlAccessType;
024 import javax.xml.bind.annotation.XmlAccessorType;
025 import javax.xml.bind.annotation.XmlElement;
026 import javax.xml.bind.annotation.XmlElements;
027 import javax.xml.bind.annotation.XmlRootElement;
028
029 import org.apache.camel.model.DataFormatDefinition;
030
031 /**
032 * Represents the XML type for a collection of DataFormats.
033 */
034 @XmlRootElement(name = "dataFormats")
035 @XmlAccessorType(XmlAccessType.FIELD)
036 public class DataFormatsDefinition {
037
038 // cannot use @XmlElementRef as it doesn't allow optional properties
039 @XmlElements({
040 @XmlElement(required = false, name = "avro", type = AvroDataFormat.class),
041 @XmlElement(required = false, name = "beanio", type = BeanioDataFormat.class),
042 @XmlElement(required = false, name = "bindy", type = BindyDataFormat.class),
043 @XmlElement(required = false, name = "castor", type = CastorDataFormat.class),
044 @XmlElement(required = false, name = "crypto", type = CryptoDataFormat.class),
045 @XmlElement(required = false, name = "csv", type = CsvDataFormat.class),
046 @XmlElement(required = false, name = "custom", type = CustomDataFormat.class),
047 @XmlElement(required = false, name = "flatpack", type = FlatpackDataFormat.class),
048 @XmlElement(required = false, name = "gzip", type = GzipDataFormat.class),
049 @XmlElement(required = false, name = "hl7", type = HL7DataFormat.class),
050 @XmlElement(required = false, name = "jaxb", type = JaxbDataFormat.class),
051 @XmlElement(required = false, name = "jibx", type = JibxDataFormat.class),
052 @XmlElement(required = false, name = "json", type = JsonDataFormat.class),
053 @XmlElement(required = false, name = "protobuf", type = ProtobufDataFormat.class),
054 @XmlElement(required = false, name = "rss", type = RssDataFormat.class),
055 @XmlElement(required = false, name = "secureXML", type = XMLSecurityDataFormat.class),
056 @XmlElement(required = false, name = "serialization", type = SerializationDataFormat.class),
057 @XmlElement(required = false, name = "soapjaxb", type = SoapJaxbDataFormat.class),
058 @XmlElement(required = false, name = "string", type = StringDataFormat.class),
059 @XmlElement(required = false, name = "syslog", type = SyslogDataFormat.class),
060 @XmlElement(required = false, name = "tidyMarkup", type = TidyMarkupDataFormat.class),
061 @XmlElement(required = false, name = "xmlBeans", type = XMLBeansDataFormat.class),
062 @XmlElement(required = false, name = "xmljson", type = XmlJsonDataFormat.class),
063 @XmlElement(required = false, name = "xstream", type = XStreamDataFormat.class),
064 @XmlElement(required = false, name = "pgp", type = PGPDataFormat.class),
065 @XmlElement(required = false, name = "zip", type = ZipDataFormat.class)}
066 )
067 private List<DataFormatDefinition> dataFormats;
068
069
070 public void setDataFormats(List<DataFormatDefinition> dataFormats) {
071 this.dataFormats = dataFormats;
072 }
073
074 public List<DataFormatDefinition> getDataFormats() {
075 return dataFormats;
076 }
077
078 /***
079 * @return A Map of the contained DataFormatType's indexed by id.
080 */
081 public Map<String, DataFormatDefinition> asMap() {
082 Map<String, DataFormatDefinition> dataFormatsAsMap = new HashMap<String, DataFormatDefinition>();
083 for (DataFormatDefinition dataFormatType : getDataFormats()) {
084 dataFormatsAsMap.put(dataFormatType.getId(), dataFormatType);
085 }
086 return dataFormatsAsMap;
087 }
088 }