mirror of https://github.com/apache/poi.git
Apply some IDE suggestions and fix some JavaDoc
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
685af351d1
commit
8347bb64ac
|
@ -70,7 +70,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
||||||
protected EvaluationWorkbook getEvaluationWorkbook() {
|
protected EvaluationWorkbook getEvaluationWorkbook() {
|
||||||
return _bookEvaluator.getWorkbook();
|
return _bookEvaluator.getWorkbook();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be called whenever there are major changes (e.g. moving sheets) to input cells
|
* Should be called whenever there are major changes (e.g. moving sheets) to input cells
|
||||||
* in the evaluated workbook. If performance is not critical, a single call to this method
|
* in the evaluated workbook. If performance is not critical, a single call to this method
|
||||||
|
@ -117,7 +117,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
||||||
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
|
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If cell contains formula, it evaluates the formula, and
|
* If cell contains formula, it evaluates the formula, and
|
||||||
* puts the formula result back into the cell, in place
|
* puts the formula result back into the cell, in place
|
||||||
|
@ -188,9 +188,11 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the cell type
|
* Set the cell type based on the computed cell type as
|
||||||
* @param cell
|
* part of a formula evaluation.
|
||||||
* @param cv
|
*
|
||||||
|
* @param cell The Cell to populate
|
||||||
|
* @param cv The CellValue to read the result type from
|
||||||
*/
|
*/
|
||||||
protected void setCellType(Cell cell, CellValue cv) {
|
protected void setCellType(Cell cell, CellValue cv) {
|
||||||
CellType cellType = cv.getCellType();
|
CellType cellType = cv.getCellType();
|
||||||
|
@ -214,15 +216,17 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override if a different variation is needed, e.g. passing the evaluator to the cell method
|
* Override if a different variation is needed, e.g. passing the evaluator to the cell method
|
||||||
* @param cell
|
*
|
||||||
* @param cellType
|
* @param cell The Cell to populate
|
||||||
|
* @param cellType The wanted type for this Cell
|
||||||
*/
|
*/
|
||||||
protected void setCellType(Cell cell, CellType cellType) {
|
protected void setCellType(Cell cell, CellType cellType) {
|
||||||
|
//noinspection deprecation
|
||||||
cell.setCellType(cellType);
|
cell.setCellType(cellType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract RichTextString createRichTextString(String str);
|
protected abstract RichTextString createRichTextString(String str);
|
||||||
|
|
||||||
protected void setCellValue(Cell cell, CellValue cv) {
|
protected void setCellValue(Cell cell, CellValue cv) {
|
||||||
CellType cellType = cv.getCellType();
|
CellType cellType = cv.getCellType();
|
||||||
switch (cellType) {
|
switch (cellType) {
|
||||||
|
@ -246,7 +250,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
||||||
throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
|
throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loops over all cells in all sheets of the supplied
|
* Loops over all cells in all sheets of the supplied
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.util.Internal;
|
import org.apache.poi.util.Internal;
|
||||||
import org.apache.poi.util.Removal;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -60,15 +60,15 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close
|
||||||
super(pkg);
|
super(pkg);
|
||||||
init(pkg);
|
init(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected POIXMLDocument(OPCPackage pkg, String coreDocumentRel) {
|
protected POIXMLDocument(OPCPackage pkg, String coreDocumentRel) {
|
||||||
super(pkg, coreDocumentRel);
|
super(pkg, coreDocumentRel);
|
||||||
init(pkg);
|
init(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(OPCPackage p) {
|
private void init(OPCPackage p) {
|
||||||
this.pkg = p;
|
this.pkg = p;
|
||||||
|
|
||||||
// Workaround for XMLBEANS-512 - ensure that when we parse
|
// Workaround for XMLBEANS-512 - ensure that when we parse
|
||||||
// the file, we start with a fresh XML Parser each time,
|
// the file, we start with a fresh XML Parser each time,
|
||||||
// and avoid the risk of getting a SaxHandler that's in error
|
// and avoid the risk of getting a SaxHandler that's in error
|
||||||
|
@ -77,10 +77,10 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper to open a package, which works around shortcomings in java's this() constructor calls
|
* Wrapper to open a package, which works around shortcomings in java's this() constructor calls
|
||||||
*
|
*
|
||||||
* @param path the path to the document
|
* @param path the path to the document
|
||||||
* @return the new OPCPackage
|
* @return the new OPCPackage
|
||||||
*
|
*
|
||||||
* @exception IOException if there was a problem opening the document
|
* @exception IOException if there was a problem opening the document
|
||||||
*/
|
*/
|
||||||
public static OPCPackage openPackage(String path) throws IOException {
|
public static OPCPackage openPackage(String path) throws IOException {
|
||||||
|
@ -107,13 +107,13 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close
|
||||||
/**
|
/**
|
||||||
* Retrieves all the PackageParts which are defined as relationships of the base document with the
|
* Retrieves all the PackageParts which are defined as relationships of the base document with the
|
||||||
* specified content type.
|
* specified content type.
|
||||||
*
|
*
|
||||||
* @param contentType the content type
|
* @param contentType the content type
|
||||||
*
|
*
|
||||||
* @return all the base document PackageParts which match the content type
|
* @return all the base document PackageParts which match the content type
|
||||||
*
|
*
|
||||||
* @throws InvalidFormatException when the relationships or the parts contain errors
|
* @throws InvalidFormatException when the relationships or the parts contain errors
|
||||||
*
|
*
|
||||||
* @see org.apache.poi.xssf.usermodel.XSSFRelation
|
* @see org.apache.poi.xssf.usermodel.XSSFRelation
|
||||||
* @see org.apache.poi.xslf.usermodel.XSLFRelation
|
* @see org.apache.poi.xslf.usermodel.XSLFRelation
|
||||||
* @see org.apache.poi.xwpf.usermodel.XWPFRelation
|
* @see org.apache.poi.xwpf.usermodel.XWPFRelation
|
||||||
|
@ -135,7 +135,7 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close
|
||||||
/**
|
/**
|
||||||
* Get the document properties. This gives you access to the
|
* Get the document properties. This gives you access to the
|
||||||
* core ooxml properties, and the extended ooxml properties.
|
* core ooxml properties, and the extended ooxml properties.
|
||||||
*
|
*
|
||||||
* @return the document properties
|
* @return the document properties
|
||||||
*/
|
*/
|
||||||
public POIXMLProperties getProperties() {
|
public POIXMLProperties getProperties() {
|
||||||
|
@ -169,7 +169,7 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close
|
||||||
onDocumentRead();
|
onDocumentRead();
|
||||||
context.clear();
|
context.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the underlying {@link OPCPackage} from which this
|
* Closes the underlying {@link OPCPackage} from which this
|
||||||
* document was read, if there is one
|
* document was read, if there is one
|
||||||
|
@ -193,17 +193,17 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write out this document to an Outputstream.
|
* Write out this document to an {@link OutputStream}.
|
||||||
*
|
*
|
||||||
* Note - if the Document was opened from a {@link File} rather
|
* Note - if the Document was opened from a {@link File} rather
|
||||||
* than an {@link InputStream}, you <b>must</b> write out to
|
* than an {@link InputStream}, you <b>must</b> write out to
|
||||||
* a different file, overwriting via an OutputStream isn't possible.
|
* a different file, overwriting via an OutputStream isn't possible.
|
||||||
*
|
*
|
||||||
* If {@code stream} is a {@link java.io.FileOutputStream} on a networked drive
|
* If {@code stream} is a {@link java.io.FileOutputStream} on a networked drive
|
||||||
* or has a high cost/latency associated with each written byte,
|
* or has a high cost/latency associated with each written byte,
|
||||||
* consider wrapping the OutputStream in a {@link java.io.BufferedOutputStream}
|
* consider wrapping the OutputStream in a {@link java.io.BufferedOutputStream}
|
||||||
* to improve write performance.
|
* to improve write performance.
|
||||||
*
|
*
|
||||||
* @param stream - the java OutputStream you wish to write the file to
|
* @param stream - the java OutputStream you wish to write the file to
|
||||||
*
|
*
|
||||||
* @exception IOException if anything can't be written.
|
* @exception IOException if anything can't be written.
|
||||||
|
@ -214,7 +214,7 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close
|
||||||
if(p == null) {
|
if(p == null) {
|
||||||
throw new IOException("Cannot write data, document seems to have been closed already");
|
throw new IOException("Cannot write data, document seems to have been closed already");
|
||||||
}
|
}
|
||||||
|
|
||||||
//force all children to commit their changes into the underlying OOXML Package
|
//force all children to commit their changes into the underlying OOXML Package
|
||||||
// TODO Shouldn't they be committing to the new one instead?
|
// TODO Shouldn't they be committing to the new one instead?
|
||||||
Set<PackagePart> context = new HashSet<>();
|
Set<PackagePart> context = new HashSet<>();
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class POIXMLDocumentPart {
|
||||||
private String coreDocumentRel = PackageRelationshipTypes.CORE_DOCUMENT;
|
private String coreDocumentRel = PackageRelationshipTypes.CORE_DOCUMENT;
|
||||||
private PackagePart packagePart;
|
private PackagePart packagePart;
|
||||||
private POIXMLDocumentPart parent;
|
private POIXMLDocumentPart parent;
|
||||||
private Map<String, RelationPart> relations = new LinkedHashMap<>();
|
private final Map<String, RelationPart> relations = new LinkedHashMap<>();
|
||||||
private boolean isCommitted = false;
|
private boolean isCommitted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -361,7 +361,7 @@ public class POIXMLDocumentPart {
|
||||||
* <p>
|
* <p>
|
||||||
* If there are multiple relationships to the same part, this will only
|
* If there are multiple relationships to the same part, this will only
|
||||||
* remove the first relationship in the order of creation. The removal
|
* remove the first relationship in the order of creation. The removal
|
||||||
* via the part id ({@link #removeRelation(String)} is preferred.
|
* via the part id ({@link #removeRelation(POIXMLDocumentPart)} is preferred.
|
||||||
*
|
*
|
||||||
* @param partId the part id which relation is to be removed from this document
|
* @param partId the part id which relation is to be removed from this document
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
|
@ -380,7 +380,7 @@ public class POIXMLDocumentPart {
|
||||||
* @return true, if the relation was removed
|
* @return true, if the relation was removed
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
private final boolean removeRelation(String partId, boolean removeUnusedParts) {
|
private boolean removeRelation(String partId, boolean removeUnusedParts) {
|
||||||
RelationPart rp = relations.get(partId);
|
RelationPart rp = relations.get(partId);
|
||||||
if (rp == null) {
|
if (rp == null) {
|
||||||
// part is not related with this POIXMLDocumentPart
|
// part is not related with this POIXMLDocumentPart
|
||||||
|
|
|
@ -379,7 +379,7 @@ public final class ZipPackage extends OPCPackage {
|
||||||
* Delete a part from the package
|
* Delete a part from the package
|
||||||
*
|
*
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* Throws if the part URI is nulll or invalid.
|
* Throws if the part URI is null or invalid.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void removePartImpl(PackagePartName partName) {
|
protected void removePartImpl(PackagePartName partName) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.poi.ss.usermodel.Cell;
|
||||||
* calls to evaluate~ methods on this class.
|
* calls to evaluate~ methods on this class.
|
||||||
*/
|
*/
|
||||||
public final class XSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
|
public final class XSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
|
||||||
private XSSFWorkbook _book;
|
private final XSSFWorkbook _book;
|
||||||
|
|
||||||
public XSSFFormulaEvaluator(XSSFWorkbook workbook) {
|
public XSSFFormulaEvaluator(XSSFWorkbook workbook) {
|
||||||
this(workbook, null, null);
|
this(workbook, null, null);
|
||||||
|
@ -79,12 +79,12 @@ public final class XSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
|
||||||
public static void evaluateAllFormulaCells(XSSFWorkbook wb) {
|
public static void evaluateAllFormulaCells(XSSFWorkbook wb) {
|
||||||
BaseFormulaEvaluator.evaluateAllFormulaCells(wb);
|
BaseFormulaEvaluator.evaluateAllFormulaCells(wb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XSSFCell evaluateInCell(Cell cell) {
|
public XSSFCell evaluateInCell(Cell cell) {
|
||||||
return (XSSFCell) super.evaluateInCell(cell);
|
return (XSSFCell) super.evaluateInCell(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loops over all cells in all sheets of the supplied
|
* Loops over all cells in all sheets of the supplied
|
||||||
* workbook.
|
* workbook.
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
||||||
* The locator of user-defined functions.
|
* The locator of user-defined functions.
|
||||||
* By default includes functions from the Excel Analysis Toolpack
|
* By default includes functions from the Excel Analysis Toolpack
|
||||||
*/
|
*/
|
||||||
private IndexedUDFFinder _udfFinder = new IndexedUDFFinder(AggregatingUDFFinder.DEFAULT);
|
private final IndexedUDFFinder _udfFinder = new IndexedUDFFinder(AggregatingUDFFinder.DEFAULT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
|
@ -214,7 +214,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
||||||
*/
|
*/
|
||||||
private List<XSSFPictureData> pictures;
|
private List<XSSFPictureData> pictures;
|
||||||
|
|
||||||
private static POILogger logger = POILogFactory.getLogger(XSSFWorkbook.class);
|
private static final POILogger logger = POILogFactory.getLogger(XSSFWorkbook.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cached instance of XSSFCreationHelper for this workbook
|
* cached instance of XSSFCreationHelper for this workbook
|
||||||
|
@ -404,7 +404,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
||||||
// Load individual sheets. The order of sheets is defined by the order
|
// Load individual sheets. The order of sheets is defined by the order
|
||||||
// of CTSheet elements in the workbook
|
// of CTSheet elements in the workbook
|
||||||
sheets = new ArrayList<>(shIdMap.size());
|
sheets = new ArrayList<>(shIdMap.size());
|
||||||
//noinspection deprecation
|
|
||||||
for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) {
|
for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) {
|
||||||
parseSheet(shIdMap, ctSheet);
|
parseSheet(shIdMap, ctSheet);
|
||||||
}
|
}
|
||||||
|
@ -1604,7 +1603,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
||||||
newcts.set(cts);
|
newcts.set(cts);
|
||||||
|
|
||||||
//notify sheets
|
//notify sheets
|
||||||
//noinspection deprecation
|
|
||||||
CTSheet[] sheetArray = ct.getSheetArray();
|
CTSheet[] sheetArray = ct.getSheetArray();
|
||||||
for(int i=0; i < sheetArray.length; i++) {
|
for(int i=0; i < sheetArray.length; i++) {
|
||||||
sheets.get(i).sheet = sheetArray[i];
|
sheets.get(i).sheet = sheetArray[i];
|
||||||
|
@ -1773,7 +1771,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
||||||
* @return true if the sheet contains the name, false otherwise.
|
* @return true if the sheet contains the name, false otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean containsSheet(String name, int excludeSheetIdx) {
|
private boolean containsSheet(String name, int excludeSheetIdx) {
|
||||||
//noinspection deprecation
|
|
||||||
CTSheet[] ctSheetArray = workbook.getSheets().getSheetArray();
|
CTSheet[] ctSheetArray = workbook.getSheets().getSheetArray();
|
||||||
|
|
||||||
if (name.length() > MAX_SENSITIVE_SHEET_NAME_LEN) {
|
if (name.length() > MAX_SENSITIVE_SHEET_NAME_LEN) {
|
||||||
|
|
Loading…
Reference in New Issue