pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1803702 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
Date Tue, 01 Aug 2017 20:23:56 GMT
Author: tilman
Date: Tue Aug  1 20:23:55 2017
New Revision: 1803702

URL: http://svn.apache.org/viewvc?rev=1803702&view=rev
Log:
PDFBOX-2852: remove unneeded nullcheck; remove dead store; use entrySet

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java?rev=1803702&r1=1803701&r2=1803702&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java Tue Aug 
1 20:23:55 2017
@@ -1305,9 +1305,9 @@ public class COSParser extends BaseParse
             {
                 List<COSObjectKey> objStreams = new ArrayList<>();
                 // find all object streams
-                for (COSObjectKey key : xrefOffset.keySet())
+                for (Entry<COSObjectKey, Long> entry : xrefOffset.entrySet())
                 {
-                    Long offset = xrefOffset.get(key);
+                    Long offset = entry.getValue();
                     if (offset != null && offset < 0)
                     {
                         COSObjectKey objStream = new COSObjectKey(-offset, 0);
@@ -1705,7 +1705,6 @@ public class COSParser extends BaseParse
                                     // is the next char a digit?
                                     if (isDigit(genID))
                                     {
-                                        genID -= 48;
                                         tempOffset--;
                                         source.seek(tempOffset);
                                         if (isSpace())
@@ -1788,27 +1787,24 @@ public class COSParser extends BaseParse
                         continue;
                     }
                     COSDictionary dictionary = parseCOSDictionary();
-                    if (dictionary != null)
+                    // document catalog
+                    if (isCatalog(dictionary))
                     {
-                        // document catalog
-                        if (isCatalog(dictionary))
-                        {
-                            trailer.setItem(COSName.ROOT, document.getObjectFromPool(entry.getKey()));
-                        }
-                        // info dictionary
-                        else if (dictionary.containsKey(COSName.MOD_DATE) && 
-                                (dictionary.containsKey(COSName.TITLE)
-                                || dictionary.containsKey(COSName.AUTHOR)
-                                || dictionary.containsKey(COSName.SUBJECT)
-                                || dictionary.containsKey(COSName.KEYWORDS)
-                                || dictionary.containsKey(COSName.CREATOR)
-                                || dictionary.containsKey(COSName.PRODUCER)
-                                || dictionary.containsKey(COSName.CREATION_DATE)))
-                        {
-                            trailer.setItem(COSName.INFO, document.getObjectFromPool(entry.getKey()));
-                        }
-                        // TODO encryption dictionary
+                        trailer.setItem(COSName.ROOT, document.getObjectFromPool(entry.getKey()));
+                    }
+                    // info dictionary
+                    else if (dictionary.containsKey(COSName.MOD_DATE) && 
+                            (dictionary.containsKey(COSName.TITLE)
+                            || dictionary.containsKey(COSName.AUTHOR)
+                            || dictionary.containsKey(COSName.SUBJECT)
+                            || dictionary.containsKey(COSName.KEYWORDS)
+                            || dictionary.containsKey(COSName.CREATOR)
+                            || dictionary.containsKey(COSName.PRODUCER)
+                            || dictionary.containsKey(COSName.CREATION_DATE)))
+                    {
+                        trailer.setItem(COSName.INFO, document.getObjectFromPool(entry.getKey()));
                     }
+                    // TODO encryption dictionary
                 }
                 catch(IOException exception)
                 {



Mime
View raw message