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 javax.xml.bind.annotation.XmlAccessType;
020 import javax.xml.bind.annotation.XmlAccessorType;
021 import javax.xml.bind.annotation.XmlAttribute;
022 import javax.xml.bind.annotation.XmlRootElement;
023
024 import org.apache.camel.model.DataFormatDefinition;
025 import org.apache.camel.spi.DataFormat;
026
027 /**
028 * Represents a <a href="http://camel.apache.org/castor.html">Castor</a> {@link org.apache.camel.spi.DataFormat}.
029 *
030 * @version $Revision: 833084 $
031 */
032 @XmlRootElement(name = "castor")
033 @XmlAccessorType(XmlAccessType.FIELD)
034 public class CastorDataFormat extends DataFormatDefinition {
035
036 @XmlAttribute(required = false)
037 private String mappingFile;
038 @XmlAttribute(required = false)
039 private Boolean validation = Boolean.TRUE;
040 @XmlAttribute(required = false)
041 private String encoding;
042 @XmlAttribute(required = false)
043 private String[] packages;
044 @XmlAttribute(required = false)
045 private String[] classes;
046
047 public CastorDataFormat() {
048 super("castor");
049 }
050
051 public Boolean isValidation() {
052 return validation;
053 }
054
055 public void setValidation(Boolean validation) {
056 this.validation = validation;
057 }
058
059 public String getMappingFile() {
060 return mappingFile;
061 }
062
063 public void setMappingFile(String mappingFile) {
064 this.mappingFile = mappingFile;
065 }
066
067 public String[] getPackages() {
068 return packages;
069 }
070
071 public void setPackages(String[] packages) {
072 this.packages = packages;
073 }
074
075 public String[] getClasses() {
076 return classes;
077 }
078
079 public void setClasses(String[] classes) {
080 this.classes = classes;
081 }
082
083 public String getEncoding() {
084 return encoding;
085 }
086
087 public void setEncoding(String encoding) {
088 this.encoding = encoding;
089 }
090
091 @Override
092 protected void configureDataFormat(DataFormat dataFormat) {
093 if (mappingFile != null) {
094 setProperty(dataFormat, "mappingFile", mappingFile);
095 }
096 if (validation != null) {
097 setProperty(dataFormat, "validation", validation);
098 }
099 if (encoding != null) {
100 setProperty(dataFormat, "encoding", encoding);
101 }
102 if (packages != null) {
103 setProperty(dataFormat, "packages", packages);
104 }
105 if (classes != null) {
106 setProperty(dataFormat, "classes", classes);
107 }
108 }
109
110 }