diff options
author | Simon Pepping <spepping@apache.org> | 2010-11-11 09:48:24 +0000 |
---|---|---|
committer | Simon Pepping <spepping@apache.org> | 2010-11-11 09:48:24 +0000 |
commit | 1939c00e198dd9c45bc5847dd58f27485372934e (patch) | |
tree | 383c85f27f9c72268b9175a5ea7436da9451bfe3 /src/java | |
parent | 353cb3efa6ada2033a43eef693c6beabd2d9c3bf (diff) | |
download | xmlgraphics-fop-1939c00e198dd9c45bc5847dd58f27485372934e.tar.gz xmlgraphics-fop-1939c00e198dd9c45bc5847dd58f27485372934e.zip |
Applied patch 50240 by Mehdi Houshmand with changes: Java source and
target changed to 1.5. EncodingMode changed from class -> enum.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1033859 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/org/apache/fop/fonts/EncodingMode.java | 35 | ||||
-rw-r--r-- | src/java/org/apache/fop/fonts/FontInfoConfigurator.java | 2 |
2 files changed, 12 insertions, 25 deletions
diff --git a/src/java/org/apache/fop/fonts/EncodingMode.java b/src/java/org/apache/fop/fonts/EncodingMode.java index 734292c54..8a40d6593 100644 --- a/src/java/org/apache/fop/fonts/EncodingMode.java +++ b/src/java/org/apache/fop/fonts/EncodingMode.java @@ -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 implements Serializable { * @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(); } } diff --git a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java index f8399b110..9a11f84bc 100644 --- a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java @@ -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); |