xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spepp...@apache.org
Subject svn commit: r1033859 - in /xmlgraphics/fop/trunk: build.xml src/java/org/apache/fop/fonts/EncodingMode.java src/java/org/apache/fop/fonts/FontInfoConfigurator.java test/java/org/apache/fop/fonts/EncodingModeTest.java
Date Thu, 11 Nov 2010 09:48:25 GMT
Author: spepping
Date: Thu Nov 11 09:48:24 2010
New Revision: 1033859

URL: http://svn.apache.org/viewvc?rev=1033859&view=rev
Log:
Applied patch 50240 by Mehdi Houshmand with changes: Java source and
target changed to 1.5. EncodingMode changed from class -> enum.

Added:
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java   (with props)
Modified:
    xmlgraphics/fop/trunk/build.xml
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EncodingMode.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfoConfigurator.java

Modified: xmlgraphics/fop/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/build.xml?rev=1033859&r1=1033858&r2=1033859&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/build.xml (original)
+++ xmlgraphics/fop/trunk/build.xml Thu Nov 11 09:48:24 2010
@@ -149,8 +149,8 @@ list of possible build targets.
   <property name="javac.debug" value="on"/>
   <property name="javac.optimize" value="off"/>
   <property name="javac.deprecation" value="on"/>
-  <property name="javac.source" value="1.4"/>
-  <property name="javac.target" value="1.4"/>
+  <property name="javac.source" value="1.5"/>
+  <property name="javac.target" value="1.5"/>
   <property name="javac.fork" value="no"/>
   <property name="junit.fork" value="on"/>
   <property name="junit.haltonfailure" value="off"/>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EncodingMode.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EncodingMode.java?rev=1033859&r1=1033858&r2=1033859&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EncodingMode.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/EncodingMode.java Thu Nov 11 09:48:24
2010
@@ -19,25 +19,19 @@
 
 package org.apache.fop.fonts;
 
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-
-
 /**
  * This class enumerates all supported encoding modes for fonts: auto, single-byte and CID.
  */
-public final class EncodingMode implements Serializable {
-
-    private static final long serialVersionUID = 8311486102457779529L;
+public enum EncodingMode {
 
     /** Automatic selection of encoding mode. */
-    public static final EncodingMode AUTO = new EncodingMode("auto");
+    AUTO("auto"),
 
     /** Single-byte encoding */
-    public static final EncodingMode SINGLE_BYTE = new EncodingMode("single-byte");
+    SINGLE_BYTE("single-byte"),
 
     /** CID encoding */
-    public static final EncodingMode CID = new EncodingMode("cid");
+    CID("cid");
 
     private String name;
 
@@ -58,25 +52,18 @@ public final class EncodingMode implemen
      * @param name the name of the encoding mode to look up
      * @return the encoding mode constant
      */
-    public static EncodingMode valueOf(String name) {
-        if (name.equalsIgnoreCase(EncodingMode.AUTO.getName())) {
-            return EncodingMode.AUTO;
-        } else if (name.equalsIgnoreCase(EncodingMode.SINGLE_BYTE.getName())) {
-            return EncodingMode.SINGLE_BYTE;
-        } else if (name.equalsIgnoreCase(EncodingMode.CID.getName())) {
-            return EncodingMode.CID;
-        } else {
-            throw new IllegalArgumentException("Invalid encoding mode: " + name);
+    public static EncodingMode getEncodingMode(String name) {
+        for (EncodingMode em : EncodingMode.values()) {
+            if (name.equalsIgnoreCase(em.getName())) {
+                return em;
+            }
         }
-    }
-
-    private Object readResolve() throws ObjectStreamException {
-        return valueOf(getName());
+        throw new IllegalArgumentException("Invalid encoding mode: " + name);
     }
 
     /** {@inheritDoc} */
     public String toString() {
-        return "EncodingMode:" + getName();
+        return "EncodingMode: " + getName();
     }
 
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfoConfigurator.java?rev=1033859&r1=1033858&r2=1033859&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfoConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfoConfigurator.java Thu Nov
11 09:48:24 2010
@@ -254,7 +254,7 @@ public class FontInfoConfigurator {
         }
 
         boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
-        EncodingMode encodingMode = EncodingMode.valueOf(
+        EncodingMode encodingMode = EncodingMode.getEncodingMode(
                 fontCfg.getAttribute("encoding-mode", EncodingMode.AUTO.getName()));
         EmbedFontInfo embedFontInfo
                 = new EmbedFontInfo(metricsUrl, useKerning, tripletList, embedUrl, subFont);

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java?rev=1033859&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java Thu Nov 11
09:48:24 2010
@@ -0,0 +1,17 @@
+package org.apache.fop.fonts;
+
+import junit.framework.TestCase;
+
+public class EncodingModeTest extends TestCase {
+	public void testGetName() {
+		assertEquals("auto", EncodingMode.AUTO.getName());
+		assertEquals("single-byte", EncodingMode.SINGLE_BYTE.getName());
+		assertEquals("cid", EncodingMode.CID.getName());
+	}
+	
+	public void testGetValue() {
+		assertEquals(EncodingMode.AUTO, EncodingMode.getEncodingMode("auto"));
+		assertEquals(EncodingMode.SINGLE_BYTE, EncodingMode.getEncodingMode("single-byte"));
+		assertEquals(EncodingMode.CID, EncodingMode.getEncodingMode("cid"));
+	}
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/fonts/EncodingModeTest.java
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message