poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1737885 - /poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
Date Tue, 05 Apr 2016 21:36:12 GMT
Author: onealj
Date: Tue Apr  5 21:36:11 2016
New Revision: 1737885

URL: http://svn.apache.org/viewvc?rev=1737885&view=rev
Log:
bug 59264: allow borders styles to be set with BorderStyles enums or Short codes for backwards
compatibility

Modified:
    poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java

Modified: poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java?rev=1737885&r1=1737884&r2=1737885&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java Tue Apr  5 21:36:11 2016
@@ -355,8 +355,20 @@ public final class CellUtil {
 	 * @return Border style if set, otherwise {@link BorderStyle#NONE}
 	 */
 	private static BorderStyle getBorderStyle(Map<String, Object> properties, String name)
{
-		BorderStyle value = (BorderStyle) properties.get(name);
-		return (value != null) ? value : BorderStyle.NONE;
+		Object value = properties.get(name);
+		BorderStyle border;
+		if (value instanceof BorderStyle) {
+			border = (BorderStyle) value;
+		}
+		// @deprecated 3.15 beta 1. getBorderStyle will only work on BorderStyle enums instead
of codes in the future.
+		else if (value instanceof Short) {
+			short code = Short.valueOf((Short) value);
+			border = BorderStyle.valueOf(code);
+		}
+		else {
+			throw new RuntimeException("Unexpected border style class. Must be BorderStyle or Short
(deprecated)");
+		}
+		return (border != null) ? border : BorderStyle.NONE;
 	}
 
 	/**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message