|
29 | 29 | import java.util.stream.Collectors; |
30 | 30 | import java.util.stream.IntStream; |
31 | 31 |
|
32 | | -public class SeparatedValuesLogStructureFinder implements LogStructureFinder { |
| 32 | +public class DelimitedLogStructureFinder implements LogStructureFinder { |
33 | 33 |
|
34 | 34 | private static final int MAX_LEVENSHTEIN_COMPARISONS = 100; |
35 | 35 |
|
36 | 36 | private final List<String> sampleMessages; |
37 | 37 | private final LogStructure structure; |
38 | 38 |
|
39 | | - static SeparatedValuesLogStructureFinder makeSeparatedValuesLogStructureFinder(List<String> explanation, String sample, |
40 | | - String charsetName, Boolean hasByteOrderMarker, |
41 | | - CsvPreference csvPreference, boolean trimFields) |
42 | | - throws IOException { |
| 39 | + static DelimitedLogStructureFinder makeDelimitedLogStructureFinder(List<String> explanation, String sample, String charsetName, |
| 40 | + Boolean hasByteOrderMarker, CsvPreference csvPreference, |
| 41 | + boolean trimFields) throws IOException { |
43 | 42 |
|
44 | 43 | Tuple<List<List<String>>, List<Integer>> parsed = readRows(sample, csvPreference); |
45 | 44 | List<List<String>> rows = parsed.v1(); |
@@ -73,13 +72,14 @@ static SeparatedValuesLogStructureFinder makeSeparatedValuesLogStructureFinder(L |
73 | 72 | String preamble = Pattern.compile("\n").splitAsStream(sample).limit(lineNumbers.get(1)).collect(Collectors.joining("\n", "", "\n")); |
74 | 73 |
|
75 | 74 | char delimiter = (char) csvPreference.getDelimiterChar(); |
76 | | - LogStructure.Builder structureBuilder = new LogStructure.Builder(LogStructure.Format.fromSeparator(delimiter)) |
| 75 | + LogStructure.Builder structureBuilder = new LogStructure.Builder(LogStructure.Format.DELIMITED) |
77 | 76 | .setCharset(charsetName) |
78 | 77 | .setHasByteOrderMarker(hasByteOrderMarker) |
79 | 78 | .setSampleStart(preamble) |
80 | 79 | .setNumLinesAnalyzed(lineNumbers.get(lineNumbers.size() - 1)) |
81 | 80 | .setNumMessagesAnalyzed(sampleRecords.size()) |
82 | 81 | .setHasHeaderRow(isHeaderInFile) |
| 82 | + .setDelimiter(delimiter) |
83 | 83 | .setInputFields(Arrays.stream(headerWithNamedBlanks).collect(Collectors.toList())); |
84 | 84 |
|
85 | 85 | if (trimFields) { |
@@ -131,10 +131,10 @@ static SeparatedValuesLogStructureFinder makeSeparatedValuesLogStructureFinder(L |
131 | 131 | .setExplanation(explanation) |
132 | 132 | .build(); |
133 | 133 |
|
134 | | - return new SeparatedValuesLogStructureFinder(sampleMessages, structure); |
| 134 | + return new DelimitedLogStructureFinder(sampleMessages, structure); |
135 | 135 | } |
136 | 136 |
|
137 | | - private SeparatedValuesLogStructureFinder(List<String> sampleMessages, LogStructure structure) { |
| 137 | + private DelimitedLogStructureFinder(List<String> sampleMessages, LogStructure structure) { |
138 | 138 | this.sampleMessages = Collections.unmodifiableList(sampleMessages); |
139 | 139 | this.structure = structure; |
140 | 140 | } |
|
0 commit comments