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