/** * Yields the tokens resulting from the splitting of the supplied * <code>line</code>. * * @param line the line to be tokenized (can be <code>null</code>) * * @return the resulting tokens */ @Override public FieldSet tokenize(String line) { if (line == null) { line = ""; } List<String> tokens = new ArrayList<>(doTokenize(line)); // if names are set and strict flag is false if ( ( names.length != 0 ) && ( ! strict ) ) { adjustTokenCountIfNecessary( tokens ); } String[] values = tokens.toArray(new String[tokens.size()]); if (names.length == 0) { return fieldSetFactory.create(values); } else if (values.length != names.length) { throw new IncorrectTokenCountException(names.length, values.length, line); } return fieldSetFactory.create(values, names); }
/** * Yields the tokens resulting from the splitting of the supplied * <code>line</code>. * * @param line the line to be tokenized (can be <code>null</code>) * * @return the resulting tokens */ @Override public FieldSet tokenize(String line) { if (line == null) { line = ""; } List<String> tokens = new ArrayList<String>(doTokenize(line)); // if names are set and strict flag is false if ( ( names.length != 0 ) && ( ! strict ) ) { adjustTokenCountIfNecessary( tokens ); } String[] values = tokens.toArray(new String[tokens.size()]); if (names.length == 0) { return fieldSetFactory.create(values); } else if (values.length != names.length) { throw new IncorrectTokenCountException(names.length, values.length, line); } return fieldSetFactory.create(values, names); }