pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1652655 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form: PDButton.java PDPushButton.java
Date Sat, 17 Jan 2015 19:04:23 GMT
Author: msahyoun
Date: Sat Jan 17 19:04:23 2015
New Revision: 1652655

URL: http://svn.apache.org/r1652655
Log:
PDFBOX-2516 complete using java native types; enhance javadoc

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java?rev=1652655&r1=1652654&r2=1652655&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
Sat Jan 17 19:04:23 2015
@@ -101,9 +101,9 @@ public abstract class PDButton extends P
      * from the appearance directory.
      *
      * The default value is used to represent the initial state of the
-     * checkbox or to revert when resetting the form.
+     * field or to revert when resetting the form.
      * 
-     * @param defaultValue the COSName object to set the field value.
+     * @param defaultValue the new field value.
      */
     @Override
     public void setDefaultValue(String defaultValue)
@@ -154,11 +154,11 @@ public abstract class PDButton extends P
      * This will set the options.
      * 
      * @see #getOptions()
-     * @param values List containing all possible options. Supplying null will remove the
Opt entry.
+     * @param values List containing all possible options. Supplying null or an empty list
will remove the Opt entry.
      */
     public void setOptions(List<String> values)
     {
-        if (values == null)
+        if (values == null || values.isEmpty())
         {
             removeInheritableAttribute(COSName.OPT);            
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDPushButton.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDPushButton.java?rev=1652655&r1=1652654&r2=1652655&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDPushButton.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDPushButton.java
Sat Jan 17 19:04:23 2015
@@ -42,43 +42,95 @@ public class PDPushButton extends PDButt
         super(theAcroForm, field, parentNode);
     }
     
+    /**
+     * Get the fields default value.
+     * 
+     * A push button field does not have a field value.
+     * 
+     * @return This will always return an empty string.
+     */
     @Override
     public String getDefaultValue()
     {
         // PushButton fields don't support the "DV" entry.
         return "";
     }    
-    
+
+    /**
+     * Set the fields default value.
+     * 
+     * A push button field does not have a field value.
+     * 
+     * @param defaultValue The field doesn't support setting any value
+     * @throws IllegalArgumentException when trying to set a value other than null
+     */
     @Override
     public void setDefaultValue(String defaultValue)
     {
-        throw new IllegalArgumentException("A PDPushButton shall not use the DV entry in
the field dictionary");
-        
-    }
-    
+        if (defaultValue != null && !defaultValue.isEmpty())
+        {
+            throw new IllegalArgumentException("A PDPushButton shall not use the DV entry
in the field dictionary");
+        }
+    }
+
+    /**
+     * Get the fields options.
+     * 
+     * A push button field does not have option value.
+     * 
+     * @return This will always return an empty List.
+     */
     @Override
     public List<String> getOptions()
     {
         return Collections.<String>emptyList();
     }
-    
+
+    /**
+     * Set the fields options.
+     * 
+     * A push button field does not have a option values.
+     * 
+     * @param values The field doesn't support setting any option value
+     * @throws IllegalArgumentException when trying to set the a value other than null or
an empty list.
+     */
     @Override
     public void setOptions(List<String> values)
     {
-        throw new IllegalArgumentException("A PDPushButton shall not use the Opt entry in
the field dictionary");
+        if (values != null && !values.isEmpty())
+        {
+            throw new IllegalArgumentException("A PDPushButton shall not use the Opt entry
in the field dictionary");
+        }
     }
     
-    
+    /**
+     * Get the fields value.
+     * 
+     * A push button field does not have field value.
+     * 
+     * @return This will always return an empty String.
+     */    
     @Override
-    public Object getValue()
+    public String getValue()
     {
         // PushButton fields don't support the "V" entry.
-        return null;
+        return "";
     }
-    
+
+    /**
+     * Set the fields value.
+     * 
+     * A push button field does not have a field value.
+     * 
+     * @param fieldValue The field doesn't support setting any field value.
+     * @throws IllegalArgumentException when trying to set the a value other than null or
an empty String.
+     */
     @Override
     public void setValue(String fieldValue)
     {
-        throw new IllegalArgumentException("A PDPushButton shall not use the V entry in the
field dictionary");
+        if (fieldValue != null && !fieldValue.isEmpty())
+        {
+            throw new IllegalArgumentException("A PDPushButton shall not use the V entry
in the field dictionary");
+        }
     }
 }



Mime
View raw message