From d256d57a583c1f49878b734e22ad75c2722e8956 Mon Sep 17 00:00:00 2001 From: Mehdi Houshmand Date: Tue, 3 Jul 2012 14:32:03 +0000 Subject: [PATCH] Check style and find bugs now pass without errors git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1356755 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/afp/modca/IncludedResourceObject.java | 3 +- .../fop/afp/util/AFPResourceAccessor.java | 12 ++-- .../org/apache/fop/apps/FopConfParser.java | 11 ++-- .../apache/fop/apps/FopFactoryBuilder.java | 2 +- .../fop/apps/io/ResourceResolverFactory.java | 7 ++- .../apache/fop/cli/CommandLineOptions.java | 1 + .../apache/fop/fonts/DefaultFontConfig.java | 2 +- .../fop/fonts/DefaultFontConfigurator.java | 22 +++---- src/java/org/apache/fop/fonts/FontCache.java | 2 +- src/java/org/apache/fop/fonts/FontLoader.java | 2 +- .../org/apache/fop/render/PrintRenderer.java | 5 -- .../fop/render/PrintRendererConfigurator.java | 15 +++-- .../apache/fop/render/afp/AFPFontConfig.java | 57 ++++++++++--------- .../fop/render/afp/AFPRendererConfig.java | 2 +- .../render/afp/AFPRendererConfigurator.java | 6 +- .../apache/fop/render/afp/AFPShadingMode.java | 3 +- .../fop/render/bitmap/PNGDocumentHandler.java | 1 - .../render/bitmap/TIFFDocumentHandler.java | 1 - .../AbstractIFDocumentHandler.java | 6 -- .../fop/render/pcl/PCLDocumentHandler.java | 2 - .../fop/render/pcl/PCLRenderingMode.java | 3 +- .../fop/render/pdf/PDFEncryptionOption.java | 2 - .../fop/render/pdf/PDFRendererOption.java | 4 +- .../render/pdf/PDFRendererOptionsConfig.java | 2 +- .../fop/render/print/PrintRendererMaker.java | 12 +--- .../fop/render/ps/PSDocumentHandler.java | 2 - .../fop/render/xml/XMLRendererMaker.java | 11 +--- .../org/apache/fop/servlet/FopServlet.java | 1 - .../org/apache/fop/util/ColorSpaceCache.java | 1 + .../fop/render/svg/SVGDocumentHandler.java | 1 - .../render/svg/SVGPrintDocumentHandler.java | 1 - 31 files changed, 82 insertions(+), 120 deletions(-) diff --git a/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java b/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java index 0d6e0bc09..9ab84a640 100644 --- a/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java +++ b/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java @@ -26,9 +26,8 @@ import java.net.URI; import org.apache.commons.io.IOUtils; -import org.apache.fop.afp.util.AFPResourceUtil; import org.apache.fop.afp.util.AFPResourceAccessor; - +import org.apache.fop.afp.util.AFPResourceUtil; /** * Encapsulates an included resource object that is loaded from an external file. diff --git a/src/java/org/apache/fop/afp/util/AFPResourceAccessor.java b/src/java/org/apache/fop/afp/util/AFPResourceAccessor.java index ddcfa001b..02691527e 100644 --- a/src/java/org/apache/fop/afp/util/AFPResourceAccessor.java +++ b/src/java/org/apache/fop/afp/util/AFPResourceAccessor.java @@ -24,8 +24,6 @@ import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.io.InternalResourceResolver; /** @@ -37,9 +35,10 @@ public final class AFPResourceAccessor { private final String baseURI; /** - * Constructor for resource to be accessed via the {@link FOUserAgent}. This contructor - * takes a base URI for resolving font resource URIs. So, if fonts need to be accessed, you can - * set the {@link FontManager}'s base URI instead of the one on the {@link FopFactory}. + * Constructor for resource to be accessed via the {@link org.apache.fop.apps.FOUserAgent}. This + * contructor takes a base URI for resolving font resource URIs. So, if fonts need to be + * accessed, you can set the {@link FontManager}'s base URI instead of the one on the + * {@link org.apache.fop.apps.FopFactory}. * * @param InternalResourceResolver resource resolver * @param baseURI the custom base URI to resolve relative URIs against (may be null) @@ -50,7 +49,7 @@ public final class AFPResourceAccessor { } /** - * Constructor for resource to be accessed via the {@link FOUserAgent}. + * Constructor for resource to be accessed via the {@link org.apache.fop.apps.FOUserAgent}. * * @param InternalResourceResolver resource resolver */ @@ -74,5 +73,4 @@ public final class AFPResourceAccessor { public InputStream createInputStream(URI uri) throws IOException { return resourceResolver.getResource(getResourceURI(uri)); } - } diff --git a/src/java/org/apache/fop/apps/FopConfParser.java b/src/java/org/apache/fop/apps/FopConfParser.java index 4c9a7bcae..bf39a53f0 100644 --- a/src/java/org/apache/fop/apps/FopConfParser.java +++ b/src/java/org/apache/fop/apps/FopConfParser.java @@ -26,6 +26,7 @@ import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.xml.sax.SAXException; @@ -39,9 +40,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry; import org.apache.xmlgraphics.image.loader.util.Penalty; +import org.apache.fop.apps.io.InternalResourceResolver; import org.apache.fop.apps.io.ResourceResolver; import org.apache.fop.apps.io.ResourceResolverFactory; -import org.apache.fop.apps.io.InternalResourceResolver; import org.apache.fop.fonts.FontManagerConfigurator; import org.apache.fop.hyphenation.HyphenationTreeCache; import org.apache.fop.util.LogUtil; @@ -233,7 +234,7 @@ public class FopConfParser { } // configure font manager - new FontManagerConfigurator(cfg, fopFactoryBuilder.getBaseUri(), resourceResolver).configure( + new FontManagerConfigurator(cfg, fopFactoryBuilder.getBaseURI(), resourceResolver).configure( fopFactoryBuilder.getFontManager(), strict); // configure image loader framework @@ -261,7 +262,7 @@ public class FopConfParser { + " element must consist of exactly two letters (" + location + ")", error); } - lang = lang.toLowerCase(); + lang = lang.toLowerCase(Locale.getDefault()); country = hyphPatConfig[i].getAttribute("country", null); if ("".equals(country)) { @@ -273,7 +274,7 @@ public class FopConfParser { + " element must consist of exactly two letters (" + location + ")", error); } - country = country.toUpperCase(); + country = country.toUpperCase(Locale.getDefault()); } filename = hyphPatConfig[i].getValue(null); @@ -318,7 +319,7 @@ public class FopConfParser { String className = penaltyCfg.getAttribute("class"); String value = penaltyCfg.getAttribute("value"); Penalty p = null; - if (value.toUpperCase().startsWith("INF")) { + if (value.toUpperCase(Locale.getDefault()).startsWith("INF")) { p = Penalty.INFINITE_PENALTY; } else { try { diff --git a/src/java/org/apache/fop/apps/FopFactoryBuilder.java b/src/java/org/apache/fop/apps/FopFactoryBuilder.java index fa3a2722e..44c44c119 100644 --- a/src/java/org/apache/fop/apps/FopFactoryBuilder.java +++ b/src/java/org/apache/fop/apps/FopFactoryBuilder.java @@ -115,7 +115,7 @@ public final class FopFactoryBuilder { * * @return the base URI */ - URI getBaseUri() { + URI getBaseURI() { return config.getBaseURI(); } diff --git a/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java b/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java index 881db20f7..2c8300fb9 100644 --- a/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java +++ b/src/java/org/apache/fop/apps/io/ResourceResolverFactory.java @@ -156,8 +156,11 @@ public final class ResourceResolverFactory { public OutputStream getOutputStream(String id) throws IOException { File file = getTempFile(id); - file.createNewFile(); - return new FileOutputStream(file); + if (file.createNewFile()) { + return new FileOutputStream(file); + } else { + throw new IOException("Filed to create temporary file: " + id); + } } } diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java index 6dda84cb4..aa402aa6a 100644 --- a/src/java/org/apache/fop/cli/CommandLineOptions.java +++ b/src/java/org/apache/fop/cli/CommandLineOptions.java @@ -1038,6 +1038,7 @@ public class CommandLineOptions { throw new FOPException(e); } fopFactoryBuilder.setStrictFOValidation(strictValidation); + fopFactoryBuilder.setComplexScriptFeatures(useComplexScriptFeatures); } factory = fopFactoryBuilder.build(); } diff --git a/src/java/org/apache/fop/fonts/DefaultFontConfig.java b/src/java/org/apache/fop/fonts/DefaultFontConfig.java index 923e68fdc..6c5cebb42 100644 --- a/src/java/org/apache/fop/fonts/DefaultFontConfig.java +++ b/src/java/org/apache/fop/fonts/DefaultFontConfig.java @@ -38,7 +38,7 @@ import org.apache.fop.util.LogUtil; */ public final class DefaultFontConfig implements FontConfig { - protected static Log log = LogFactory.getLog(DefaultFontConfig.class); + private static final Log log = LogFactory.getLog(DefaultFontConfig.class); private final List directories = new ArrayList(); diff --git a/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java b/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java index 043f0f14e..2c60cf4bf 100644 --- a/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java +++ b/src/java/org/apache/fop/fonts/DefaultFontConfigurator.java @@ -43,7 +43,7 @@ import org.apache.fop.util.LogUtil; */ public class DefaultFontConfigurator implements FontConfigurator { /** logger instance */ - protected static Log log = LogFactory.getLog(DefaultFontConfigurator.class); + protected static final Log log = LogFactory.getLog(DefaultFontConfigurator.class); private final FontManager fontManager; private final InternalResourceResolver resourceResolver; @@ -68,11 +68,11 @@ public class DefaultFontConfigurator implements FontConfigurator * Initializes font info settings from the user configuration * @throws FOPException if an exception occurs while processing the configuration */ - public List configure(FontConfig fontInfoConfig) - throws FOPException { + public List configure(FontConfig fontInfoConfig) throws FOPException { List fontInfoList = new ArrayList(); - DefaultFontConfig adobeFontInfoConfig = (DefaultFontConfig) fontInfoConfig; - if (adobeFontInfoConfig != null) { + if (fontInfoConfig != null) { + assert fontInfoConfig instanceof DefaultFontConfig; + DefaultFontConfig adobeFontInfoConfig = (DefaultFontConfig) fontInfoConfig; long start = 0; if (log.isDebugEnabled()) { log.debug("Starting font configuration..."); @@ -154,14 +154,10 @@ public class DefaultFontConfigurator implements FontConfigurator // no font triplet info if (tripletList.size() == 0) { URI fontUri = resourceResolver.resolveFromBase(embedUri); - if (fontUri != null) { - FontInfoFinder finder = new FontInfoFinder(); - finder.setEventListener(listener); - EmbedFontInfo[] infos = finder.find(fontUri, resourceResolver, fontCache); - return infos[0]; //When subFont is set, only one font is returned - } else { - return null; - } + FontInfoFinder finder = new FontInfoFinder(); + finder.setEventListener(listener); + EmbedFontInfo[] infos = finder.find(fontUri, resourceResolver, fontCache); + return infos[0]; //When subFont is set, only one font is returned } EncodingMode encodingMode = EncodingMode.getValue(font.getEncodingMode()); EmbeddingMode embeddingMode = EmbeddingMode.getValue(font.getEmbeddingMode()); diff --git a/src/java/org/apache/fop/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java index 47c0f95e2..35997f3d7 100644 --- a/src/java/org/apache/fop/fonts/FontCache.java +++ b/src/java/org/apache/fop/fonts/FontCache.java @@ -333,7 +333,7 @@ public final class FontCache implements Serializable { // try and determine modified date URI fontUri = resourceResolver.resolveFromBase(fontInfo.getEmbedURI()); File fontFile = new File(fontUri); - long lastModified = (fontFile != null ? fontFile.lastModified() : -1); + long lastModified = fontFile.lastModified(); cachedFontFile = new CachedFontFile(lastModified); if (log.isTraceEnabled()) { log.trace("Font added to cache: " + cacheKey); diff --git a/src/java/org/apache/fop/fonts/FontLoader.java b/src/java/org/apache/fop/fonts/FontLoader.java index 96915e097..f7ee24cbc 100644 --- a/src/java/org/apache/fop/fonts/FontLoader.java +++ b/src/java/org/apache/fop/fonts/FontLoader.java @@ -106,7 +106,7 @@ public abstract class FontLoader { loader = new Type1FontLoader(fontFileURI, embedded, useKerning, resourceResolver); } else { loader = new TTFFontLoader(fontFileURI, subFontName, embedded, embeddingMode, - encodingMode, useKerning, useAdvanced, resourceResolver); + encodingMode, useKerning, useAdvanced, resourceResolver); } return loader.getFont(); } diff --git a/src/java/org/apache/fop/render/PrintRenderer.java b/src/java/org/apache/fop/render/PrintRenderer.java index 5302975f6..b1ff59c84 100644 --- a/src/java/org/apache/fop/render/PrintRenderer.java +++ b/src/java/org/apache/fop/render/PrintRenderer.java @@ -39,8 +39,6 @@ import org.apache.fop.fonts.FontManager; import org.apache.fop.fonts.FontTriplet; import org.apache.fop.fonts.base14.Base14FontCollection; -import sun.font.FontResolver; - /** Abstract base class of "Print" type renderers. */ public abstract class PrintRenderer extends AbstractRenderer { @@ -54,9 +52,6 @@ public abstract class PrintRenderer extends AbstractRenderer { /** Font configuration */ protected FontInfo fontInfo; - /** Font resolver */ - protected FontResolver fontResolver = null; - /** list of fonts */ protected List embedFontInfoList = null; diff --git a/src/java/org/apache/fop/render/PrintRendererConfigurator.java b/src/java/org/apache/fop/render/PrintRendererConfigurator.java index f36bd4c7f..8de2d1a92 100644 --- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java +++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.java @@ -22,9 +22,6 @@ package org.apache.fop.render; import java.util.Collections; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.io.InternalResourceResolver; @@ -46,9 +43,6 @@ import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; public abstract class PrintRendererConfigurator extends AbstractRendererConfigurator implements IFDocumentHandlerConfigurator { - /** logger instance */ - private static Log LOG = LogFactory.getLog(PrintRendererConfigurator.class); - private final RendererConfigParser rendererConfigParser; private final FontConfigurator fontInfoConfigurator; @@ -170,4 +164,13 @@ public abstract class PrintRendererConfigurator extends AbstractRendererConfigur private List buildFontList(String mimeType) throws FOPException { return fontInfoConfigurator.configure(getRendererConfig(mimeType).getFontInfoConfig()); } + + public static PrintRendererConfigurator createDefaultInstance(FOUserAgent userAgent) { + return new PrintRendererConfigurator(userAgent, null) { + @Override + protected List getDefaultFontCollection() { + throw new UnsupportedOperationException(); + } + }; + } } diff --git a/src/java/org/apache/fop/render/afp/AFPFontConfig.java b/src/java/org/apache/fop/render/afp/AFPFontConfig.java index 4b2ece440..eca76078f 100644 --- a/src/java/org/apache/fop/render/afp/AFPFontConfig.java +++ b/src/java/org/apache/fop/render/afp/AFPFontConfig.java @@ -351,19 +351,10 @@ public final class AFPFontConfig implements FontConfig { CharacterSet characterSet = null; if (base14 != null) { try { - Class clazz = Class.forName( - "org.apache.fop.fonts.base14." + base14).asSubclass(Typeface.class); - try { - Typeface tf = clazz.newInstance(); - characterSet = CharacterSetBuilder.getSingleByteInstance() - .build(characterset, super.codePage, - super.encoding, - tf, eventProducer); - } catch (Exception ie) { - String msg = "The base 14 font class " + clazz.getName() - + " could not be instantiated"; - LOG.error(msg); - } + Typeface tf = getTypeFace(base14); + characterSet = CharacterSetBuilder.getSingleByteInstance() + .build(characterset, super.codePage, + super.encoding, tf, eventProducer); } catch (ClassNotFoundException cnfe) { String msg = "The base 14 font class for " + characterset + " could not be found"; @@ -378,6 +369,22 @@ public final class AFPFontConfig implements FontConfig { } } + private static Typeface getTypeFace(String base14Name) throws ClassNotFoundException { + try { + Class clazz = Class.forName("org.apache.fop.fonts.base14." + + base14Name).asSubclass(Typeface.class); + return clazz.newInstance(); + } catch (IllegalAccessException iae) { + LOG.error(iae.getMessage()); + } catch (ClassNotFoundException cnfe) { + LOG.error(cnfe.getMessage()); + } catch (InstantiationException ie) { + LOG.error(ie.getMessage()); + } + throw new ClassNotFoundException("Couldn't load file for AFP font with base14 name: " + + base14Name); + } + static final class RasterFontConfig extends AFPFontConfigData { private final List charsets; @@ -395,24 +402,20 @@ public final class AFPFontConfig implements FontConfig { for (RasterCharactersetData charset : charsets) { if (charset.base14 != null) { try { - Class clazz = Class.forName( - "org.apache.fop.fonts.base14." + charset.base14).asSubclass( - Typeface.class); - try { - Typeface tf = clazz.newInstance(); - rasterFont.addCharacterSet(charset.size, - CharacterSetBuilder.getSingleByteInstance().build( - charset.characterset, super.codePage, super.encoding, - tf, eventProducer)); - } catch (Exception ie) { - String msg = "The base 14 font class " + clazz.getName() - + " could not be instantiated"; - LOG.error(msg); - } + Typeface tf = getTypeFace(charset.base14); + rasterFont.addCharacterSet(charset.size, + CharacterSetBuilder.getSingleByteInstance().build( + charset.characterset, super.codePage, super.encoding, + tf, eventProducer)); + } catch (ClassNotFoundException cnfe) { String msg = "The base 14 font class for " + charset.characterset + " could not be found"; LOG.error(msg); + } catch (IOException ie) { + String msg = "The base 14 font class " + charset.characterset + + " could not be instantiated"; + LOG.error(msg); } } else { AFPResourceAccessor accessor = getAccessor(resourceResolver); diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfig.java b/src/java/org/apache/fop/render/afp/AFPRendererConfig.java index 6d210c0d0..90cc6e767 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfig.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfig.java @@ -208,7 +208,7 @@ public final class AFPRendererConfig implements RendererConfig { /** {@inheritDoc} */ public AFPRendererConfig build(FOUserAgent userAgent, Configuration cfg) throws FOPException { - boolean strict = userAgent != null ? userAgent.validateUserConfigStrictly() : false; + boolean strict = userAgent.validateUserConfigStrictly(); AFPRendererConfig config = null; AFPEventProducer eventProducer = AFPEventProducer.Provider.get(userAgent.getEventBroadcaster()); try { diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java index 92115bc92..3412c3d67 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java @@ -46,7 +46,7 @@ import org.apache.fop.util.LogUtil; */ public class AFPRendererConfigurator extends PrintRendererConfigurator implements IFDocumentHandlerConfigurator { - private static Log LOG = LogFactory.getLog(AFPRendererConfigurator.class); + private static Log log = LogFactory.getLog(AFPRendererConfigurator.class); private final AFPEventProducer eventProducer; @@ -137,10 +137,10 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator implement config.getFontInfoConfig(), mimeType)); } catch (IOException e) { eventProducer.invalidConfiguration(this, e); - LogUtil.handleException(LOG, e, userAgent.validateUserConfigStrictly()); + LogUtil.handleException(log, e, userAgent.validateUserConfigStrictly()); } catch (IllegalArgumentException iae) { eventProducer.invalidConfiguration(this, iae); - LogUtil.handleException(LOG, iae, userAgent.validateUserConfigStrictly()); + LogUtil.handleException(log, iae, userAgent.validateUserConfigStrictly()); } } return new AFPFontCollection(userAgent.getEventBroadcaster(), null); diff --git a/src/java/org/apache/fop/render/afp/AFPShadingMode.java b/src/java/org/apache/fop/render/afp/AFPShadingMode.java index c2ae21f74..7e963148a 100644 --- a/src/java/org/apache/fop/render/afp/AFPShadingMode.java +++ b/src/java/org/apache/fop/render/afp/AFPShadingMode.java @@ -20,10 +20,9 @@ package org.apache.fop.render.afp; import java.io.ObjectStreamException; -import java.io.Serializable; /** Enumeration of the AFP shading modes. */ -public enum AFPShadingMode implements Serializable { +public enum AFPShadingMode { /** the color mode (the default) */ COLOR("COLOR"), /** the dithered mode */ diff --git a/src/java/org/apache/fop/render/bitmap/PNGDocumentHandler.java b/src/java/org/apache/fop/render/bitmap/PNGDocumentHandler.java index 68f6bac05..c63cd3a4d 100644 --- a/src/java/org/apache/fop/render/bitmap/PNGDocumentHandler.java +++ b/src/java/org/apache/fop/render/bitmap/PNGDocumentHandler.java @@ -22,7 +22,6 @@ package org.apache.fop.render.bitmap; import org.apache.fop.apps.MimeConstants; import org.apache.fop.render.bitmap.PNGRendererConfig.PNGRendererConfigParser; import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; /** diff --git a/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java b/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java index b147f497b..48e79520f 100644 --- a/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java +++ b/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java @@ -22,7 +22,6 @@ package org.apache.fop.render.bitmap; import org.apache.fop.apps.MimeConstants; import org.apache.fop.render.bitmap.TIFFRendererConfig.TIFFRendererConfigParser; import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; /** diff --git a/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java b/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java index 72ff9a1ac..0a949e777 100644 --- a/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java +++ b/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java @@ -21,9 +21,6 @@ package org.apache.fop.render.intermediate; import java.util.Locale; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.apache.fop.accessibility.DummyStructureTreeEventHandler; import org.apache.fop.accessibility.StructureTreeEventHandler; import org.apache.fop.apps.FOUserAgent; @@ -33,9 +30,6 @@ import org.apache.fop.apps.FOUserAgent; */ public abstract class AbstractIFDocumentHandler implements IFDocumentHandler { - /** logging instance */ - private static Log log = LogFactory.getLog(AbstractIFDocumentHandler.class); - private final IFContext ifContext; /** diff --git a/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java b/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java index d2e06d76f..a44205d06 100644 --- a/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java +++ b/src/java/org/apache/fop/render/pcl/PCLDocumentHandler.java @@ -37,7 +37,6 @@ import org.apache.fop.apps.MimeConstants; import org.apache.fop.fonts.FontInfo; import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler; import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; import org.apache.fop.render.intermediate.IFException; import org.apache.fop.render.intermediate.IFPainter; @@ -46,7 +45,6 @@ import org.apache.fop.render.java2d.Java2DUtil; import org.apache.fop.render.pcl.PCLRendererConfig.PCLRendererConfigParser; import org.apache.fop.render.pcl.extensions.PCLElementMapping; - /** * {@link org.apache.fop.render.intermediate.IFDocumentHandler} implementation * that produces PCL 5. diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderingMode.java b/src/java/org/apache/fop/render/pcl/PCLRenderingMode.java index 9b8213948..afea5a7fe 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRenderingMode.java +++ b/src/java/org/apache/fop/render/pcl/PCLRenderingMode.java @@ -20,12 +20,11 @@ package org.apache.fop.render.pcl; import java.io.ObjectStreamException; -import java.io.Serializable; /** * Enumeration class for PCL rendering modes. */ -public enum PCLRenderingMode implements Serializable { +public enum PCLRenderingMode { /** "Quality" rendering (mixed native and bitmap for improved quality) */ QUALITY("quality", 1.0f), /** "Speed" rendering (maximum speed with native rendering, reduced visual quality) */ diff --git a/src/java/org/apache/fop/render/pdf/PDFEncryptionOption.java b/src/java/org/apache/fop/render/pdf/PDFEncryptionOption.java index 3d94e236b..f3e51e34a 100644 --- a/src/java/org/apache/fop/render/pdf/PDFEncryptionOption.java +++ b/src/java/org/apache/fop/render/pdf/PDFEncryptionOption.java @@ -19,8 +19,6 @@ package org.apache.fop.render.pdf; -import org.apache.fop.pdf.PDFAMode; -import org.apache.fop.pdf.PDFXMode; import org.apache.fop.render.RendererConfigOption; public enum PDFEncryptionOption implements RendererConfigOption { diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererOption.java b/src/java/org/apache/fop/render/pdf/PDFRendererOption.java index 7305b9646..2ebd691fe 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererOption.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererOption.java @@ -36,14 +36,14 @@ public enum PDFRendererOption implements RendererConfigOption { } }, /** Rendering Options key for the PDF/A mode, default: {@link PDFAMode#DISABLED} */ - PDF_A_MODE("pdf-a-mode", PDFAMode.DISABLED){ + PDF_A_MODE("pdf-a-mode", PDFAMode.DISABLED) { @Override PDFAMode deserialize(String value) { return PDFAMode.getValueOf(value); } }, /** Rendering Options key for the PDF/X mode, default: {@link PDFXMode#DISABLED} */ - PDF_X_MODE("pdf-x-mode", PDFXMode.DISABLED){ + PDF_X_MODE("pdf-x-mode", PDFXMode.DISABLED) { @Override PDFXMode deserialize(String value) { return PDFXMode.getValueOf(value); diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java b/src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java index e8b068647..71102ecf0 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java @@ -46,7 +46,7 @@ public final class PDFRendererOptionsConfig { static { final EnumMap props = new EnumMap(PDFRendererOption.class); - for(PDFRendererOption option : PDFRendererOption.values()) { + for (PDFRendererOption option : PDFRendererOption.values()) { props.put(option, option.getDefaultValue()); } DEFAULT = new PDFRendererOptionsConfig(props, null); diff --git a/src/java/org/apache/fop/render/print/PrintRendererMaker.java b/src/java/org/apache/fop/render/print/PrintRendererMaker.java index 66eb4b108..e5673c1f4 100644 --- a/src/java/org/apache/fop/render/print/PrintRendererMaker.java +++ b/src/java/org/apache/fop/render/print/PrintRendererMaker.java @@ -19,12 +19,9 @@ package org.apache.fop.render.print; -import java.util.List; - import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; -import org.apache.fop.fonts.FontCollection; import org.apache.fop.render.AbstractRendererMaker; import org.apache.fop.render.PrintRendererConfigurator; import org.apache.fop.render.Renderer; @@ -43,13 +40,7 @@ public class PrintRendererMaker extends AbstractRendererMaker { @Override public void configureRenderer(FOUserAgent userAgent, Renderer renderer) throws FOPException { - // TODO what constructor params? - new PrintRendererConfigurator(userAgent, null) { - @Override - protected List getDefaultFontCollection() { - throw new UnsupportedOperationException(); - } - } .configure(renderer); + PrintRendererConfigurator.createDefaultInstance(userAgent).configure(renderer); } @Override @@ -61,5 +52,4 @@ public class PrintRendererMaker extends AbstractRendererMaker { public String[] getSupportedMimeTypes() { return MIMES; } - } diff --git a/src/java/org/apache/fop/render/ps/PSDocumentHandler.java b/src/java/org/apache/fop/render/ps/PSDocumentHandler.java index d73beb759..0ec5fdda6 100644 --- a/src/java/org/apache/fop/render/ps/PSDocumentHandler.java +++ b/src/java/org/apache/fop/render/ps/PSDocumentHandler.java @@ -56,7 +56,6 @@ import org.apache.fop.apps.MimeConstants; import org.apache.fop.apps.io.TempResourceURIGenerator; import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler; import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; import org.apache.fop.render.intermediate.IFException; import org.apache.fop.render.intermediate.IFPainter; @@ -67,7 +66,6 @@ import org.apache.fop.render.ps.extensions.PSPageTrailerCodeBefore; import org.apache.fop.render.ps.extensions.PSSetPageDevice; import org.apache.fop.render.ps.extensions.PSSetupCode; - /** * {@link org.apache.fop.render.intermediate.IFDocumentHandler} implementation * that produces PostScript. diff --git a/src/java/org/apache/fop/render/xml/XMLRendererMaker.java b/src/java/org/apache/fop/render/xml/XMLRendererMaker.java index f0cd3a850..3110ed0ef 100644 --- a/src/java/org/apache/fop/render/xml/XMLRendererMaker.java +++ b/src/java/org/apache/fop/render/xml/XMLRendererMaker.java @@ -19,12 +19,9 @@ package org.apache.fop.render.xml; -import java.util.List; - import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; -import org.apache.fop.fonts.FontCollection; import org.apache.fop.render.AbstractRendererMaker; import org.apache.fop.render.PrintRendererConfigurator; import org.apache.fop.render.Renderer; @@ -43,13 +40,7 @@ public class XMLRendererMaker extends AbstractRendererMaker { @Override public void configureRenderer(FOUserAgent userAgent, Renderer renderer) throws FOPException { - // TODO what constructor params? - new PrintRendererConfigurator(userAgent, null) { - @Override - protected List getDefaultFontCollection() { - throw new UnsupportedOperationException(); - } - } .configure(renderer); + PrintRendererConfigurator.createDefaultInstance(userAgent).configure(renderer); } @Override diff --git a/src/java/org/apache/fop/servlet/FopServlet.java b/src/java/org/apache/fop/servlet/FopServlet.java index 57c5a295b..9dcf10a2b 100644 --- a/src/java/org/apache/fop/servlet/FopServlet.java +++ b/src/java/org/apache/fop/servlet/FopServlet.java @@ -21,7 +21,6 @@ package org.apache.fop.servlet; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; diff --git a/src/java/org/apache/fop/util/ColorSpaceCache.java b/src/java/org/apache/fop/util/ColorSpaceCache.java index af7b26736..a249fe47b 100644 --- a/src/java/org/apache/fop/util/ColorSpaceCache.java +++ b/src/java/org/apache/fop/util/ColorSpaceCache.java @@ -98,6 +98,7 @@ public class ColorSpaceCache { } catch (Exception e) { // Ignore exception - will be logged a bit further down // (colorSpace == null case) + log.warn("Exception thrown resolving the color space: " + e.getMessage()); } if (colorSpace != null) { diff --git a/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java b/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java index 378bd879c..12dd948e5 100644 --- a/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java +++ b/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java @@ -48,7 +48,6 @@ import org.apache.fop.render.bitmap.BitmapRendererEventProducer; import org.apache.fop.render.bitmap.MultiFileRenderingUtil; import org.apache.fop.render.intermediate.DelegatingFragmentContentHandler; import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFException; import org.apache.fop.render.intermediate.IFPainter; import org.apache.fop.util.GenerationHelperContentHandler; diff --git a/src/sandbox/org/apache/fop/render/svg/SVGPrintDocumentHandler.java b/src/sandbox/org/apache/fop/render/svg/SVGPrintDocumentHandler.java index 4810ba995..b97d3d261 100644 --- a/src/sandbox/org/apache/fop/render/svg/SVGPrintDocumentHandler.java +++ b/src/sandbox/org/apache/fop/render/svg/SVGPrintDocumentHandler.java @@ -26,7 +26,6 @@ import org.xml.sax.helpers.AttributesImpl; import org.apache.fop.render.intermediate.IFConstants; import org.apache.fop.render.intermediate.IFContext; -import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFException; import org.apache.fop.render.intermediate.IFPainter; import org.apache.fop.util.XMLUtil; -- 2.39.5