diff --git a/spring-core/src/main/java/org/springframework/util/xml/DomUtils.java b/spring-core/src/main/java/org/springframework/util/xml/DomUtils.java index 12940934c4..61c6271dc3 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/DomUtils.java +++ b/spring-core/src/main/java/org/springframework/util/xml/DomUtils.java @@ -32,7 +32,8 @@ import org.xml.sax.ContentHandler; import org.springframework.util.Assert; /** - * Convenience methods for working with the DOM API, in particular for working with DOM Nodes and DOM Elements. + * Convenience methods for working with the DOM API, + * in particular for working with DOM Nodes and DOM Elements. * * @author Juergen Hoeller * @author Rob Harrop @@ -55,7 +56,7 @@ public abstract class DomUtils { * @see org.w3c.dom.Element * @see org.w3c.dom.Element#getElementsByTagName */ - public static List getChildElementsByTagName(Element ele, String[] childEleNames) { + public static List getChildElementsByTagName(Element ele, String... childEleNames) { Assert.notNull(ele, "Element must not be null"); Assert.notNull(childEleNames, "Element names collection must not be null"); List childEleNameList = Arrays.asList(childEleNames); @@ -81,7 +82,7 @@ public abstract class DomUtils { * @see org.w3c.dom.Element#getElementsByTagName */ public static List getChildElementsByTagName(Element ele, String childEleName) { - return getChildElementsByTagName(ele, new String[]{childEleName}); + return getChildElementsByTagName(ele, new String[] {childEleName}); } /** @@ -184,7 +185,7 @@ public abstract class DomUtils { /** * Matches the given node's name and local name against the given desired names. */ - private static boolean nodeNameMatch(Node node, Collection desiredNames) { + private static boolean nodeNameMatch(Node node, Collection desiredNames) { return (desiredNames.contains(node.getNodeName()) || desiredNames.contains(node.getLocalName())); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java index 167963844d..ecad94de5d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -18,6 +18,8 @@ package org.springframework.web.servlet.config; import java.util.List; +import org.w3c.dom.Element; + import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.parsing.CompositeComponentDefinition; @@ -27,11 +29,10 @@ import org.springframework.beans.factory.xml.BeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.util.xml.DomUtils; import org.springframework.web.servlet.handler.MappedInterceptor; -import org.w3c.dom.Element; /** - * {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses a {@code interceptors} element to register - * a set of {@link MappedInterceptor} definitions. + * {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses a + * {@code interceptors} element to register a set of {@link MappedInterceptor} definitions. * * @author Keith Donald * @since 3.0 @@ -42,7 +43,7 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element)); parserContext.pushContainingComponent(compDefinition); - List interceptors = DomUtils.getChildElementsByTagName(element, new String[] { "bean", "ref", "interceptor" }); + List interceptors = DomUtils.getChildElementsByTagName(element, "bean", "ref", "interceptor"); for (Element interceptor : interceptors) { RootBeanDefinition mappedInterceptorDef = new RootBeanDefinition(MappedInterceptor.class); mappedInterceptorDef.setSource(parserContext.extractSource(interceptor)); @@ -54,7 +55,7 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { if ("interceptor".equals(interceptor.getLocalName())) { includePatterns = getIncludePatterns(interceptor, "mapping"); excludePatterns = getIncludePatterns(interceptor, "exclude-mapping"); - Element beanElem = DomUtils.getChildElementsByTagName(interceptor, new String[] { "bean", "ref"}).get(0); + Element beanElem = DomUtils.getChildElementsByTagName(interceptor, "bean", "ref").get(0); interceptorBean = parserContext.getDelegate().parsePropertySubElement(beanElem, null); } else { @@ -75,8 +76,8 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { private ManagedList getIncludePatterns(Element interceptor, String elementName) { List paths = DomUtils.getChildElementsByTagName(interceptor, elementName); ManagedList patterns = new ManagedList(paths.size()); - for (int i = 0; i < paths.size(); i++) { - patterns.add(paths.get(i).getAttribute("path")); + for (Element path : paths) { + patterns.add(path.getAttribute("path")); } return patterns; }