From 1e7fade89ee6fbe35c166ce5f311e534170edbfa Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 12 May 2014 20:27:53 +0200 Subject: [PATCH] JasperReports-related polishing (cherry picked from commit 782d10c) --- .../org/springframework/tests/Assume.java | 14 ++++---- .../JasperReportsMultiFormatView.java | 33 ++++++++++--------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/tests/Assume.java b/spring-core/src/test/java/org/springframework/tests/Assume.java index e558642140b..80eb5753700 100644 --- a/spring-core/src/test/java/org/springframework/tests/Assume.java +++ b/spring-core/src/test/java/org/springframework/tests/Assume.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.junit.internal.AssumptionViolatedException; + import org.springframework.util.ClassUtils; import static org.junit.Assume.*; @@ -78,7 +79,6 @@ import static org.junit.Assume.*; */ public abstract class Assume { - private static final Set GROUPS = TestGroup.parse(System.getProperty("testGroups")); @@ -119,13 +119,15 @@ public abstract class Assume { public static void canLoadNativeDirFonts() { try { GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); - Class parserClass = ClassUtils.forName("net.sf.jasperreports.engine.util.JRStyledTextParser", null); + Class parserClass = ClassUtils.forName( + "net.sf.jasperreports.engine.util.JRStyledTextParser", Assume.class.getClassLoader()); Method method = parserClass.getMethod("getInstance"); method.setAccessible(true); method.invoke(null); - } catch(Throwable ex) { - throw new AssumptionViolatedException( - "Requires GraphicsEnvironment that can load fonts.", ex); + } + catch (Throwable ex) { + throw new AssumptionViolatedException("Requires GraphicsEnvironment that can load fonts", ex); } } + } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatView.java index b2a1b3ef0d0..e1f74c277ab 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,26 +27,26 @@ import org.springframework.beans.BeanUtils; import org.springframework.util.CollectionUtils; /** - * Jasper Reports view class that allows for the actual rendering format to be - * specified at runtime using a parameter contained in the model. + * Jasper Reports view class that allows for the actual rendering format + * to be specified at runtime using a parameter contained in the model. * *

This view works on the concept of a format key and a mapping key. - * The format key is used to pass the mapping key from your - * {@code Controller} to Spring through as part of the model and the - * mapping key is used to map a logical format to an actual JasperReports - * view class. For example you might add the following code to your - * {@code Controller}: + * The format key is used to pass the mapping key from your {@code Controller} + * to Spring through as part of the model and the mapping key is used to map + * a logical format to an actual JasperReports view class. + * + *

For example, you might add the following code to your {@code Controller}: * *

  * Map model = new HashMap();
  * model.put("format", "pdf");
* - * Here {@code format} is the format key and {@code pdf} is - * the mapping key. When rendering a report, this class looks for a - * model parameter under the format key, which by default is - * {@code format}. It then uses the value of this parameter to lookup - * the actual {@code View} class to use. The default mappings for this - * lookup are: + * Here {@code format} is the format key and {@code pdf} is the mapping key. + * When rendering a report, this class looks for a model parameter under the + * format key, which by default is {@code format}. It then uses the value of + * this parameter to lookup the actual {@code View} class to use. + * + *

The default mappings for the format lookup are: * *

* - *

The format key can be changed using the {@code formatKey} - * property and the mapping key to view class mappings can be changed using the + *

The format key can be changed using the {@code formatKey} property. + * The applicable key-to-view-class mappings can be configured using the * {@code formatMappings} property. * * @author Rob Harrop @@ -102,6 +102,7 @@ public class JasperReportsMultiFormatView extends AbstractJasperReportsView { this.formatMappings.put("xls", JasperReportsXlsView.class); } + /** * Set the key of the model parameter that holds the format discriminator. * Default is "format".