try to use IllegalStateException instead of RuntimeException

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1904051 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-09-14 01:32:10 +00:00
parent 59b16f025b
commit 7235ff9036
37 changed files with 69 additions and 69 deletions

View File

@ -273,7 +273,7 @@ public class POIXMLPropertiesTextExtractor implements POIXMLTextExtractor {
getExtendedPropertiesText() + getExtendedPropertiesText() +
getCustomPropertiesText(); getCustomPropertiesText();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
} }

View File

@ -1413,7 +1413,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
try { try {
partMarshallers.remove(new ContentType(contentType)); partMarshallers.remove(new ContentType(contentType));
} catch (InvalidFormatException e) { } catch (InvalidFormatException e) {
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
} }
@ -1427,7 +1427,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
try { try {
partUnmarshallers.remove(new ContentType(contentType)); partUnmarshallers.remove(new ContentType(contentType));
} catch (InvalidFormatException e) { } catch (InvalidFormatException e) {
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
} }

View File

@ -493,7 +493,7 @@ public class SignatureInfo {
*/ */
String signatureId = signatureConfig.getPackageSignatureId(); String signatureId = signatureConfig.getPackageSignatureId();
if (!signatureId.equals(document.getDocumentElement().getAttribute("Id"))) { 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"); final Element signatureNode = getDsigElement(document, "SignatureValue");
if (signatureNode == null) { 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); signatureNode.setTextContent(signatureValue);
@ -675,7 +675,7 @@ public class SignatureInfo {
RelationshipTransformService.registerDsigProvider(); RelationshipTransformService.registerDsigProvider();
CryptoFunctions.registerBouncyCastle(); CryptoFunctions.registerBouncyCastle();
} catch (Exception e) { } 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() { 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!");
} }
} }

View File

@ -84,7 +84,7 @@ public class KeyInfoSignatureFacet implements SignatureFacet {
try { try {
keyValue = keyInfoFactory.newKeyValue(signingCertificate.getPublicKey()); keyValue = keyInfoFactory.newKeyValue(signingCertificate.getPublicKey());
} catch (KeyException e) { } catch (KeyException e) {
throw new RuntimeException("key exception: " + e.getMessage(), e); throw new IllegalStateException("key exception: " + e.getMessage(), e);
} }
keyInfoContent.add(keyValue); keyInfoContent.add(keyValue);
} }
@ -137,7 +137,7 @@ public class KeyInfoSignatureFacet implements SignatureFacet {
if (nextSibling != null) { if (nextSibling != null) {
NodeList kiNl = document.getElementsByTagNameNS(XML_DIGSIG_NS, "KeyInfo"); NodeList kiNl = document.getElementsByTagNameNS(XML_DIGSIG_NS, "KeyInfo");
if (kiNl.getLength() != 1) { 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); nextSibling.getParentNode().insertBefore(kiNl.item(0), nextSibling);
} }

View File

@ -169,7 +169,7 @@ public class XAdESSignatureFacet implements SignatureFacet {
SignatureConfig signatureConfig = signatureInfo.getSignatureConfig(); SignatureConfig signatureConfig = signatureInfo.getSignatureConfig();
List<X509Certificate> chain = signatureConfig.getSigningCertificateChain(); List<X509Certificate> chain = signatureConfig.getSigningCertificateChain();
if (chain == null || chain.isEmpty()) { 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(); CertIDListType signingCertificates = signedSignatureProperties.addNewSigningCertificate();
CertIDType certId = signingCertificates.addNewCert(); CertIDType certId = signingCertificates.addNewCert();
@ -332,7 +332,7 @@ public class XAdESSignatureFacet implements SignatureFacet {
try { try {
encodedCertificate = certificate.getEncoded(); encodedCertificate = certificate.getEncoded();
} catch (CertificateEncodingException e) { } catch (CertificateEncodingException e) {
throw new RuntimeException("certificate encoding error: " throw new IllegalStateException("certificate encoding error: "
+ e.getMessage(), e); + e.getMessage(), e);
} }
DigestAlgAndValueType certDigest = certId.addNewCertDigest(); DigestAlgAndValueType certDigest = certId.addNewCertDigest();

View File

@ -94,7 +94,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
try { try {
this.certificateFactory = CertificateFactory.getInstance("X.509"); this.certificateFactory = CertificateFactory.getInstance("X.509");
} catch (CertificateException e) { } 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 crl = (X509CRL) this.certificateFactory
.generateCRL(new UnsynchronizedByteArrayInputStream(encodedCrl)); .generateCRL(new UnsynchronizedByteArrayInputStream(encodedCrl));
} catch (CRLException e) { } 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(); CRLIdentifierType crlIdentifier = crlRef.addNewCRLIdentifier();
@ -277,7 +277,7 @@ public class XAdESXLSignatureFacet implements SignatureFacet {
responderId.setByName(nameStr); responderId.setByName(nameStr);
} }
} catch (Exception e) { } 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()); certificateValues.addNewEncapsulatedX509Certificate().setByteArrayValue(certificate.getEncoded());
} }
} catch (CertificateEncodingException e) { } 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) { } catch (RuntimeException e) {
throw e; throw e;
} catch (Exception 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(); return integer.getPositiveValue();
} }
} catch (IOException e) { } 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 { try {
timeStampToken = signatureConfig.getTspService().timeStamp(signatureInfo, c14nSignatureValueElement, revocationData); timeStampToken = signatureConfig.getTspService().timeStamp(signatureInfo, c14nSignatureValueElement, revocationData);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("error while creating a time-stamp: " throw new IllegalStateException("error while creating a time-stamp: "
+ e.getMessage(), e); + e.getMessage(), e);
} }

View File

@ -133,7 +133,7 @@ public class TSPTimeStampService implements TimeStampService {
byte[] responseBytes = response.getResponseBytes(); byte[] responseBytes = response.getResponseBytes();
if (responseBytes.length == 0) { if (responseBytes.length == 0) {
throw new RuntimeException("Content-Length is zero"); throw new IllegalStateException("Content-Length is zero");
} }
// TSP response parsing and validation // TSP response parsing and validation
@ -150,7 +150,7 @@ public class TSPTimeStampService implements TimeStampService {
LOG.atDebug().log("unaccepted policy"); LOG.atDebug().log("unaccepted policy");
} }
} }
throw new RuntimeException("timestamp response status != 0: " throw new IllegalStateException("timestamp response status != 0: "
+ timeStampResponse.getStatus()); + timeStampResponse.getStatus());
} }
TimeStampToken timeStampToken = timeStampResponse.getTimeStampToken(); TimeStampToken timeStampToken = timeStampResponse.getTimeStampToken();
@ -171,7 +171,7 @@ public class TSPTimeStampService implements TimeStampService {
.filter(h -> signerCertIssuer.equals(h.getIssuer()) .filter(h -> signerCertIssuer.equals(h.getIssuer())
&& signerCertSerialNumber.equals(h.getSerialNumber())) && signerCertSerialNumber.equals(h.getSerialNumber()))
.findFirst() .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(); JcaX509CertificateConverter x509converter = new JcaX509CertificateConverter();
x509converter.setProvider("BC"); x509converter.setProvider("BC");

View File

@ -279,7 +279,7 @@ public class XMLSlideShow extends POIXMLDocument
try { try {
return getPackage().getUnusedPartIndex(relationType.getDefaultFileName()); return getPackage().getUnusedPartIndex(relationType.getDefaultFileName());
} catch (InvalidFormatException e) { } 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) { String importBlip(String blipId, POIXMLDocumentPart parent, POIXMLDocumentPart target) {
OPCPackage targetPackage = target.getPackagePart().getPackage(); OPCPackage targetPackage = target.getPackagePart().getPackage();
if (targetPackage != 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(); final POIXMLDocumentPart docPart = parent.getRelationPartById(blipId).getDocumentPart();
XSLFPictureData parData; XSLFPictureData parData;
if (docPart instanceof XSLFPictureData) { if (docPart instanceof XSLFPictureData) {
parData = (XSLFPictureData)docPart; parData = (XSLFPictureData)docPart;
} else { } 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; final XSLFPictureData pictureData;
if (targetPackage == parent.getPackagePart().getPackage()) { if (targetPackage == parent.getPackagePart().getPackage()) {

View File

@ -212,7 +212,7 @@ public class XSLFFontInfo implements FontInfo {
try { try {
fntDataIdx = ppt.getPackage().getUnusedPartIndex(fntRel.getDefaultFileName()); fntDataIdx = ppt.getPackage().getUnusedPartIndex(fntRel.getDefaultFileName());
} catch (InvalidFormatException e) { } catch (InvalidFormatException e) {
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
POIXMLDocumentPart.RelationPart rp = ppt.createRelationship(fntRel, XSLFFactory.getInstance(), fntDataIdx, false); 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); header.init(buf, 0, buf.length);
} catch (IOException e) { } catch (IOException e) {
// TODO: better exception class // TODO: better exception class
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
} }
} }

View File

@ -84,7 +84,7 @@ public class XSLFTexturePaint implements PaintStyle.TexturePaint {
try { try {
return getPart().getInputStream(); return getPart().getInputStream();
} catch (Exception e) { } 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 { try {
return getPart().getContentType(); return getPart().getContentType();
} catch (InvalidFormatException e) { } catch (InvalidFormatException e) {
throw new RuntimeException("Failed to read package part", e); throw new IllegalStateException("Failed to read package part", e);
} }
} }

View File

@ -37,7 +37,7 @@ public class DummyFormat implements OutputFormat {
bos = new UnsynchronizedByteArrayOutputStream(); bos = new UnsynchronizedByteArrayOutputStream();
dummy2d = new DummyGraphics2d(new PrintStream(bos, true, StandardCharsets.UTF_8.name())); dummy2d = new DummyGraphics2d(new PrintStream(bos, true, StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
} }

View File

@ -179,7 +179,7 @@ class PPTHandler extends MFProxy {
return IOUtils.toByteArray(is); return IOUtils.toByteArray(is);
} catch (IOException e) { } catch (IOException e) {
// TODO: change to custom runtime exception // TODO: change to custom runtime exception
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
}); });
return embed; return embed;

View File

@ -245,7 +245,7 @@ public class XSSFEventBasedExcelExtractor
sheetParser.setContentHandler(handler); sheetParser.setContentHandler(handler);
sheetParser.parse(sheetSource); sheetParser.parse(sheetSource);
} catch (ParserConfigurationException e) { } 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());
} }
} }

View File

@ -48,7 +48,7 @@ public class DeferredSXSSFSheet extends SXSSFSheet {
*/ */
@Override @Override
public InputStream getWorksheetXMLInputStream() throws IOException { public InputStream getWorksheetXMLInputStream() throws IOException {
throw new RuntimeException("Not supported by DeferredSXSSFSheet"); throw new IllegalStateException("Not supported by DeferredSXSSFSheet");
} }
/** /**

View File

@ -58,7 +58,7 @@ public class DeferredSXSSFWorkbook extends SXSSFWorkbook {
@NotImplemented @NotImplemented
@Override @Override
protected SheetDataWriter createSheetDataWriter() throws IOException { 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 { protected StreamingSheetWriter createSheetDataWriter(OutputStream out) throws IOException {
@ -79,7 +79,7 @@ public class DeferredSXSSFWorkbook extends SXSSFWorkbook {
try { try {
sxSheet = new DeferredSXSSFSheet(this, xSheet); sxSheet = new DeferredSXSSFSheet(this, xSheet);
} catch (IOException ioe) { } catch (IOException ioe) {
throw new RuntimeException(ioe); throw new IllegalStateException(ioe);
} }
registerSheetMapping(sxSheet, xSheet); registerSheetMapping(sxSheet, xSheet);
return sxSheet; return sxSheet;

View File

@ -154,7 +154,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
try { try {
flushRows(_randomAccessWindowSize); flushRows(_randomAccessWindowSize);
} catch (IOException ioe) { } catch (IOException ioe) {
throw new RuntimeException(ioe); throw new IllegalStateException(ioe);
} }
} }
return newRow; return newRow;
@ -981,7 +981,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
@NotImplemented @NotImplemented
@Override @Override
public void shiftRows(int startRow, int endRow, int n) { 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 @NotImplemented
@Override @Override
public void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) { 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); collapseRow(row);
} else { } else {
//expandRow(rowIndex); //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 // corrupted .xlsx files as rows appear multiple times in the resulting sheetX.xml files
// return _sh.setArrayFormula(formula, range); // 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 // corrupted .xlsx files as rows appear multiple times in the resulting sheetX.xml files
// return _sh.removeArrayFormula(cell); // return _sh.removeArrayFormula(cell);
throw new RuntimeException("Not Implemented"); throw new IllegalStateException("Not Implemented");
} }
@Override @Override

View File

@ -725,7 +725,7 @@ public class SXSSFWorkbook implements Workbook {
try { try {
sxSheet = new SXSSFSheet(this,xSheet); sxSheet = new SXSSFSheet(this,xSheet);
} catch (IOException ioe) { } catch (IOException ioe) {
throw new RuntimeException(ioe); throw new IllegalStateException(ioe);
} }
registerSheetMapping(sxSheet,xSheet); registerSheetMapping(sxSheet,xSheet);
return sxSheet; return sxSheet;
@ -755,7 +755,7 @@ public class SXSSFWorkbook implements Workbook {
@Override @Override
@NotImplemented @NotImplemented
public Sheet cloneSheet(int sheetNum) { 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 @Override
@NotImplemented @NotImplemented
public int linkExternalWorkbook(String name, Workbook workbook) { public int linkExternalWorkbook(String name, Workbook workbook) {
throw new RuntimeException("Not Implemented"); throw new IllegalStateException("Not Implemented");
} }
/** /**

View File

@ -41,7 +41,7 @@ public class StreamingSheetWriter extends SheetDataWriter {
private boolean closed = false; private boolean closed = false;
public StreamingSheetWriter() throws IOException { public StreamingSheetWriter() throws IOException {
throw new RuntimeException("StreamingSheetWriter requires OutputStream"); throw new IllegalStateException("StreamingSheetWriter requires OutputStream");
} }
public StreamingSheetWriter(OutputStream out) throws IOException { public StreamingSheetWriter(OutputStream out) throws IOException {
@ -51,12 +51,12 @@ public class StreamingSheetWriter extends SheetDataWriter {
@Override @Override
public File createTempFile() throws IOException { public File createTempFile() throws IOException {
throw new RuntimeException("Not supported with StreamingSheetWriter"); throw new IllegalStateException("Not supported with StreamingSheetWriter");
} }
@Override @Override
public Writer createWriter(File fd) throws IOException { 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 @Override
public InputStream getWorksheetXMLInputStream() throws IOException { public InputStream getWorksheetXMLInputStream() throws IOException {
throw new RuntimeException("Not supported with StreamingSheetWriter"); throw new IllegalStateException("Not supported with StreamingSheetWriter");
} }
@Override @Override

View File

@ -131,7 +131,7 @@ public abstract class BaseXSSFEvaluationWorkbook implements FormulaRenderingWork
} }
// Not properly referenced // 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? */ /* This is case-sensitive. Is that correct? */
private int findExternalLinkIndex(String bookName, List<ExternalLinksTable> tables) { private int findExternalLinkIndex(String bookName, List<ExternalLinksTable> tables) {
@ -317,7 +317,7 @@ public abstract class BaseXSSFEvaluationWorkbook implements FormulaRenderingWork
@Override @Override
@NotImplemented @NotImplemented
public int getExternalSheetIndex(String workbookName, String sheetName) { public int getExternalSheetIndex(String workbookName, String sheetName) {
throw new RuntimeException("not implemented yet"); throw new IllegalStateException("not implemented yet");
} }
@Override @Override
public int getSheetIndex(String sheetName) { public int getSheetIndex(String sheetName) {

View File

@ -75,7 +75,7 @@ public abstract class BaseXSSFFormulaEvaluator extends BaseFormulaEvaluator {
if (eval instanceof ErrorEval) { if (eval instanceof ErrorEval) {
return CellValue.getError(((ErrorEval)eval).getErrorCode()); return CellValue.getError(((ErrorEval)eval).getErrorCode());
} }
throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")"); throw new IllegalStateException("Unexpected eval class (" + eval.getClass().getName() + ")");
} }
/** /**

View File

@ -416,7 +416,7 @@ public enum XSSFBuiltinTableStyle {
styleMap.put(builtIn, new XSSFBuiltinTypeStyleStyle(builtIn, styles.getExplicitTableStyle(styleName))); styleMap.put(builtIn, new XSSFBuiltinTypeStyleStyle(builtIn, styles.getExplicitTableStyle(styleName)));
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
} }

View File

@ -99,7 +99,7 @@ public class XSSFChartSheet extends XSSFSheet {
try { try {
new XSSFSheet().write(out); new XSSFSheet().write(out);
} catch (IOException e){ } catch (IOException e){
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
return out.toByteArray(); return out.toByteArray();
} }

View File

@ -1918,13 +1918,13 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
@Override @Override
@NotImplemented @NotImplemented
public boolean isHidden() { public boolean isHidden() {
throw new RuntimeException("Not implemented yet"); throw new IllegalStateException("Not implemented yet");
} }
@Override @Override
@NotImplemented @NotImplemented
public void setHidden(boolean hiddenFlag) { public void setHidden(boolean hiddenFlag) {
throw new RuntimeException("Not implemented yet"); throw new IllegalStateException("Not implemented yet");
} }
@Override @Override

View File

@ -629,7 +629,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
public void setBorderTop(Borders border) { public void setBorderTop(Borders border) {
CTPBdr ct = getCTPBrd(true); CTPBdr ct = getCTPBrd(true);
if (ct == null) { if (ct == null) {
throw new RuntimeException("invalid paragraph state"); throw new IllegalStateException("invalid paragraph state");
} }
CTBorder pr = (ct.isSetTop()) ? ct.getTop() : ct.addNewTop(); CTBorder pr = (ct.isSetTop()) ? ct.getTop() : ct.addNewTop();

View File

@ -1218,7 +1218,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
*/ */
protected static void setWidthValue(String widthValue, CTTblWidth ctWidth) { protected static void setWidthValue(String widthValue, CTTblWidth ctWidth) {
if (!widthValue.matches(REGEX_WIDTH_VALUE)) { 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 + "\"."); + "must match regular expression \"" + REGEX_WIDTH_VALUE + "\".");
} }
if (widthValue.matches("auto")) { if (widthValue.matches("auto")) {
@ -1250,7 +1250,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
} else if (widthValue.matches("[0-9]+")) { } else if (widthValue.matches("[0-9]+")) {
ctWidth.setW(new BigInteger(widthValue)); ctWidth.setW(new BigInteger(widthValue));
} else { } 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 + "\"");
} }
} }

View File

@ -103,7 +103,7 @@ public class HemfPlusGDIImageRenderer extends BitmapImageRenderer {
bOffs = new int[]{2, 1, 0}; bOffs = new int[]{2, 1, 0};
break; break;
default: default:
throw new RuntimeException("not yet implemented"); throw new IllegalStateException("not yet implemented");
} }
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);

View File

@ -205,7 +205,7 @@ public class HemfPlusObject {
) { ) {
other.linkContinuedObject(objectData); other.linkContinuedObject(objectData);
} else { } else {
throw new RuntimeException("can't find previous record for continued record"); throw new IllegalStateException("can't find previous record for continued record");
} }
} else { } else {
ctx.addPlusObjectTableEntry(this, getObjectId()); ctx.addPlusObjectTableEntry(this, getObjectId());

View File

@ -299,7 +299,7 @@ public class HemfEmbeddedIterator implements Iterator<HwmfEmbedded> {
emb.setData(bos.toByteArray()); emb.setData(bos.toByteArray());
} catch (IOException e) { } catch (IOException e) {
// TODO: throw appropriate exception // TODO: throw appropriate exception
throw new RuntimeException(e); throw new IllegalStateException(e);
} }
} }

View File

@ -329,7 +329,7 @@ public class TextPropCollection implements GenericRecord, Duplicatable {
public void setIndentLevel(short indentLevel) { public void setIndentLevel(short indentLevel) {
if (textPropType == TextPropType.character) { 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; this.indentLevel = indentLevel;
} }

View File

@ -241,7 +241,7 @@ public final class HSLFObjectShape extends HSLFPictureShape implements ObjectSha
public OutputStream updateObjectData(final Application application, final ObjectMetaData metaData) { public OutputStream updateObjectData(final Application application, final ObjectMetaData metaData) {
final ObjectMetaData md = (application != null) ? application.getMetaData() : metaData; final ObjectMetaData md = (application != null) ? application.getMetaData() : metaData;
if (md == null) { 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 // can't use UnsynchronizedByteArrayOutputStream here, because it's final

View File

@ -278,7 +278,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
); );
return rtf.getDataString(); return rtf.getDataString();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("Shouldn't happen", e); throw new IllegalStateException("Shouldn't happen", e);
} }
} }

View File

@ -528,7 +528,7 @@ public class HwmfMisc {
case BS_DIBPATTERN8X8: case BS_DIBPATTERN8X8:
case BS_MONOPATTERN: case BS_MONOPATTERN:
case BS_PATTERN8X8: case BS_PATTERN8X8:
throw new RuntimeException("pattern not supported"); throw new IllegalStateException("pattern not supported");
} }
return size; return size;
} }

View File

@ -429,7 +429,7 @@ public enum HwmfTernaryRasterOp {
stack[stackPnt++] = "all black"; stack[stackPnt++] = "all black";
break; break;
default: default:
throw new RuntimeException("unknown cmd '"+c+"'."); throw new IllegalStateException("unknown cmd '"+c+"'.");
} }
} }

View File

@ -208,7 +208,7 @@ public class HwmfPicture implements Iterable<HwmfRecord>, GenericRecord {
if (inner != null) { if (inner != null) {
return inner; return inner;
} }
throw new RuntimeException("invalid wmf file - window records are incomplete."); throw new IllegalStateException("invalid wmf file - window records are incomplete.");
} }
/** /**

View File

@ -263,7 +263,7 @@ public final class HWPFLister {
} }
} }
catch ( IOException e ) { catch ( IOException e ) {
throw new RuntimeException( e ); throw new IllegalStateException( e );
} }
} }

View File

@ -259,7 +259,7 @@ public final class WordExtractor implements POIOLE2TextExtractor {
} catch (RuntimeException e) { } catch (RuntimeException e) {
throw e; throw e;
} catch ( Exception exc ) { } catch ( Exception exc ) {
throw new RuntimeException( exc ); throw new IllegalStateException( exc );
} }
} }

View File

@ -116,7 +116,7 @@ public final class SprmUtils {
break; break;
default: default:
//should never happen //should never happen
throw new RuntimeException("Invalid sprm type"); throw new IllegalStateException("Invalid sprm type");
} }
LittleEndian.putShort(sprm, 0, instruction); LittleEndian.putShort(sprm, 0, instruction);
list.add(sprm); list.add(sprm);