]> source.dussan.org Git - poi.git/commitdiff
try to use IllegalStateException instead of RuntimeException
authorPJ Fanning <fanningpj@apache.org>
Wed, 14 Sep 2022 01:32:10 +0000 (01:32 +0000)
committerPJ Fanning <fanningpj@apache.org>
Wed, 14 Sep 2022 01:32:10 +0000 (01:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1904051 13f79535-47bb-0310-9956-ffa450edef68

37 files changed:
poi-ooxml/src/main/java/org/apache/poi/ooxml/extractor/POIXMLPropertiesTextExtractor.java
poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java
poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/KeyInfoSignatureFacet.java
poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESSignatureFacet.java
poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/facets/XAdESXLSignatureFacet.java
poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFFontInfo.java
poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTexturePaint.java
poi-ooxml/src/main/java/org/apache/poi/xslf/util/DummyFormat.java
poi-ooxml/src/main/java/org/apache/poi/xslf/util/PPTHandler.java
poi-ooxml/src/main/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFSheet.java
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/DeferredSXSSFWorkbook.java
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/StreamingSheetWriter.java
poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java
poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java
poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java
poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusGDIImageRenderer.java
poi-scratchpad/src/main/java/org/apache/poi/hemf/record/emfplus/HemfPlusObject.java
poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfEmbeddedIterator.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFObjectShape.java
poi-scratchpad/src/main/java/org/apache/poi/hsmf/MAPIMessage.java
poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfMisc.java
poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfTernaryRasterOp.java
poi-scratchpad/src/main/java/org/apache/poi/hwmf/usermodel/HwmfPicture.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/dev/HWPFLister.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/extractor/WordExtractor.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java

index c5a36d74b5e1609bc8ff77bb8133e98329b99594..3709fddf4e866285af07aaee1d64cf67a5532f5c 100644 (file)
@@ -273,7 +273,7 @@ public class POIXMLPropertiesTextExtractor implements POIXMLTextExtractor {
                             getExtendedPropertiesText() +
                             getCustomPropertiesText();
         } catch (Exception e) {
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
index 4625a940ed09e4251d0898bef5de4b03c30c2138..d1d8b344f7b2a339e0e351e10775b37200f45a95 100644 (file)
@@ -1413,7 +1413,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
         try {
             partMarshallers.remove(new ContentType(contentType));
         } catch (InvalidFormatException e) {
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
@@ -1427,7 +1427,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
         try {
             partUnmarshallers.remove(new ContentType(contentType));
         } catch (InvalidFormatException e) {
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
index 942c22ca22ce89ea2f14c9fd9844624b094bcdd2..3c300d7e8d496d3869c774c73c00b5b84068426a 100644 (file)
@@ -493,7 +493,7 @@ public class SignatureInfo {
          */
         String signatureId = signatureConfig.getPackageSignatureId();
         if (!signatureId.equals(document.getDocumentElement().getAttribute("Id"))) {
-            throw new RuntimeException("ds:Signature not found for @Id: " + signatureId);
+            throw new IllegalStateException("ds:Signature not found for @Id: " + signatureId);
         }
 
         /*
@@ -501,7 +501,7 @@ public class SignatureInfo {
          */
         final Element signatureNode = getDsigElement(document, "SignatureValue");
         if (signatureNode == null) {
-            throw new RuntimeException("preSign has to be called before postSign");
+            throw new IllegalStateException("preSign has to be called before postSign");
         }
         signatureNode.setTextContent(signatureValue);
 
@@ -675,7 +675,7 @@ public class SignatureInfo {
                 RelationshipTransformService.registerDsigProvider();
                 CryptoFunctions.registerBouncyCastle();
             } catch (Exception e) {
-                throw new RuntimeException("Xml & BouncyCastle-Provider initialization failed", e);
+                throw new IllegalStateException("Xml & BouncyCastle-Provider initialization failed", e);
             }
         }
 
@@ -710,7 +710,7 @@ public class SignatureInfo {
         }
 
         private RuntimeException providerNotFound() {
-            return new RuntimeException("JRE doesn't support default xml signature provider - set jsr105Provider system property!");
+            return new IllegalStateException("JRE doesn't support default xml signature provider - set jsr105Provider system property!");
         }
     }
 
index 84cccecb77992c703fd533c28304e8ae75fdc0ca..43be4656c35da6107d8faaa20625ab8b32019b22 100644 (file)
@@ -84,7 +84,7 @@ public class KeyInfoSignatureFacet implements SignatureFacet {
             try {
                 keyValue = keyInfoFactory.newKeyValue(signingCertificate.getPublicKey());
             } catch (KeyException e) {
-                throw new RuntimeException("key exception: " + e.getMessage(), e);
+                throw new IllegalStateException("key exception: " + e.getMessage(), e);
             }
             keyInfoContent.add(keyValue);
         }
@@ -137,7 +137,7 @@ public class KeyInfoSignatureFacet implements SignatureFacet {
         if (nextSibling != null) {
             NodeList kiNl = document.getElementsByTagNameNS(XML_DIGSIG_NS, "KeyInfo");
             if (kiNl.getLength() != 1) {
-                throw new RuntimeException("KeyInfo wasn't set");
+                throw new IllegalStateException("KeyInfo wasn't set");
             }
             nextSibling.getParentNode().insertBefore(kiNl.item(0), nextSibling);
         }
index b87bd950556c79fd5fed2b02107d84ecad154aac..f69bb33e1ec5ef7d5e25094d62ff30e87ddb3f68 100644 (file)
@@ -169,7 +169,7 @@ public class XAdESSignatureFacet implements SignatureFacet {
         SignatureConfig signatureConfig = signatureInfo.getSignatureConfig();
         List<X509Certificate> chain = signatureConfig.getSigningCertificateChain();
         if (chain == null || chain.isEmpty()) {
-            throw new RuntimeException("no signing certificate chain available");
+            throw new IllegalStateException("no signing certificate chain available");
         }
         CertIDListType signingCertificates = signedSignatureProperties.addNewSigningCertificate();
         CertIDType certId = signingCertificates.addNewCert();
@@ -332,7 +332,7 @@ public class XAdESSignatureFacet implements SignatureFacet {
         try {
             encodedCertificate = certificate.getEncoded();
         } catch (CertificateEncodingException e) {
-            throw new RuntimeException("certificate encoding error: "
+            throw new IllegalStateException("certificate encoding error: "
                     + e.getMessage(), e);
         }
         DigestAlgAndValueType certDigest = certId.addNewCertDigest();
index a83d2912297a442055a976f17a633d9bc7163fd6..a9d0a4171e091b756c5b6775605b230c7027fde7 100644 (file)
@@ -94,7 +94,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
         try {
             this.certificateFactory = CertificateFactory.getInstance("X.509");
         } catch (CertificateException e) {
-            throw new RuntimeException("X509 JCA error: " + e.getMessage(), e);
+            throw new IllegalStateException("X509 JCA error: " + e.getMessage(), e);
         }
     }
 
@@ -225,7 +225,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
                     crl = (X509CRL) this.certificateFactory
                         .generateCRL(new UnsynchronizedByteArrayInputStream(encodedCrl));
                 } catch (CRLException e) {
-                    throw new RuntimeException("CRL parse error: " + e.getMessage(), e);
+                    throw new IllegalStateException("CRL parse error: " + e.getMessage(), e);
                 }
 
                 CRLIdentifierType crlIdentifier = crlRef.addNewCRLIdentifier();
@@ -277,7 +277,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
                         responderId.setByName(nameStr);
                     }
                 } catch (Exception e) {
-                    throw new RuntimeException("OCSP decoding error: " + e.getMessage(), e);
+                    throw new IllegalStateException("OCSP decoding error: " + e.getMessage(), e);
                 }
             }
         }
@@ -294,7 +294,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
                 certificateValues.addNewEncapsulatedX509Certificate().setByteArrayValue(certificate.getEncoded());
             }
         } catch (CertificateEncodingException e) {
-            throw new RuntimeException("certificate encoding error: " + e.getMessage(), e);
+            throw new IllegalStateException("certificate encoding error: " + e.getMessage(), e);
         }
     }
 
@@ -312,7 +312,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {
-            throw new RuntimeException("c14n error: " + e.getMessage(), e);
+            throw new IllegalStateException("c14n error: " + e.getMessage(), e);
         }
     }
 
@@ -330,7 +330,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
                 return integer.getPositiveValue();
             }
         } catch (IOException e) {
-            throw new RuntimeException("I/O error: " + e.getMessage(), e);
+            throw new IllegalStateException("I/O error: " + e.getMessage(), e);
         }
     }
 
@@ -346,7 +346,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
         try {
             timeStampToken = signatureConfig.getTspService().timeStamp(signatureInfo, c14nSignatureValueElement, revocationData);
         } catch (Exception e) {
-            throw new RuntimeException("error while creating a time-stamp: "
+            throw new IllegalStateException("error while creating a time-stamp: "
                 + e.getMessage(), e);
         }
 
index 0f5531245804bdc101078579c99cb2b1c261823b..2e845e20d70bc553d8543609f978c1d2b24330f9 100644 (file)
@@ -133,7 +133,7 @@ public class TSPTimeStampService implements TimeStampService {
         byte[] responseBytes = response.getResponseBytes();
 
         if (responseBytes.length == 0) {
-            throw new RuntimeException("Content-Length is zero");
+            throw new IllegalStateException("Content-Length is zero");
         }
 
         // TSP response parsing and validation
@@ -150,7 +150,7 @@ public class TSPTimeStampService implements TimeStampService {
                     LOG.atDebug().log("unaccepted policy");
                 }
             }
-            throw new RuntimeException("timestamp response status != 0: "
+            throw new IllegalStateException("timestamp response status != 0: "
                     + timeStampResponse.getStatus());
         }
         TimeStampToken timeStampToken = timeStampResponse.getTimeStampToken();
@@ -171,7 +171,7 @@ public class TSPTimeStampService implements TimeStampService {
             .filter(h -> signerCertIssuer.equals(h.getIssuer())
                 && signerCertSerialNumber.equals(h.getSerialNumber()))
             .findFirst()
-            .orElseThrow(() -> new RuntimeException("TSP response token has no signer certificate"));
+            .orElseThrow(() -> new IllegalStateException("TSP response token has no signer certificate"));
 
         JcaX509CertificateConverter x509converter = new JcaX509CertificateConverter();
         x509converter.setProvider("BC");
index 3392f3a02becc004e7b6f26dc2e64668ec9c3216..3a6b4c6007b0ce12a1a861ef38715b8fe25946f2 100644 (file)
@@ -279,7 +279,7 @@ public class XMLSlideShow extends POIXMLDocument
         try {
             return getPackage().getUnusedPartIndex(relationType.getDefaultFileName());
         } catch (InvalidFormatException e) {
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
@@ -695,14 +695,14 @@ public class XMLSlideShow extends POIXMLDocument
     String importBlip(String blipId, POIXMLDocumentPart parent, POIXMLDocumentPart target) {
         OPCPackage targetPackage = target.getPackagePart().getPackage();
         if (targetPackage != getPackage()) {
-            throw new RuntimeException("the target document part is not a child of this package");
+            throw new IllegalStateException("the target document part is not a child of this package");
         }
         final POIXMLDocumentPart docPart = parent.getRelationPartById(blipId).getDocumentPart();
         XSLFPictureData parData;
         if (docPart instanceof XSLFPictureData) {
             parData = (XSLFPictureData)docPart;
         } else {
-            throw new RuntimeException("cannot import blip " + blipId + " - its document part is not XSLFPictureData");
+            throw new IllegalStateException("cannot import blip " + blipId + " - its document part is not XSLFPictureData");
         }
         final XSLFPictureData pictureData;
         if (targetPackage == parent.getPackagePart().getPackage()) {
index 1e7462113ebbb554dc60591c69462dbca0d43cd2..70ce9e522e04863ec13da8b1f038bcca2cb50e3d 100644 (file)
@@ -212,7 +212,7 @@ public class XSLFFontInfo implements FontInfo {
                 try {
                     fntDataIdx = ppt.getPackage().getUnusedPartIndex(fntRel.getDefaultFileName());
                 } catch (InvalidFormatException e) {
-                    throw new RuntimeException(e);
+                    throw new IllegalStateException(e);
                 }
 
                 POIXMLDocumentPart.RelationPart rp = ppt.createRelationship(fntRel, XSLFFactory.getInstance(), fntDataIdx, false);
@@ -235,7 +235,7 @@ public class XSLFFontInfo implements FontInfo {
                     header.init(buf, 0, buf.length);
                 } catch (IOException e) {
                     // TODO: better exception class
-                    throw new RuntimeException(e);
+                    throw new IllegalStateException(e);
                 }
             }
         }
index c0b1f1488d7cbfdc8c61ab1fdf182f28b9f0b174..bb9c04e862b1686ff939375f5eb4333abad679d1 100644 (file)
@@ -84,7 +84,7 @@ public class XSLFTexturePaint implements PaintStyle.TexturePaint {
         try {
             return getPart().getInputStream();
         } catch (Exception e) {
-            throw new RuntimeException("Failed to read image data", e);
+            throw new IllegalStateException("Failed to read image data", e);
         }
     }
 
@@ -97,7 +97,7 @@ public class XSLFTexturePaint implements PaintStyle.TexturePaint {
         try {
             return getPart().getContentType();
         } catch (InvalidFormatException e) {
-            throw new RuntimeException("Failed to read package part", e);
+            throw new IllegalStateException("Failed to read package part", e);
         }
     }
 
index c1cf538c8fa5e7d6fbd1e84d1d00148d32c4ae21..b090c34cc347bf41e7244c3e9f06e7b6f81dd6ab 100644 (file)
@@ -37,7 +37,7 @@ public class DummyFormat implements OutputFormat {
             bos = new UnsynchronizedByteArrayOutputStream();
             dummy2d = new DummyGraphics2d(new PrintStream(bos, true, StandardCharsets.UTF_8.name()));
         } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
index 5a70ea976786f91756ee40d8b25446133423c251..48de2bd69d29d35efa02a387836642f417a18f99 100644 (file)
@@ -179,7 +179,7 @@ class PPTHandler extends MFProxy {
                 return IOUtils.toByteArray(is);
             } catch (IOException e) {
                 // TODO: change to custom runtime exception
-                throw new RuntimeException(e);
+                throw new IllegalStateException(e);
             }
         });
         return embed;
index 2fc9cfe01b0d951f3fc13e95a29d71e3870cf9ab..fd008f3a3d077bf1f3e09cf9b7ba90b18584da68 100644 (file)
@@ -245,7 +245,7 @@ public class XSSFEventBasedExcelExtractor
             sheetParser.setContentHandler(handler);
             sheetParser.parse(sheetSource);
         } catch (ParserConfigurationException e) {
-            throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage());
+            throw new IllegalStateException("SAX parser appears to be broken - " + e.getMessage());
         }
     }
 
index 42e7d2aca26456d0e22b6d22215e3373ec37ca60..4baa90bc7de96e841e2cc7418cc105e98907bc37 100644 (file)
@@ -48,7 +48,7 @@ public class DeferredSXSSFSheet extends SXSSFSheet {
      */
     @Override
     public InputStream getWorksheetXMLInputStream() throws IOException {
-        throw new RuntimeException("Not supported by DeferredSXSSFSheet");
+        throw new IllegalStateException("Not supported by DeferredSXSSFSheet");
     }
 
     /**
index 6483a33bbd8f4eeb72cef0aa3e4cda6181eb68f1..37186f876d0cbb039e4cb95adfd28f93580ac8a8 100644 (file)
@@ -58,7 +58,7 @@ public class DeferredSXSSFWorkbook extends SXSSFWorkbook {
     @NotImplemented
     @Override
     protected SheetDataWriter createSheetDataWriter() throws IOException {
-        throw new RuntimeException("Not supported by DeferredSXSSFWorkbook");
+        throw new IllegalStateException("Not supported by DeferredSXSSFWorkbook");
     }
 
     protected StreamingSheetWriter createSheetDataWriter(OutputStream out) throws IOException {
@@ -79,7 +79,7 @@ public class DeferredSXSSFWorkbook extends SXSSFWorkbook {
         try {
             sxSheet = new DeferredSXSSFSheet(this, xSheet);
         } catch (IOException ioe) {
-            throw new RuntimeException(ioe);
+            throw new IllegalStateException(ioe);
         }
         registerSheetMapping(sxSheet, xSheet);
         return sxSheet;
index c0007cfcdc3e0e39b6f9a97f9fad0a30159d3b2f..748117d8e14f340ca50a1704c5e9621a7ce750f0 100644 (file)
@@ -154,7 +154,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
             try {
                 flushRows(_randomAccessWindowSize);
             } catch (IOException ioe) {
-                throw new RuntimeException(ioe);
+                throw new IllegalStateException(ioe);
             }
         }
         return newRow;
@@ -981,7 +981,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
     @NotImplemented
     @Override
     public void shiftRows(int startRow, int endRow, int n) {
-        throw new RuntimeException("Not Implemented");
+        throw new IllegalStateException("Not Implemented");
     }
 
     /**
@@ -1005,7 +1005,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
     @NotImplemented
     @Override
     public void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) {
-        throw new RuntimeException("Not Implemented");
+        throw new IllegalStateException("Not Implemented");
     }
 
     /**
@@ -1361,7 +1361,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
             collapseRow(row);
         } else {
             //expandRow(rowIndex);
-            throw new RuntimeException("Unable to expand row: Not Implemented");
+            throw new IllegalStateException("Unable to expand row: Not Implemented");
         }
     }
 
@@ -1761,7 +1761,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
         // corrupted .xlsx files as rows appear multiple times in the resulting sheetX.xml files
         // return _sh.setArrayFormula(formula, range);
 
-        throw new RuntimeException("Not Implemented");
+        throw new IllegalStateException("Not Implemented");
     }
 
     /**
@@ -1776,7 +1776,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
         // corrupted .xlsx files as rows appear multiple times in the resulting sheetX.xml files
         // return _sh.removeArrayFormula(cell);
 
-        throw new RuntimeException("Not Implemented");
+        throw new IllegalStateException("Not Implemented");
     }
 
     @Override
index 560c196f89229fd78ed147746fa7d030cf79fa47..e8b881f3a4ce56a76305cf1121664f9fba33891f 100644 (file)
@@ -725,7 +725,7 @@ public class SXSSFWorkbook implements Workbook {
         try {
             sxSheet = new SXSSFSheet(this,xSheet);
         } catch (IOException ioe) {
-            throw new RuntimeException(ioe);
+            throw new IllegalStateException(ioe);
         }
         registerSheetMapping(sxSheet,xSheet);
         return sxSheet;
@@ -755,7 +755,7 @@ public class SXSSFWorkbook implements Workbook {
     @Override
     @NotImplemented
     public Sheet cloneSheet(int sheetNum) {
-        throw new RuntimeException("Not Implemented");
+        throw new IllegalStateException("Not Implemented");
     }
 
 
@@ -1320,7 +1320,7 @@ public class SXSSFWorkbook implements Workbook {
     @Override
     @NotImplemented
     public int linkExternalWorkbook(String name, Workbook workbook) {
-        throw new RuntimeException("Not Implemented");
+        throw new IllegalStateException("Not Implemented");
     }
 
     /**
index bd500bff2521805283a4ee1a014193eab18f916a..91b7b95f86a2ae3dbc1ee9d9fb96643a8dc702a4 100644 (file)
@@ -41,7 +41,7 @@ public class StreamingSheetWriter extends SheetDataWriter {
     private boolean closed = false;
 
     public StreamingSheetWriter() throws IOException {
-        throw new RuntimeException("StreamingSheetWriter requires OutputStream");
+        throw new IllegalStateException("StreamingSheetWriter requires OutputStream");
     }
 
     public StreamingSheetWriter(OutputStream out) throws IOException {
@@ -51,12 +51,12 @@ public class StreamingSheetWriter extends SheetDataWriter {
 
     @Override
     public File createTempFile() throws IOException {
-        throw new RuntimeException("Not supported with StreamingSheetWriter");
+        throw new IllegalStateException("Not supported with StreamingSheetWriter");
     }
 
     @Override
     public Writer createWriter(File fd) throws IOException {
-        throw new RuntimeException("Not supported with StreamingSheetWriter");
+        throw new IllegalStateException("Not supported with StreamingSheetWriter");
     }
 
     /**
@@ -77,7 +77,7 @@ public class StreamingSheetWriter extends SheetDataWriter {
 
     @Override
     public InputStream getWorksheetXMLInputStream() throws IOException {
-        throw new RuntimeException("Not supported with StreamingSheetWriter");
+        throw new IllegalStateException("Not supported with StreamingSheetWriter");
     }
 
     @Override
index c1b5eb104213aed0dc4efa9c89cff480ae329272..c21f0593deb35adbf2eed09201d61cbd68500d7b 100644 (file)
@@ -131,7 +131,7 @@ public abstract class BaseXSSFEvaluationWorkbook implements FormulaRenderingWork
         }
 
         // Not properly referenced
-        throw new RuntimeException("Book not linked for filename " + bookName);
+        throw new IllegalStateException("Book not linked for filename " + bookName);
     }
     /* This is case-sensitive. Is that correct? */
     private int findExternalLinkIndex(String bookName, List<ExternalLinksTable> tables) {
@@ -317,7 +317,7 @@ public abstract class BaseXSSFEvaluationWorkbook implements FormulaRenderingWork
     @Override
     @NotImplemented
     public int getExternalSheetIndex(String workbookName, String sheetName) {
-        throw new RuntimeException("not implemented yet");
+        throw new IllegalStateException("not implemented yet");
     }
     @Override
     public int getSheetIndex(String sheetName) {
index 8b3eef1bc4e4a6bfad57b2a42ffebe9e49d697bd..f47d255c4ae9944cbd094ad56eb9618bced80578 100644 (file)
@@ -75,7 +75,7 @@ public abstract class BaseXSSFFormulaEvaluator extends BaseFormulaEvaluator {
         if (eval instanceof ErrorEval) {
             return CellValue.getError(((ErrorEval)eval).getErrorCode());
         }
-        throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")");
+        throw new IllegalStateException("Unexpected eval class (" + eval.getClass().getName() + ")");
     }
 
     /**
index 347f1895ebe959c1ee3a7441182ec492ecc4d573..63ef92a7075f019d09713c22efd59a0aa8690ba1 100644 (file)
@@ -416,7 +416,7 @@ public enum XSSFBuiltinTableStyle {
                 styleMap.put(builtIn, new XSSFBuiltinTypeStyleStyle(builtIn, styles.getExplicitTableStyle(styleName)));
             }
         } catch (Exception e) {
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
index bbd8c261b4299a3c222ee78f41a8f74a7b93333d..6f0b5e11694ad163bce880de4e51d0054206a064 100644 (file)
@@ -99,7 +99,7 @@ public class XSSFChartSheet extends XSSFSheet  {
         try {
             new XSSFSheet().write(out);
         } catch (IOException e){
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
         return out.toByteArray();
     }
index 7a588ecb0f31ca842144833b97a722d34dcdc948..c649cd74d10aee08f02fb7a16cf2ca0b5344ece4 100644 (file)
@@ -1918,13 +1918,13 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
     @Override
     @NotImplemented
     public boolean isHidden() {
-        throw new RuntimeException("Not implemented yet");
+        throw new IllegalStateException("Not implemented yet");
     }
 
     @Override
     @NotImplemented
     public void setHidden(boolean hiddenFlag) {
-        throw new RuntimeException("Not implemented yet");
+        throw new IllegalStateException("Not implemented yet");
     }
 
     @Override
index 2b08c4ef6b313370d1b1ff4b1f0d6f27bf4ce9fe..d747e44cf93426d772579e8f66ebfd75568b0792 100644 (file)
@@ -629,7 +629,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
     public void setBorderTop(Borders border) {
         CTPBdr ct = getCTPBrd(true);
         if (ct == null) {
-            throw new RuntimeException("invalid paragraph state");
+            throw new IllegalStateException("invalid paragraph state");
         }
 
         CTBorder pr = (ct.isSetTop()) ? ct.getTop() : ct.addNewTop();
index 33548e791daea4267cd0e9b716cff1645cb4e59a..82c08e260c6ebcf02699b64ac4f0e4c7229a2a83 100644 (file)
@@ -1218,7 +1218,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
      */
     protected static void setWidthValue(String widthValue, CTTblWidth ctWidth) {
         if (!widthValue.matches(REGEX_WIDTH_VALUE)) {
-            throw new RuntimeException("Table width value \"" + widthValue + "\" "
+            throw new IllegalStateException("Table width value \"" + widthValue + "\" "
                     + "must match regular expression \"" + REGEX_WIDTH_VALUE + "\".");
         }
         if (widthValue.matches("auto")) {
@@ -1250,7 +1250,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
         } else if (widthValue.matches("[0-9]+")) {
             ctWidth.setW(new BigInteger(widthValue));
         } else {
-            throw new RuntimeException("setWidthPercentage(): Width value must be a percentage (\"33.3%\" or an integer, was \"" + widthValue + "\"");
+            throw new IllegalStateException("setWidthPercentage(): Width value must be a percentage (\"33.3%\" or an integer, was \"" + widthValue + "\"");
         }
     }
 
index 2d8f3b0e4529e266e871e61e0e84fcc4858a216b..dfa4685fe1ff832d3f3fde40de3bedc48584fc14 100644 (file)
@@ -103,7 +103,7 @@ public class HemfPlusGDIImageRenderer extends BitmapImageRenderer {
                 bOffs = new int[]{2, 1, 0};
                 break;
             default:
-                throw new RuntimeException("not yet implemented");
+                throw new IllegalStateException("not yet implemented");
         }
 
         ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
index 2553102d1181b7286e9f1fe2d4cb2345404c38cf..ebeb0f1d0f2b58661240eaa1c85f357f79a903a9 100644 (file)
@@ -205,7 +205,7 @@ public class HemfPlusObject {
                 ) {
                     other.linkContinuedObject(objectData);
                 } else {
-                    throw new RuntimeException("can't find previous record for continued record");
+                    throw new IllegalStateException("can't find previous record for continued record");
                 }
             } else {
                 ctx.addPlusObjectTableEntry(this, getObjectId());
index 0faf461808a28d4395062dc321846f567848bc4b..d6d2b536f4244abdb027a22b4b390b362eab225f 100644 (file)
@@ -299,7 +299,7 @@ public class HemfEmbeddedIterator implements Iterator<HwmfEmbedded> {
             emb.setData(bos.toByteArray());
         } catch (IOException e) {
             // TODO: throw appropriate exception
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
index de90c60c8de4a3a16a7a68a7ed45594a9d18314d..814c82e788b0e48407ff292f217ce962b143be32 100644 (file)
@@ -329,7 +329,7 @@ public class TextPropCollection implements GenericRecord, Duplicatable {
 
     public void setIndentLevel(short indentLevel) {
         if (textPropType == TextPropType.character) {
-            throw new RuntimeException("trying to set an indent on a character collection.");
+            throw new IllegalStateException("trying to set an indent on a character collection.");
         }
         this.indentLevel = indentLevel;
     }
index 2111d5387ab1031dd37aaef7f3bb65b75b09d1b2..4739ddb90767dadfe14baa84c1807bfab3916cae 100644 (file)
@@ -241,7 +241,7 @@ public final class HSLFObjectShape extends HSLFPictureShape implements ObjectSha
     public OutputStream updateObjectData(final Application application, final ObjectMetaData metaData) {
         final ObjectMetaData md = (application != null) ? application.getMetaData() : metaData;
         if (md == null) {
-            throw new RuntimeException("either application or metaData needs to be set");
+            throw new IllegalStateException("either application or metaData needs to be set");
         }
 
         // can't use UnsynchronizedByteArrayOutputStream here, because it's final
index 643463e191eba397f30af2b673d864bbb959008e..52a0a962c3a7e635280812a53d86c339af532932 100644 (file)
@@ -278,7 +278,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
             );
             return rtf.getDataString();
         } catch (IOException e) {
-            throw new RuntimeException("Shouldn't happen", e);
+            throw new IllegalStateException("Shouldn't happen", e);
         }
     }
 
index dc307614ea681521a216d8dc0ce1d4f8b7110c1f..da669354df28f9bb829839cb3976ae883420fe15 100644 (file)
@@ -528,7 +528,7 @@ public class HwmfMisc {
             case BS_DIBPATTERN8X8:
             case BS_MONOPATTERN:
             case BS_PATTERN8X8:
-                throw new RuntimeException("pattern not supported");
+                throw new IllegalStateException("pattern not supported");
             }
             return size;
         }
index b9d9f7ed2b3ac1d0a49a63d646bf88cc2237101e..dd5c7e0c80ee8ee8d6ed63a200791870cc926b9d 100644 (file)
@@ -429,7 +429,7 @@ public enum HwmfTernaryRasterOp {
                     stack[stackPnt++] = "all black";
                     break;
                 default:
-                    throw new RuntimeException("unknown cmd '"+c+"'.");
+                    throw new IllegalStateException("unknown cmd '"+c+"'.");
             }
         }
 
index 0ac072ddd2341a57f62e01bade80cd451de31e68..7098f2811dd56d67a61b7ee594dca1e9c003def4 100644 (file)
@@ -208,7 +208,7 @@ public class HwmfPicture implements Iterable<HwmfRecord>, GenericRecord {
         if (inner != null) {
             return inner;
         }
-        throw new RuntimeException("invalid wmf file - window records are incomplete.");
+        throw new IllegalStateException("invalid wmf file - window records are incomplete.");
     }
 
     /**
index 55657f72b3ff01a8f7f5c77c8b686bb41856e2ec..52ae97a3ed28d328ea1e461c2edb88ad700a9bb2 100644 (file)
@@ -263,7 +263,7 @@ public final class HWPFLister {
             }
         }
         catch ( IOException e ) {
-            throw new RuntimeException( e );
+            throw new IllegalStateException( e );
         }
     }
 
index 9c8dc8b568d43b845fab129a4bba062713dd2e29..880c4e2d389d5c6c1da56d8a6923f34b94b5009c 100644 (file)
@@ -259,7 +259,7 @@ public final class WordExtractor implements POIOLE2TextExtractor {
         } catch (RuntimeException e) {
             throw e;
         } catch ( Exception exc ) {
-            throw new RuntimeException( exc );
+            throw new IllegalStateException( exc );
         }
     }
 
index 2c30f29a0183a4a7512973a1446a2aa903ac2f19..bf3fd50c3e3e6df9c04a5c8a92f31240110eeb3c 100644 (file)
@@ -116,7 +116,7 @@ public final class SprmUtils {
                 break;
             default:
                 //should never happen
-                throw new RuntimeException("Invalid sprm type");
+                throw new IllegalStateException("Invalid sprm type");
         }
         LittleEndian.putShort(sprm, 0, instruction);
         list.add(sprm);