Skip to content

Commit 1e7fade

Browse files
committed
JasperReports-related polishing
(cherry picked from commit 782d10c)
1 parent 3c58be0 commit 1e7fade

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

spring-core/src/test/java/org/springframework/tests/Assume.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
2222

2323
import org.apache.commons.logging.Log;
2424
import org.junit.internal.AssumptionViolatedException;
25+
2526
import org.springframework.util.ClassUtils;
2627

2728
import static org.junit.Assume.*;
@@ -78,7 +79,6 @@
7879
*/
7980
public abstract class Assume {
8081

81-
8282
private static final Set<TestGroup> GROUPS = TestGroup.parse(System.getProperty("testGroups"));
8383

8484

@@ -119,13 +119,15 @@ public static void notLogging(Log log) {
119119
public static void canLoadNativeDirFonts() {
120120
try {
121121
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
122-
Class<?> parserClass = ClassUtils.forName("net.sf.jasperreports.engine.util.JRStyledTextParser", null);
122+
Class<?> parserClass = ClassUtils.forName(
123+
"net.sf.jasperreports.engine.util.JRStyledTextParser", Assume.class.getClassLoader());
123124
Method method = parserClass.getMethod("getInstance");
124125
method.setAccessible(true);
125126
method.invoke(null);
126-
} catch(Throwable ex) {
127-
throw new AssumptionViolatedException(
128-
"Requires GraphicsEnvironment that can load fonts.", ex);
127+
}
128+
catch (Throwable ex) {
129+
throw new AssumptionViolatedException("Requires GraphicsEnvironment that can load fonts", ex);
129130
}
130131
}
132+
131133
}

spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatView.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,26 +27,26 @@
2727
import org.springframework.util.CollectionUtils;
2828

2929
/**
30-
* Jasper Reports view class that allows for the actual rendering format to be
31-
* specified at runtime using a parameter contained in the model.
30+
* Jasper Reports view class that allows for the actual rendering format
31+
* to be specified at runtime using a parameter contained in the model.
3232
*
3333
* <p>This view works on the concept of a format key and a mapping key.
34-
* The format key is used to pass the mapping key from your
35-
* {@code Controller} to Spring through as part of the model and the
36-
* mapping key is used to map a logical format to an actual JasperReports
37-
* view class. For example you might add the following code to your
38-
* {@code Controller}:
34+
* The format key is used to pass the mapping key from your {@code Controller}
35+
* to Spring through as part of the model and the mapping key is used to map
36+
* a logical format to an actual JasperReports view class.
37+
*
38+
* <p>For example, you might add the following code to your {@code Controller}:
3939
*
4040
* <pre class="code">
4141
* Map<String, Object> model = new HashMap<String, Object>();
4242
* model.put("format", "pdf");</pre>
4343
*
44-
* Here {@code format} is the format key and {@code pdf} is
45-
* the mapping key. When rendering a report, this class looks for a
46-
* model parameter under the format key, which by default is
47-
* {@code format}. It then uses the value of this parameter to lookup
48-
* the actual {@code View} class to use. The default mappings for this
49-
* lookup are:
44+
* Here {@code format} is the format key and {@code pdf} is the mapping key.
45+
* When rendering a report, this class looks for a model parameter under the
46+
* format key, which by default is {@code format}. It then uses the value of
47+
* this parameter to lookup the actual {@code View} class to use.
48+
*
49+
* <p>The default mappings for the format lookup are:
5050
*
5151
* <p><ul>
5252
* <li>{@code csv} - {@code JasperReportsCsvView}</li>
@@ -55,8 +55,8 @@
5555
* <li>{@code xls} - {@code JasperReportsXlsView}</li>
5656
* </ul>
5757
*
58-
* <p>The format key can be changed using the {@code formatKey}
59-
* property and the mapping key to view class mappings can be changed using the
58+
* <p>The format key can be changed using the {@code formatKey} property.
59+
* The applicable key-to-view-class mappings can be configured using the
6060
* {@code formatMappings} property.
6161
*
6262
* @author Rob Harrop
@@ -102,6 +102,7 @@ public JasperReportsMultiFormatView() {
102102
this.formatMappings.put("xls", JasperReportsXlsView.class);
103103
}
104104

105+
105106
/**
106107
* Set the key of the model parameter that holds the format discriminator.
107108
* Default is "format".

0 commit comments

Comments
 (0)