test_class.declarator: csvSchemaParser
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private CSVSchemaParser csvSchemaParser;
test_class.type: CSVSchemaParser
test_class.var_name: csvSchemaParser
test_class.declarator: csvFormatFamily
test_class.modifier: @Autowired
test_class.original_string: @Autowired
      CSVFormatFamily csvFormatFamily;
test_class.type: CSVFormatFamily
test_class.var_name: csvFormatFamily
test_class.declarator: csvFormatUtils
test_class.modifier: @Autowired
test_class.original_string: @Autowired
      CSVFormatUtils csvFormatUtils;
test_class.type: CSVFormatUtils
test_class.var_name: csvFormatUtils
test_class.file: dataprep-backend-service/src/test/java/org/talend/dataprep/schema/csv/CSVSchemaParserTest.java
test_class.identifier: CSVSchemaParserTest
test_class.superclass: extends AbstractSchemaTestUtils
test_case.body: @Test
      public void TDP_1259() throws IOException {
          try (InputStream inputStream = this.getClass().getResourceAsStream("tdp-1259.csv")) {
              // We do know the format and therefore we go directly to the CSV schema guessing
              SchemaParser.Request request = getRequest(inputStream, "#1");
              request.getMetadata().setEncoding("UTF-8");
  
              csvSchemaParser.parse(request);
              final Map<String, String> parameters = request.getMetadata().getContent().getParameters();
              char actual = parameters.get(CSVFormatFamily.SEPARATOR_PARAMETER).charAt(0);
  
              List<String> header = csvFormatUtils.retrieveHeader(parameters);
              assertEquals(';', actual);
              List<String> expected = Arrays.asList("id", "first_name", "last_name", "email", "job_title", "company",
                      "city", "state", "country", "date", "campaign_id", "lead_score", "registration", "city", "birth",
                      "nbCommands", "id", "first_name", "last_name", "email", "job_title", "company", "city", "state",
                      "country", "date", "campaign_id", "lead_score", "registration", "city", "birth", "nbCommands");
              assertEquals(expected, header);
          }
      }
test_case.class_method_signature: CSVSchemaParserTest.TDP_1259()
test_case.full_signature: @Test public void TDP_1259()
test_case.identifier: TDP_1259
test_case.invocations: getResourceAsStream getClass getRequest setEncoding getMetadata parse getParameters getContent getMetadata charAt get retrieveHeader assertEquals asList assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void TDP_1259()
focal_class.declarator: DEFAULT_VALID_SEPARATORS =
              Collections.unmodifiableList(Arrays.asList(' ', '\t', ',', ';', '|'))
focal_class.modifier: public static final
focal_class.original_string: public static final List<Character> DEFAULT_VALID_SEPARATORS =
              Collections.unmodifiableList(Arrays.asList(' ', '\t', ',', ';', '|'));
focal_class.type: List<Character>
focal_class.var_name: DEFAULT_VALID_SEPARATORS
focal_class.declarator: LOGGER = LoggerFactory.getLogger(CSVSchemaParser.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(CSVSchemaParser.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: META_KEY = "key"
focal_class.modifier: private static final
focal_class.original_string: private static final String META_KEY = "key";
focal_class.type: String
focal_class.var_name: META_KEY
focal_class.declarator: SIZE_LIMIT = 64L * 1024L
focal_class.modifier: private static final
focal_class.original_string: private static final long SIZE_LIMIT = 64L * 1024L;
focal_class.type: long
focal_class.var_name: SIZE_LIMIT
focal_class.declarator: LINE_LIMIT = 100
focal_class.modifier: private static final
focal_class.original_string: private static final int LINE_LIMIT = 100;
focal_class.type: int
focal_class.var_name: LINE_LIMIT
focal_class.declarator: SMALL_SAMPLE_LIMIT = 10
focal_class.modifier: private static final
focal_class.original_string: private static final int SMALL_SAMPLE_LIMIT = 10;
focal_class.type: int
focal_class.var_name: SMALL_SAMPLE_LIMIT
focal_class.declarator: csvFormatUtils
focal_class.modifier: @Autowired
      protected
focal_class.original_string: @Autowired
      protected CSVFormatUtils csvFormatUtils;
focal_class.type: CSVFormatUtils
focal_class.var_name: csvFormatUtils
focal_class.file: dataprep-backend-service/src/main/java/org/talend/dataprep/schema/csv/CSVSchemaParser.java
focal_class.identifier: CSVSchemaParser
focal_class.interfaces: implements SchemaParser
focal_class.class_method_signature: CSVSchemaParser.accept(DataSetMetadata metadata)
focal_class.full_signature: @Override public boolean accept(DataSetMetadata metadata)
focal_class.identifier: accept
focal_class.modifiers: @Override public
focal_class.parameters: (DataSetMetadata metadata)
focal_class.return: boolean
focal_class.signature: boolean accept(DataSetMetadata metadata)
focal_class.class_method_signature: CSVSchemaParser.parse(Request request)
focal_class.full_signature: @Override public Schema parse(Request request)
focal_class.identifier: parse
focal_class.modifiers: @Override public
focal_class.parameters: (Request request)
focal_class.return: Schema
focal_class.signature: Schema parse(Request request)
focal_class.class_method_signature: CSVSchemaParser.guess(SchemaParser.Request request, String encoding)
focal_class.full_signature: public Map<String, String> guess(SchemaParser.Request request, String encoding)
focal_class.identifier: guess
focal_class.modifiers: public
focal_class.parameters: (SchemaParser.Request request, String encoding)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> guess(SchemaParser.Request request, String encoding)
focal_class.class_method_signature: CSVSchemaParser.guessSeparator(InputStream is, String encoding, Optional<Character> forcedSeparator)
focal_class.full_signature: private Separator guessSeparator(InputStream is, String encoding, Optional<Character> forcedSeparator)
focal_class.identifier: guessSeparator
focal_class.modifiers: private
focal_class.parameters: (InputStream is, String encoding, Optional<Character> forcedSeparator)
focal_class.return: Separator
focal_class.signature: Separator guessSeparator(InputStream is, String encoding, Optional<Character> forcedSeparator)
focal_class.class_method_signature: CSVSchemaParser.processLine(String line, Map<Character, Separator> separatorMap, List<Character> validSeparators,
              int lineCount)
focal_class.full_signature: private void processLine(String line, Map<Character, Separator> separatorMap, List<Character> validSeparators,
              int lineCount)
focal_class.identifier: processLine
focal_class.modifiers: private
focal_class.parameters: (String line, Map<Character, Separator> separatorMap, List<Character> validSeparators,
              int lineCount)
focal_class.return: void
focal_class.signature: void processLine(String line, Map<Character, Separator> separatorMap, List<Character> validSeparators,
              int lineCount)
focal_class.class_method_signature: CSVSchemaParser.processCharAsSeparatorCandidate(char candidate, Map<Character, Separator> separatorMap,
              List<Character> validSeparators, int lineNumber)
focal_class.full_signature: protected void processCharAsSeparatorCandidate(char candidate, Map<Character, Separator> separatorMap,
              List<Character> validSeparators, int lineNumber)
focal_class.identifier: processCharAsSeparatorCandidate
focal_class.modifiers: protected
focal_class.parameters: (char candidate, Map<Character, Separator> separatorMap,
              List<Character> validSeparators, int lineNumber)
focal_class.return: void
focal_class.signature: void processCharAsSeparatorCandidate(char candidate, Map<Character, Separator> separatorMap,
              List<Character> validSeparators, int lineNumber)
focal_class.class_method_signature: CSVSchemaParser.updateSeparatorMap(char candidate, Map<Character, Separator> separatorMap, int lineNumber)
focal_class.full_signature: private void updateSeparatorMap(char candidate, Map<Character, Separator> separatorMap, int lineNumber)
focal_class.identifier: updateSeparatorMap
focal_class.modifiers: private
focal_class.parameters: (char candidate, Map<Character, Separator> separatorMap, int lineNumber)
focal_class.return: void
focal_class.signature: void updateSeparatorMap(char candidate, Map<Character, Separator> separatorMap, int lineNumber)
focal_class.class_method_signature: CSVSchemaParser.chooseSeparator(List<Separator> separators, int lineCount, List<String> sampleLines,
              Optional<Character> forcedSeparator)
focal_class.full_signature: private Separator chooseSeparator(List<Separator> separators, int lineCount, List<String> sampleLines,
              Optional<Character> forcedSeparator)
focal_class.identifier: chooseSeparator
focal_class.modifiers: private
focal_class.parameters: (List<Separator> separators, int lineCount, List<String> sampleLines,
              Optional<Character> forcedSeparator)
focal_class.return: Separator
focal_class.signature: Separator chooseSeparator(List<Separator> separators, int lineCount, List<String> sampleLines,
              Optional<Character> forcedSeparator)
focal_method.body: @Override
      public Schema parse(Request request) {
          List<Schema.SheetContent> sheetContents = new ArrayList<>();
          sheetContents.add(new Schema.SheetContent(META_KEY, new ArrayList<>()));
          try {
              final DataSetMetadata metadata = request.getMetadata();
              final Map<String, String> parameters = guess(request, metadata.getEncoding());
              metadata.getContent().setParameters(parameters);
              metadata.getContent().setNbLinesInHeader(Integer.parseInt(parameters.get(HEADER_NB_LINES_PARAMETER)));
              List<String> header = csvFormatUtils.retrieveHeader(parameters);
              if (header == null || header.isEmpty()) {
                  throw new TDPException(DataSetErrorCodes.UNABLE_TO_READ_DATASET_CONTENT);
              }
              LOGGER.debug("Columns found: {}", header);
              // By default, consider all columns as Strings (to be refined by deeper analysis).
              LOGGER.debug("Setting default type for columns...");
              int i = 0;
              for (String column : header) {
                  sheetContents
                          .stream()
                          .filter(sheetContent -> META_KEY.equals(sheetContent.getName()))
                          .findFirst() //
                          .get()
                          .getColumnMetadatas() //
                          .add(column().id(i++).name(column).type(Type.STRING).build());
              }
          } catch (Exception e) {
              throw new TDPException(CommonErrorCodes.UNABLE_TO_READ_CONTENT, e);
          }
          return Schema.Builder
                  .parserResult() //
                  .sheetContents(sheetContents) //
                  .draft(false)
                  .build();
      }
focal_method.class_method_signature: CSVSchemaParser.parse(Request request)
focal_method.full_signature: @Override public Schema parse(Request request)
focal_method.identifier: parse
focal_method.invocations: add getMetadata guess getEncoding setParameters getContent setNbLinesInHeader getContent parseInt get retrieveHeader isEmpty debug debug add getColumnMetadatas get findFirst filter stream equals getName build type name id column build draft sheetContents parserResult
focal_method.modifiers: @Override public
focal_method.parameters: (Request request)
focal_method.return: Schema
focal_method.signature: Schema parse(Request request)