congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CsvConfiguration.getCharset
Code IndexAdd Tabnine to your IDE (free)

How to use
getCharset
method
in
com.asakusafw.runtime.io.csv.CsvConfiguration

Best Java code snippets using com.asakusafw.runtime.io.csv.CsvConfiguration.getCharset (Showing top 7 results out of 315)

origin: asakusafw/asakusafw

private CsvParser create(String content) {
  CsvConfiguration conf = createConfiguration();
  return new CsvParser(
      new ByteArrayInputStream(content.getBytes(conf.getCharset())),
      testName.getMethodName(),
      conf);
}
origin: asakusafw/asakusafw

/**
 * Creates a new instance.
 * @param stream the source stream
 * @param path the source path
 * @param config current configuration
 * @throws IllegalArgumentException if some parameters were {@code null}
 */
public CsvParser(InputStream stream, String path, CsvConfiguration config) {
  if (stream == null) {
    throw new IllegalArgumentException("stream must not be null"); //$NON-NLS-1$
  }
  if (config == null) {
    throw new IllegalArgumentException("config must not be null"); //$NON-NLS-1$
  }
  this.reader = new InputStreamReader(stream, config.getCharset());
  this.path = path;
  this.separator = config.getSeparatorChar();
  this.trueFormat = config.getTrueFormat();
  this.dateFormat = DateFormatter.newInstance(config.getDateFormat());
  this.dateTimeFormat = DateTimeFormatter.newInstance(config.getDateTimeFormat());
  this.headerCellsFormat = config.getHeaderCells();
  this.forceConsumeHeader = config.isForceConsumeHeader();
  this.allowLineBreakInValue = config.isLineBreakInValue();
  readerBuffer.clear();
  readerBuffer.flip();
}
origin: asakusafw/asakusafw

private String[][] parse(int columns, String string) {
  CsvConfiguration conf = new CsvConfiguration(
      CsvConfiguration.DEFAULT_CHARSET,
      CsvConfiguration.DEFAULT_HEADER_CELLS,
      CsvConfiguration.DEFAULT_TRUE_FORMAT,
      CsvConfiguration.DEFAULT_FALSE_FORMAT,
      CsvConfiguration.DEFAULT_DATE_FORMAT,
      CsvConfiguration.DEFAULT_DATE_TIME_FORMAT);
  List<String[]> results = new ArrayList<>();
  ByteArrayInputStream input = new ByteArrayInputStream(string.getBytes(conf.getCharset()));
  try (CsvParser parser = new CsvParser(input, string, conf)) {
    StringOption buffer = new StringOption();
    while (parser.next()) {
      String[] line = new String[columns];
      for (int i = 0; i < columns; i++) {
        parser.fill(buffer);
        line[i] = buffer.or((String) null);
      }
      parser.endRecord();
      results.add(line);
    }
  } catch (Exception e) {
    throw new AssertionError(e);
  }
  return results.toArray(new String[results.size()][]);
}
origin: asakusafw/asakusafw

/**
 * Creates a new instance.
 * @param stream the target stream
 * @param path the destination path
 * @param config current configuration
 * @throws IllegalArgumentException if some parameters were {@code null}
 */
public CsvEmitter(OutputStream stream, String path, CsvConfiguration config) {
  if (stream == null) {
    throw new IllegalArgumentException("stream must not be null"); //$NON-NLS-1$
  }
  if (config == null) {
    throw new IllegalArgumentException("config must not be null"); //$NON-NLS-1$
  }
  this.writer = new OutputStreamWriter(stream, config.getCharset());
  this.separator = config.getSeparatorChar();
  this.escapePattern = Pattern.compile(
      "[" + ESCAPE + separator + LINE_DELIMITER + "]"); //$NON-NLS-1$ //$NON-NLS-2$
  this.trueFormat = escape(config.getTrueFormat());
  this.escapeTrue = hasEscapeTarget(config.getTrueFormat());
  this.falseFormat = escape(config.getFalseFormat());
  this.escapeFalse = hasEscapeTarget(config.getFalseFormat());
  this.dateFormat = DateFormatter.newInstance(config.getDateFormat());
  this.escapeDate = hasMetaCharacter(dateFormat.getPattern());
  this.dateTimeFormat = DateTimeFormatter.newInstance(config.getDateTimeFormat());
  this.escapeDateTime = hasMetaCharacter(dateTimeFormat.getPattern());
  this.headerCellsFormat = config.getHeaderCells();
  this.forceEscapeMask = buildQuoteMask(config.getForceQuoteColumns());
  this.columnIndex = 0;
}
origin: asakusafw/asakusafw

/**
 * Simple stress test for {@link DecimalOption} type.
 * @throws Exception if failed
 */
@Test
public void stress_decimal() throws Exception {
  int count = 5000000;
  CsvConfiguration conf = createConfiguration();
  try (RCReader reader = new RCReader("3.141592\r\n".getBytes(conf.getCharset()), count);
      CsvParser parser = new CsvParser(reader, "testing", conf)) {
    int rows = 0;
    DecimalOption date = new DecimalOption();
    while (parser.next()) {
      parser.fill(date);
      parser.endRecord();
      if (rows == 0) {
        assertThat(date, is(new DecimalOption(new BigDecimal("3.141592"))));
      }
      rows++;
    }
    assertThat(rows, is(count));
  }
}
origin: asakusafw/asakusafw

/**
 * Simple stress test for {@link Date} type.
 * @throws Exception if failed
 */
@Test
public void stress_date() throws Exception {
  int count = 5000000;
  CsvConfiguration conf = createConfiguration();
  try (RCReader reader = new RCReader("1999-12-31\r\n".getBytes(conf.getCharset()), count);
      CsvParser parser = new CsvParser(reader, "testing", conf)) {
    int rows = 0;
    DateOption date = new DateOption();
    while (parser.next()) {
      parser.fill(date);
      parser.endRecord();
      if (rows == 0) {
        assertThat(date, is(new DateOption(new Date(1999, 12, 31))));
      }
      rows++;
    }
    parser.close();
    assertThat(rows, is(count));
  }
}
origin: asakusafw/asakusafw

/**
 * Simple stress test for {@link DateTime} type.
 * @throws Exception if failed
 */
@Test
public void stress_datetime() throws Exception {
  int count = 5000000;
  CsvConfiguration conf = createConfiguration();
  try (RCReader reader = new RCReader("1999-12-31 01:23:45\r\n".getBytes(conf.getCharset()), count);
      CsvParser parser = new CsvParser(reader, "testing", conf)) {
    int rows = 0;
    DateTimeOption date = new DateTimeOption();
    while (parser.next()) {
      parser.fill(date);
      parser.endRecord();
      if (rows == 0) {
        assertThat(date, is(new DateTimeOption(new DateTime(1999, 12, 31, 1, 23, 45))));
      }
      rows++;
    }
    parser.close();
    assertThat(rows, is(count));
  }
}
com.asakusafw.runtime.io.csvCsvConfigurationgetCharset

Javadoc

Returns the character set encoding name.

Popular methods of CsvConfiguration

  • <init>
    Creates a new instance.
  • getDateFormat
    The Date format in SimpleDateFormat.
  • getDateTimeFormat
    The DateTime format in SimpleDateFormat.
  • getFalseFormat
    The boolean false format.
  • getForceQuoteColumns
    Returns column indices which quoting is always required.
  • getHeaderCells
    The header cell values.
  • getSeparatorChar
    Returns the field separator character.
  • getTrueFormat
    The boolean true format.
  • isForceConsumeHeader
    Returns whether forcibly consumes header cells or not.
  • isLineBreakInValue
    Returns whether allows line breaks in value.
  • setDefaultQuoteMode
  • setFieldDelimiter
  • setDefaultQuoteMode,
  • setFieldDelimiter,
  • setForceQuoteColumns,
  • setLineBreakInValue

Popular in Java

  • Updating database using SQL prepared statement
  • startActivity (Activity)
  • getApplicationContext (Context)
  • setRequestProperty (URLConnection)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JFrame (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now