Sort 1 method into place.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1742957 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8b24cd1fb0
commit
b502c5a20d
|
@ -1096,6 +1096,41 @@ public final class CSVFormat implements Serializable {
|
||||||
return withHeader().withSkipHeaderRecord();
|
return withHeader().withSkipHeaderRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new {@code CSVFormat} with the header of the format defined by the enum class:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* public enum Header {
|
||||||
|
* Name, Email, Phone
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* CSVFormat format = aformat.withHeader(Header.class);
|
||||||
|
* </pre>
|
||||||
|
* <p>
|
||||||
|
* The header is also used by the {@link CSVPrinter}..
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param headerEnum
|
||||||
|
* the enum defining the header, {@code null} if disabled, empty if parsed automatically, user
|
||||||
|
* specified otherwise.
|
||||||
|
*
|
||||||
|
* @return A new CSVFormat that is equal to this but with the specified header
|
||||||
|
* @see #withHeader(String...)
|
||||||
|
* @see #withSkipHeaderRecord(boolean)
|
||||||
|
* @since 1.3
|
||||||
|
*/
|
||||||
|
public CSVFormat withHeader(final Class<? extends Enum<?>> headerEnum) {
|
||||||
|
String[] header = null;
|
||||||
|
if (headerEnum != null) {
|
||||||
|
Enum<?>[] enumValues = headerEnum.getEnumConstants();
|
||||||
|
header = new String[enumValues.length];
|
||||||
|
for (int i = 0; i < enumValues.length; i++) {
|
||||||
|
header[i] = enumValues[i].name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return withHeader(header);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new {@code CSVFormat} with the header of the format set from the result set metadata. The header can
|
* Returns a new {@code CSVFormat} with the header of the format set from the result set metadata. The header can
|
||||||
* either be parsed automatically from the input file with:
|
* either be parsed automatically from the input file with:
|
||||||
|
@ -1193,41 +1228,6 @@ public final class CSVFormat implements Serializable {
|
||||||
skipHeaderRecord, allowMissingColumnNames, ignoreHeaderCase, trim, trailingDelimiter);
|
skipHeaderRecord, allowMissingColumnNames, ignoreHeaderCase, trim, trailingDelimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a new {@code CSVFormat} with the header of the format defined by the enum class:
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* public enum Header {
|
|
||||||
* Name, Email, Phone
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* CSVFormat format = aformat.withHeader(Header.class);
|
|
||||||
* </pre>
|
|
||||||
* <p>
|
|
||||||
* The header is also used by the {@link CSVPrinter}..
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param headerEnum
|
|
||||||
* the enum defining the header, {@code null} if disabled, empty if parsed automatically, user
|
|
||||||
* specified otherwise.
|
|
||||||
*
|
|
||||||
* @return A new CSVFormat that is equal to this but with the specified header
|
|
||||||
* @see #withHeader(String...)
|
|
||||||
* @see #withSkipHeaderRecord(boolean)
|
|
||||||
* @since 1.3
|
|
||||||
*/
|
|
||||||
public CSVFormat withHeader(final Class<? extends Enum<?>> headerEnum) {
|
|
||||||
String[] header = null;
|
|
||||||
if (headerEnum != null) {
|
|
||||||
Enum<?>[] enumValues = headerEnum.getEnumConstants();
|
|
||||||
header = new String[enumValues.length];
|
|
||||||
for (int i = 0; i < enumValues.length; i++) {
|
|
||||||
header[i] = enumValues[i].name();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return withHeader(header);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new {@code CSVFormat} with the header comments of the format set to the given values. The comments will
|
* Returns a new {@code CSVFormat} with the header comments of the format set to the given values. The comments will
|
||||||
* be printed first, before the headers. This setting is ignored by the parser.
|
* be printed first, before the headers. This setting is ignored by the parser.
|
||||||
|
|
Loading…
Reference in New Issue