From b945428eafbeccd7195a44ebb501ea8e335ab71c Mon Sep 17 00:00:00 2001 From: Marten Deinum Date: Tue, 3 Feb 2015 21:40:54 +0100 Subject: [PATCH] Javadoc Fixed javadoc errors and warnings --- spring-batch-excel/pom.xml | 28 +++++++++++- .../item/excel/AbstractExcelItemReader.java | 44 ++++++++++++++++--- .../batch/item/excel/RowMapper.java | 4 +- .../excel/mapping/BeanPropertyRowMapper.java | 26 ++++++++--- .../batch/item/excel/poi/PoiItemReader.java | 2 +- .../support/rowset/ColumnNameExtractor.java | 4 +- .../batch/item/excel/MockExcelItemReader.java | 5 +++ 7 files changed, 95 insertions(+), 18 deletions(-) diff --git a/spring-batch-excel/pom.xml b/spring-batch-excel/pom.xml index 4840fd6..ac8f2ab 100644 --- a/spring-batch-excel/pom.xml +++ b/spring-batch-excel/pom.xml @@ -87,12 +87,38 @@ org.apache.maven.plugins maven-compiler-plugin - 2.5.1 + 3.2 1.6 1.6 + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.1 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.4 + + + attach-sources + + jar + + + + diff --git a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/AbstractExcelItemReader.java b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/AbstractExcelItemReader.java index 651ea55..91630a9 100644 --- a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/AbstractExcelItemReader.java +++ b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/AbstractExcelItemReader.java @@ -27,9 +27,6 @@ import org.springframework.core.io.Resource; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; -import java.io.IOException; -import java.io.InputStream; - /** * {@link org.springframework.batch.item.ItemReader} implementation to read an Excel * file. It will read the file sheet for sheet and row for row. It is loosy based on @@ -45,7 +42,6 @@ public abstract class AbstractExcelItemReader extends AbstractItemCountingIte protected final Log logger = LogFactory.getLog(getClass()); private Resource resource; private int linesToSkip = 0; - private int currentRow = 0; private int currentSheet = 0; private RowMapper rowMapper; private RowCallbackHandler skippedRowsCallback; @@ -59,6 +55,10 @@ public abstract class AbstractExcelItemReader extends AbstractItemCountingIte this.setName(ClassUtils.getShortName(this.getClass())); } + /** + * @return string corresponding to logical record according to + * {@link #setRowMapper(RowMapper)} (might span multiple rows in file). + */ @Override protected T doRead() throws Exception { if (this.noInput || this.rs == null) { @@ -136,6 +136,11 @@ public abstract class AbstractExcelItemReader extends AbstractItemCountingIte } + /** + * Public setter for the input resource. + * + * @param resource the {@code Resource} pointing to the Excelfile + */ public void setResource(final Resource resource) { this.resource = resource; } @@ -148,16 +153,31 @@ public abstract class AbstractExcelItemReader extends AbstractItemCountingIte * Set the number of lines to skip. This number is applied to all worksheet * in the excel file! default to 0 * - * @param linesToSkip + * @param linesToSkip number of lines to skip */ public void setLinesToSkip(final int linesToSkip) { this.linesToSkip = linesToSkip; } + /** + * + * @param sheet the sheet index + * @return the sheet or null when no sheet available. + */ protected abstract Sheet getSheet(int sheet); + /** + * The number of sheets in the underlying workbook. + * + * @return the number of sheets. + */ protected abstract int getNumberOfSheets(); + /** + * + * @param resource {@code Resource} pointing to the Excel file to read + * @throws Exception when the Excel sheet cannot be accessed + */ protected abstract void openExcelFile(Resource resource) throws Exception; /** @@ -170,14 +190,28 @@ public abstract class AbstractExcelItemReader extends AbstractItemCountingIte this.strict = strict; } + /** + * Public setter for the {@code rowMapper}. Used to map a row read from the underlying Excel workbook. + * + * @param rowMapper the {@code RowMapper} to use. + */ public void setRowMapper(final RowMapper rowMapper) { this.rowMapper = rowMapper; } + /** + * Public setter for the rowSetFactory. Used to create a {@code RowSet} implemenation. By default the + * {@code DefaultRowSetFactory} is used. + * + * @param rowSetFactory the {@code RowSetFactory} to use. + */ public void setRowSetFactory(RowSetFactory rowSetFactory) { this.rowSetFactory = rowSetFactory; } + /** + * @param skippedRowsCallback will be called for each one of the initial skipped lines before any items are read. + */ public void setSkippedRowsCallback(final RowCallbackHandler skippedRowsCallback) { this.skippedRowsCallback = skippedRowsCallback; } diff --git a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/RowMapper.java b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/RowMapper.java index 6bda223..03971f8 100644 --- a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/RowMapper.java +++ b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/RowMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.batch.item.excel.support.rowset.RowSet; /** * Map rows from an excel sheet to an object. * - * @param + * @param the type * @author Marten Deinum * @since 0.5.0 */ diff --git a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/mapping/BeanPropertyRowMapper.java b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/mapping/BeanPropertyRowMapper.java index 3705077..497f559 100644 --- a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/mapping/BeanPropertyRowMapper.java +++ b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/mapping/BeanPropertyRowMapper.java @@ -58,6 +58,7 @@ import java.util.Set; * For best performance, consider using a custom {@link RowMapper} implementation. * * @author Marten Deinum + * @param The type * @since 0.5.0 */ public class BeanPropertyRowMapper implements RowMapper, BeanFactoryAware, InitializingBean { @@ -115,7 +116,7 @@ public class BeanPropertyRowMapper implements RowMapper, BeanFactoryAware, * that will be passed into {@link #mapRow(RowSet)}. Typically a * prototype scoped bean so that a new instance is returned for each field * set mapped. - *

+ * * Either this property or the type property must be specified, but not * both. * @@ -129,7 +130,7 @@ public class BeanPropertyRowMapper implements RowMapper, BeanFactoryAware, * Public setter for the type of bean to create instead of using a prototype * bean. An object of this type will be created from its default constructor * for every call to {@link #mapRow(RowSet)}.
- *

+ * * Either this property or the prototype bean name must be specified, but * not both. * @@ -187,9 +188,10 @@ public class BeanPropertyRowMapper implements RowMapper, BeanFactoryAware, /** * Set whether we're strictly validating that all bean properties have been - * mapped from corresponding database fields. - *

Default is {@code false}, accepting unpopulated properties in the - * target bean. + * mapped from corresponding database fields. Default is {@code false}, + * accepting unpopulated properties in the target bean. + * + * @param checkFullyPopulated true or false */ public void setCheckFullyPopulated(boolean checkFullyPopulated) { this.checkFullyPopulated = checkFullyPopulated; @@ -198,6 +200,8 @@ public class BeanPropertyRowMapper implements RowMapper, BeanFactoryAware, /** * Return whether we're strictly validating that all bean properties have been * mapped from corresponding database fields. + * + * @return true when resulting bean should be checked */ public boolean isCheckFullyPopulated() { return this.checkFullyPopulated; @@ -206,7 +210,10 @@ public class BeanPropertyRowMapper implements RowMapper, BeanFactoryAware, /** * Set whether we're defaulting Java primitives in the case of mapping a null value * from corresponding database fields. - *

Default is {@code false}, throwing an exception when nulls are mapped to Java primitives. + * + * Default is {@code false}, throwing an exception when nulls are mapped to Java primitives. + * + * @param primitivesDefaultedForNullValue should default values be used when read value is {@code null} */ public void setPrimitivesDefaultedForNullValue(boolean primitivesDefaultedForNullValue) { this.primitivesDefaultedForNullValue = primitivesDefaultedForNullValue; @@ -215,6 +222,8 @@ public class BeanPropertyRowMapper implements RowMapper, BeanFactoryAware, /** * Return whether we're defaulting Java primitives in the case of mapping a null value * from corresponding database fields. + * + * @return {@code true} when default values be used when read value is {@code null} */ public boolean isPrimitivesDefaultedForNullValue() { return primitivesDefaultedForNullValue; @@ -222,7 +231,8 @@ public class BeanPropertyRowMapper implements RowMapper, BeanFactoryAware, /** * Extract the values for all columns in the current row. - *

Utilizes public setters and result set metadata. + * + * Utilizes public setters and result set metadata. * * @see java.sql.ResultSetMetaData */ @@ -314,6 +324,8 @@ public class BeanPropertyRowMapper implements RowMapper, BeanFactoryAware, * (with the mapped class specified only once). * * @param targetType the class that each row should be mapped to + * @param the targetType + * @return the newly created instance */ public static BeanPropertyRowMapper newInstance(Class targetType) { BeanPropertyRowMapper newInstance = new BeanPropertyRowMapper(); diff --git a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/poi/PoiItemReader.java b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/poi/PoiItemReader.java index 718c705..19a3b9b 100644 --- a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/poi/PoiItemReader.java +++ b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/poi/PoiItemReader.java @@ -72,7 +72,7 @@ public class PoiItemReader extends AbstractExcelItemReader { * it can be closed cleanly on the end of reading the file. This to be able to release the resources used by * Apache POI. * - * @param resource + * @param resource the {@code Resource} pointing to the Excel file. * @throws Exception is thrown for any errors. */ @Override diff --git a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/support/rowset/ColumnNameExtractor.java b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/support/rowset/ColumnNameExtractor.java index dd68547..fc9ee51 100644 --- a/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/support/rowset/ColumnNameExtractor.java +++ b/spring-batch-excel/src/main/java/org/springframework/batch/item/excel/support/rowset/ColumnNameExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package org.springframework.batch.item.excel.support.rowset; import org.springframework.batch.item.excel.Sheet; /** - * Contract for extracting column names for a given {@Sheet sheet}. + * Contract for extracting column names for a given {@code sheet}. * * @author Marten Deinum * @since 0.5.0 diff --git a/spring-batch-excel/src/test/java/org/springframework/batch/item/excel/MockExcelItemReader.java b/spring-batch-excel/src/test/java/org/springframework/batch/item/excel/MockExcelItemReader.java index 3ed2bbc..7a658f7 100644 --- a/spring-batch-excel/src/test/java/org/springframework/batch/item/excel/MockExcelItemReader.java +++ b/spring-batch-excel/src/test/java/org/springframework/batch/item/excel/MockExcelItemReader.java @@ -37,4 +37,9 @@ public class MockExcelItemReader extends AbstractExcelItemReader { protected void openExcelFile(Resource resource) throws Exception { } + + @Override + protected void doClose() throws Exception { + sheets.clear(); + } }