diff options
Diffstat (limited to 'src/java/org/apache/fop')
12 files changed, 73 insertions, 62 deletions
diff --git a/src/java/org/apache/fop/events/Event.java b/src/java/org/apache/fop/events/Event.java index c48530c1c..ffec9473e 100644 --- a/src/java/org/apache/fop/events/Event.java +++ b/src/java/org/apache/fop/events/Event.java @@ -38,7 +38,7 @@ public class Event extends EventObject { private String eventKey; private EventSeverity severity; - private Map params; + private Map<String, Object> params; /** * Creates a new Event. @@ -47,7 +47,8 @@ public class Event extends EventObject { * @param severity the severity level * @param params the event parameters (a map of name/value pairs) */ - public Event(Object source, String eventID, EventSeverity severity, Map params) { + public Event(Object source, String eventID, EventSeverity severity, Map<String, Object> params) + { super(source); int pos = eventID.lastIndexOf('.'); if (pos < 0 || pos == eventID.length() - 1) { @@ -122,7 +123,7 @@ public class Event extends EventObject { * Returns an unmodifiable {@link java.util.Map} with all event parameters. * @return the parameter map */ - public Map getParams() { + public Map<String, Object> getParams() { return Collections.unmodifiableMap(this.params); } @@ -138,7 +139,7 @@ public class Event extends EventObject { * This class is a fluent builder class for building up the parameter map. */ public static class ParamsBuilder { - private Map params; + private Map<String, Object> params; /** * Adds a new parameter (a name/value pair). @@ -148,7 +149,7 @@ public class Event extends EventObject { */ public ParamsBuilder param(String name, Object value) { if (this.params == null) { - this.params = new java.util.HashMap(); + this.params = new java.util.HashMap<String, Object>(); } this.params.put(name, value); return this; @@ -158,7 +159,7 @@ public class Event extends EventObject { * Returns the accumulated parameter map. * @return the accumulated parameter map */ - public Map build() { + public Map<String, Object> build() { return this.params; } } diff --git a/src/java/org/apache/fop/events/EventExceptionManager.java b/src/java/org/apache/fop/events/EventExceptionManager.java index f7d679282..3494dc560 100644 --- a/src/java/org/apache/fop/events/EventExceptionManager.java +++ b/src/java/org/apache/fop/events/EventExceptionManager.java @@ -32,11 +32,12 @@ public final class EventExceptionManager { private EventExceptionManager() { } - private static final Map EXCEPTION_FACTORIES = new java.util.HashMap(); + private static final Map<String, ExceptionFactory> EXCEPTION_FACTORIES + = new java.util.HashMap<String, ExceptionFactory>(); static { - Iterator iter; - iter = Service.providers(ExceptionFactory.class, true); + Iterator<Object> iter; + iter = Service.providers(ExceptionFactory.class); while (iter.hasNext()) { ExceptionFactory factory = (ExceptionFactory)iter.next(); EXCEPTION_FACTORIES.put(factory.getExceptionClass().getName(), factory); @@ -63,7 +64,7 @@ public final class EventExceptionManager { String msg = EventFormatter.format(event); //Get original exception as cause if it is given as one of the parameters Throwable t = null; - Iterator iter = event.getParams().values().iterator(); + Iterator<Object> iter = event.getParams().values().iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof Throwable) { @@ -96,6 +97,6 @@ public final class EventExceptionManager { * Returns the {@link Exception} class created by this factory. * @return the exception class */ - Class getExceptionClass(); + Class<? extends Exception> getExceptionClass(); } } diff --git a/src/java/org/apache/fop/events/PropertyExceptionFactory.java b/src/java/org/apache/fop/events/PropertyExceptionFactory.java index 753019b31..d8c7f39fb 100644 --- a/src/java/org/apache/fop/events/PropertyExceptionFactory.java +++ b/src/java/org/apache/fop/events/PropertyExceptionFactory.java @@ -40,7 +40,7 @@ public class PropertyExceptionFactory implements ExceptionFactory { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<PropertyException> getExceptionClass() { return PropertyException.class; } diff --git a/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java b/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java index 7ec9d19b2..570fcbd64 100644 --- a/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java +++ b/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java @@ -36,7 +36,7 @@ public class UnsupportedOperationExceptionFactory implements ExceptionFactory { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<UnsupportedOperationException> getExceptionClass() { return UnsupportedOperationException.class; } diff --git a/src/java/org/apache/fop/events/ValidationExceptionFactory.java b/src/java/org/apache/fop/events/ValidationExceptionFactory.java index 760c4ec58..2c7c69ce9 100644 --- a/src/java/org/apache/fop/events/ValidationExceptionFactory.java +++ b/src/java/org/apache/fop/events/ValidationExceptionFactory.java @@ -43,7 +43,7 @@ public class ValidationExceptionFactory implements ExceptionFactory { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<ValidationException> getExceptionClass() { return ValidationException.class; } diff --git a/src/java/org/apache/fop/fo/pagination/PageProductionException.java b/src/java/org/apache/fop/fo/pagination/PageProductionException.java index bb09db6f4..39060f3d4 100644 --- a/src/java/org/apache/fop/fo/pagination/PageProductionException.java +++ b/src/java/org/apache/fop/fo/pagination/PageProductionException.java @@ -98,7 +98,7 @@ public class PageProductionException extends RuntimeException { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<PageProductionException> getExceptionClass() { return PageProductionException.class; } diff --git a/src/java/org/apache/fop/layoutmgr/LayoutException.java b/src/java/org/apache/fop/layoutmgr/LayoutException.java index 2638d0210..f22d34bd8 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutException.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutException.java @@ -97,7 +97,7 @@ public class LayoutException extends RuntimeException { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<LayoutException> getExceptionClass() { return LayoutException.class; } diff --git a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java index f5a51b058..913a72b0d 100644 --- a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java @@ -148,7 +148,10 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter { RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @deprecated + */ public void paintImage(Graphics2DImagePainter painter, RendererContext context, int x, int y, int width, int height) throws IOException { diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index d70d8113f..273f0bc16 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -208,15 +208,17 @@ public abstract class AbstractRenderer return sb.toString(); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @deprecated + */ public void startPageSequence(LineArea seqTitle) { //do nothing } /** {@inheritDoc} */ public void startPageSequence(PageSequence pageSequence) { - //TODO Discuss removing old deprecated method startPageSequence(LineArea) - startPageSequence(pageSequence.getTitle()); + // do nothing } // normally this would be overriden to create a page in the diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java index 1cf291112..c1d959dd1 100644 --- a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java @@ -92,8 +92,8 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { protected PageReference currentPageRef; /** Used for bookmarks/outlines. */ - protected Map<Integer, PageReference> pageReferences = - new java.util.HashMap<Integer, PageReference>(); + protected Map<Integer, PageReference> pageReferences + = new java.util.HashMap<Integer, PageReference>(); private final PDFDocumentNavigationHandler documentNavigationHandler = new PDFDocumentNavigationHandler(this); diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java index 21277d60a..674079369 100644 --- a/src/java/org/apache/fop/util/ColorUtil.java +++ b/src/java/org/apache/fop/util/ColorUtil.java @@ -27,6 +27,7 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.xmlgraphics.java2d.color.ColorSpaces; import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; import org.apache.fop.apps.FOUserAgent; @@ -50,7 +51,7 @@ public final class ColorUtil { * This map is used to predefine given colors, as well as speeding up * parsing of already parsed colors. */ - private static Map colorMap = null; + private static Map<String, Color> colorMap = null; /** Logger instance */ protected static final Log log = LogFactory.getLog(ColorUtil.class); @@ -328,7 +329,7 @@ public final class ColorUtil { String iccProfileSrc = null; if (isPseudoProfile(iccProfileName)) { if (CMYK_PSEUDO_PROFILE.equalsIgnoreCase(iccProfileName)) { - colorSpace = DeviceCMYKColorSpace.getInstance(); + colorSpace = ColorSpaces.getDeviceCMYKColorSpace(); } else { assert false : "Incomplete implementation"; } @@ -453,7 +454,7 @@ public final class ColorUtil { + "Arguments to cmyk() must be in the range [0%-100%] or [0.0-1.0]"); } float[] cmyk = new float[] {cyan, magenta, yellow, black}; - DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance(); + DeviceCMYKColorSpace cmykCs = ColorSpaces.getDeviceCMYKColorSpace(); float[] rgb = cmykCs.toRGB(cmyk); parsedColor = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2], CMYK_PSEUDO_PROFILE, null, cmykCs, cmyk); @@ -521,7 +522,7 @@ public final class ColorUtil { * Initializes the colorMap with some predefined values. */ private static void initializeColorMap() { // CSOK: MethodLength - colorMap = Collections.synchronizedMap(new java.util.HashMap()); + colorMap = Collections.synchronizedMap(new java.util.HashMap<String, Color>()); colorMap.put("aliceblue", new Color(240, 248, 255)); colorMap.put("antiquewhite", new Color(250, 235, 215)); @@ -710,7 +711,7 @@ public final class ColorUtil { */ public static Color toCMYKGrayColor(float black) { float[] cmyk = new float[] {0f, 0f, 0f, 1.0f - black}; - DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance(); + DeviceCMYKColorSpace cmykCs = ColorSpaces.getDeviceCMYKColorSpace(); float[] rgb = cmykCs.toRGB(cmyk); return ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2], CMYK_PSEUDO_PROFILE, null, cmykCs, cmyk); diff --git a/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java index 002b3f95c..41b70046c 100644 --- a/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java +++ b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java @@ -46,24 +46,27 @@ public class AdvancedMessageFormat { /** Regex that matches "," but not "\," (escaped comma) */ static final Pattern COMMA_SEPARATOR_REGEX = Pattern.compile("(?<!\\\\),"); - private static final Map PART_FACTORIES = new java.util.HashMap(); - private static final List OBJECT_FORMATTERS = new java.util.ArrayList(); - private static final Map FUNCTIONS = new java.util.HashMap(); + private static final Map<String, PartFactory> PART_FACTORIES + = new java.util.HashMap<String, PartFactory>(); + private static final List<ObjectFormatter> OBJECT_FORMATTERS + = new java.util.ArrayList<ObjectFormatter>(); + private static final Map<Object, Function> FUNCTIONS + = new java.util.HashMap<Object, Function>(); private CompositePart rootPart; static { - Iterator iter; - iter = Service.providers(PartFactory.class, true); + Iterator<Object> iter; + iter = Service.providers(PartFactory.class); while (iter.hasNext()) { PartFactory factory = (PartFactory)iter.next(); PART_FACTORIES.put(factory.getFormat(), factory); } - iter = Service.providers(ObjectFormatter.class, true); + iter = Service.providers(ObjectFormatter.class); while (iter.hasNext()) { OBJECT_FORMATTERS.add((ObjectFormatter)iter.next()); } - iter = Service.providers(Function.class, true); + iter = Service.providers(Function.class); while (iter.hasNext()) { Function function = (Function)iter.next(); FUNCTIONS.put(function.getName(), function); @@ -189,7 +192,7 @@ public class AdvancedMessageFormat { * @param params a Map of named parameters (Contents: <String, Object>) * @return the formatted message */ - public String format(Map params) { + public String format(Map<String, Object> params) { StringBuffer sb = new StringBuffer(); format(params, sb); return sb.toString(); @@ -200,7 +203,7 @@ public class AdvancedMessageFormat { * @param params a Map of named parameters (Contents: <String, Object>) * @param target the target StringBuffer to write the formatted message to */ - public void format(Map params, StringBuffer target) { + public void format(Map<String, Object> params, StringBuffer target) { rootPart.write(target, params); } @@ -215,14 +218,14 @@ public class AdvancedMessageFormat { * @param sb the target string buffer * @param params the parameters to work with */ - void write(StringBuffer sb, Map params); + void write(StringBuffer sb, Map<String, Object> params); /** * Indicates whether there is any content that is generated by this message part. * @param params the parameters to work with * @return true if the part has content */ - boolean isGenerated(Map params); + boolean isGenerated(Map<String, Object> params); } /** @@ -277,7 +280,7 @@ public class AdvancedMessageFormat { * @param params the message parameters * @return the function result */ - Object evaluate(Map params); + Object evaluate(Map<String, Object> params); /** * Returns the name of the function. @@ -294,11 +297,11 @@ public class AdvancedMessageFormat { this.text = text; } - public void write(StringBuffer sb, Map params) { + public void write(StringBuffer sb, Map<String, Object> params) { sb.append(text); } - public boolean isGenerated(Map params) { + public boolean isGenerated(Map<String, Object> params) { return true; } @@ -316,7 +319,7 @@ public class AdvancedMessageFormat { this.fieldName = fieldName; } - public void write(StringBuffer sb, Map params) { + public void write(StringBuffer sb, Map<String, Object> params) { if (!params.containsKey(fieldName)) { throw new IllegalArgumentException( "Message pattern contains unsupported field name: " + fieldName); @@ -325,7 +328,7 @@ public class AdvancedMessageFormat { formatObject(obj, sb); } - public boolean isGenerated(Map params) { + public boolean isGenerated(Map<String, Object> params) { Object obj = params.get(fieldName); return obj != null; } @@ -349,9 +352,9 @@ public class AdvancedMessageFormat { target.append(obj); } else { boolean handled = false; - Iterator iter = OBJECT_FORMATTERS.iterator(); + Iterator<ObjectFormatter> iter = OBJECT_FORMATTERS.iterator(); while (iter.hasNext()) { - ObjectFormatter formatter = (ObjectFormatter)iter.next(); + ObjectFormatter formatter = iter.next(); if (formatter.supportsObject(obj)) { formatter.format(target, obj); handled = true; @@ -375,12 +378,12 @@ public class AdvancedMessageFormat { } } - public void write(StringBuffer sb, Map params) { + public void write(StringBuffer sb, Map<String, Object> params) { Object obj = this.function.evaluate(params); formatObject(obj, sb); } - public boolean isGenerated(Map params) { + public boolean isGenerated(Map<String, Object> params) { Object obj = this.function.evaluate(params); return obj != null; } @@ -393,7 +396,7 @@ public class AdvancedMessageFormat { private static class CompositePart implements Part { - protected List parts = new java.util.ArrayList(); + protected List<Part> parts = new java.util.ArrayList<Part>(); private boolean conditional; private boolean hasSections = false; @@ -401,7 +404,7 @@ public class AdvancedMessageFormat { this.conditional = conditional; } - private CompositePart(List parts) { + private CompositePart(List<Part> parts) { this.parts.addAll(parts); this.conditional = true; } @@ -411,7 +414,7 @@ public class AdvancedMessageFormat { throw new NullPointerException("part must not be null"); } if (hasSections) { - CompositePart composite = (CompositePart)this.parts.get(this.parts.size() - 1); + CompositePart composite = (CompositePart) this.parts.get(this.parts.size() - 1); composite.addChild(part); } else { this.parts.add(part); @@ -420,20 +423,20 @@ public class AdvancedMessageFormat { public void newSection() { if (!hasSections) { - List p = this.parts; + List<Part> p = this.parts; //Dropping into a different mode... - this.parts = new java.util.ArrayList(); + this.parts = new java.util.ArrayList<Part>(); this.parts.add(new CompositePart(p)); hasSections = true; } this.parts.add(new CompositePart(true)); } - public void write(StringBuffer sb, Map params) { + public void write(StringBuffer sb, Map<String, Object> params) { if (hasSections) { - Iterator iter = this.parts.iterator(); + Iterator<Part> iter = this.parts.iterator(); while (iter.hasNext()) { - CompositePart part = (CompositePart)iter.next(); + Part part = iter.next(); if (part.isGenerated(params)) { part.write(sb, params); break; @@ -441,20 +444,20 @@ public class AdvancedMessageFormat { } } else { if (isGenerated(params)) { - Iterator iter = this.parts.iterator(); + Iterator<Part> iter = this.parts.iterator(); while (iter.hasNext()) { - Part part = (Part)iter.next(); + Part part = iter.next(); part.write(sb, params); } } } } - public boolean isGenerated(Map params) { + public boolean isGenerated(Map<String, Object> params) { if (hasSections) { - Iterator iter = this.parts.iterator(); + Iterator<Part> iter = this.parts.iterator(); while (iter.hasNext()) { - Part part = (Part)iter.next(); + Part part = iter.next(); if (part.isGenerated(params)) { return true; } @@ -462,9 +465,9 @@ public class AdvancedMessageFormat { return false; } else { if (conditional) { - Iterator iter = this.parts.iterator(); + Iterator<Part> iter = this.parts.iterator(); while (iter.hasNext()) { - Part part = (Part)iter.next(); + Part part = iter.next(); if (!part.isGenerated(params)) { return false; } |