pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1848232 - in /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel: PageLayout.java PageMode.java graphics/state/RenderingIntent.java
Date Wed, 05 Dec 2018 18:42:27 GMT
Author: tilman
Date: Wed Dec  5 18:42:27 2018
New Revision: 1848232

URL: http://svn.apache.org/viewvc?rev=1848232&view=rev
Log:
PDFBOX-4397: avoid duplicate strings

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageLayout.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageMode.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntent.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageLayout.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageLayout.java?rev=1848232&r1=1848231&r2=1848232&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageLayout.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageLayout.java Wed
Dec  5 18:42:27 2018
@@ -44,29 +44,12 @@ public enum PageLayout
 
     public static PageLayout fromString(String value)
     {
-        if (value.equals("SinglePage"))
+        for (PageLayout instance : PageLayout.values())
         {
-            return SINGLE_PAGE;
-        }
-        else if (value.equals("OneColumn"))
-        {
-            return ONE_COLUMN;
-        }
-        else if (value.equals("TwoColumnLeft"))
-        {
-            return TWO_COLUMN_LEFT;
-        }
-        else if (value.equals("TwoColumnRight"))
-        {
-            return TWO_COLUMN_RIGHT;
-        }
-        else if (value.equals("TwoPageLeft"))
-        {
-            return TWO_PAGE_LEFT;
-        }
-        else if (value.equals("TwoPageRight"))
-        {
-            return TWO_PAGE_RIGHT;
+            if (instance.value.equals(value))
+            {
+                return instance;
+            }
         }
         throw new IllegalArgumentException(value);
     }
@@ -80,8 +63,6 @@ public enum PageLayout
 
     /**
      * Returns the string value, as used in a PDF file.
-     *
-     * @return the string value.
      */
     public String stringValue()
     {

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageMode.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageMode.java?rev=1848232&r1=1848231&r2=1848232&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageMode.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PageMode.java Wed Dec
 5 18:42:27 2018
@@ -44,29 +44,12 @@ public enum PageMode
 
     public static PageMode fromString(String value)
     {
-        if (value.equals("UseNone"))
+        for (PageMode instance : PageMode.values())
         {
-            return USE_NONE;
-        }
-        else if (value.equals("UseOutlines"))
-        {
-            return USE_OUTLINES;
-        }
-        else if (value.equals("UseThumbs"))
-        {
-            return USE_THUMBS;
-        }
-        else if (value.equals("FullScreen"))
-        {
-            return FULL_SCREEN;
-        }
-        else if (value.equals("UseOC"))
-        {
-            return USE_OPTIONAL_CONTENT;
-        }
-        else if (value.equals("UseAttachments"))
-        {
-            return USE_ATTACHMENTS;
+            if (instance.value.equals(value))
+            {
+                return instance;
+            }
         }
         throw new IllegalArgumentException(value);
     }

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntent.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntent.java?rev=1848232&r1=1848231&r2=1848232&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntent.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/RenderingIntent.java
Wed Dec  5 18:42:27 2018
@@ -46,23 +46,14 @@ public enum RenderingIntent
 
     public static RenderingIntent fromString(String value)
     {
-        if (value.equals("AbsoluteColorimetric"))
+        for (RenderingIntent instance : RenderingIntent.values())
         {
-            return ABSOLUTE_COLORIMETRIC;
+            if (instance.value.equals(value))
+            {
+                return instance;
+            }
         }
-        else if (value.equals("RelativeColorimetric"))
-        {
-          return RELATIVE_COLORIMETRIC;
-        }
-        else if (value.equals("Saturation"))
-        {
-          return SATURATION;
-        }
-        else if (value.equals("Perceptual"))
-        {
-          return PERCEPTUAL;
-        }
-        // "If a conforming reader does not recognize the specified name, 
+        // "If a conforming reader does not recognize the specified name,
         // it shall use the RelativeColorimetric intent by default."
         return RELATIVE_COLORIMETRIC;
     }



Mime
View raw message