You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/01/05 02:48:50 UTC

svn commit: r1850454 - in /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common: PDNameTreeNode.java PDNumberTreeNode.java

Author: tilman
Date: Sat Jan  5 02:48:50 2019
New Revision: 1850454

URL: http://svn.apache.org/viewvc?rev=1850454&view=rev
Log:
PDFBOX-4071: correct javadoc + rename variables

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java
    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/PDNameTreeNode.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java?rev=1850454&r1=1850453&r2=1850454&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java Sat Jan  5 02:48:50 2019
@@ -295,11 +295,10 @@ public abstract class PDNameTreeNode<T e
     protected abstract PDNameTreeNode<T> createChildNode( COSDictionary dic );
 
     /**
-     * Set the names of for this node.  The keys should be java.lang.String and the
-     * values must be a COSObjectable.  This method will set the appropriate upper and lower
-     * limits based on the keys in the map.
+     * Set the names for this node. This method will set the appropriate upper and lower limits
+     * based on the keys in the map.
      *
-     * @param names map of names to objects, or <code>null</code>
+     * @param names map of names to objects, or <code>null</code> for nothing.
      */
     public void setNames( Map<String, T> names )
     {

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=1850454&r1=1850453&r2=1850454&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 Sat Jan  5 02:48:50 2019
@@ -59,7 +59,7 @@ public class PDNumberTreeNode implements
     /**
      * Constructor.
      *
-     * @param dict The dictionary that holds the name information.
+     * @param dict The dictionary that holds the number information.
      * @param valueClass The PD Model type of object that is the value.
      */
     public PDNumberTreeNode( COSDictionary dict, Class<? extends COSObjectable> valueClass )
@@ -136,10 +136,10 @@ public class PDNumberTreeNode implements
      */
     public Object getValue(Integer index) throws IOException
     {
-        Map<Integer, COSObjectable> names = getNumbers();
-        if (names != null)
+        Map<Integer, COSObjectable> numbers = getNumbers();
+        if (numbers != null)
         {
-            return names.get(index);
+            return numbers.get(index);
         }
         Object retval = null;
         List<PDNumberTreeNode> kids = getKids();
@@ -177,18 +177,18 @@ public class PDNumberTreeNode implements
         COSBase numBase = node.getDictionaryObject(COSName.NUMS);
         if (numBase instanceof COSArray)
         {
-            COSArray namesArray = (COSArray) numBase;        
-            indices = new HashMap<Integer,COSObjectable>();
-            for( int i=0; i<namesArray.size(); i+=2 )
+            COSArray numbersArray = (COSArray) numBase;
+            indices = new HashMap<Integer, COSObjectable>();
+            for (int i = 0; i < numbersArray.size(); i += 2)
             {
-                COSBase base = namesArray.getObject(i);
+                COSBase base = numbersArray.getObject(i);
                 if (!(base instanceof COSInteger))
                 {
                     LOG.error("page labels ignored, index " + i + " should be a number, but is " + base);
                     return null;
                 }
                 COSInteger key = (COSInteger) base;
-                COSBase cosValue = namesArray.getObject( i+1 );
+                COSBase cosValue = numbersArray.getObject(i + 1);
                 COSObjectable pdValue = convertCOSToPD( cosValue );
                 indices.put( key.intValue(), pdValue );
             }
@@ -198,16 +198,17 @@ public class PDNumberTreeNode implements
     }
 
     /**
-     * Method to convert the COS value in the name tree to the PD Model object.  The
-     * default implementation will simply use reflection to create the correct object
-     * type.  Subclasses can do whatever they want.
+     * Method to convert the COS value in the number tree to the PD Model object. The default
+     * implementation will simply use reflection to create the correct object type. Subclasses can
+     * do whatever they want.
      *
      * @param base The COS object to convert.
      * @return The converted PD Model object.
      * @throws IOException If there is an error during creation.
      */
-    protected COSObjectable convertCOSToPD( COSBase base ) throws IOException
+    protected COSObjectable convertCOSToPD(COSBase base) throws IOException
     {
+        // valueType (passed in constructor here) must have a constructor of type of COSBase as parameter
         try
         {
             return valueType.getDeclaredConstructor(base.getClass()).newInstance(base);
@@ -230,11 +231,10 @@ public class PDNumberTreeNode implements
     }
 
     /**
-     * Set the names of for this node.  The keys should be java.lang.String and the
-     * values must be a COSObjectable.  This method will set the appropriate upper and lower
-     * limits based on the keys in the map.
+     * Set the numbers for this node. This method will set the appropriate upper and lower limits
+     * based on the keys in the map.
      *
-     * @param numbers The map of names to objects.
+     * @param numbers The map of numbers to objects, or <code>null</code> for nothing.
      */
     public void setNumbers( Map<Integer, ? extends COSObjectable> numbers )
     {
@@ -268,7 +268,7 @@ public class PDNumberTreeNode implements
     }
 
     /**
-     * Get the highest value for a key in the name map.
+     * Get the highest value for a key in the number map.
      *
      * @return The highest value for a key in the map.
      */
@@ -309,7 +309,7 @@ public class PDNumberTreeNode implements
     }
 
     /**
-     * Get the lowest value for a key in the name map.
+     * Get the lowest value for a key in the number map.
      *
      * @return The lowest value for a key in the map.
      */