Polishing (includes varargs for selected String array setters)

This commit is contained in:
Juergen Hoeller
2014-08-09 00:19:56 +02:00
parent d61353db51
commit c08ded769a
34 changed files with 376 additions and 390 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 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.
@@ -38,7 +38,7 @@ public class UserRoleAuthorizationInterceptor extends HandlerInterceptorAdapter
* Set the roles that this interceptor should treat as authorized.
* @param authorizedRoles array of role names
*/
public final void setAuthorizedRoles(String[] authorizedRoles) {
public final void setAuthorizedRoles(String... authorizedRoles) {
this.authorizedRoles = authorizedRoles;
}

View File

@@ -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.
@@ -124,7 +124,7 @@ public class ParameterMethodNameResolver implements MethodNameResolver {
* can be considered a logical name only.
* @see #setParamName
*/
public void setMethodParamNames(String[] methodParamNames) {
public void setMethodParamNames(String... methodParamNames) {
this.methodParamNames = methodParamNames;
}

View File

@@ -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.
@@ -60,7 +60,7 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
* e.g. a {@link org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping},
* alongside this ControllerClassNameHandlerMapping for application controllers.
*/
public void setExcludedPackages(String[] excludedPackages) {
public void setExcludedPackages(String... excludedPackages) {
this.excludedPackages = (excludedPackages != null) ?
new HashSet<String>(Arrays.asList(excludedPackages)) : new HashSet<String>();
}
@@ -69,7 +69,7 @@ public abstract class AbstractControllerUrlHandlerMapping extends AbstractDetect
* Specify controller classes that should be excluded from this mapping.
* Any such classes will simply be ignored by this HandlerMapping.
*/
public void setExcludedClasses(Class<?>[] excludedClasses) {
public void setExcludedClasses(Class<?>... excludedClasses) {
this.excludedClasses = (excludedClasses != null) ?
new HashSet<Class<?>>(Arrays.asList(excludedClasses)) : new HashSet<Class<?>>();
}

View File

@@ -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.
@@ -120,7 +120,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport {
* <p>Default is GET, HEAD and POST for simple form controller types;
* unrestricted for general controllers and interceptors.
*/
public final void setSupportedMethods(String[] methods) {
public final void setSupportedMethods(String... methods) {
if (methods != null) {
this.supportedMethods = new HashSet<String>(Arrays.asList(methods));
}

View File

@@ -227,7 +227,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
}
/**
* Whether to add path variables in the model or not.
* Specify whether to add path variables to the model or not.
* <p>Path variables are commonly bound to URI template variables through the {@code @PathVariable}
* annotation. They're are effectively URI template variables with type conversion applied to
* them to derive typed Object values. Such values are frequently needed in views for
@@ -235,14 +235,14 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
* <p>Path variables added to the model override static attributes (see {@link #setAttributes(Properties)})
* but not attributes already present in the model.
* <p>By default this flag is set to {@code true}. Concrete view types can override this.
* @param exposePathVariables {@code true} to expose path variables, and {@code false} otherwise.
* @param exposePathVariables {@code true} to expose path variables, and {@code false} otherwise
*/
public void setExposePathVariables(boolean exposePathVariables) {
this.exposePathVariables = exposePathVariables;
}
/**
* Returns the value of the flag indicating whether path variables should be added to the model or not.
* Return whether to add path variables to the model or not.
*/
public boolean isExposePathVariables() {
return this.exposePathVariables;

View File

@@ -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.
@@ -141,7 +141,7 @@ public class InternalResourceView extends AbstractUrlBasedView {
* the {@link #setExposeContextBeansAsAttributes "exposeContextBeansAsAttributes"}
* flag on but do not list specific bean names for this property.
*/
public void setExposedContextBeanNames(String[] exposedContextBeanNames) {
public void setExposedContextBeanNames(String... exposedContextBeanNames) {
this.exposedContextBeanNames = new HashSet<String>(Arrays.asList(exposedContextBeanNames));
}

View File

@@ -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.
@@ -70,6 +70,7 @@ public class InternalResourceViewResolver extends UrlBasedViewResolver {
setViewClass(viewClass);
}
/**
* This resolver requires {@link InternalResourceView}.
*/
@@ -78,7 +79,6 @@ public class InternalResourceViewResolver extends UrlBasedViewResolver {
return InternalResourceView.class;
}
/**
* Specify whether to always include the view rather than forward to it.
* <p>Default is "false". Switch this flag on to enforce the use of a
@@ -86,7 +86,7 @@ public class InternalResourceViewResolver extends UrlBasedViewResolver {
* @see InternalResourceView#setAlwaysInclude
*/
public void setAlwaysInclude(boolean alwaysInclude) {
this.alwaysInclude = Boolean.valueOf(alwaysInclude);
this.alwaysInclude = alwaysInclude;
}
/**
@@ -108,7 +108,7 @@ public class InternalResourceViewResolver extends UrlBasedViewResolver {
* attributes.
* @see InternalResourceView#setExposedContextBeanNames
*/
public void setExposedContextBeanNames(String[] exposedContextBeanNames) {
public void setExposedContextBeanNames(String... exposedContextBeanNames) {
this.exposedContextBeanNames = exposedContextBeanNames;
}

View File

@@ -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.
@@ -130,7 +130,7 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
* @see #setBasename
* @see java.util.ResourceBundle#getBundle(String)
*/
public void setBasenames(String[] basenames) {
public void setBasenames(String... basenames) {
this.basenames = basenames;
}

View File

@@ -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.
@@ -106,8 +106,6 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
private String suffix = "";
private String[] viewNames = null;
private String contentType;
private boolean redirectContextRelative = true;
@@ -116,13 +114,16 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
private String requestContextAttribute;
private int order = Integer.MAX_VALUE;
/** Map of static attributes, keyed by attribute name (String) */
private final Map<String, Object> staticAttributes = new HashMap<String, Object>();
private Boolean exposePathVariables;
private String[] viewNames;
private int order = Integer.MAX_VALUE;
/**
* Set the view class that should be used to create views.
* @param viewClass class that is assignable to the required view class
@@ -303,6 +304,29 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
return this.staticAttributes;
}
/**
* Specify whether views resolved by this resolver should add path variables to the model or not.
* <p>>The default setting is to let each View decide (see {@link AbstractView#setExposePathVariables}.
* However, you can use this property to override that.
* @param exposePathVariables
* <ul>
* <li>{@code true} - all Views resolved by this resolver will expose path variables
* <li>{@code false} - no Views resolved by this resolver will expose path variables
* <li>{@code null} - individual Views can decide for themselves (this is used by the default)
* <ul>
* @see AbstractView#setExposePathVariables
*/
public void setExposePathVariables(Boolean exposePathVariables) {
this.exposePathVariables = exposePathVariables;
}
/**
* Return whether views resolved by this resolver should add path variables to the model or not.
*/
protected Boolean getExposePathVariables() {
return this.exposePathVariables;
}
/**
* Set the view names (or name patterns) that can be handled by this
* {@link org.springframework.web.servlet.ViewResolver}. View names can contain
@@ -310,7 +334,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
* view name 'myReport'.
* @see #canHandle
*/
public void setViewNames(String[] viewNames) {
public void setViewNames(String... viewNames) {
this.viewNames = viewNames;
}
@@ -339,22 +363,6 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
return this.order;
}
/**
* Whether views resolved by this resolver should add path variables the model or not.
* The default setting is to allow each View decide (see {@link AbstractView#setExposePathVariables(boolean)}.
* However, you can use this property to override that.
* @param exposePathVariables
* <ul>
* <li>{@code true} - all Views resolved by this resolver will expose path variables
* <li>{@code false} - no Views resolved by this resolver will expose path variables
* <li>{@code null} - individual Views can decide for themselves (this is used by the default)
* <ul>
* @see AbstractView#setExposePathVariables(boolean)
*/
public void setExposePathVariables(Boolean exposePathVariables) {
this.exposePathVariables = exposePathVariables;
}
@Override
protected void initApplicationContext() {
super.initApplicationContext();
@@ -363,6 +371,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
}
}
/**
* This implementation returns just the view name,
* as this ViewResolver doesn't support localized resolution.
@@ -460,15 +469,20 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
protected AbstractUrlBasedView buildView(String viewName) throws Exception {
AbstractUrlBasedView view = (AbstractUrlBasedView) BeanUtils.instantiateClass(getViewClass());
view.setUrl(getPrefix() + viewName + getSuffix());
String contentType = getContentType();
if (contentType != null) {
view.setContentType(contentType);
}
view.setRequestContextAttribute(getRequestContextAttribute());
view.setAttributesMap(getAttributesMap());
if (this.exposePathVariables != null) {
Boolean exposePathVariables = getExposePathVariables();
if (exposePathVariables != null) {
view.setExposePathVariables(exposePathVariables);
}
return view;
}

View File

@@ -228,7 +228,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
* @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
* @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
*/
public void setSubReportDataKeys(String[] subReportDataKeys) {
public void setSubReportDataKeys(String... subReportDataKeys) {
this.subReportDataKeys = subReportDataKeys;
}

View File

@@ -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.
@@ -75,7 +75,7 @@ public class JasperReportsViewResolver extends UrlBasedViewResolver {
* Set the {@code subReportDataKeys} the view class should use.
* @see AbstractJasperReportsView#setSubReportDataKeys
*/
public void setSubReportDataKeys(String[] subReportDataKeys) {
public void setSubReportDataKeys(String... subReportDataKeys) {
this.subReportDataKeys = subReportDataKeys;
}