Author: fanningpj
Date: Sun Jul 10 10:24:34 2022
New Revision: 1902623
URL: http://svn.apache.org/viewvc?rev=1902623&view=rev
Log:
throw exception if wrong Color class is used
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java?rev=1902623&r1=1902622&r2=1902623&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
Sun Jul 10 10:24:34 2022
@@ -833,12 +833,15 @@ public class XSSFCellStyle implements Ce
* Set the background fill color represented as a {@link
org.apache.poi.ss.usermodel.Color} value.
* <br>
* @param color the color to use
+ * @throws IllegalArgumentException if you provide a <code>Color</code>
instance that is not a {@link XSSFColor}
* @since POI 5.2.3
*/
@Override
public void setFillBackgroundColor(org.apache.poi.ss.usermodel.Color
color) {
if (color instanceof XSSFColor) {
setFillBackgroundColor((XSSFColor)color);
+ } else {
+ throw new IllegalArgumentException("XSSFCellStyle only accepts
XSSFColor instances");
}
}
@@ -900,12 +903,15 @@ public class XSSFCellStyle implements Ce
* Set the foreground fill color represented as a {@link
org.apache.poi.ss.usermodel.Color} value.
* <br>
* @param color the color to use
+ * @throws IllegalArgumentException if you provide a <code>Color</code>
instance that is not a {@link XSSFColor}
* @since POI 5.2.3
*/
@Override
public void setFillForegroundColor(org.apache.poi.ss.usermodel.Color
color) {
if (color instanceof XSSFColor) {
setFillForegroundColor((XSSFColor)color);
+ } else {
+ throw new IllegalArgumentException("XSSFCellStyle only accepts
XSSFColor instances");
}
}
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java?rev=1902623&r1=1902622&r2=1902623&view=diff
==============================================================================
---
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
(original)
+++
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
Sun Jul 10 10:24:34 2022
@@ -642,6 +642,7 @@ public final class HSSFCellStyle impleme
* Set the background fill color represented as a {@link
org.apache.poi.ss.usermodel.Color} value.
* <br>
* @param color the color to use
+ * @throws IllegalArgumentException if you provide a <code>Color</code>
instance that is not a {@link HSSFColor}
* @since POI 5.2.3
*/
@Override
@@ -650,6 +651,8 @@ public final class HSSFCellStyle impleme
if (color instanceof HSSFColor) {
short index2 = ((HSSFColor)color).getIndex2();
if (index2 != -1) setFillBackgroundColor(index2);
+ } else {
+ throw new IllegalArgumentException("HSSFCellStyle only accepts
HSSFColor instances");
}
}
@@ -698,6 +701,7 @@ public final class HSSFCellStyle impleme
* Set the foreground fill color represented as a {@link
org.apache.poi.ss.usermodel.Color} value.
* <br>
* @param color the color to use
+ * @throws IllegalArgumentException if you provide a <code>Color</code>
instance that is not a {@link HSSFColor}
* @since POI 5.2.3
*/
@Override
@@ -706,6 +710,8 @@ public final class HSSFCellStyle impleme
if (color instanceof HSSFColor) {
short index2 = ((HSSFColor)color).getIndex2();
if (index2 != -1) setFillForegroundColor(index2);
+ } else {
+ throw new IllegalArgumentException("HSSFCellStyle only accepts
HSSFColor instances");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]