Format JavaDoc

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1522865 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benedikt Ritter 2013-09-13 11:01:28 +00:00
parent cb900843d2
commit 23898d62e2
1 changed files with 57 additions and 12 deletions

View File

@ -35,10 +35,13 @@ import java.util.Set;
/** /**
* Specifies the format of a CSV file and parses input. * Specifies the format of a CSV file and parses input.
*
* <h4>Using predefined formats</h4> * <h4>Using predefined formats</h4>
*
* <p> * <p>
* You can use one of the predefined formats: * You can use one of the predefined formats:
* </p> * </p>
*
* <ul> * <ul>
* <li>{@link #DEFAULT}</li> * <li>{@link #DEFAULT}</li>
* <li>{@link #EXCEL}</li> * <li>{@link #EXCEL}</li>
@ -46,55 +49,97 @@ import java.util.Set;
* <li>{@link #RFC4180}</li> * <li>{@link #RFC4180}</li>
* <li>{@link #TDF}</li> * <li>{@link #TDF}</li>
* </ul> * </ul>
* <p>For example:</p> *
* <pre>CSVParser parser = CSVFormat.EXCEL.parse(reader);</pre> * <p>
* <p>The {@link CSVRecord} provides static methods to parse other input types, for example:</p> * For example:
* </p>
*
* <pre>
* CSVParser parser = CSVFormat.EXCEL.parse(reader);
* </pre>
*
* <p>
* The {@link CSVRecord} provides static methods to parse other input types, for example:
* </p>
*
* <pre>CSVParser parser = CSVFormat.parseFile(file, CSVFormat.EXCEL);</pre> * <pre>CSVParser parser = CSVFormat.parseFile(file, CSVFormat.EXCEL);</pre>
*
* <h4>Defining formats</h4> * <h4>Defining formats</h4>
*
* <p> * <p>
* You can extend a format by calling the {@code with} methods. For example: * You can extend a format by calling the {@code with} methods. For example:
* </p> * </p>
* <pre>CSVFormat.EXCEL *
* <pre>
* CSVFormat.EXCEL
* .withNullString(&quot;N/A&quot;) * .withNullString(&quot;N/A&quot;)
* .withIgnoreSurroundingSpaces(true);</pre> * .withIgnoreSurroundingSpaces(true);
* </pre>
*
* <h4>Defining column names</h4> * <h4>Defining column names</h4>
*
* <p> * <p>
* To define the column names you want to use to access records, write: * To define the column names you want to use to access records, write:
* </p> * </p>
* <pre>CSVFormat.EXCEL.withHeader(&quot;Col1&quot;, &quot;Col2&quot;, &quot;Col3&quot;);</pre> *
* <pre>
* CSVFormat.EXCEL.withHeader(&quot;Col1&quot;, &quot;Col2&quot;, &quot;Col3&quot;);
* </pre>
*
* <p> * <p>
* Calling {@link #withHeader(String...)} let's you use the given names to address values in a {@link CSVRecord}, and * Calling {@link #withHeader(String...)} let's you use the given names to address values in a {@link CSVRecord}, and
* assumes that your CSV source does not contain a first record that also defines column names. If it does, then * assumes that your CSV source does not contain a first record that also defines column names.
* you are overriding this metadata with your names and you should skip the first record by calling *
* If it does, then you are overriding this metadata with your names and you should skip the first record by calling
* {@link #withSkipHeaderRecord(boolean)} with {@code true}. * {@link #withSkipHeaderRecord(boolean)} with {@code true}.
* </p> * </p>
*
* <h4>Parsing</h4> * <h4>Parsing</h4>
*
* <p> * <p>
* You can use a format directly to parse a reader. For example, to parse an Excel file with columns header, write: * You can use a format directly to parse a reader. For example, to parse an Excel file with columns header, write:
* </p> * </p>
* <pre>Reader in = ...; *
*CSVFormat.EXCEL.withHeader(&quot;Col1&quot;, &quot;Col2&quot;, &quot;Col3&quot;).parse(in);</pre> * <pre>
* Reader in = ...;
* CSVFormat.EXCEL.withHeader(&quot;Col1&quot;, &quot;Col2&quot;, &quot;Col3&quot;).parse(in);
* </pre>
*
* <p> * <p>
* For other input types, like resources, files, and URLs, use the static methods on {@link CSVParser}. * For other input types, like resources, files, and URLs, use the static methods on {@link CSVParser}.
* </p> * </p>
*
* <h4>Referencing columns safely</h4> * <h4>Referencing columns safely</h4>
*
* <p> * <p>
* If your source contains a header record, you can simplify your code and safely reference columns, * If your source contains a header record, you can simplify your code and safely reference columns,
* by using {@link #withHeader(String...)} with no arguments: * by using {@link #withHeader(String...)} with no arguments:
* </p> * </p>
* <pre>CSVFormat.EXCEL.withHeader();</pre> *
* <pre>
* CSVFormat.EXCEL.withHeader();
* </pre>
*
* <p> * <p>
* This causes the parser to read the first record and use its values as column names. * This causes the parser to read the first record and use its values as column names.
*
* Then, call one of the {@link CSVRecord} get method that takes a String column name argument: * Then, call one of the {@link CSVRecord} get method that takes a String column name argument:
* </p> * </p>
* <pre>String value = record.get(&quot;Col1&quot;);</pre> *
* <pre>
* String value = record.get(&quot;Col1&quot;);
* </pre>
*
* <p> * <p>
* This makes your code impervious to changes in column order in the CSV file. * This makes your code impervious to changes in column order in the CSV file.
* </p> * </p>
*
* <h4>Notes</h4> * <h4>Notes</h4>
*
* <p> * <p>
* This class is immutable. * This class is immutable.
* </p> * </p>
*
* @version $Id$ * @version $Id$
*/ */
public class CSVFormat implements Serializable { public class CSVFormat implements Serializable {