]> source.dussan.org Git - poi.git/commitdiff
bug 59264: allow borders styles to be set with BorderStyles enums or Short codes...
authorJaven O'Neal <onealj@apache.org>
Tue, 5 Apr 2016 21:36:11 +0000 (21:36 +0000)
committerJaven O'Neal <onealj@apache.org>
Tue, 5 Apr 2016 21:36:11 +0000 (21:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1737885 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/util/CellUtil.java

index ad3425aac1d8e7bd8ed4db5031d78700e1fa0999..3cc16dd63c562bddd0d0ac2d741c792d1d9cbb4b 100644 (file)
@@ -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;
        }
 
        /**