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