Skip to content

Commit 95887c8

Browse files
committed
Polish naming for Charset setters in FreeMarker support
See gh-33102
1 parent 0811296 commit 95887c8

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ public void setDefaultEncoding(String defaultEncoding) {
158158
}
159159

160160
/**
161-
* Set the default encoding for the FreeMarker {@link Configuration}, which
162-
* is used to decode byte sequences to character sequences when reading template
163-
* files.
161+
* Set the {@link Charset} for the default encoding for the FreeMarker
162+
* {@link Configuration}, which is used to decode byte sequences to character
163+
* sequences when reading template files.
164164
* <p>See {@link #setDefaultEncoding(String)} for details.
165165
* @since 6.2
166166
* @see java.nio.charset.StandardCharsets
167167
*/
168-
public void setDefaultEncoding(Charset defaultEncoding) {
169-
setDefaultEncoding(defaultEncoding.name());
168+
public void setDefaultCharset(Charset defaultCharset) {
169+
this.defaultEncoding = defaultCharset.name();
170170
}
171171

172172
/**

spring-webflux/src/main/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerConfigurer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class FreeMarkerConfigurer extends FreeMarkerConfigurationFactory
6969

7070

7171
public FreeMarkerConfigurer() {
72-
setDefaultEncoding(StandardCharsets.UTF_8);
72+
setDefaultCharset(StandardCharsets.UTF_8);
7373
}
7474

7575

spring-webflux/src/main/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerView.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -167,22 +167,22 @@ protected Configuration obtainConfiguration() {
167167
* process. See the note in the {@linkplain FreeMarkerView class-level
168168
* documentation} for details.
169169
* @see freemarker.template.Configuration#setDefaultEncoding
170-
* @see #setEncoding(Charset)
170+
* @see #setCharset(Charset)
171171
* @see #getEncoding()
172172
*/
173173
public void setEncoding(@Nullable String encoding) {
174174
this.encoding = encoding;
175175
}
176176

177177
/**
178-
* Set the encoding used to decode byte sequences to character sequences when
179-
* reading the FreeMarker template file for this view.
178+
* Set the {@link Charset} used to decode byte sequences to character sequences
179+
* when reading the FreeMarker template file for this view.
180180
* <p>See {@link #setEncoding(String)} for details.
181181
* @since 6.2
182182
* @see java.nio.charset.StandardCharsets
183183
*/
184-
public void setEncoding(@Nullable Charset encoding) {
185-
setEncoding(encoding != null ? encoding.name() : null);
184+
public void setCharset(@Nullable Charset charset) {
185+
this.encoding = (charset != null ? charset.name() : null);
186186
}
187187

188188
/**

spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxViewResolutionIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void configureViewResolvers(ViewResolverRegistry registry) {
135135
public FreeMarkerConfigurer freeMarkerConfigurer() {
136136
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
137137
configurer.setPreTemplateLoaders(classTemplateLoader);
138-
configurer.setDefaultEncoding(UTF_8);
138+
configurer.setDefaultCharset(UTF_8);
139139
return configurer;
140140
}
141141
}
@@ -158,7 +158,7 @@ public void configureViewResolvers(ViewResolverRegistry registry) {
158158
public FreeMarkerConfigurer freeMarkerConfigurer() {
159159
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
160160
configurer.setPreTemplateLoaders(classTemplateLoader);
161-
configurer.setDefaultEncoding(ISO_8859_1);
161+
configurer.setDefaultCharset(ISO_8859_1);
162162
return configurer;
163163
}
164164

spring-webmvc/src/main/java/org/springframework/web/servlet/view/freemarker/FreeMarkerView.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public class FreeMarkerView extends AbstractTemplateView {
116116
* process. See the note in the {@linkplain FreeMarkerView class-level
117117
* documentation} for details.
118118
* @see freemarker.template.Configuration#setDefaultEncoding
119-
* @see #setEncoding(Charset)
119+
* @see #setCharset(Charset)
120120
* @see #getEncoding()
121121
* @see #setContentType(String)
122122
*/
@@ -125,14 +125,14 @@ public void setEncoding(@Nullable String encoding) {
125125
}
126126

127127
/**
128-
* Set the encoding used to decode byte sequences to character sequences when
129-
* reading the FreeMarker template file for this view.
128+
* Set the {@link Charset} used to decode byte sequences to character sequences
129+
* when reading the FreeMarker template file for this view.
130130
* <p>See {@link #setEncoding(String)} for details.
131131
* @since 6.2
132132
* @see java.nio.charset.StandardCharsets
133133
*/
134-
public void setEncoding(@Nullable Charset encoding) {
135-
setEncoding(encoding != null ? encoding.name() : null);
134+
public void setCharset(@Nullable Charset charset) {
135+
this.encoding = (charset != null ? charset.name() : null);
136136
}
137137

138138
/**

spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void configureViewResolvers(ViewResolverRegistry registry) {
164164
public FreeMarkerConfigurer freeMarkerConfigurer() {
165165
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
166166
configurer.setTemplateLoaderPath("/WEB-INF/");
167-
configurer.setDefaultEncoding(UTF_8);
167+
configurer.setDefaultCharset(UTF_8);
168168
return configurer;
169169
}
170170
}
@@ -183,7 +183,7 @@ public FreeMarkerViewResolver freeMarkerViewResolver() {
183183
public FreeMarkerConfigurer freeMarkerConfigurer() {
184184
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
185185
configurer.setTemplateLoaderPath("/WEB-INF/");
186-
configurer.setDefaultEncoding(UTF_8);
186+
configurer.setDefaultCharset(UTF_8);
187187
return configurer;
188188
}
189189
}

0 commit comments

Comments
 (0)