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.model.DataFormatDefinition; 025import org.apache.camel.spi.Metadata; 026 027/** 028 * The BeanIO data format is used for working with flat payloads (such as CSV, 029 * delimited, or fixed length formats). 030 */ 031@Metadata(firstVersion = "2.10.0", label = "dataformat,transformation,csv", title = "BeanIO") 032@XmlRootElement(name = "beanio") 033@XmlAccessorType(XmlAccessType.FIELD) 034public 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 @XmlAttribute 049 @Metadata(label = "advanced") 050 private String beanReaderErrorHandlerType; 051 @XmlAttribute 052 @Metadata(label = "advanced") 053 private Boolean unmarshalSingleObject; 054 055 public BeanioDataFormat() { 056 super("beanio"); 057 } 058 059 public String getMapping() { 060 return mapping; 061 } 062 063 /** 064 * The BeanIO mapping file. Is by default loaded from the classpath. You can 065 * prefix with file:, http:, or classpath: to denote from where to load the 066 * mapping file. 067 */ 068 public void setMapping(String mapping) { 069 this.mapping = mapping; 070 } 071 072 public String getStreamName() { 073 return streamName; 074 } 075 076 /** 077 * The name of the stream to use. 078 */ 079 public void setStreamName(String streamName) { 080 this.streamName = streamName; 081 } 082 083 public Boolean getIgnoreUnidentifiedRecords() { 084 return ignoreUnidentifiedRecords; 085 } 086 087 /** 088 * Whether to ignore unidentified records. 089 */ 090 public void setIgnoreUnidentifiedRecords(Boolean ignoreUnidentifiedRecords) { 091 this.ignoreUnidentifiedRecords = ignoreUnidentifiedRecords; 092 } 093 094 public Boolean getIgnoreUnexpectedRecords() { 095 return ignoreUnexpectedRecords; 096 } 097 098 /** 099 * Whether to ignore unexpected records. 100 */ 101 public void setIgnoreUnexpectedRecords(Boolean ignoreUnexpectedRecords) { 102 this.ignoreUnexpectedRecords = ignoreUnexpectedRecords; 103 } 104 105 public Boolean getIgnoreInvalidRecords() { 106 return ignoreInvalidRecords; 107 } 108 109 /** 110 * Whether to ignore invalid records. 111 */ 112 public void setIgnoreInvalidRecords(Boolean ignoreInvalidRecords) { 113 this.ignoreInvalidRecords = ignoreInvalidRecords; 114 } 115 116 public String getEncoding() { 117 return encoding; 118 } 119 120 /** 121 * The charset to use. 122 * <p/> 123 * Is by default the JVM platform default charset. 124 */ 125 public void setEncoding(String encoding) { 126 this.encoding = encoding; 127 } 128 129 public String getBeanReaderErrorHandlerType() { 130 return beanReaderErrorHandlerType; 131 } 132 133 /** 134 * To use a custom org.apache.camel.dataformat.beanio.BeanIOErrorHandler as 135 * error handler while parsing. Configure the fully qualified class name of 136 * the error handler. Notice the options ignoreUnidentifiedRecords, 137 * ignoreUnexpectedRecords, and ignoreInvalidRecords may not be in use when 138 * you use a custom error handler. 139 */ 140 public void setBeanReaderErrorHandlerType(String beanReaderErrorHandlerType) { 141 this.beanReaderErrorHandlerType = beanReaderErrorHandlerType; 142 } 143 144 public Boolean getUnmarshalSingleObject() { 145 return unmarshalSingleObject; 146 } 147 148 /** 149 * This options controls whether to unmarshal as a list of objects or as a 150 * single object only. The former is the default mode, and the latter is 151 * only intended in special use-cases where beanio maps the Camel message to 152 * a single POJO bean. 153 */ 154 public void setUnmarshalSingleObject(Boolean unmarshalSingleObject) { 155 this.unmarshalSingleObject = unmarshalSingleObject; 156 } 157}