Skip to content

Commit

Permalink
#373 improve code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed Dec 6, 2023
1 parent 130db76 commit 06ed238
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws

Iterable<CSVRecord> records = format.parse(in);
Iterator<CSVRecord> recordIterator = records.iterator();
LinkedHashMap<Integer, String> headers_map = makeHeadersMap(recordIterator, properties, format, charset);
LinkedHashMap<Integer, String> headers_map = makeHeadersMapFromOpenIterator(recordIterator, properties, format, charset);

log.debug("Iterating records");
int rown = 0;
Expand Down Expand Up @@ -115,21 +115,21 @@ public static CSVFormat buildFormat(Properties properties) throws IOException {
return format;
}

public LinkedHashMap<Integer, String> makeHeadersMap(Iterator<CSVRecord> recordIterator, Properties properties, CSVFormat format, Charset charset) throws TriplifierHTTPException, IOException {
public LinkedHashMap<Integer, String> makeHeadersMapFromOpenIterator(Iterator<CSVRecord> recordIterator, Properties properties, CSVFormat format, Charset charset) throws TriplifierHTTPException, IOException {
int headersRow = PropertyUtils.getIntegerProperty(properties, PROPERTY_HEADER_ROW);
Iterator<CSVRecord> iterator = recordIterator;
if (headersRow > 0) {
Reader in = new InputStreamReader(new BOMInputStream(Triplifier.getInputStream(properties)), charset);
Iterable<CSVRecord> records = format.parse(in);
iterator = records.iterator();
LinkedHashMap<Integer, String> headers_map = makeHeadersMap(properties, headersRow, iterator);
LinkedHashMap<Integer, String> headers_map = makeHeadersMapFromOpenIterator(properties, headersRow, iterator);
in.close();
return headers_map;
}
return makeHeadersMap(properties, headersRow, iterator);
return makeHeadersMapFromOpenIterator(properties, headersRow, iterator);
}

private static LinkedHashMap<Integer, String> makeHeadersMap(Properties properties, int headersRow, Iterator<CSVRecord> iterator) {
private static LinkedHashMap<Integer, String> makeHeadersMapFromOpenIterator(Properties properties, int headersRow, Iterator<CSVRecord> iterator) {
int rowNumber = 1;
LinkedHashMap<Integer, String> headers_map = new LinkedHashMap<Integer, String>();
if (hasHeaders(properties) && iterator.hasNext()) {
Expand Down Expand Up @@ -215,7 +215,7 @@ public Iterable<Slice> slice(Properties properties) throws IOException, Triplifi

Iterable<CSVRecord> records = format.parse(in);
final Iterator<CSVRecord> recordIterator = records.iterator();
final LinkedHashMap<Integer, String> headers_map = makeHeadersMap(recordIterator, properties, format, charset);
final LinkedHashMap<Integer, String> headers_map = makeHeadersMapFromOpenIterator(recordIterator, properties, format, charset);

return new Iterable<Slice>() {
@Override
Expand Down

0 comments on commit 06ed238

Please sign in to comment.