Skip to content

Commit 07fa2fd

Browse files
committed
Make JavaDoc more readable and clear up field values of CSVFormats
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1610485 13f79535-47bb-0310-9956-ffa450edef68
1 parent 83df300 commit 07fa2fd

1 file changed

Lines changed: 59 additions & 21 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -161,28 +161,30 @@ public final class CSVFormat implements Serializable {
161161

162162
/**
163163
* Standard comma separated format, as for {@link #RFC4180} but allowing empty lines.
164-
* <h3>RFC 4180:</h3>
165-
* <ul>
166-
* <li>withDelimiter(',')</li>
167-
* <li>withQuoteChar('"')</li>
168-
* <li>withRecordSeparator(CRLF)</li>
169-
* </ul>
170-
* <h3>Additional:</h3>
164+
*
165+
* <p>Settings are:
171166
* <ul>
172-
* <li>withIgnoreEmptyLines(true)</li>
167+
* <li>withDelimiter(',')</li>
168+
* <li>withQuoteChar('"')</li>
169+
* <li>withRecordSeparator("\r\n")</li>
170+
* <li>withIgnoreEmptyLines(true)</li>
173171
* </ul>
172+
* </p>
174173
*/
175174
public static final CSVFormat DEFAULT = new CSVFormat(COMMA, DOUBLE_QUOTE_CHAR, null, null, null,
176175
false, true, CRLF, null, null, false, false);
177176

178177
/**
179178
* Comma separated format as defined by <a href="http://tools.ietf.org/html/rfc4180">RFC 4180</a>.
180-
* <h3>RFC 4180:</h3>
179+
*
180+
* <p>Settings are:
181181
* <ul>
182-
* <li>withDelimiter(',')</li>
183-
* <li>withQuoteChar('"')</li>
184-
* <li>withRecordSeparator(CRLF)</li>
182+
* <li>withDelimiter(',')</li>
183+
* <li>withQuoteChar('"')</li>
184+
* <li>withRecordSeparator("\r\n")</li>
185+
* <li>withIgnoreEmptyLines(false)</li>
185186
* </ul>
187+
* </p>
186188
*/
187189
public static final CSVFormat RFC4180 = DEFAULT.withIgnoreEmptyLines(false);
188190

@@ -195,32 +197,59 @@ public final class CSVFormat implements Serializable {
195197
* </p>
196198
*
197199
* <pre>
198-
* CSVFormat fmt = CSVFormat.newBuilder(EXCEL).withDelimiter(';');
200+
* CSVFormat fmt = CSVFormat.EXCEL.withDelimiter(';');
199201
* </pre>
200202
*
201203
* <p>
202204
* Settings are:
203-
* </p>
204205
* <ul>
205-
* <li>withDelimiter(',')</li>
206-
* <li>withQuoteChar('"')</li>
207-
* <li>withRecordSeparator(CRLF)</li>
206+
* <li>withDelimiter(',')</li>
207+
* <li>withQuoteChar('"')</li>
208+
* <li>withRecordSeparator("\r\n")</li>
209+
* <li>withIgnoreEmptyLines(false)</li>
208210
* </ul>
209-
* Note: this is currently the same as RFC4180
211+
* </p>
212+
* <p>
213+
* Note: this is currently the same as {@link #RFC4180}.
214+
* </p>
210215
*/
211216
public static final CSVFormat EXCEL = DEFAULT.withIgnoreEmptyLines(false);
212217

213-
/** Tab-delimited format, with quote; leading and trailing spaces ignored. */
218+
/**
219+
* Tab-delimited format.
220+
*
221+
* <p>Settings are:
222+
* <ul>
223+
* <li>withDelimiter('\t')</li>
224+
* <li>withQuoteChar('"')</li>
225+
* <li>withRecordSeparator("\r\n")</li>
226+
* <li>withIgnoreSurroundingSpaces(true)</li>
227+
* </ul>
228+
* </p>
229+
*/
214230
public static final CSVFormat TDF =
215231
DEFAULT
216232
.withDelimiter(TAB)
217233
.withIgnoreSurroundingSpaces(true);
218234

219235
/**
220-
* Default MySQL format used by the <tt>SELECT INTO OUTFILE</tt> and <tt>LOAD DATA INFILE</tt> operations. This is
221-
* a tab-delimited format with a LF character as the line separator. Values are not quoted and special characters
236+
* Default MySQL format used by the <tt>SELECT INTO OUTFILE</tt> and <tt>LOAD DATA INFILE</tt> operations.
237+
*
238+
* <p>
239+
* This is a tab-delimited format with a LF character as the line separator. Values are not quoted and special characters
222240
* are escaped with '\'.
241+
* </p>
223242
*
243+
* <p>
244+
* Settings are:
245+
* <ul>
246+
* <li>withDelimiter('\t')</li>
247+
* <li>withQuoteChar(null)</li>
248+
* <li>withRecordSeparator('\n')</li>
249+
* <li>withIgnoreEmptyLines(false)</li>
250+
* <li>withEscape('\\')</li>
251+
* </ul>
252+
* </p>
224253
* @see <a href="http://dev.mysql.com/doc/refman/5.1/en/load-data.html">
225254
* http://dev.mysql.com/doc/refman/5.1/en/load-data.html</a>
226255
*/
@@ -259,10 +288,19 @@ private static boolean isLineBreak(final Character c) {
259288
/**
260289
* Creates a new CSV format with the specified delimiter.
261290
*
291+
* <p>Use this method if you want to create a CSVFormat from scratch. All fields but the delimiter will be
292+
* initialized with null/false.</p>
293+
*
262294
* @param delimiter
263295
* the char used for value separation, must not be a line break character
264296
* @return a new CSV format.
265297
* @throws IllegalArgumentException if the delimiter is a line break character
298+
*
299+
* @see #DEFAULT
300+
* @see #RFC4180
301+
* @see #MYSQL
302+
* @see #EXCEL
303+
* @see #TDF
266304
*/
267305
public static CSVFormat newFormat(final char delimiter) {
268306
return new CSVFormat(delimiter, null, null, null, null, false, false, null, null, null, false, false);

0 commit comments

Comments
 (0)