diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java b/org.springframework.beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java index b7d4db0e589..922187b34ba 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java @@ -91,17 +91,17 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { private boolean configValueEditorsActive = false; - private Map defaultEditors; + private Map, PropertyEditor> defaultEditors; - private Map overriddenDefaultEditors; + private Map, PropertyEditor> overriddenDefaultEditors; - private Map customEditors; + private Map, PropertyEditor> customEditors; private Map customEditorsForPath; private Set sharedEditors; - private Map customEditorCache; + private Map, PropertyEditor> customEditorCache; /** @@ -152,9 +152,9 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * @param propertyEditor the editor to register * @see #registerCustomEditor(Class, PropertyEditor) */ - public void overrideDefaultEditor(Class requiredType, PropertyEditor propertyEditor) { + public void overrideDefaultEditor(Class requiredType, PropertyEditor propertyEditor) { if (this.overriddenDefaultEditors == null) { - this.overriddenDefaultEditors = new HashMap(); + this.overriddenDefaultEditors = new HashMap, PropertyEditor>(); } this.overriddenDefaultEditors.put(requiredType, propertyEditor); } @@ -166,7 +166,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * @return the default editor, or null if none found * @see #registerDefaultEditors */ - public PropertyEditor getDefaultEditor(Class requiredType) { + public PropertyEditor getDefaultEditor(Class requiredType) { if (!this.defaultEditorsActive) { return null; } @@ -186,7 +186,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * Actually register the default editors for this registry instance. */ private void createDefaultEditors() { - this.defaultEditors = new HashMap(64); + this.defaultEditors = new HashMap, PropertyEditor>(64); // Simple editors, without parameterization capabilities. // The JDK does not contain a default editor for any of these target types. @@ -269,11 +269,11 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { // Management of custom editors //--------------------------------------------------------------------- - public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor) { + public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor) { registerCustomEditor(requiredType, null, propertyEditor); } - public void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor) { + public void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor) { if (requiredType == null && propertyPath == null) { throw new IllegalArgumentException("Either requiredType or propertyPath is required"); } @@ -285,7 +285,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { } else { if (this.customEditors == null) { - this.customEditors = new LinkedHashMap(16); + this.customEditors = new LinkedHashMap, PropertyEditor>(16); } this.customEditors.put(requiredType, propertyEditor); this.customEditorCache = null; @@ -301,7 +301,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * @deprecated as of Spring 3.0, in favor of PropertyEditorRegistrars or ConversionService usage */ @Deprecated - public void registerSharedEditor(Class requiredType, PropertyEditor propertyEditor) { + public void registerSharedEditor(Class requiredType, PropertyEditor propertyEditor) { registerCustomEditor(requiredType, null, propertyEditor); if (this.sharedEditors == null) { this.sharedEditors = new HashSet(); @@ -319,8 +319,8 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { return (this.sharedEditors != null && this.sharedEditors.contains(propertyEditor)); } - public PropertyEditor findCustomEditor(Class requiredType, String propertyPath) { - Class requiredTypeToUse = requiredType; + public PropertyEditor findCustomEditor(Class requiredType, String propertyPath) { + Class requiredTypeToUse = requiredType; if (propertyPath != null) { if (this.customEditorsForPath != null) { // Check property-specific editor first. @@ -354,7 +354,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * can be null if not known) * @return whether a matching custom editor has been found */ - public boolean hasCustomEditorForElement(Class elementType, String propertyPath) { + public boolean hasCustomEditorForElement(Class elementType, String propertyPath) { if (propertyPath != null && this.customEditorsForPath != null) { for (Map.Entry entry : this.customEditorsForPath.entrySet()) { if (PropertyAccessorUtils.matchesProperty(entry.getKey(), propertyPath)) { @@ -379,7 +379,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * @return the type of the property, or null if not determinable * @see BeanWrapper#getPropertyType(String) */ - protected Class getPropertyType(String propertyPath) { + protected Class getPropertyType(String propertyPath) { return null; } @@ -389,7 +389,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * @param requiredType the type to look for * @return the custom editor, or null if none specific for this property */ - private PropertyEditor getCustomEditor(String propertyName, Class requiredType) { + private PropertyEditor getCustomEditor(String propertyName, Class requiredType) { CustomEditorHolder holder = this.customEditorsForPath.get(propertyName); return (holder != null ? holder.getPropertyEditor(requiredType) : null); } @@ -402,7 +402,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * @return the custom editor, or null if none found for this type * @see java.beans.PropertyEditor#getAsText() */ - private PropertyEditor getCustomEditor(Class requiredType) { + private PropertyEditor getCustomEditor(Class requiredType) { if (requiredType == null || this.customEditors == null) { return null; } @@ -415,14 +415,14 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { } if (editor == null) { // Find editor for superclass or interface. - for (Iterator it = this.customEditors.keySet().iterator(); it.hasNext() && editor == null;) { - Class key = it.next(); + for (Iterator> it = this.customEditors.keySet().iterator(); it.hasNext() && editor == null;) { + Class key = it.next(); if (key.isAssignableFrom(requiredType)) { editor = this.customEditors.get(key); // Cache editor for search type, to avoid the overhead // of repeated assignable-from checks. if (this.customEditorCache == null) { - this.customEditorCache = new HashMap(); + this.customEditorCache = new HashMap, PropertyEditor>(); } this.customEditorCache.put(requiredType, editor); } @@ -438,7 +438,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * @param propertyName the name of the property * @return the property type, or null if not determinable */ - protected Class guessPropertyTypeFromEditors(String propertyName) { + protected Class guessPropertyTypeFromEditors(String propertyName) { if (this.customEditorsForPath != null) { CustomEditorHolder editorHolder = this.customEditorsForPath.get(propertyName); if (editorHolder == null) { @@ -467,7 +467,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { String actualPropertyName = (nestedProperty != null ? PropertyAccessorUtils.getPropertyName(nestedProperty) : null); if (this.customEditors != null) { - for (Map.Entry entry : this.customEditors.entrySet()) { + for (Map.Entry, PropertyEditor> entry : this.customEditors.entrySet()) { target.registerCustomEditor(entry.getKey(), entry.getValue()); } } @@ -529,9 +529,9 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { private final PropertyEditor propertyEditor; - private final Class registeredType; + private final Class registeredType; - private CustomEditorHolder(PropertyEditor propertyEditor, Class registeredType) { + private CustomEditorHolder(PropertyEditor propertyEditor, Class registeredType) { this.propertyEditor = propertyEditor; this.registeredType = registeredType; } @@ -540,11 +540,11 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { return this.propertyEditor; } - private Class getRegisteredType() { + private Class getRegisteredType() { return this.registeredType; } - private PropertyEditor getPropertyEditor(Class requiredType) { + private PropertyEditor getPropertyEditor(Class requiredType) { // Special case: If no required type specified, which usually only happens for // Collection elements, or required type is not assignable to registered type, // which usually only happens for generic properties of type Object - diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java b/org.springframework.beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java index d1ca79798ca..7a746089f77 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java @@ -70,7 +70,7 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar { * @see org.springframework.core.io.support.ResourcePatternResolver * @see org.springframework.context.ApplicationContext * @deprecated as of Spring 3.1 in favor of - * {@link ResourceEditorRegistrar#ResourceEditorRegistrar(ResourceLoader, Environment)} + * {@link #ResourceEditorRegistrar(ResourceLoader, Environment)} */ @Deprecated public ResourceEditorRegistrar(ResourceLoader resourceLoader) { @@ -91,16 +91,19 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar { /** - * Populate the given bean factory with the following resource editors: - * ResourceEditor, InputStreamEditor, FileEditor, URLEditor, ClassEditor, URIEditor. - *

In case of a {@link org.springframework.core.io.support.ResourcePatternResolver}, + * Populate the given registry with the following resource editors: + * ResourceEditor, InputStreamEditor, InputSourceEditor, FileEditor, URLEditor, + * URIEditor, ClassEditor, ClassArrayEditor. + *

If this registrar has been configured with a {@link ResourcePatternResolver}, * a ResourceArrayPropertyEditor will be registered as well. * @see org.springframework.core.io.ResourceEditor * @see org.springframework.beans.propertyeditors.InputStreamEditor + * @see org.springframework.beans.propertyeditors.InputSourceEditor * @see org.springframework.beans.propertyeditors.FileEditor * @see org.springframework.beans.propertyeditors.URLEditor - * @see org.springframework.beans.propertyeditors.ClassEditor * @see org.springframework.beans.propertyeditors.URIEditor + * @see org.springframework.beans.propertyeditors.ClassEditor + * @see org.springframework.beans.propertyeditors.ClassArrayEditor * @see org.springframework.core.io.support.ResourceArrayPropertyEditor */ public void registerCustomEditors(PropertyEditorRegistry registry) { @@ -126,7 +129,7 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar { * Override default editor, if possible (since that's what we really mean to do here); * otherwise register as a custom editor. */ - private void doRegisterEditor(PropertyEditorRegistry registry, Class requiredType, PropertyEditor editor) { + private void doRegisterEditor(PropertyEditorRegistry registry, Class requiredType, PropertyEditor editor) { if (registry instanceof PropertyEditorRegistrySupport) { ((PropertyEditorRegistrySupport) registry).overrideDefaultEditor(requiredType, editor); } diff --git a/org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java b/org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java index 8ed5a1b54fd..a9d473da2ac 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java +++ b/org.springframework.core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java @@ -84,8 +84,8 @@ import org.springframework.util.StringUtils; * "zip:" in WebLogic, "wsjar" in WebSphere", etc.), * then a java.io.File is obtained from it, and used to resolve the * wildcard by walking the filesystem. In the case of a jar URL, the resolver - * either gets a java.net.JarURLConnection from it, or manually parse - * the jar URL, and then traverse the contents of the jar file, to resolve the + * either gets a java.net.JarURLConnection from it, or manually parses + * the jar URL, and then traverses the contents of the jar file, to resolve the * wildcards. * *

Implications on portability: @@ -173,7 +173,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol static { // Detect Equinox OSGi (e.g. on WebSphere 6.1) try { - Class fileLocatorClass = PathMatchingResourcePatternResolver.class.getClassLoader().loadClass( + Class fileLocatorClass = PathMatchingResourcePatternResolver.class.getClassLoader().loadClass( "org.eclipse.core.runtime.FileLocator"); equinoxResolveMethod = fileLocatorClass.getMethod("resolve", URL.class); logger.debug("Found Equinox FileLocator for OSGi bundle URL resolution"); @@ -220,7 +220,6 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol this.resourceLoader = resourceLoader; } - /** * Return the ResourceLoader that this pattern resolver works with. */ @@ -286,7 +285,6 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol } } - /** * Find all class location resources with the given location via the ClassLoader. * @param location the absolute path within the classpath @@ -300,10 +298,10 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol if (path.startsWith("/")) { path = path.substring(1); } - Enumeration resourceUrls = getClassLoader().getResources(path); + Enumeration resourceUrls = getClassLoader().getResources(path); Set result = new LinkedHashSet(16); while (resourceUrls.hasMoreElements()) { - URL url = (URL) resourceUrls.nextElement(); + URL url = resourceUrls.nextElement(); result.add(convertClassLoaderURL(url)); } return result.toArray(new Resource[result.size()]); @@ -384,7 +382,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol *

The default implementation detects an Equinox OSGi "bundleresource:" * / "bundleentry:" URL and resolves it into a standard jar file URL that * can be traversed using Spring's standard jar file traversal algorithm. - * @param original the resource to resolfe + * @param original the resource to resolve * @return the resolved resource (may be identical to the passed-in resource) * @throws IOException in case of resolution failure */ @@ -471,8 +469,8 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol rootEntryPath = rootEntryPath + "/"; } Set result = new LinkedHashSet(8); - for (Enumeration entries = jarFile.entries(); entries.hasMoreElements();) { - JarEntry entry = (JarEntry) entries.nextElement(); + for (Enumeration entries = jarFile.entries(); entries.hasMoreElements();) { + JarEntry entry = entries.nextElement(); String entryPath = entry.getName(); if (entryPath.startsWith(rootEntryPath)) { String relativePath = entryPath.substring(rootEntryPath.length()); @@ -604,7 +602,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol * Recursively retrieve files that match the given pattern, * adding them to the given result list. * @param fullPattern the pattern to match against, - * with preprended root directory path + * with prepended root directory path * @param dir the current directory * @param result the Set of matching File instances to add to * @throws IOException if directory contents could not be retrieved @@ -712,11 +710,11 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol return VfsPatternUtils.getVisitorAttribute(); } - public Set getResources() { return this.resources; } + @SuppressWarnings("unused") public int size() { return this.resources.size(); } diff --git a/org.springframework.core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java b/org.springframework.core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java index e09dd9f90b0..a9b8bf1ad10 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java +++ b/org.springframework.core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java @@ -37,9 +37,9 @@ import org.springframework.core.io.Resource; * to Resource array properties. Can also translate a collection * or array of location patterns into a merged Resource array. * - *

The path may contain ${...} placeholders, - * to be resolved as system properties: e.g. ${user.dir}. - * Unresolvable placeholder are ignored by default. + *

A path may contain ${...} placeholders, to be + * resolved as {@link org.springframework.core.env.Environment} properties: + * e.g. ${user.dir}. Unresolvable placeholders are ignored by default. * *

Delegates to a {@link ResourcePatternResolver}, * by default using a {@link PathMatchingResourcePatternResolver}. @@ -123,7 +123,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport { /** - * Treat the given text as location pattern and convert it to a Resource array. + * Treat the given text as a location pattern and convert it to a Resource array. */ @Override public void setAsText(String text) { @@ -138,13 +138,13 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport { } /** - * Treat the given value as collection or array and convert it to a Resource array. - * Considers String elements as location patterns, and takes Resource elements as-is. + * Treat the given value as a collection or array and convert it to a Resource array. + * Considers String elements as location patterns and takes Resource elements as-is. */ @Override public void setValue(Object value) throws IllegalArgumentException { if (value instanceof Collection || (value instanceof Object[] && !(value instanceof Resource[]))) { - Collection input = (value instanceof Collection ? (Collection) value : Arrays.asList((Object[]) value)); + Collection input = (value instanceof Collection ? (Collection) value : Arrays.asList((Object[]) value)); List merged = new ArrayList(); for (Object element : input) { if (element instanceof String) {