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 2014/10/07 19:57:18 UTC

svn commit: r1629939 - in /pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font: Type3FontValidator.java descriptor/Type1DescriptorHelper.java

Author: tilman
Date: Tue Oct  7 17:57:18 2014
New Revision: 1629939

URL: http://svn.apache.org/r1629939
Log:
PDFBOX-2299: code + javadoc cleanup

Modified:
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java?rev=1629939&r1=1629938&r2=1629939&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java Tue Oct  7 17:57:18 2014
@@ -74,6 +74,7 @@ public class Type3FontValidator extends 
         this.font = font;
     }
 
+    @Override
     public void validate() throws ValidationException
     {
         checkMandatoryField();
@@ -103,7 +104,8 @@ public class Type3FontValidator extends 
     }
 
     /**
-     * Check that the FontBBox element has the right format as declared in the PDF reference document.
+     * Check that the FontBBox element has the right format as declared in the
+     * PDF reference document.
      */
     private void checkFontBBox()
     {
@@ -126,17 +128,15 @@ public class Type3FontValidator extends 
                     "The FontBBox element is invalid"));
             return;
         }
-        else
+        
+        for (int i = 0; i < 4; i++)
         {
-            for (int i = 0; i < 4; i++)
+            COSBase elt = bbox.get(i);
+            if (!(COSUtils.isFloat(elt, cosDocument) || COSUtils.isInteger(elt, cosDocument)))
             {
-                COSBase elt = bbox.get(i);
-                if (!(COSUtils.isFloat(elt, cosDocument) || COSUtils.isInteger(elt, cosDocument)))
-                {
-                    this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
-                            "An element of FontBBox isn't a number"));
-                    return;
-                }
+                this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
+                        "An element of FontBBox isn't a number"));
+                return;
             }
         }
     }
@@ -165,40 +165,38 @@ public class Type3FontValidator extends 
                     "The FontMatrix element is invalid"));
             return;
         }
-        else
+
+        for (int i = 0; i < 6; i++)
         {
-            for (int i = 0; i < 6; i++)
+            COSBase elt = matrix.get(i);
+            if (!(COSUtils.isFloat(elt, cosDocument) || COSUtils.isInteger(elt, cosDocument)))
             {
-                COSBase elt = matrix.get(i);
-                if (!(COSUtils.isFloat(elt, cosDocument) || COSUtils.isInteger(elt, cosDocument)))
-                {
-                    this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
-                            "An element of FontMatrix isn't a number"));
-                    return;
-                }
+                this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
+                        "An element of FontMatrix isn't a number"));
+                return;
             }
         }
     }
 
-    @Override
     /**
-     * For a Type3 font, the mapping between the Character Code and the Character
-     * name is entirely defined in the Encoding Entry. The Encoding Entry can be a
-     * Name (For the 5 predefined Encoding) or a Dictionary. If it is a
-     * dictionary, the "Differences" array contains the correspondence between a
-     * character code and a set of character name which are different from the
-     * encoding entry of the dictionary.
-     * 
+     * For a Type3 font, the mapping between the Character Code and the
+     * Character name is entirely defined in the Encoding Entry. The Encoding
+     * Entry can be a Name (For the 5 predefined Encoding) or a Dictionary. If
+     * it is a dictionary, the "Differences" array contains the correspondence
+     * between a character code and a set of character name which are different
+     * from the encoding entry of the dictionary.
+     *
      * This method checks that the encoding is :
      * <UL>
      * <li>An existing encoding name.
-     * <li>A dictionary with an existing encoding name (the name is optional) and
-     * a well formed "Differences" array (the array is optional)
+     * <li>A dictionary with an existing encoding name (the name is optional)
+     * and a well formed "Differences" array (the array is optional)
      * </UL>
-     * 
-     * At the end of this method, if the validation succeed the Font encoding is kept in the {@link #encoding} attribute
-     * @return
+     *
+     * At the end of this method, if the validation succeed the Font encoding is
+     * kept in the {@link #encoding} attribute
      */
+    @Override
     protected void checkEncoding()
     {
         COSBase fontEncoding = fontDictionary.getItem(COSName.ENCODING);

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java?rev=1629939&r1=1629938&r2=1629939&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java Tue Oct  7 17:57:18 2014
@@ -61,6 +61,7 @@ public class Type1DescriptorHelper exten
         super(context, font, fontContainer);
     }
 
+    @Override
     protected boolean checkMandatoryFields(COSDictionary fDescriptor)
     {
         boolean result = super.checkMandatoryFields(fDescriptor);
@@ -131,9 +132,9 @@ public class Type1DescriptorHelper exten
     }
 
     /**
-     * Try to load the font using the java.awt.font object. if the font is invalid, an exception will be pushed in the
-     * font container
-     * 
+     * Try to load the font using the java.awt.font object. if the font is
+     * invalid, an exception will be pushed in the font container
+     *
      * @param fontDescriptor
      * @param fontFile
      */