Skip to content

Commit 23898d6

Browse files
committed
Format JavaDoc
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1522865 13f79535-47bb-0310-9956-ffa450edef68
1 parent cb90084 commit 23898d6

1 file changed

Lines changed: 57 additions & 12 deletions

File tree

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

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,66 +35,111 @@
3535

3636
/**
3737
* Specifies the format of a CSV file and parses input.
38+
*
3839
* <h4>Using predefined formats</h4>
40+
*
3941
* <p>
4042
* You can use one of the predefined formats:
4143
* </p>
44+
*
4245
* <ul>
4346
* <li>{@link #DEFAULT}</li>
4447
* <li>{@link #EXCEL}</li>
4548
* <li>{@link #MYSQL}</li>
4649
* <li>{@link #RFC4180}</li>
4750
* <li>{@link #TDF}</li>
4851
* </ul>
49-
* <p>For example:</p>
50-
* <pre>CSVParser parser = CSVFormat.EXCEL.parse(reader);</pre>
51-
* <p>The {@link CSVRecord} provides static methods to parse other input types, for example:</p>
52+
*
53+
* <p>
54+
* For example:
55+
* </p>
56+
*
57+
* <pre>
58+
* CSVParser parser = CSVFormat.EXCEL.parse(reader);
59+
* </pre>
60+
*
61+
* <p>
62+
* The {@link CSVRecord} provides static methods to parse other input types, for example:
63+
* </p>
64+
*
5265
* <pre>CSVParser parser = CSVFormat.parseFile(file, CSVFormat.EXCEL);</pre>
66+
*
5367
* <h4>Defining formats</h4>
68+
*
5469
* <p>
5570
* You can extend a format by calling the {@code with} methods. For example:
5671
* </p>
57-
* <pre>CSVFormat.EXCEL
72+
*
73+
* <pre>
74+
* CSVFormat.EXCEL
5875
* .withNullString(&quot;N/A&quot;)
59-
* .withIgnoreSurroundingSpaces(true);</pre>
76+
* .withIgnoreSurroundingSpaces(true);
77+
* </pre>
78+
*
6079
* <h4>Defining column names</h4>
80+
*
6181
* <p>
6282
* To define the column names you want to use to access records, write:
6383
* </p>
64-
* <pre>CSVFormat.EXCEL.withHeader(&quot;Col1&quot;, &quot;Col2&quot;, &quot;Col3&quot;);</pre>
84+
*
85+
* <pre>
86+
* CSVFormat.EXCEL.withHeader(&quot;Col1&quot;, &quot;Col2&quot;, &quot;Col3&quot;);
87+
* </pre>
88+
*
6589
* <p>
6690
* Calling {@link #withHeader(String...)} let's you use the given names to address values in a {@link CSVRecord}, and
67-
* assumes that your CSV source does not contain a first record that also defines column names. If it does, then
68-
* you are overriding this metadata with your names and you should skip the first record by calling
91+
* assumes that your CSV source does not contain a first record that also defines column names.
92+
*
93+
* If it does, then you are overriding this metadata with your names and you should skip the first record by calling
6994
* {@link #withSkipHeaderRecord(boolean)} with {@code true}.
7095
* </p>
96+
*
7197
* <h4>Parsing</h4>
98+
*
7299
* <p>
73100
* You can use a format directly to parse a reader. For example, to parse an Excel file with columns header, write:
74101
* </p>
75-
* <pre>Reader in = ...;
76-
*CSVFormat.EXCEL.withHeader(&quot;Col1&quot;, &quot;Col2&quot;, &quot;Col3&quot;).parse(in);</pre>
102+
*
103+
* <pre>
104+
* Reader in = ...;
105+
* CSVFormat.EXCEL.withHeader(&quot;Col1&quot;, &quot;Col2&quot;, &quot;Col3&quot;).parse(in);
106+
* </pre>
107+
*
77108
* <p>
78109
* For other input types, like resources, files, and URLs, use the static methods on {@link CSVParser}.
79110
* </p>
111+
*
80112
* <h4>Referencing columns safely</h4>
113+
*
81114
* <p>
82115
* If your source contains a header record, you can simplify your code and safely reference columns,
83116
* by using {@link #withHeader(String...)} with no arguments:
84117
* </p>
85-
* <pre>CSVFormat.EXCEL.withHeader();</pre>
118+
*
119+
* <pre>
120+
* CSVFormat.EXCEL.withHeader();
121+
* </pre>
122+
*
86123
* <p>
87124
* This causes the parser to read the first record and use its values as column names.
125+
*
88126
* Then, call one of the {@link CSVRecord} get method that takes a String column name argument:
89127
* </p>
90-
* <pre>String value = record.get(&quot;Col1&quot;);</pre>
128+
*
129+
* <pre>
130+
* String value = record.get(&quot;Col1&quot;);
131+
* </pre>
132+
*
91133
* <p>
92134
* This makes your code impervious to changes in column order in the CSV file.
93135
* </p>
136+
*
94137
* <h4>Notes</h4>
138+
*
95139
* <p>
96140
* This class is immutable.
97141
* </p>
142+
*
98143
* @version $Id$
99144
*/
100145
public class CSVFormat implements Serializable {

0 commit comments

Comments
 (0)