All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.univocity.parsers.csv.CsvWriterSettings Maven / Gradle / Ivy

Go to download

univocity's open source parsers for processing different text formats using a consistent API

There is a newer version: 2.9.1
Show newest version
/*******************************************************************************
 * Copyright 2014 uniVocity Software Pty Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.univocity.parsers.csv;

import com.univocity.parsers.common.*;

/**
 * This is the configuration class used by the CSV writer ({@link CsvWriter})
 *
 * 

In addition to the configuration options provided by {@link CommonWriterSettings}, the CsvWriterSettings include: * *

    *
  • emptyValue (defaults to null): Defines a replacement string to signify an empty value (which is not a null value) *

    If the writer has an empty String to write to the output, the emptyValue is used instead of an empty string

  • *
  • quoteAllFields (defaults to false): By default, only values that contain a field separator are enclosed within quotes. *

    If this property is set to true, this indicates that all written values should be enclosed within quotes (as defined in {@link CsvFormat})

  • *
* * @see com.univocity.parsers.csv.CsvWriter * @see com.univocity.parsers.csv.CsvFormat * @see com.univocity.parsers.common.CommonWriterSettings * * @author uniVocity Software Pty Ltd - [email protected] * */ public class CsvWriterSettings extends CommonWriterSettings { private boolean quoteAllFields = false; /** * Indicates that all written values should be enclosed within quotes (as defined in {@link CsvFormat}) *

(Defaults to false) * @return true if all written values should be enclosed within quotes, false otherwise */ public boolean getQuoteAllFields() { return quoteAllFields; } /** * Indicates indicates whether or not all written values should be enclosed within quotes (as defined in {@link CsvFormat}) * *

(Defaults to false) *

By default, only values that contain a field separator are enclosed within quotes. * * @param quoteAllFields a flag indicating whether to enclose all fields within quotes */ public void setQuoteAllFields(boolean quoteAllFields) { this.quoteAllFields = quoteAllFields; } /** * Returns the default CsvFormat configured to produce CSV outputs compliant to the RFC4180 standard. * @return and instance of CsvFormat configured to produce CSV outputs compliant to the RFC4180 standard. */ @Override protected CsvFormat createDefaultFormat() { return new CsvFormat(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy