pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1867479 - in /pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff: CharStringHandler.java Type1CharString.java Type2CharString.java
Date Tue, 24 Sep 2019 17:53:18 GMT
Author: tilman
Date: Tue Sep 24 17:53:18 2019
New Revision: 1867479

URL: http://svn.apache.org/viewvc?rev=1867479&view=rev
Log:
PDFBOX-4071: turn abstract class into interface + use member reference

Modified:
    pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/CharStringHandler.java
    pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java
    pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java

Modified: pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/CharStringHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/CharStringHandler.java?rev=1867479&r1=1867478&r2=1867479&view=diff
==============================================================================
--- pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/CharStringHandler.java
(original)
+++ pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/CharStringHandler.java
Tue Sep 24 17:53:18 2019
@@ -27,7 +27,7 @@ import java.util.Stack;
  * @author John Hewson
  * 
  */
-public abstract class CharStringHandler
+public interface CharStringHandler
 {
     /**
      * Handler for a sequence of CharStringCommands.
@@ -35,22 +35,22 @@ public abstract class CharStringHandler
      * @param sequence of CharStringCommands
      *
      */
-    public List<Number> handleSequence(List<Object> sequence)
+    default List<Number> handleSequence(List<Object> sequence)
     {
         Stack<Number> stack = new Stack<>();
-        for (Object obj : sequence)
+        sequence.forEach(obj ->
         {
             if (obj instanceof CharStringCommand)
             {
-                List<Number> results = handleCommand(stack, (CharStringCommand)obj);
+                List<Number> results = handleCommand(stack, (CharStringCommand) obj);
                 stack.clear();  // this is basically returning the new stack
                 stack.addAll(results);
             }
             else
             {
-                stack.push((Number)obj);
+                stack.push((Number) obj);
             }
-        }
+        });
         return stack;
     }
 

Modified: pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java?rev=1867479&r1=1867478&r2=1867479&view=diff
==============================================================================
--- pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java
(original)
+++ pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java
Tue Sep 24 17:53:18 2019
@@ -153,13 +153,7 @@ public class Type1CharString
         path = new GeneralPath();
         leftSideBearing = new Point2D.Float(0, 0);
         width = 0;
-        CharStringHandler handler = new CharStringHandler() {
-            @Override
-            public List<Number> handleCommand(List<Number> numbers, CharStringCommand
command)
-            {
-                return Type1CharString.this.handleCommand(numbers, command);
-            }
-        };
+        CharStringHandler handler = Type1CharString.this::handleCommand;
         handler.handleSequence(type1Sequence);
     }
 

Modified: pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java?rev=1867479&r1=1867478&r2=1867479&view=diff
==============================================================================
--- pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java
(original)
+++ pdfbox/branches/issue4569/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java
Tue Sep 24 17:53:18 2019
@@ -82,13 +82,7 @@ public class Type2CharString extends Typ
     {
         type1Sequence = new ArrayList<>();
         pathCount = 0;
-        CharStringHandler handler = new CharStringHandler() {
-            @Override
-            public List<Number> handleCommand(List<Number> numbers, CharStringCommand
command)
-            {
-                return Type2CharString.this.handleCommand(numbers, command);
-            }
-        };
+        CharStringHandler handler = Type2CharString.this::handleCommand;
         handler.handleSequence(sequence);
     }
 



Mime
View raw message