Author: tilman
Date: Tue Sep 23 07:14:28 2025
New Revision: 1928704

Log:
PDFBOX-5660: optimize, as suggested by Valery Bokov; improve javadoc; closes 
#257

Modified:
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java
      Tue Sep 23 07:14:24 2025        (r1928703)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java
      Tue Sep 23 07:14:28 2025        (r1928704)
@@ -145,7 +145,7 @@ public class PDBorderStyleDictionary imp
     /**
      * This will retrieve the border style, see the STYLE_* constants for 
valid values.
      *
-     * @return the style of the border
+     * @return the style of the border, never null.
      */
     public String getStyle()
     {

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java
    Tue Sep 23 07:14:24 2025        (r1928703)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java
    Tue Sep 23 07:14:28 2025        (r1928704)
@@ -42,9 +42,13 @@ class AnnotationBorder
         if (borderStyle == null)
         {
             COSArray border = annotation.getBorder();
-            if (border.size() >= 3 && border.getObject(2) instanceof COSNumber)
+            if (border.size() >= 3)
             {
-                ab.width = ((COSNumber) border.getObject(2)).floatValue();
+                COSBase base = border.getObject(2);
+                if (base instanceof COSNumber)
+                {
+                    ab.width = ((COSNumber) base).floatValue();
+                }
             }
             if (border.size() > 3)
             {
@@ -58,11 +62,12 @@ class AnnotationBorder
         else
         {
             ab.width = borderStyle.getWidth();
-            if 
(borderStyle.getStyle().equals(PDBorderStyleDictionary.STYLE_DASHED))
+            String style = borderStyle.getStyle();
+            if (style.equals(PDBorderStyleDictionary.STYLE_DASHED))
             {
                 ab.dashArray = borderStyle.getDashStyle().getDashArray();
             }
-            if 
(borderStyle.getStyle().equals(PDBorderStyleDictionary.STYLE_UNDERLINE))
+            if (style.equals(PDBorderStyleDictionary.STYLE_UNDERLINE))
             {
                 ab.underline = true;
             }

Reply via email to