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 java.util.List; 020 021import javax.xml.bind.annotation.XmlAccessType; 022import javax.xml.bind.annotation.XmlAccessorType; 023import javax.xml.bind.annotation.XmlAttribute; 024import javax.xml.bind.annotation.XmlElementRef; 025 026import org.apache.camel.model.DataFormatDefinition; 027import org.apache.camel.spi.Metadata; 028 029/** 030 * Represents the common parts of all uniVocity 031 * {@link org.apache.camel.spi.DataFormat} parsers. 032 */ 033@Metadata(label = "dataformat,transformation,csv", title = "uniVocity") 034@XmlAccessorType(XmlAccessType.FIELD) 035public abstract class UniVocityAbstractDataFormat extends DataFormatDefinition { 036 037 @XmlAttribute 038 protected String nullValue; 039 @XmlAttribute 040 @Metadata(defaultValue = "true") 041 protected Boolean skipEmptyLines; 042 @XmlAttribute 043 @Metadata(defaultValue = "true") 044 protected Boolean ignoreTrailingWhitespaces; 045 @XmlAttribute 046 @Metadata(defaultValue = "true") 047 protected Boolean ignoreLeadingWhitespaces; 048 @XmlAttribute 049 protected Boolean headersDisabled; 050 @XmlElementRef 051 protected List<UniVocityHeader> headers; 052 @XmlAttribute 053 protected Boolean headerExtractionEnabled; 054 @XmlAttribute 055 protected Integer numberOfRecordsToRead; 056 @XmlAttribute 057 protected String emptyValue; 058 @XmlAttribute 059 protected String lineSeparator; 060 @XmlAttribute 061 @Metadata(defaultValue = "\\n") 062 protected String normalizedLineSeparator; 063 @XmlAttribute 064 @Metadata(defaultValue = "#") 065 protected String comment; 066 @XmlAttribute 067 protected Boolean lazyLoad; 068 @XmlAttribute 069 protected Boolean asMap; 070 071 protected UniVocityAbstractDataFormat() { 072 // This constructor is needed by jaxb for schema generation 073 } 074 075 protected UniVocityAbstractDataFormat(String dataFormatName) { 076 super(dataFormatName); 077 } 078 079 public String getNullValue() { 080 return nullValue; 081 } 082 083 /** 084 * The string representation of a null value. 085 * <p/> 086 * The default value is null 087 */ 088 public void setNullValue(String nullValue) { 089 this.nullValue = nullValue; 090 } 091 092 public Boolean getSkipEmptyLines() { 093 return skipEmptyLines; 094 } 095 096 /** 097 * Whether or not the empty lines must be ignored. 098 * <p/> 099 * The default value is true 100 */ 101 public void setSkipEmptyLines(Boolean skipEmptyLines) { 102 this.skipEmptyLines = skipEmptyLines; 103 } 104 105 public Boolean getIgnoreTrailingWhitespaces() { 106 return ignoreTrailingWhitespaces; 107 } 108 109 /** 110 * Whether or not the trailing white spaces must ignored. 111 * <p/> 112 * The default value is true 113 */ 114 public void setIgnoreTrailingWhitespaces(Boolean ignoreTrailingWhitespaces) { 115 this.ignoreTrailingWhitespaces = ignoreTrailingWhitespaces; 116 } 117 118 public Boolean getIgnoreLeadingWhitespaces() { 119 return ignoreLeadingWhitespaces; 120 } 121 122 /** 123 * Whether or not the leading white spaces must be ignored. 124 * <p/> 125 * The default value is true 126 */ 127 public void setIgnoreLeadingWhitespaces(Boolean ignoreLeadingWhitespaces) { 128 this.ignoreLeadingWhitespaces = ignoreLeadingWhitespaces; 129 } 130 131 public Boolean getHeadersDisabled() { 132 return headersDisabled; 133 } 134 135 /** 136 * Whether or not the headers are disabled. When defined, this option 137 * explicitly sets the headers as null which indicates that there is no 138 * header. 139 * <p/> 140 * The default value is false 141 */ 142 public void setHeadersDisabled(Boolean headersDisabled) { 143 this.headersDisabled = headersDisabled; 144 } 145 146 public List<UniVocityHeader> getHeaders() { 147 return headers; 148 } 149 150 /** 151 * The headers to use. 152 */ 153 public void setHeaders(List<UniVocityHeader> headers) { 154 this.headers = headers; 155 } 156 157 public Boolean getHeaderExtractionEnabled() { 158 return headerExtractionEnabled; 159 } 160 161 /** 162 * Whether or not the header must be read in the first line of the test 163 * document 164 * <p/> 165 * The default value is false 166 */ 167 public void setHeaderExtractionEnabled(Boolean headerExtractionEnabled) { 168 this.headerExtractionEnabled = headerExtractionEnabled; 169 } 170 171 public Integer getNumberOfRecordsToRead() { 172 return numberOfRecordsToRead; 173 } 174 175 /** 176 * The maximum number of record to read. 177 */ 178 public void setNumberOfRecordsToRead(Integer numberOfRecordsToRead) { 179 this.numberOfRecordsToRead = numberOfRecordsToRead; 180 } 181 182 public String getEmptyValue() { 183 return emptyValue; 184 } 185 186 /** 187 * The String representation of an empty value 188 */ 189 public void setEmptyValue(String emptyValue) { 190 this.emptyValue = emptyValue; 191 } 192 193 public String getLineSeparator() { 194 return lineSeparator; 195 } 196 197 /** 198 * The line separator of the files 199 * <p/> 200 * The default value is to use the JVM platform line separator 201 */ 202 public void setLineSeparator(String lineSeparator) { 203 this.lineSeparator = lineSeparator; 204 } 205 206 public String getNormalizedLineSeparator() { 207 return normalizedLineSeparator; 208 } 209 210 /** 211 * The normalized line separator of the files 212 * <p/> 213 * The default value is a new line character. 214 */ 215 public void setNormalizedLineSeparator(String normalizedLineSeparator) { 216 this.normalizedLineSeparator = normalizedLineSeparator; 217 } 218 219 public String getComment() { 220 return comment; 221 } 222 223 /** 224 * The comment symbol. 225 * <p/> 226 * The default value is # 227 */ 228 public void setComment(String comment) { 229 this.comment = comment; 230 } 231 232 public Boolean getLazyLoad() { 233 return lazyLoad; 234 } 235 236 /** 237 * Whether the unmarshalling should produce an iterator that reads the lines 238 * on the fly or if all the lines must be read at one. 239 * <p/> 240 * The default value is false 241 */ 242 public void setLazyLoad(Boolean lazyLoad) { 243 this.lazyLoad = lazyLoad; 244 } 245 246 public Boolean getAsMap() { 247 return asMap; 248 } 249 250 /** 251 * Whether the unmarshalling should produce maps for the lines values 252 * instead of lists. It requires to have header (either defined or 253 * collected). 254 * <p/> 255 * The default value is false 256 */ 257 public void setAsMap(Boolean asMap) { 258 this.asMap = asMap; 259 } 260 261}