pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1861855 - /pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
Date Sat, 22 Jun 2019 12:13:30 GMT
Author: tilman
Date: Sat Jun 22 12:13:30 2019
New Revision: 1861855

URL: http://svn.apache.org/viewvc?rev=1861855&view=rev
Log:
PDFBOX-4071: Simplify code: null check for xobj isn't needed due to instanceof check; PDXObject.createXObject()
never returns null for non-null argument.

Modified:
    pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java

Modified: pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java?rev=1861855&r1=1861854&r2=1861855&view=diff
==============================================================================
--- pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
(original)
+++ pdfbox/branches/issue4569/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
Sat Jun 22 12:13:30 2019
@@ -202,39 +202,28 @@ public class ResourcesValidationProcess
     protected void validateXObjects(PreflightContext context, PDResources resources) throws
ValidationException
     {
         COSDictionary mapOfXObj = resources.getCOSObject().getCOSDictionary(COSName.XOBJECT);
-        if (mapOfXObj != null)
+        if (mapOfXObj == null)
         {
-            for (Entry<COSName, COSBase> entry : mapOfXObj.entrySet())
+            return;
+        }
+        for (Entry<COSName, COSBase> entry : mapOfXObj.entrySet())
+        {
+            COSBase xobj = entry.getValue();
+            if (xobj instanceof COSObject)
+            {
+                xobj = ((COSObject) xobj).getObject();
+            }
+            if (xobj instanceof COSStream)
             {
-                COSBase xobj = entry.getValue();
-                if (xobj != null)
+                try
+                {
+                    PDXObject pdXObject = PDXObject.createXObject(xobj, resources);
+                    ContextHelper.validateElement(context, pdXObject, GRAPHIC_PROCESS);
+                }
+                catch (IOException e)
                 {
-                    if (xobj instanceof COSObject)
-                    {
-                        xobj = ((COSObject) xobj).getObject();
-                    }
-                    if (xobj instanceof COSStream) 
-                    {
-                        try
-                        {
-                            COSStream stream = (COSStream) xobj;
-                            PDXObject pdXObject = PDXObject.createXObject(stream, resources);
-                            if (pdXObject != null)
-                            {
-                                ContextHelper.validateElement(context, pdXObject, GRAPHIC_PROCESS);
-                            }
-                            else
-                            {
-                                ContextHelper.validateElement(context, stream, GRAPHIC_PROCESS);
-                            }
-                        }
-                        catch (IOException e)
-                        {
-                            context.addValidationError(new ValidationError(ERROR_GRAPHIC_MAIN,
-                                    e.getMessage() + " for entry '"
-                                    + entry.getKey().getName() + "'", e));
-                        }
-                    }
+                    context.addValidationError(new ValidationError(ERROR_GRAPHIC_MAIN,
+                            e.getMessage() + " for entry '" + entry.getKey().getName() +
"'", e));
                 }
             }
         }



Mime
View raw message