pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1775058 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
Date Mon, 19 Dec 2016 11:24:21 GMT
Author: tilman
Date: Mon Dec 19 11:24:21 2016
New Revision: 1775058

URL: http://svn.apache.org/viewvc?rev=1775058&view=rev
Log:
PDFBOX-2852: simplify code

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java?rev=1775058&r1=1775057&r2=1775058&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNumberTreeNode.java
Mon Dec 19 11:24:21 2016
@@ -109,7 +109,7 @@ public class PDNumberTreeNode implements
      */
     public void setKids( List<? extends PDNumberTreeNode> kids )
     {
-        if (kids != null && kids.size() > 0)
+        if (kids != null && !kids.isEmpty())
         {
             PDNumberTreeNode firstKid = kids.get(0);
             PDNumberTreeNode lastKid = kids.get(kids.size() - 1);
@@ -135,33 +135,30 @@ public class PDNumberTreeNode implements
      *
      * @throws IOException If there is a problem creating the values.
      */
-    public Object getValue( Integer index ) throws IOException
+    public Object getValue(Integer index) throws IOException
     {
-        Object retval = null;
-        Map<Integer,COSObjectable> names = getNumbers();
-        if( names != null )
+        Map<Integer, COSObjectable> names = getNumbers();
+        if (names != null)
         {
-            retval = names.get( index );
+            return names.get(index);
         }
-        else
+        Object retval = null;
+        List<PDNumberTreeNode> kids = getKids();
+        if (kids != null)
         {
-            List<PDNumberTreeNode> kids = getKids();
-            if ( kids != null )
+            for (int i = 0; i < kids.size() && retval == null; i++)
             {
-                for( int i=0; i<kids.size() && retval == null; i++ )
+                PDNumberTreeNode childNode = kids.get(i);
+                if (childNode.getLowerLimit().compareTo(index) <= 0 &&
+                    childNode.getUpperLimit().compareTo(index) >= 0)
                 {
-                    PDNumberTreeNode childNode = kids.get( i );
-                    if( childNode.getLowerLimit().compareTo( index ) <= 0 &&
-                        childNode.getUpperLimit().compareTo( index ) >= 0 )
-                    {
-                        retval = childNode.getValue( index );
-                    }
+                    retval = childNode.getValue(index);
                 }
             }
-            else
-            {
-                LOG.warn("NumberTreeNode does not have \"nums\" nor \"kids\" objects.");
-            }
+        }
+        else
+        {
+            LOG.warn("NumberTreeNode does not have \"nums\" nor \"kids\" objects.");
         }
         return retval;
     }
@@ -256,7 +253,7 @@ public class PDNumberTreeNode implements
             }
             Integer lower = null;
             Integer upper = null;
-            if( keys.size() > 0 )
+            if (!keys.isEmpty())
             {
                 lower = keys.get( 0 );
                 upper = keys.get( keys.size()-1 );



Mime
View raw message