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 the BeanIO {@link org.apache.camel.spi.DataFormat}
029     *
030     * @version 
031     */
032    @XmlRootElement(name = "beanio")
033    @XmlAccessorType(XmlAccessType.FIELD)
034    public class BeanioDataFormat extends DataFormatDefinition {
035    
036        @XmlAttribute(required = true)
037        private String mapping;
038        @XmlAttribute(required = true)
039        private String streamName;
040        @XmlAttribute
041        private Boolean ignoreUnidentifiedRecords;
042        @XmlAttribute
043        private Boolean ignoreUnexpectedRecords;
044        @XmlAttribute
045        private Boolean ignoreInvalidRecords;
046        @XmlAttribute
047        private String encoding;
048    
049        public BeanioDataFormat() {
050            super("beanio");
051        }
052    
053        @Override
054        protected void configureDataFormat(DataFormat dataFormat) {
055            setProperty(dataFormat, "mapping", mapping);
056            setProperty(dataFormat, "streamName", streamName);
057            if (ignoreUnidentifiedRecords != null) {
058                setProperty(dataFormat, "ignoreUnidentifiedRecords", ignoreUnidentifiedRecords);
059            }
060            if (ignoreUnexpectedRecords != null) {
061                setProperty(dataFormat, "ignoreUnexpectedRecords", ignoreUnexpectedRecords);
062            }
063            if (ignoreInvalidRecords != null) {
064                setProperty(dataFormat, "ignoreInvalidRecords", ignoreInvalidRecords);
065            }
066            if (encoding != null) {
067                setProperty(dataFormat, "encoding", encoding);
068            }
069        }
070    
071        public String getMapping() {
072            return mapping;
073        }
074    
075        public void setMapping(String mapping) {
076            this.mapping = mapping;
077        }
078    
079        public String getStreamName() {
080            return streamName;
081        }
082    
083        public void setStreamName(String streamName) {
084            this.streamName = streamName;
085        }
086    
087        public Boolean getIgnoreUnidentifiedRecords() {
088            return ignoreUnidentifiedRecords;
089        }
090    
091        public void setIgnoreUnidentifiedRecords(Boolean ignoreUnidentifiedRecords) {
092            this.ignoreUnidentifiedRecords = ignoreUnidentifiedRecords;
093        }
094    
095        public Boolean getIgnoreUnexpectedRecords() {
096            return ignoreUnexpectedRecords;
097        }
098    
099        public void setIgnoreUnexpectedRecords(Boolean ignoreUnexpectedRecords) {
100            this.ignoreUnexpectedRecords = ignoreUnexpectedRecords;
101        }
102    
103        public Boolean getIgnoreInvalidRecords() {
104            return ignoreInvalidRecords;
105        }
106    
107        public void setIgnoreInvalidRecords(Boolean ignoreInvalidRecords) {
108            this.ignoreInvalidRecords = ignoreInvalidRecords;
109        }
110    
111        public String getEncoding() {
112            return encoding;
113        }
114    
115        public void setEncoding(String encoding) {
116            this.encoding = encoding;
117        }
118    
119    }