当前位置: 首页>>代码示例>>Java>>正文


Java AlwaysQuoteMode类代码示例

本文整理汇总了Java中org.supercsv.quote.AlwaysQuoteMode的典型用法代码示例。如果您正苦于以下问题:Java AlwaysQuoteMode类的具体用法?Java AlwaysQuoteMode怎么用?Java AlwaysQuoteMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AlwaysQuoteMode类属于org.supercsv.quote包,在下文中一共展示了AlwaysQuoteMode类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCustomPreference

import org.supercsv.quote.AlwaysQuoteMode; //导入依赖的package包/类
/**
 * Tests a custom CsvPreference with supplied optional values.
 */
@Test
public void testCustomPreference() {
	final CsvPreference custom = new CsvPreference.Builder('"', ',', "\n")
			.surroundingSpacesNeedQuotes(true)
			.useEncoder(new DefaultCsvEncoder())
			.useQuoteMode(new AlwaysQuoteMode())
			.setQuoteEscapeChar('\\')
			.build();
	assertEquals('"', custom.getQuoteChar());
	assertEquals(',', custom.getDelimiterChar());
	assertEquals("\n", custom.getEndOfLineSymbols());
	assertTrue(custom.isSurroundingSpacesNeedQuotes());
	assertTrue(custom.getEncoder() instanceof DefaultCsvEncoder);
	assertTrue(custom.getQuoteMode() instanceof AlwaysQuoteMode);
	assertEquals('\\', custom.getQuoteEscapeChar());
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:20,代码来源:CsvPreferenceTest.java

示例2: testCustomPreferenceBasedOnExisting

import org.supercsv.quote.AlwaysQuoteMode; //导入依赖的package包/类
/**
 * Tests a custom CsvPreference based on an existing constant with supplied optional values.
 */
@Test
public void testCustomPreferenceBasedOnExisting() {
	final CsvPreference custom = new CsvPreference.Builder(EXCEL_PREFERENCE).surroundingSpacesNeedQuotes(true)
		.useEncoder(new DefaultCsvEncoder()).useQuoteMode(new AlwaysQuoteMode()).build();
	assertEquals(EXCEL_PREFERENCE.getQuoteChar(), custom.getQuoteChar());
	assertEquals(EXCEL_PREFERENCE.getDelimiterChar(), custom.getDelimiterChar());
	assertEquals(EXCEL_PREFERENCE.getEndOfLineSymbols(), custom.getEndOfLineSymbols());
	assertTrue(custom.isSurroundingSpacesNeedQuotes());
	assertTrue(custom.getEncoder() instanceof DefaultCsvEncoder);
	assertTrue(custom.getQuoteMode() instanceof AlwaysQuoteMode);
	assertEquals(EXCEL_PREFERENCE.getQuoteEscapeChar(), custom.getQuoteEscapeChar());
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:16,代码来源:CsvPreferenceTest.java

示例3: testWriteAll_custom_preference

import org.supercsv.quote.AlwaysQuoteMode; //导入依赖的package包/类
/**
 * 書き込みのテスト - {@link CsvPreference}のカスタマイズ
 */
@Test
public void testWriteAll_custom_preference() throws IOException {
    
    // テストデータの作成
    final List<SampleNormalBean> list = createNormalData();
    
    StringWriter strWriter = new StringWriter();
    
    // タブ区切り、改行コード「LF」、必ずダブルクウォートで囲む設定
    final CsvPreference preference = new CsvPreference.Builder('\"', '\t', "\n")
            .useQuoteMode(new AlwaysQuoteMode())
            .build();
    
    CsvAnnotationBeanWriter<SampleNormalBean> csvWriter = new CsvAnnotationBeanWriter<>(
            SampleNormalBean.class,
            strWriter,
            preference,
            DefaultGroup.class, SampleNormalBean.WriteGroup.class);
    
    csvWriter.writeAll(list, true);
    csvWriter.flush();
    
    String actual = strWriter.toString();
    System.out.println(actual);
    
    String expected = getTextFromFile("src/test/data/test_write_tab.csv", Charset.forName("UTF-8"));
    assertThat(actual).isEqualTo(expected);
    
    assertThat(csvWriter.getErrorMessages()).hasSize(0);
    
    csvWriter.close();
    
}
 
开发者ID:mygreen,项目名称:super-csv-annotation,代码行数:37,代码来源:CsvAnnotationBeanWriterTest.java


注:本文中的org.supercsv.quote.AlwaysQuoteMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。