Author: tilman
Date: Sat Sep 17 15:41:54 2016
New Revision: 1761253

URL: http://svn.apache.org/viewvc?rev=1761253&view=rev
Log:
PDFBOX-2852: make inner classes static + optimize bit operations, as suggested 
by Simon Steiner

Modified:
    
pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/PDFTreeCellRenderer.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
    
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/AccessPermission.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptor.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java

Modified: 
pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/PDFTreeCellRenderer.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/PDFTreeCellRenderer.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- 
pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/PDFTreeCellRenderer.java
 (original)
+++ 
pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/PDFTreeCellRenderer.java
 Sat Sep 17 15:41:54 2016
@@ -329,7 +329,7 @@ public class PDFTreeCellRenderer extends
     /**
      * An ImageIcon which allows other ImageIcon overlays.
      */
-    private class OverlayIcon extends ImageIcon
+    private static class OverlayIcon extends ImageIcon
     {
         private final ImageIcon base;
         private final List<ImageIcon> overlays;

Modified: 
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java 
(original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java 
Sat Sep 17 15:41:54 2016
@@ -742,7 +742,7 @@ public class CMapParser
     /**
      * Internal class.
      */
-    private final class LiteralName
+    private static final class LiteralName
     {
         private String name;
 
@@ -755,7 +755,7 @@ public class CMapParser
     /**
      * Internal class.
      */
-    private final class Operator
+    private static final class Operator
     {
         private String op;
 

Modified: 
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java 
(original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java 
Sat Sep 17 15:41:54 2016
@@ -623,7 +623,7 @@ public class CmapSubtable
      * Class used to manage CMap - Format 2.
      * 
      */
-    private class SubHeader
+    private static class SubHeader
     {
         private final int firstCode;
         private final int entryCount;

Modified: 
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- 
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java 
(original)
+++ 
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/KerningSubtable.java 
Sat Sep 17 15:41:54 2016
@@ -248,14 +248,14 @@ public class KerningSubtable
         return (bits & mask) >> shift;
     }
 
-    private abstract static class PairData
+    private static interface PairData
     {
-        public abstract void read(TTFDataStream data) throws IOException;
+        abstract void read(TTFDataStream data) throws IOException;
 
-        public abstract int getKerning(int l, int r);
+        abstract int getKerning(int l, int r);
     }
 
-    private static class PairData0Format0 extends PairData implements 
Comparator<int[]>
+    private static class PairData0Format0 implements Comparator<int[]>, 
PairData
     {
         private int searchRange;
         private int[][] pairs;

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXRefStream.java
 Sat Sep 17 15:41:54 2016
@@ -317,7 +317,7 @@ public class PDFXRefStream implements PD
      * A class representing an object stream reference. 
      *
      */
-    class ObjectStreamReference
+    static class ObjectStreamReference
     {
         long objectNumberOfObjectStream;
         long offset;
@@ -327,7 +327,7 @@ public class PDFXRefStream implements PD
      * A class representing a normal reference. 
      *
      */
-    class NormalReference
+    static class NormalReference
     {
         int genNumber;
         long offset;
@@ -337,7 +337,7 @@ public class PDFXRefStream implements PD
      * A class representing a free reference. 
      *
      */
-    class FreeReference
+    static class FreeReference
     {
         int nextGenNumber;
         long nextFree;

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java
 Sat Sep 17 15:41:54 2016
@@ -59,7 +59,7 @@ public class XrefTrailerResolver
     /**
      * A class which represents a xref/trailer object.
      */
-    private class XrefTrailerObj
+    private static class XrefTrailerObj
     {
         protected COSDictionary trailer = null;
 

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/AccessPermission.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/AccessPermission.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/AccessPermission.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/AccessPermission.java
 Sat Sep 17 15:41:54 2016
@@ -49,7 +49,7 @@ package org.apache.pdfbox.pdmodel.encryp
 public class AccessPermission
 {
 
-    private static final int DEFAULT_PERMISSIONS = 0xFFFFFFFF ^ 3;//bits 0 & 1 
need to be zero
+    private static final int DEFAULT_PERMISSIONS = ~3; //bits 0 & 1 need to be 
zero
     private static final int PRINT_BIT = 3;
     private static final int MODIFICATION_BIT = 4;
     private static final int EXTRACT_BIT = 5;
@@ -115,7 +115,7 @@ public class AccessPermission
         }
         else
         {
-            permissions = permissions & (0xFFFFFFFF ^ (1 << (bit-1)));
+            permissions = permissions & (~(1 << (bit - 1)));
         }
         bytes = permissions;
 

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
 Sat Sep 17 15:41:54 2016
@@ -666,7 +666,7 @@ final class FontMapperImpl implements Fo
     /**
      * A potential match for a font substitution.
      */
-    private class FontMatch implements Comparable<FontMatch>
+    private static class FontMatch implements Comparable<FontMatch>
     {
         double score;
         final FontInfo info;

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptor.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptor.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptor.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontDescriptor.java
 Sat Sep 17 15:41:54 2016
@@ -262,7 +262,7 @@ public final class PDFontDescriptor impl
         }
         else
         {
-            flags = flags & (0xFFFFFFFF ^ bit);
+            flags = flags & (~bit);
         }
         setFlags( flags );
     }

Modified: 
pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java?rev=1761253&r1=1761252&r2=1761253&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java 
(original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java 
Sat Sep 17 15:41:54 2016
@@ -882,7 +882,7 @@ public class DomXmpParser
         }
     }
 
-    protected class NamespaceFinder
+    protected static class NamespaceFinder
     {
 
         private final Stack<Map<String, String>> stack = new Stack<Map<String, 
String>>();


Reply via email to