• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / displaytag / 1753

12 Feb 2026 03:17AM UTC coverage: 77.321% (-0.01%) from 77.334%
1753

push

github

web-flow
Merge pull request #1102 from hazendaz/renovate/javax-support-logback-monorepo

Update dependency ch.qos.logback:logback-classic to v1.5.29 (javax-support)

1438 of 2003 branches covered (71.79%)

Branch coverage included in aggregate %.

4034 of 5074 relevant lines covered (79.5%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.68
/displaytag/src/main/java/org/displaytag/export/CsvView.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2002-2026 Fabrizio Giustina, the Displaytag team
6
 */
7
package org.displaytag.export;
8

9
import java.io.IOException;
10
import java.io.Writer;
11
import java.nio.charset.StandardCharsets;
12

13
import javax.servlet.jsp.JspException;
14

15
import org.apache.commons.lang3.StringUtils;
16
import org.apache.commons.lang3.Strings;
17

18
/**
19
 * Export view for comma separated value exporting.
20
 */
21
public class CsvView extends BaseExportView {
1✔
22

23
    /** The Constant UTF8_BOM. */
24
    private static final String UTF8_BOM = "\uFEFF";
25

26
    /**
27
     * Do export.
28
     *
29
     * @param out
30
     *            the out
31
     * @param characterEncoding
32
     *            the character encoding
33
     *
34
     * @throws IOException
35
     *             Signals that an I/O exception has occurred.
36
     * @throws JspException
37
     *             the jsp exception
38
     */
39
    @Override
40
    public void doExport(final Writer out, final String characterEncoding) throws IOException, JspException {
41
        if (Strings.CI.equals(characterEncoding, StandardCharsets.UTF_8.name())) {
1!
42
            out.write(CsvView.UTF8_BOM);
×
43
        }
44
        super.doExport(out, characterEncoding);
1✔
45
    }
1✔
46

47
    /**
48
     * Gets the row end.
49
     *
50
     * @return the row end
51
     *
52
     * @see org.displaytag.export.BaseExportView#getRowEnd()
53
     */
54
    @Override
55
    protected String getRowEnd() {
56
        return "\n"; //$NON-NLS-1$
1✔
57
    }
58

59
    /**
60
     * Gets the cell end.
61
     *
62
     * @return the cell end
63
     *
64
     * @see org.displaytag.export.BaseExportView#getCellEnd()
65
     */
66
    @Override
67
    protected String getCellEnd() {
68
        return ","; //$NON-NLS-1$
1✔
69
    }
70

71
    /**
72
     * Gets the always append cell end.
73
     *
74
     * @return the always append cell end
75
     *
76
     * @see org.displaytag.export.BaseExportView#getAlwaysAppendCellEnd()
77
     */
78
    @Override
79
    protected boolean getAlwaysAppendCellEnd() {
80
        return false;
1✔
81
    }
82

83
    /**
84
     * Gets the always append row end.
85
     *
86
     * @return the always append row end
87
     *
88
     * @see org.displaytag.export.BaseExportView#getAlwaysAppendRowEnd()
89
     */
90
    @Override
91
    protected boolean getAlwaysAppendRowEnd() {
92
        return true;
1✔
93
    }
94

95
    /**
96
     * Gets the mime type.
97
     *
98
     * @return the mime type
99
     *
100
     * @see org.displaytag.export.ExportView#getMimeType()
101
     */
102
    @Override
103
    public String getMimeType() {
104
        return "text/csv"; //$NON-NLS-1$
1✔
105
    }
106

107
    /**
108
     * Escaping for csv format.
109
     * <ul>
110
     * <li>Quotes inside quoted strings are escaped with a /</li>
111
     * <li>Fields containings newlines or , are surrounded by "</li>
112
     * </ul>
113
     * Note this is the standard CVS format and it's not handled well by excel.
114
     *
115
     * @param value
116
     *            the value
117
     *
118
     * @return the string
119
     *
120
     * @see org.displaytag.export.BaseExportView#escapeColumnValue(java.lang.Object)
121
     */
122
    @Override
123
    protected String escapeColumnValue(final Object value) {
124
        final String stringValue = StringUtils.trim(value.toString());
1✔
125

126
        if (!StringUtils.containsNone(stringValue, '\r', '\n', ',')) {
1!
127
            return "\"" + //$NON-NLS-1$
×
128
                    Strings.CS.replace(stringValue, "\"", "\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
×
129
        }
130

131
        return stringValue;
1✔
132
    }
133

134
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc