pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1621477 - in /pdfbox/branches/1.8: examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
Date Sat, 30 Aug 2014 16:03:41 GMT
Author: lehmi
Date: Sat Aug 30 16:03:41 2014
New Revision: 1621477

URL: http://svn.apache.org/r1621477
Log:
PDFBOX-2270: optimized handling of null values

Modified:
    pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java

Modified: pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java?rev=1621477&r1=1621476&r2=1621477&view=diff
==============================================================================
--- pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
(original)
+++ pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
Sat Aug 30 16:03:41 2014
@@ -63,15 +63,18 @@ public class PrintFields
     private void processField(PDField field, String sLevel, String sParent) throws IOException
     {
         List<COSObjectable> kids = field.getKids();
+        String partialName = field.getPartialName();
         if (kids != null)
         {
             Iterator<COSObjectable> kidsIter = kids.iterator();
-            if (!sParent.equals(field.getPartialName()))
+            if (!sParent.equals(partialName))
             {
-                sParent = sParent + "." + field.getPartialName();
+                if (partialName != null)
+                {
+                    sParent = sParent + "." + partialName;
+                }
             }
             System.out.println(sLevel + sParent);
-            // System.out.println(sParent + " is of type " + field.getClass().getName());
             while (kidsIter.hasNext())
             {
                 Object pdfObj = kidsIter.next();
@@ -92,10 +95,22 @@ public class PrintFields
             }
             else
             {
-                fieldValue = field.getValue();
+                if (field.getValue() != null)
+                {
+                    fieldValue = field.getValue();
+                }
+                else
+                {
+                    fieldValue = "no value available";
+                }
+            }
+            StringBuilder outputString = new StringBuilder(sLevel + sParent);
+            if (partialName != null)
+            {
+                outputString.append( "." + partialName);
             }
-            String outputString = sLevel + sParent + "." + field.getPartialName() + " = "
+ fieldValue + ",  type="
-                    + field.getClass().getName();
+            outputString.append(" = " + fieldValue);
+            outputString.append(",  type=" + field.getClass().getName());
             System.out.println(outputString);
         }
     }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java?rev=1621477&r1=1621476&r2=1621477&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
Sat Aug 30 16:03:41 2014
@@ -120,7 +120,14 @@ public abstract class PDField implements
         String finalName = getPartialName();
         if (parentName != null)
         {
-            finalName = parentName + "." + finalName;
+            if (finalName != null)
+            {
+                finalName = parentName + "." + finalName;
+            }
+            else
+            {
+                finalName = parentName;
+            }
         }
         return finalName;
     }



Mime
View raw message