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 Flatpack data format is used for working with flat payloads (such as CSV, 029 * delimited, or fixed length formats). 030 */ 031@Metadata(firstVersion = "2.1.0", label = "dataformat,transformation,csv", title = "Flatpack") 032@XmlRootElement(name = "flatpack") 033@XmlAccessorType(XmlAccessType.FIELD) 034public class FlatpackDataFormat extends DataFormatDefinition { 035 @XmlAttribute 036 private String definition; 037 @XmlAttribute 038 @Metadata(javaType = "java.lang.Boolean") 039 private String fixed; 040 @XmlAttribute 041 @Metadata(defaultValue = "true", javaType = "java.lang.Boolean") 042 private String ignoreFirstRecord; 043 @XmlAttribute 044 private String textQualifier; 045 @XmlAttribute 046 @Metadata(defaultValue = ",") 047 private String delimiter; 048 @XmlAttribute 049 @Metadata(javaType = "java.lang.Boolean") 050 private String allowShortLines; 051 @XmlAttribute 052 @Metadata(javaType = "java.lang.Boolean") 053 private String ignoreExtraColumns; 054 @XmlAttribute 055 @Metadata(label = "advanced") 056 private String parserFactoryRef; 057 058 public FlatpackDataFormat() { 059 super("flatpack"); 060 } 061 062 public String getDefinition() { 063 return definition; 064 } 065 066 /** 067 * The flatpack pzmap configuration file. Can be omitted in simpler 068 * situations, but its preferred to use the pzmap. 069 */ 070 public void setDefinition(String definition) { 071 this.definition = definition; 072 } 073 074 public String getFixed() { 075 return fixed; 076 } 077 078 /** 079 * Delimited or fixed. Is by default false = delimited 080 */ 081 public void setFixed(String fixed) { 082 this.fixed = fixed; 083 } 084 085 public String getIgnoreFirstRecord() { 086 return ignoreFirstRecord; 087 } 088 089 /** 090 * Whether the first line is ignored for delimited files (for the column 091 * headers). 092 * <p/> 093 * Is by default true. 094 */ 095 public void setIgnoreFirstRecord(String ignoreFirstRecord) { 096 this.ignoreFirstRecord = ignoreFirstRecord; 097 } 098 099 public String getTextQualifier() { 100 return textQualifier; 101 } 102 103 /** 104 * If the text is qualified with a character. 105 * <p/> 106 * Uses quote character by default. 107 */ 108 public void setTextQualifier(String textQualifier) { 109 this.textQualifier = textQualifier; 110 } 111 112 public String getDelimiter() { 113 return delimiter; 114 } 115 116 /** 117 * The delimiter char (could be ; , or similar) 118 */ 119 public void setDelimiter(String delimiter) { 120 this.delimiter = delimiter; 121 } 122 123 public String getAllowShortLines() { 124 return allowShortLines; 125 } 126 127 /** 128 * Allows for lines to be shorter than expected and ignores the extra 129 * characters 130 */ 131 public void setAllowShortLines(String allowShortLines) { 132 this.allowShortLines = allowShortLines; 133 } 134 135 public String getIgnoreExtraColumns() { 136 return ignoreExtraColumns; 137 } 138 139 /** 140 * Allows for lines to be longer than expected and ignores the extra 141 * characters. 142 */ 143 public void setIgnoreExtraColumns(String ignoreExtraColumns) { 144 this.ignoreExtraColumns = ignoreExtraColumns; 145 } 146 147 public String getParserFactoryRef() { 148 return parserFactoryRef; 149 } 150 151 /** 152 * References to a custom parser factory to lookup in the registry 153 */ 154 public void setParserFactoryRef(String parserFactoryRef) { 155 this.parserFactoryRef = parserFactoryRef; 156 } 157 158}