Skip to content

Commit bebb747

Browse files
committed
PDFBOX-5660: optimize, as suggested by Valery Bokov; improve javadoc; closes #257
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1928702 13f79535-47bb-0310-9956-ffa450edef68
1 parent b0bc125 commit bebb747

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDBorderStyleDictionary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void setStyle(String s)
145145
/**
146146
* This will retrieve the border style, see the STYLE_* constants for valid values.
147147
*
148-
* @return the style of the border
148+
* @return the style of the border, never null.
149149
*/
150150
public String getStyle()
151151
{

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ static AnnotationBorder getAnnotationBorder(PDAnnotation annotation,
4242
if (borderStyle == null)
4343
{
4444
COSArray border = annotation.getBorder();
45-
if (border.size() >= 3 && border.getObject(2) instanceof COSNumber)
45+
if (border.size() >= 3)
4646
{
47-
ab.width = ((COSNumber) border.getObject(2)).floatValue();
47+
COSBase base = border.getObject(2);
48+
if (base instanceof COSNumber)
49+
{
50+
ab.width = ((COSNumber) base).floatValue();
51+
}
4852
}
4953
if (border.size() > 3)
5054
{
@@ -58,11 +62,12 @@ static AnnotationBorder getAnnotationBorder(PDAnnotation annotation,
5862
else
5963
{
6064
ab.width = borderStyle.getWidth();
61-
if (borderStyle.getStyle().equals(PDBorderStyleDictionary.STYLE_DASHED))
65+
String style = borderStyle.getStyle();
66+
if (style.equals(PDBorderStyleDictionary.STYLE_DASHED))
6267
{
6368
ab.dashArray = borderStyle.getDashStyle().getDashArray();
6469
}
65-
if (borderStyle.getStyle().equals(PDBorderStyleDictionary.STYLE_UNDERLINE))
70+
if (style.equals(PDBorderStyleDictionary.STYLE_UNDERLINE))
6671
{
6772
ab.underline = true;
6873
}

0 commit comments

Comments
 (0)