aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-09-14 09:54:24 +0000
committerPJ Fanning <fanningpj@apache.org>2022-09-14 09:54:24 +0000
commit6e7f6dad21f8b618abb7c3af331c83629a785150 (patch)
tree1f77419bba8910953ac1a14ed81e0f482234f955 /poi-ooxml
parent1e50886b5424de56d6fae60f3b64ccba4003eeaf (diff)
downloadpoi-6e7f6dad21f8b618abb7c3af331c83629a785150.tar.gz
poi-6e7f6dad21f8b618abb7c3af331c83629a785150.zip
try to use IllegalStateException instead of RuntimeException
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1904065 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java6
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java6
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFSheet.java2
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java1
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java3
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java4
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java2
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java2
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java2
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java12
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java4
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/xssf/XSSFTestDataSamples.java4
12 files changed, 25 insertions, 23 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
index 3a6b4c6007..9c9fd0ad1d 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
@@ -110,7 +110,7 @@ public class XMLSlideShow extends POIXMLDocument
/**
* @param pkg OPC package
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
public XMLSlideShow(OPCPackage pkg) {
@@ -132,7 +132,7 @@ public class XMLSlideShow extends POIXMLDocument
* @param is InputStream
* @throws IOException If reading data from the stream fails
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
public XMLSlideShow(InputStream is) throws IOException {
@@ -472,7 +472,7 @@ public class XMLSlideShow extends POIXMLDocument
* @param index The slide number to remove.
* @return The slide that was removed.
*
- * @throws RuntimeException a number of runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
public XSLFSlide removeSlide(int index) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java
index 326137b6a1..f489b8c32e 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSlideShow.java
@@ -236,7 +236,7 @@ public class XSLFSlideShow extends POIXMLDocument {
try {
commentRels = slidePart.getRelationshipsByType(XSLFRelation.COMMENTS.getRelation());
} catch(InvalidFormatException e) {
- throw new IllegalStateException(e);
+ throw new IOException(e);
}
if(commentRels.isEmpty()) {
@@ -244,7 +244,7 @@ public class XSLFSlideShow extends POIXMLDocument {
return null;
}
if(commentRels.size() > 1) {
- throw new IllegalStateException("Expecting 0 or 1 comments for a slide, but found " + commentRels.size());
+ throw new IOException("Expecting 0 or 1 comments for a slide, but found " + commentRels.size());
}
try {
@@ -256,7 +256,7 @@ public class XSLFSlideShow extends POIXMLDocument {
return commDoc.getCmLst();
}
} catch(InvalidFormatException e) {
- throw new IllegalStateException(e);
+ throw new IOException(e);
}
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFSheet.java
index 4baa90bc7d..077eaaef3f 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFSheet.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFSheet.java
@@ -44,7 +44,7 @@ public class DeferredSXSSFSheet extends SXSSFSheet {
/**
* Unsupported in DeferredSXSSFSheet
*
- * @throws RuntimeException this is unsupported
+ * @throws IllegalStateException this is unsupported
*/
@Override
public InputStream getWorksheetXMLInputStream() throws IOException {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java
index 581606f82d..2079746f94 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java
@@ -71,6 +71,7 @@ class OpcOutputStream extends DeflaterOutputStream {
}
/**
+ * @throws IllegalStateException if no entry found
* @see ZipOutputStream#closeEntry()
*/
public void closeEntry() throws IOException {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java
index dd96f37256..17d8e147b6 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java
@@ -139,6 +139,7 @@ public class SXSSFCell extends CellBase {
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
+ * @throws IllegalStateException if cell is not a formula cell
*/
@Override
public CellType getCachedFormulaResultType() {
@@ -253,7 +254,7 @@ public class SXSSFCell extends CellBase {
_value = new ErrorFormulaValue(formula, getErrorCellValue());
break;
default:
- throw new IllegalStateException("Cannot set a formula for a cell of type " + getCellType());
+ throw new FormulaParseException("Cannot set a formula for a cell of type " + getCellType());
}
}
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java
index fb9a8846a1..edf1977c2a 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java
@@ -146,7 +146,7 @@ public class SXSSFRow implements Row, Comparable<SXSSFRow>
}
/**
- * @throws RuntimeException if the bounds are exceeded.
+ * @throws IllegalStateException if the bounds are exceeded.
*/
private static void checkBounds(int cellIndex) {
SpreadsheetVersion v = SpreadsheetVersion.EXCEL2007;
@@ -219,7 +219,7 @@ public class SXSSFRow implements Row, Comparable<SXSSFRow>
* @param cellnum 0 based column number
* @return Cell representing that column or null if undefined.
* @see #getCell(int, org.apache.poi.ss.usermodel.Row.MissingCellPolicy)
- * @throws RuntimeException if cellnum is out of bounds
+ * @throws IllegalStateException if cellnum is out of bounds
*/
@Override
public SXSSFCell getCell(int cellnum) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
index 748117d8e1..5eb5a4be49 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
@@ -1353,7 +1353,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
*
* @param row start row of a groupped range of rows (0-based)
* @param collapse whether to expand/collapse the detail rows
- * @throws RuntimeException if collapse is false as this is not implemented for SXSSF.
+ * @throws IllegalStateException if collapse is false as this is not implemented for SXSSF.
*/
@Override
public void setRowGroupCollapsed(int row, boolean collapse) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
index e8b881f3a4..38feae68e9 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
@@ -1315,7 +1315,7 @@ public class SXSSFWorkbook implements Workbook {
* @param name The name the workbook will be referenced as in formulas
* @param workbook The open workbook to fetch the link required information from
*
- * @throws RuntimeException stating that this method is not implemented yet.
+ * @throws IllegalStateException stating that this method is not implemented yet.
*/
@Override
@NotImplemented
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
index 0a85c786c7..bbdb2c35e5 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
@@ -988,7 +988,7 @@ public final class XSSFCell extends CellBase {
}
/**
- * @throws RuntimeException if the bounds are exceeded.
+ * @throws IllegalStateException if the bounds are exceeded.
*/
private static void checkBounds(int cellIndex) {
SpreadsheetVersion v = SpreadsheetVersion.EXCEL2007;
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
index c649cd74d1..a31f669b26 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
@@ -247,7 +247,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
* @param pkg the OpenXML4J {@code OPC Package} object.
* @throws IOException If reading data from the package fails
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
public XSSFWorkbook(OPCPackage pkg) throws IOException {
@@ -279,7 +279,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
*
* @throws IOException If reading data from the stream fails
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
public XSSFWorkbook(InputStream is) throws IOException {
@@ -304,7 +304,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
* @throws IOException If reading data from the file fails
* @throws InvalidFormatException If the file has a format that cannot be read or if the file is corrupted
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
public XSSFWorkbook(File file) throws IOException, InvalidFormatException {
@@ -325,7 +325,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
* @param path the file name.
* @throws IOException If reading data from the file fails
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*
*/
@@ -338,7 +338,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
* @param part package part
* @throws IOException If reading data from the Package Part fails
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
* @since POI 4.0.0
*/
@@ -455,7 +455,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
* the DOM based parse of large sheets (see examples).
*
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
public void parseSheet(Map<String, XSSFSheet> shIdMap, CTSheet ctSheet) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
index 29be42e926..0f7f08f619 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
@@ -136,7 +136,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
* @param pkg OPC package
* @throws IOException If reading data from the package fails
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
public XWPFDocument(OPCPackage pkg) throws IOException {
@@ -150,7 +150,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
* @param is The InputStream to read data from
* @throws IOException If reading data from the stream fails
* @throws POIXMLException a RuntimeException that can be caused by invalid OOXML data
- * @throws RuntimeException a number of other runtime exceptions can be thrown, especially if there are problems with the
+ * @throws IllegalStateException a number of other runtime exceptions can be thrown, especially if there are problems with the
* input format
*/
public XWPFDocument(InputStream is) throws IOException {
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/XSSFTestDataSamples.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/XSSFTestDataSamples.java
index 3a0ed9d4c3..30cb09a09a 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xssf/XSSFTestDataSamples.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/XSSFTestDataSamples.java
@@ -139,7 +139,7 @@ public class XSSFTestDataSamples {
* @param wb The workbook to write out, it is closed after the call.
* @param testName file name to be used to write to a file. This file will be cleaned up by a call to readBack(String)
* @return workbook location
- * @throws RuntimeException if {@link #TEST_OUTPUT_DIR} System property is not set
+ * @throws IllegalStateException if {@link #TEST_OUTPUT_DIR} System property is not set
*/
public static <R extends Workbook> File writeOutAndClose(R wb, String testName) {
try {
@@ -160,7 +160,7 @@ public class XSSFTestDataSamples {
*
* @param wb the workbook to write
* @return the memory buffer
- * @throws RuntimeException If writing the file fails
+ * @throws IllegalStateException If writing the file fails
*/
public static <R extends Workbook> UnsynchronizedByteArrayOutputStream writeOutAndClose(R wb) throws IOException {
UnsynchronizedByteArrayOutputStream out = writeOut(wb);