pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1688730 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java
Date Wed, 01 Jul 2015 20:33:38 GMT
Author: msahyoun
Date: Wed Jul  1 20:33:38 2015
New Revision: 1688730

URL: http://svn.apache.org/r1688730
Log:
PDFBOX-2851: resolve fixme comment in getExportValue method

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java?rev=1688730&r1=1688729&r2=1688730&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java
Wed Jul  1 20:33:38 2015
@@ -24,7 +24,6 @@ import java.util.Set;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry;
@@ -92,7 +91,7 @@ public final class PDRadioButton extends
      * A RadioButton might have an export value to allow field values
      * which can not be encoded as PDFDocEncoding or for the same export value 
      * being assigned to multiple RadioButtons in a group.<br/>
-     * To define an export value the RadioButton must define options {@link #setOptions(List)}
+     * To define an export value the RadioButton must define options {@link #setExportValues(List)}
      * which correspond to the individual items within the RadioButton.</p>
      * <p>
      * The method will either return the value from the options entry or in case there
@@ -103,32 +102,20 @@ public final class PDRadioButton extends
      */
     public String getExportValue() throws IOException
     {
-        List<String> options = getOptions();
-        if (options.isEmpty())
+        List<String> exportValues = getExportValues();
+        if (exportValues.isEmpty())
         {
             return getValue();
         }
         else
         {
             String fieldValue = getValue();
-            List<PDAnnotationWidget> kids = getWidgets();
-            int idx = 0;
-            for (COSObjectable kid : kids)
-            {
-                // fixme: this is always false, because it's kids are always widgets, not
fields.
-                /*if (kid instanceof PDCheckbox)
-                {
-                    PDCheckbox btn = (PDCheckbox) kid;
-                    if (btn.getOnValue().equals(fieldValue))
-                    {
-                        break;
-                    }
-                    idx++;
-                }*/
-            }
-            if (idx <= options.size())
+            List<String> onValues = getOnValues();
+            int idx = onValues.indexOf(fieldValue);
+            
+            if (idx != -1 && idx < exportValues.size())
             {
-                return options.get(idx);
+                return exportValues.get(idx);
             }
         }
         return "";
@@ -227,8 +214,7 @@ public final class PDRadioButton extends
         {
             dictionary.setName(COSName.DV, value);
         }
-    }
-    
+    }    
     
     /**
      * Get the List of values to set individual radio buttons to the on state.
@@ -267,7 +253,6 @@ public final class PDRadioButton extends
             }
         }
         return onValues;
-    }
-    
+    }  
     
 }



Mime
View raw message