protected void writeItem()

in src/main/java/org/apache/sling/pipes/internal/CsvWriter.java [67:90]


    protected void writeItem(Resource resource) {
        if (headers == null) {
            headers = new ArrayList<>();
            headers.add(PATH_KEY);
            if (customOutputs != null) {
                headers.addAll(customOutputs.keySet());
            }
            try {
                writer.write(headers.stream().collect(Collectors.joining(SEPARATOR)) + NEW_LINE);
            } catch (IOException e) {
                LOGGER.error("unable to write header");
            }
        }
        try {
            List<String> elts = new ArrayList<>();
            for (String key : headers){
                writeCell(resource, elts, key);
            }
            String line = elts.stream().collect(Collectors.joining(SEPARATOR));
            writer.write(line + NEW_LINE);
        } catch (IOException e) {
            LOGGER.error("unable to write header", e);
        }
    }