mirror of
https://github.com/apache/commons-csv.git
synced 2025-02-17 07:26:32 +00:00
Use final.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1602944 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2076464484
commit
c1049b549b
@ -317,8 +317,8 @@ public final class CSVFormat implements Serializable {
|
|||||||
if (header == null) {
|
if (header == null) {
|
||||||
this.header = null;
|
this.header = null;
|
||||||
} else {
|
} else {
|
||||||
Set<String> dupCheck = new HashSet<String>();
|
final Set<String> dupCheck = new HashSet<String>();
|
||||||
for (String hdr : header) {
|
for (final String hdr : header) {
|
||||||
if (!dupCheck.add(hdr)) {
|
if (!dupCheck.add(hdr)) {
|
||||||
throw new IllegalArgumentException("The header contains a duplicate entry: '" + hdr + "' in " +
|
throw new IllegalArgumentException("The header contains a duplicate entry: '" + hdr + "' in " +
|
||||||
Arrays.toString(header));
|
Arrays.toString(header));
|
||||||
|
@ -153,7 +153,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* If an I/O error occurs
|
* If an I/O error occurs
|
||||||
*/
|
*/
|
||||||
public static CSVParser parse(final File file, Charset charset, final CSVFormat format) throws IOException {
|
public static CSVParser parse(final File file, final Charset charset, final CSVFormat format) throws IOException {
|
||||||
Assertions.notNull(file, "file");
|
Assertions.notNull(file, "file");
|
||||||
Assertions.notNull(format, "format");
|
Assertions.notNull(format, "format");
|
||||||
// Use the default Charset explicitly
|
// Use the default Charset explicitly
|
||||||
@ -343,7 +343,7 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* on parse error or input read-failure
|
* on parse error or input read-failure
|
||||||
*/
|
*/
|
||||||
public <T extends Collection<CSVRecord>> T getRecords(T records) throws IOException {
|
public <T extends Collection<CSVRecord>> T getRecords(final T records) throws IOException {
|
||||||
CSVRecord rec;
|
CSVRecord rec;
|
||||||
while ((rec = this.nextRecord()) != null) {
|
while ((rec = this.nextRecord()) != null) {
|
||||||
records.add(rec);
|
records.add(rec);
|
||||||
|
@ -191,10 +191,10 @@ public class CSVParserTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore("CSV-107")
|
@Ignore("CSV-107")
|
||||||
public void testBOM() throws IOException {
|
public void testBOM() throws IOException {
|
||||||
URL url = ClassLoader.getSystemClassLoader().getResource("CSVFileParser/bom.csv");
|
final URL url = ClassLoader.getSystemClassLoader().getResource("CSVFileParser/bom.csv");
|
||||||
final CSVParser parser = CSVParser.parse(url, null, CSVFormat.EXCEL.withHeader());
|
final CSVParser parser = CSVParser.parse(url, null, CSVFormat.EXCEL.withHeader());
|
||||||
try {
|
try {
|
||||||
for (CSVRecord record : parser) {
|
for (final CSVRecord record : parser) {
|
||||||
final String string = record.get("Date");
|
final String string = record.get("Date");
|
||||||
Assert.assertNotNull(string);
|
Assert.assertNotNull(string);
|
||||||
//System.out.println("date: " + record.get("Date"));
|
//System.out.println("date: " + record.get("Date"));
|
||||||
@ -206,11 +206,11 @@ public class CSVParserTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBOMInputStream() throws IOException {
|
public void testBOMInputStream() throws IOException {
|
||||||
URL url = ClassLoader.getSystemClassLoader().getResource("CSVFileParser/bom.csv");
|
final URL url = ClassLoader.getSystemClassLoader().getResource("CSVFileParser/bom.csv");
|
||||||
Reader reader = new InputStreamReader(new BOMInputStream(url.openStream()), "UTF-8");
|
final Reader reader = new InputStreamReader(new BOMInputStream(url.openStream()), "UTF-8");
|
||||||
final CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader());
|
final CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader());
|
||||||
try {
|
try {
|
||||||
for (CSVRecord record : parser) {
|
for (final CSVRecord record : parser) {
|
||||||
final String string = record.get("Date");
|
final String string = record.get("Date");
|
||||||
Assert.assertNotNull(string);
|
Assert.assertNotNull(string);
|
||||||
//System.out.println("date: " + record.get("Date"));
|
//System.out.println("date: " + record.get("Date"));
|
||||||
@ -546,8 +546,8 @@ public class CSVParserTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetOneLineOneParser() throws IOException {
|
public void testGetOneLineOneParser() throws IOException {
|
||||||
PipedWriter writer = new PipedWriter();
|
final PipedWriter writer = new PipedWriter();
|
||||||
PipedReader reader = new PipedReader(writer);
|
final PipedReader reader = new PipedReader(writer);
|
||||||
final CSVFormat format = CSVFormat.DEFAULT;
|
final CSVFormat format = CSVFormat.DEFAULT;
|
||||||
final CSVParser parser = new CSVParser(reader, format);
|
final CSVParser parser = new CSVParser(reader, format);
|
||||||
try {
|
try {
|
||||||
|
@ -172,7 +172,7 @@ public class CSVRecordTest {
|
|||||||
public void testToMapWithNoHeader() throws Exception {
|
public void testToMapWithNoHeader() throws Exception {
|
||||||
final CSVParser parser = CSVParser.parse("a,b", CSVFormat.newFormat(','));
|
final CSVParser parser = CSVParser.parse("a,b", CSVFormat.newFormat(','));
|
||||||
final CSVRecord shortRec = parser.iterator().next();
|
final CSVRecord shortRec = parser.iterator().next();
|
||||||
Map<String, String> map = shortRec.toMap();
|
final Map<String, String> map = shortRec.toMap();
|
||||||
assertNotNull("Map is not null.", map);
|
assertNotNull("Map is not null.", map);
|
||||||
assertTrue("Map is empty.", map.isEmpty());
|
assertTrue("Map is empty.", map.isEmpty());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user