diff --git a/spring-binding/.settings/org.eclipse.jdt.core.prefs b/spring-binding/.settings/org.eclipse.jdt.core.prefs index f201f9dc..7a83a2f8 100644 --- a/spring-binding/.settings/org.eclipse.jdt.core.prefs +++ b/spring-binding/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Wed Jun 09 09:16:13 BST 2010 +#Tue Jan 17 17:40:54 PST 2012 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -19,6 +19,8 @@ org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled @@ -26,11 +28,13 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore @@ -42,6 +46,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public @@ -49,7 +54,9 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore @@ -57,12 +64,20 @@ org.eclipse.jdt.core.compiler.problem.nullReference=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning @@ -70,14 +85,19 @@ org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false diff --git a/spring-binding/src/main/java/org/springframework/binding/collection/CompositeIterator.java b/spring-binding/src/main/java/org/springframework/binding/collection/CompositeIterator.java index bb19e127..bf19d5be 100644 --- a/spring-binding/src/main/java/org/springframework/binding/collection/CompositeIterator.java +++ b/spring-binding/src/main/java/org/springframework/binding/collection/CompositeIterator.java @@ -28,9 +28,9 @@ import org.springframework.util.Assert; * * @author Erwin Vervaet */ -public class CompositeIterator implements Iterator { +public class CompositeIterator implements Iterator { - private List iterators = new LinkedList(); + private List> iterators = new LinkedList>(); private boolean inUse = false; @@ -43,7 +43,7 @@ public class CompositeIterator implements Iterator { /** * Add given iterator to this composite. */ - public void add(Iterator iterator) { + public void add(Iterator iterator) { Assert.state(!inUse, "You can no longer add iterator to a composite iterator that's already in use"); if (iterators.contains(iterator)) { throw new IllegalArgumentException("You cannot add the same iterator twice"); @@ -53,18 +53,17 @@ public class CompositeIterator implements Iterator { public boolean hasNext() { inUse = true; - for (Iterator it = iterators.iterator(); it.hasNext();) { - if (((Iterator) it.next()).hasNext()) { + for (Iterator iterator : iterators) { + if (iterator.hasNext()) { return true; } } return false; } - public Object next() { + public E next() { inUse = true; - for (Iterator it = iterators.iterator(); it.hasNext();) { - Iterator iterator = (Iterator) it.next(); + for (Iterator iterator : iterators) { if (iterator.hasNext()) { return iterator.next(); } diff --git a/spring-binding/src/main/java/org/springframework/binding/collection/MapAccessor.java b/spring-binding/src/main/java/org/springframework/binding/collection/MapAccessor.java index 092d64ea..babe5aaf 100644 --- a/spring-binding/src/main/java/org/springframework/binding/collection/MapAccessor.java +++ b/spring-binding/src/main/java/org/springframework/binding/collection/MapAccessor.java @@ -26,25 +26,25 @@ import org.springframework.util.Assert; * * @author Keith Donald */ -public class MapAccessor implements MapAdaptable { +public class MapAccessor implements MapAdaptable { /** * The target map. */ - private Map map; + private Map map; /** * Creates a new attribute map accessor. * @param map the map */ - public MapAccessor(Map map) { + public MapAccessor(Map map) { Assert.notNull(map, "The map to decorate is required"); this.map = map; } // implementing MapAdaptable - public Map asMap() { + public Map asMap() { return map; } @@ -53,7 +53,7 @@ public class MapAccessor implements MapAdaptable { * @param key the key * @return the value */ - public Object get(Object key) { + public V get(Object key) { return map.get(key); } @@ -63,7 +63,7 @@ public class MapAccessor implements MapAdaptable { * @param defaultValue the default * @return the attribute value */ - public Object get(Object key, Object defaultValue) { + public V get(Object key, V defaultValue) { if (!map.containsKey(key)) { return defaultValue; } @@ -78,7 +78,7 @@ public class MapAccessor implements MapAdaptable { * @return the value * @throws IllegalArgumentException if the key is present but the value is not of the required type */ - public Object get(Object key, Class requiredType) throws IllegalArgumentException { + public T get(Object key, Class requiredType) throws IllegalArgumentException { return get(key, requiredType, null); } @@ -90,7 +90,7 @@ public class MapAccessor implements MapAdaptable { * @return the attribute value * @throws IllegalArgumentException if the key is present but the value is not of the required type */ - public Object get(Object key, Class requiredType, Object defaultValue) { + public T get(Object key, Class requiredType, T defaultValue) { if (!map.containsKey(key)) { return defaultValue; } @@ -102,7 +102,7 @@ public class MapAccessor implements MapAdaptable { * @param key the key * @return the value */ - public Object getRequired(Object key) throws IllegalArgumentException { + public V getRequired(Object key) throws IllegalArgumentException { assertContainsKey(key); return map.get(key); } @@ -113,7 +113,7 @@ public class MapAccessor implements MapAdaptable { * @param requiredType the required type * @return the value */ - public Object getRequired(Object key, Class requiredType) throws IllegalArgumentException { + public T getRequired(Object key, Class requiredType) throws IllegalArgumentException { assertContainsKey(key); return assertKeyValueOfType(key, requiredType); } @@ -139,7 +139,7 @@ public class MapAccessor implements MapAdaptable { if (!map.containsKey(key)) { return defaultValue; } - return (String) assertKeyValueOfType(key, String.class); + return assertKeyValueOfType(key, String.class); } /** @@ -150,7 +150,7 @@ public class MapAccessor implements MapAdaptable { */ public String getRequiredString(Object key) throws IllegalArgumentException { assertContainsKey(key); - return (String) assertKeyValueOfType(key, String.class); + return assertKeyValueOfType(key, String.class); } /** @@ -159,11 +159,12 @@ public class MapAccessor implements MapAdaptable { * @return the collection value * @throws IllegalArgumentException if the key is present but the value is not a collection */ - public Collection getCollection(Object key) throws IllegalArgumentException { + @SuppressWarnings("unchecked") + public Collection getCollection(Object key) throws IllegalArgumentException { if (!map.containsKey(key)) { return null; } - return (Collection) assertKeyValueOfType(key, Collection.class); + return assertKeyValueOfType(key, Collection.class); } /** @@ -173,12 +174,12 @@ public class MapAccessor implements MapAdaptable { * @return the collection value * @throws IllegalArgumentException if the key is present but the value is not a collection */ - public Collection getCollection(Object key, Class requiredType) throws IllegalArgumentException { + public > T getCollection(Object key, Class requiredType) throws IllegalArgumentException { if (!map.containsKey(key)) { return null; } assertAssignableTo(Collection.class, requiredType); - return (Collection) assertKeyValueOfType(key, requiredType); + return assertKeyValueOfType(key, requiredType); } /** @@ -187,9 +188,10 @@ public class MapAccessor implements MapAdaptable { * @return the collection value * @throws IllegalArgumentException if the key is not present or present but the value is not a collection */ - public Collection getRequiredCollection(Object key) throws IllegalArgumentException { + @SuppressWarnings("unchecked") + public Collection getRequiredCollection(Object key) throws IllegalArgumentException { assertContainsKey(key); - return (Collection) assertKeyValueOfType(key, Collection.class); + return assertKeyValueOfType(key, Collection.class); } /** @@ -200,10 +202,11 @@ public class MapAccessor implements MapAdaptable { * @throws IllegalArgumentException if the key is not present or present but the value is not a collection of the * required type */ - public Collection getRequiredCollection(Object key, Class requiredType) throws IllegalArgumentException { + public > T getRequiredCollection(Object key, Class requiredType) + throws IllegalArgumentException { assertContainsKey(key); assertAssignableTo(Collection.class, requiredType); - return (Collection) assertKeyValueOfType(key, requiredType); + return assertKeyValueOfType(key, requiredType); } /** @@ -213,12 +216,12 @@ public class MapAccessor implements MapAdaptable { * @return the array value * @throws IllegalArgumentException if the key is present but the value is not an array of the required type */ - public Object[] getArray(Object key, Class requiredType) throws IllegalArgumentException { + public T[] getArray(Object key, Class requiredType) throws IllegalArgumentException { assertAssignableTo(Object[].class, requiredType); if (!map.containsKey(key)) { return null; } - return (Object[]) assertKeyValueOfType(key, requiredType); + return assertKeyValueOfType(key, requiredType); } /** @@ -229,10 +232,11 @@ public class MapAccessor implements MapAdaptable { * @throws IllegalArgumentException if the key is not present or present but the value is not a array of the * required type */ - public Object[] getRequiredArray(Object key, Class requiredType) throws IllegalArgumentException { + public T[] getRequiredArray(Object key, Class requiredType) + throws IllegalArgumentException { assertContainsKey(key); assertAssignableTo(Object[].class, requiredType); - return (Object[]) assertKeyValueOfType(key, requiredType); + return assertKeyValueOfType(key, requiredType); } /** @@ -240,10 +244,10 @@ public class MapAccessor implements MapAdaptable { * found. * @param key the key * @param requiredType the required number type - * @return the numbervalue + * @return the number value * @throws IllegalArgumentException if the key is present but the value is not a number of the required type */ - public Number getNumber(Object key, Class requiredType) throws IllegalArgumentException { + public T getNumber(Object key, Class requiredType) throws IllegalArgumentException { return getNumber(key, requiredType, null); } @@ -255,12 +259,13 @@ public class MapAccessor implements MapAdaptable { * @param defaultValue the default * @throws IllegalArgumentException if the key is present but the value is not a number of the required type */ - public Number getNumber(Object key, Class requiredType, Number defaultValue) throws IllegalArgumentException { + public T getNumber(Object key, Class requiredType, T defaultValue) + throws IllegalArgumentException { if (!map.containsKey(key)) { return defaultValue; } assertAssignableTo(Number.class, requiredType); - return (Number) assertKeyValueOfType(key, requiredType); + return assertKeyValueOfType(key, requiredType); } /** @@ -270,9 +275,9 @@ public class MapAccessor implements MapAdaptable { * @throws IllegalArgumentException if the key is not present or present but the value is not a number of the * required type */ - public Number getRequiredNumber(Object key, Class requiredType) throws IllegalArgumentException { + public T getRequiredNumber(Object key, Class requiredType) throws IllegalArgumentException { assertContainsKey(key); - return (Number) assertKeyValueOfType(key, requiredType); + return assertKeyValueOfType(key, requiredType); } /** @@ -293,7 +298,7 @@ public class MapAccessor implements MapAdaptable { * @throws IllegalArgumentException if the key is present but the value is not an integer */ public Integer getInteger(Object key, Integer defaultValue) throws IllegalArgumentException { - return (Integer) getNumber(key, Integer.class, defaultValue); + return getNumber(key, Integer.class, defaultValue); } /** @@ -303,7 +308,7 @@ public class MapAccessor implements MapAdaptable { * @throws IllegalArgumentException if the key is not present or present but the value is not an integer */ public Integer getRequiredInteger(Object key) throws IllegalArgumentException { - return (Integer) getRequiredNumber(key, Integer.class); + return getRequiredNumber(key, Integer.class); } /** @@ -324,7 +329,7 @@ public class MapAccessor implements MapAdaptable { * @throws IllegalArgumentException if the key is present but the value is not a long */ public Long getLong(Object key, Long defaultValue) throws IllegalArgumentException { - return (Long) getNumber(key, Long.class, defaultValue); + return getNumber(key, Long.class, defaultValue); } /** @@ -334,7 +339,7 @@ public class MapAccessor implements MapAdaptable { * @throws IllegalArgumentException if the key is not present or present but the value is not a long */ public Long getRequiredLong(Object key) throws IllegalArgumentException { - return (Long) getRequiredNumber(key, Long.class); + return getRequiredNumber(key, Long.class); } /** @@ -358,7 +363,7 @@ public class MapAccessor implements MapAdaptable { if (!map.containsKey(key)) { return defaultValue; } - return (Boolean) assertKeyValueOfType(key, Boolean.class); + return assertKeyValueOfType(key, Boolean.class); } /** @@ -369,7 +374,7 @@ public class MapAccessor implements MapAdaptable { */ public Boolean getRequiredBoolean(Object key) throws IllegalArgumentException { assertContainsKey(key); - return (Boolean) assertKeyValueOfType(key, Boolean.class); + return assertKeyValueOfType(key, Boolean.class); } /** @@ -389,7 +394,7 @@ public class MapAccessor implements MapAdaptable { * @param key the attribute name * @return true if present and of the required type, false if not present. */ - public boolean containsKey(Object key, Class requiredType) throws IllegalArgumentException { + public boolean containsKey(Object key, Class requiredType) throws IllegalArgumentException { if (map.containsKey(key)) { assertKeyValueOfType(key, requiredType); return true; @@ -404,7 +409,7 @@ public class MapAccessor implements MapAdaptable { * @param requiredType the required attribute value type * @return the attribute value */ - public Object assertKeyValueOfType(Object key, Class requiredType) { + public T assertKeyValueOfType(Object key, Class requiredType) { return assertKeyValueInstanceOf(key, map.get(key), requiredType); } @@ -415,17 +420,18 @@ public class MapAccessor implements MapAdaptable { * @param requiredType the required type * @return the value */ - public Object assertKeyValueInstanceOf(Object key, Object value, Class requiredType) { + @SuppressWarnings("unchecked") + public T assertKeyValueInstanceOf(Object key, Object value, Class requiredType) { Assert.notNull(requiredType, "The required type to assert is required"); if (value != null && !requiredType.isInstance(value)) { throw new IllegalArgumentException("Map key '" + key + "' has value [" + value + "] that is not of expected type [" + requiredType + "], instead it is of type [" + value.getClass().getName() + "]"); } - return value; + return (T) value; } - private void assertAssignableTo(Class clazz, Class requiredType) { + private void assertAssignableTo(Class clazz, Class requiredType) { Assert.isTrue(clazz.isAssignableFrom(requiredType), "The provided required type must be assignable to [" + clazz + "]"); } diff --git a/spring-binding/src/main/java/org/springframework/binding/collection/MapAdaptable.java b/spring-binding/src/main/java/org/springframework/binding/collection/MapAdaptable.java index b8c8980c..9303beb0 100644 --- a/spring-binding/src/main/java/org/springframework/binding/collection/MapAdaptable.java +++ b/spring-binding/src/main/java/org/springframework/binding/collection/MapAdaptable.java @@ -18,11 +18,11 @@ package org.springframework.binding.collection; import java.util.Map; /** - * An object whose contents are capable of being exposed as an unmodifiable map. + * An object whose contents are capable of being exposed as a map. * * @author Keith Donald */ -public interface MapAdaptable { +public interface MapAdaptable { /** * Returns this object's contents as a {@link Map}. The returned map may or may not be modifiable depending on this @@ -32,6 +32,6 @@ public interface MapAdaptable { * calculated) be cached as appropriate. * @return the object's contents as a map */ - public Map asMap(); + public Map asMap(); } \ No newline at end of file diff --git a/spring-binding/src/main/java/org/springframework/binding/collection/SharedMap.java b/spring-binding/src/main/java/org/springframework/binding/collection/SharedMap.java index f503eeb6..9da1cd5b 100644 --- a/spring-binding/src/main/java/org/springframework/binding/collection/SharedMap.java +++ b/spring-binding/src/main/java/org/springframework/binding/collection/SharedMap.java @@ -25,7 +25,7 @@ import java.util.Map; * * @author Keith Donald */ -public interface SharedMap extends Map { +public interface SharedMap extends Map { /** * Returns the shared mutex that may be synchronized on using a synchronized block. The returned mutex is guaranteed diff --git a/spring-binding/src/main/java/org/springframework/binding/collection/SharedMapDecorator.java b/spring-binding/src/main/java/org/springframework/binding/collection/SharedMapDecorator.java index c6109fab..9bea757f 100644 --- a/spring-binding/src/main/java/org/springframework/binding/collection/SharedMapDecorator.java +++ b/spring-binding/src/main/java/org/springframework/binding/collection/SharedMapDecorator.java @@ -28,18 +28,18 @@ import org.springframework.core.style.ToStringCreator; * * @author Keith Donald */ -public class SharedMapDecorator implements SharedMap, Serializable { +public class SharedMapDecorator implements SharedMap, Serializable { /** * The wrapped, target map. */ - private Map map; + private Map map; /** * Creates a new shared map decorator. * @param map the map that is shared by multiple threads, to be synced */ - public SharedMapDecorator(Map map) { + public SharedMapDecorator(Map map) { this.map = map; } @@ -57,11 +57,11 @@ public class SharedMapDecorator implements SharedMap, Serializable { return map.containsValue(value); } - public Set entrySet() { + public Set> entrySet() { return map.entrySet(); } - public Object get(Object key) { + public V get(Object key) { return map.get(key); } @@ -69,19 +69,19 @@ public class SharedMapDecorator implements SharedMap, Serializable { return map.isEmpty(); } - public Set keySet() { + public Set keySet() { return map.keySet(); } - public Object put(Object key, Object value) { + public V put(K key, V value) { return map.put(key, value); } - public void putAll(Map map) { + public void putAll(Map map) { this.map.putAll(map); } - public Object remove(Object key) { + public V remove(Object key) { return map.remove(key); } @@ -89,7 +89,7 @@ public class SharedMapDecorator implements SharedMap, Serializable { return map.size(); } - public Collection values() { + public Collection values() { return map.values(); } diff --git a/spring-binding/src/main/java/org/springframework/binding/collection/StringKeyedMapAdapter.java b/spring-binding/src/main/java/org/springframework/binding/collection/StringKeyedMapAdapter.java index 3e1a92ed..47ad417b 100644 --- a/spring-binding/src/main/java/org/springframework/binding/collection/StringKeyedMapAdapter.java +++ b/spring-binding/src/main/java/org/springframework/binding/collection/StringKeyedMapAdapter.java @@ -27,19 +27,19 @@ import java.util.Set; * * @author Keith Donald */ -public abstract class StringKeyedMapAdapter implements Map { +public abstract class StringKeyedMapAdapter implements Map { - private Set keySet; + private Set keySet; - private Collection values; + private Collection values; - private Set entrySet; + private Set> entrySet; // implementing Map public void clear() { - for (Iterator it = getAttributeNames(); it.hasNext();) { - removeAttribute((String) it.next()); + for (Iterator it = getAttributeNames(); it.hasNext();) { + removeAttribute(it.next()); } } @@ -51,8 +51,8 @@ public abstract class StringKeyedMapAdapter implements Map { if (value == null) { return false; } - for (Iterator it = getAttributeNames(); it.hasNext();) { - Object aValue = getAttribute((String) it.next()); + for (Iterator it = getAttributeNames(); it.hasNext();) { + Object aValue = getAttribute(it.next()); if (value.equals(aValue)) { return true; } @@ -60,11 +60,11 @@ public abstract class StringKeyedMapAdapter implements Map { return false; } - public Set entrySet() { + public Set> entrySet() { return (entrySet != null) ? entrySet : (entrySet = new EntrySet()); } - public Object get(Object key) { + public V get(Object key) { return getAttribute(key.toString()); } @@ -72,41 +72,40 @@ public abstract class StringKeyedMapAdapter implements Map { return !getAttributeNames().hasNext(); } - public Set keySet() { + public Set keySet() { return (keySet != null) ? keySet : (keySet = new KeySet()); } - public Object put(Object key, Object value) { + public V put(String key, V value) { String stringKey = String.valueOf(key); - Object previousValue = getAttribute(stringKey); + V previousValue = getAttribute(stringKey); setAttribute(stringKey, value); return previousValue; } - public void putAll(Map map) { - for (Iterator it = map.entrySet().iterator(); it.hasNext();) { - Entry entry = (Entry) it.next(); - setAttribute(entry.getKey().toString(), entry.getValue()); + public void putAll(Map map) { + for (Entry entry : map.entrySet()) { + setAttribute(entry.getKey(), entry.getValue()); } } - public Object remove(Object key) { + public V remove(Object key) { String stringKey = key.toString(); - Object retval = getAttribute(stringKey); + V retval = getAttribute(stringKey); removeAttribute(stringKey); return retval; } public int size() { int size = 0; - for (Iterator it = getAttributeNames(); it.hasNext();) { + for (Iterator it = getAttributeNames(); it.hasNext();) { size++; it.next(); } return size; } - public Collection values() { + public Collection values() { return (values != null) ? values : (values = new Values()); } @@ -117,7 +116,7 @@ public abstract class StringKeyedMapAdapter implements Map { * @param key the key to lookup * @return the associated value, or null if none */ - protected abstract Object getAttribute(String key); + protected abstract V getAttribute(String key); /** * Hook method that needs to be implemented by concrete subclasses. Puts a key-value pair in the map, overwriting @@ -125,7 +124,7 @@ public abstract class StringKeyedMapAdapter implements Map { * @param key the key to associate the value with * @param value the value to associate with the key */ - protected abstract void setAttribute(String key, Object value); + protected abstract void setAttribute(String key, V value); /** * Hook method that needs to be implemented by concrete subclasses. Removes a key and its associated value from the @@ -139,11 +138,11 @@ public abstract class StringKeyedMapAdapter implements Map { * the map. * @return the key enumeration */ - protected abstract Iterator getAttributeNames(); + protected abstract Iterator getAttributeNames(); // internal helper classes - private abstract class AbstractSet extends java.util.AbstractSet { + private abstract class AbstractSet extends java.util.AbstractSet { public boolean isEmpty() { return StringKeyedMapAdapter.this.isEmpty(); } @@ -157,8 +156,8 @@ public abstract class StringKeyedMapAdapter implements Map { } } - private class KeySet extends AbstractSet { - public Iterator iterator() { + private class KeySet extends AbstractSet { + public Iterator iterator() { return new KeyIterator(); } @@ -171,10 +170,10 @@ public abstract class StringKeyedMapAdapter implements Map { } } - private class KeyIterator implements Iterator { - protected final Iterator it = getAttributeNames(); + private abstract class AbstractKeyIterator { + private final Iterator it = getAttributeNames(); - protected Object currentKey; + private String currentKey; public void remove() { if (currentKey == null) { @@ -187,13 +186,19 @@ public abstract class StringKeyedMapAdapter implements Map { return it.hasNext(); } - public Object next() { + protected String nextKey() { return currentKey = it.next(); } } - private class Values extends AbstractSet { - public Iterator iterator() { + private class KeyIterator extends AbstractKeyIterator implements Iterator { + public String next() { + return nextKey(); + } + } + + private class Values extends AbstractSet { + public Iterator iterator() { return new ValuesIterator(); } @@ -205,7 +210,7 @@ public abstract class StringKeyedMapAdapter implements Map { if (o == null) { return false; } - for (Iterator it = iterator(); it.hasNext();) { + for (Iterator it = iterator(); it.hasNext();) { if (o.equals(it.next())) { it.remove(); return true; @@ -215,68 +220,69 @@ public abstract class StringKeyedMapAdapter implements Map { } } - private class ValuesIterator extends KeyIterator { - public Object next() { - super.next(); - return StringKeyedMapAdapter.this.get(currentKey); + private class ValuesIterator extends AbstractKeyIterator implements Iterator { + public V next() { + return StringKeyedMapAdapter.this.get(nextKey()); } } - private class EntrySet extends AbstractSet { - public Iterator iterator() { + private class EntrySet extends AbstractSet> { + public Iterator> iterator() { return new EntryIterator(); } public boolean contains(Object o) { - if (!(o instanceof Entry)) { + Entry entry = getAsEntry(o); + if (entry == null || entry.getKey() == null || entry.getValue() == null) { return false; } - Entry entry = (Entry) o; - Object key = entry.getKey(); - Object value = entry.getValue(); - if (key == null || value == null) { - return false; - } - return value.equals(StringKeyedMapAdapter.this.get(key)); + V valueFromThisMap = StringKeyedMapAdapter.this.get(entry.getKey()); + return entry.getValue().equals(valueFromThisMap); } public boolean remove(Object o) { - if (!(o instanceof Entry)) { + Entry entry = getAsEntry(o); + if (entry == null || entry.getKey() == null || entry.getValue() == null) { return false; } - Entry entry = (Entry) o; - Object key = entry.getKey(); - Object value = entry.getValue(); - if (key == null || value == null || !value.equals(StringKeyedMapAdapter.this.get(key))) { + V valueFromThisMap = StringKeyedMapAdapter.this.get(entry.getKey()); + if (!entry.getValue().equals(valueFromThisMap)) { return false; } - return StringKeyedMapAdapter.this.remove(((Entry) o).getKey()) != null; + return StringKeyedMapAdapter.this.remove(entry.getKey()) != null; + } + + @SuppressWarnings("unchecked") + private Entry getAsEntry(Object o) { + if (o instanceof Entry) { + return (Entry) o; + } + return null; } } - private class EntryIterator extends KeyIterator { - public Object next() { - super.next(); - return new EntrySetEntry(currentKey); + private class EntryIterator extends AbstractKeyIterator implements Iterator> { + public Entry next() { + return new EntrySetEntry(nextKey()); } } - private class EntrySetEntry implements Entry { - private final Object currentKey; + private class EntrySetEntry implements Entry { + private final String currentKey; - public EntrySetEntry(Object currentKey) { + public EntrySetEntry(String currentKey) { this.currentKey = currentKey; } - public Object getKey() { + public String getKey() { return currentKey; } - public Object getValue() { + public V getValue() { return StringKeyedMapAdapter.this.get(currentKey); } - public Object setValue(Object value) { + public V setValue(V value) { return StringKeyedMapAdapter.this.put(currentKey, value); } } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutionException.java b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutionException.java index 474fc1af..cb355ba9 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutionException.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutionException.java @@ -32,12 +32,12 @@ public class ConversionExecutionException extends ConversionException { /** * The source type we tried to convert the value from. */ - private Class sourceClass; + private Class sourceClass; /** * The target type we tried to convert the value to. */ - private Class targetClass; + private Class targetClass; /** * Creates a new conversion exception. @@ -46,7 +46,7 @@ public class ConversionExecutionException extends ConversionException { * @param targetClass the value's target type * @param cause the cause of the conversion failure */ - public ConversionExecutionException(Object value, Class sourceClass, Class targetClass, Throwable cause) { + public ConversionExecutionException(Object value, Class sourceClass, Class targetClass, Throwable cause) { super(defaultMessage(value, sourceClass, targetClass, cause), cause); this.value = value; this.sourceClass = sourceClass; @@ -60,7 +60,7 @@ public class ConversionExecutionException extends ConversionException { * @param targetClass the value's target type * @param message a descriptive message of what went wrong. */ - public ConversionExecutionException(Object value, Class sourceClass, Class targetClass, String message) { + public ConversionExecutionException(Object value, Class sourceClass, Class targetClass, String message) { super(message); this.value = value; this.sourceClass = sourceClass; @@ -77,18 +77,18 @@ public class ConversionExecutionException extends ConversionException { /** * Returns the source type we tried to convert the value from. */ - public Class getSourceClass() { + public Class getSourceClass() { return sourceClass; } /** * Returns the target type we tried to convert the value to. */ - public Class getTargetClass() { + public Class getTargetClass() { return targetClass; } - private static String defaultMessage(Object value, Class sourceClass, Class targetClass, Throwable cause) { + private static String defaultMessage(Object value, Class sourceClass, Class targetClass, Throwable cause) { return "Unable to convert value " + StylerUtils.style(value) + " from type '" + sourceClass.getName() + "' to type '" + targetClass.getName() + "'; reason = '" + cause.getMessage() + "'"; } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutor.java b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutor.java index ba171f53..eff08dc0 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutor.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutor.java @@ -28,13 +28,13 @@ public interface ConversionExecutor { * Returns the source class of conversions performed by this executor. * @return the source class */ - public Class getSourceClass(); + public Class getSourceClass(); /** * Returns the target class of conversions performed by this executor. * @return the target class */ - public Class getTargetClass(); + public Class getTargetClass(); /** * Execute the conversion for the provided source object. diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutorNotFoundException.java b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutorNotFoundException.java index 55ca51f8..9d73a768 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutorNotFoundException.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionExecutorNotFoundException.java @@ -23,9 +23,9 @@ package org.springframework.binding.convert; */ public class ConversionExecutorNotFoundException extends ConversionException { - private Class sourceClass; + private Class sourceClass; - private Class targetClass; + private Class targetClass; /** * Creates a new conversion executor not found exception. @@ -33,7 +33,7 @@ public class ConversionExecutorNotFoundException extends ConversionException { * @param targetClass the target type requested to convert to * @param message a descriptive message */ - public ConversionExecutorNotFoundException(Class sourceClass, Class targetClass, String message) { + public ConversionExecutorNotFoundException(Class sourceClass, Class targetClass, String message) { super(message); this.sourceClass = sourceClass; this.targetClass = targetClass; @@ -42,14 +42,14 @@ public class ConversionExecutorNotFoundException extends ConversionException { /** * Returns the source type requested to convert from. */ - public Class getSourceClass() { + public Class getSourceClass() { return sourceClass; } /** * Returns the target type requested to convert to. */ - public Class getTargetClass() { + public Class getTargetClass() { return targetClass; } } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionService.java b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionService.java index 1744ce61..c24a78eb 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionService.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionService.java @@ -15,7 +15,6 @@ */ package org.springframework.binding.convert; - /** * A service interface for retrieving type conversion executors. The returned command objects are thread-safe and may be * safely cached for use by client code. @@ -33,7 +32,7 @@ public interface ConversionService { * @return the converted object, an instance of the targetClass * @throws ConversionException if an exception occurred during the conversion process */ - public Object executeConversion(Object source, Class targetClass) throws ConversionException; + public Object executeConversion(Object source, Class targetClass) throws ConversionException; /** * Execute a conversion using the custom converter with the provided id. @@ -44,7 +43,7 @@ public interface ConversionService { * @return the converted object, an instance of the targetClass * @throws ConversionException if an exception occurred during the conversion process */ - public Object executeConversion(String converterId, Object source, Class targetClass); + public Object executeConversion(String converterId, Object source, Class targetClass); /** * Return the default conversion executor capable of converting source objects of the specified @@ -56,7 +55,7 @@ public interface ConversionService { * @return the executor that can execute instance type conversion, never null * @throws ConversionExecutorNotFoundException when no suitable conversion executor could be found */ - public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) throws ConversionExecutorNotFoundException; /** @@ -70,7 +69,7 @@ public interface ConversionService { * @return the executor that can execute instance type conversion, never null * @throws ConversionExecutorNotFoundException when no suitable conversion executor could be found */ - public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) throws ConversionExecutorNotFoundException; /** @@ -78,7 +77,7 @@ public interface ConversionService { * @param alias the class alias * @return the class, or null if no alias exists */ - public Class getClassForAlias(String alias); + public Class getClassForAlias(String alias); /** * Return the underlying Spring ConversionService. diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToArray.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToArray.java index 256097c0..977cd660 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToArray.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToArray.java @@ -51,20 +51,20 @@ public class ArrayToArray implements Converter { this.elementConverter = elementConverter; } - public Class getSourceClass() { + public Class getSourceClass() { return Object[].class; } - public Class getTargetClass() { + public Class getTargetClass() { return Object[].class; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { if (source == null) { return null; } - Class sourceComponentType = source.getClass().getComponentType(); - Class targetComponentType = targetClass.getComponentType(); + Class sourceComponentType = source.getClass().getComponentType(); + Class targetComponentType = targetClass.getComponentType(); int length = Array.getLength(source); Object targetArray = Array.newInstance(targetComponentType, length); ConversionExecutor converter = getElementConverter(sourceComponentType, targetComponentType); @@ -75,7 +75,7 @@ public class ArrayToArray implements Converter { return targetArray; } - private ConversionExecutor getElementConverter(Class sourceComponentType, Class targetComponentType) { + private ConversionExecutor getElementConverter(Class sourceComponentType, Class targetComponentType) { if (elementConverter != null) { return elementConverter; } else { diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToCollection.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToCollection.java index 4a854f86..b5589c4d 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToCollection.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ArrayToCollection.java @@ -29,7 +29,6 @@ import java.util.TreeSet; import org.springframework.binding.convert.ConversionExecutor; import org.springframework.binding.convert.ConversionService; import org.springframework.core.GenericCollectionTypeResolver; -import org.springframework.core.JdkVersion; /** * Special converter that converts from a source array to a target collection. Supports the selection of an @@ -67,21 +66,22 @@ public class ArrayToCollection implements TwoWayConverter { this.elementConverter = elementConverter; } - public Class getSourceClass() { + public Class getSourceClass() { return Object[].class; } - public Class getTargetClass() { + public Class getTargetClass() { return Collection.class; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + @SuppressWarnings("unchecked") + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { if (source == null) { return null; } - Class collectionImplClass = getCollectionImplClass(targetClass); - Constructor constructor = collectionImplClass.getConstructor(null); - Collection collection = (Collection) constructor.newInstance(null); + Class collectionImplClass = getCollectionImplClass(targetClass); + Constructor constructor = collectionImplClass.getConstructor(); + Collection collection = (Collection) constructor.newInstance(); ConversionExecutor converter = getArrayElementConverter(source, targetClass); int length = Array.getLength(source); for (int i = 0; i < length; i++) { @@ -94,22 +94,22 @@ public class ArrayToCollection implements TwoWayConverter { return collection; } - public Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception { + public Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception { if (target == null) { return null; } - Collection collection = (Collection) target; + Collection collection = (Collection) target; Object array = Array.newInstance(sourceClass.getComponentType(), collection.size()); int i = 0; - for (Iterator it = collection.iterator(); it.hasNext(); i++) { + for (Iterator it = collection.iterator(); it.hasNext(); i++) { Object value = it.next(); if (value != null) { ConversionExecutor converter; if (elementConverter != null) { converter = elementConverter; } else { - converter = conversionService.getConversionExecutor(value.getClass(), sourceClass - .getComponentType()); + converter = conversionService.getConversionExecutor(value.getClass(), + sourceClass.getComponentType()); } value = converter.execute(value); } @@ -118,7 +118,7 @@ public class ArrayToCollection implements TwoWayConverter { return array; } - private Class getCollectionImplClass(Class targetClass) { + private Class getCollectionImplClass(Class targetClass) { if (targetClass.isInterface()) { if (List.class.equals(targetClass)) { return ArrayList.class; @@ -134,16 +134,16 @@ public class ArrayToCollection implements TwoWayConverter { } } - private ConversionExecutor getArrayElementConverter(Object source, Class targetClass) { + @SuppressWarnings("unchecked") + private ConversionExecutor getArrayElementConverter(Object source, Class targetClass) { if (elementConverter != null) { return elementConverter; } else { - if (JdkVersion.isAtLeastJava15()) { - Class elementType = GenericCollectionTypeResolver.getCollectionType(targetClass); - if (elementType != null) { - Class componentType = source.getClass().getComponentType(); - return conversionService.getConversionExecutor(componentType, elementType); - } + Class elementType = GenericCollectionTypeResolver + .getCollectionType((Class>) targetClass); + if (elementType != null) { + Class componentType = source.getClass().getComponentType(); + return conversionService.getConversionExecutor(componentType, elementType); } return null; } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/CollectionToCollection.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/CollectionToCollection.java index f4b81442..d9c50354 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/CollectionToCollection.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/CollectionToCollection.java @@ -1,18 +1,12 @@ package org.springframework.binding.convert.converters; -import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; import org.springframework.binding.convert.ConversionExecutor; import org.springframework.binding.convert.ConversionService; +import org.springframework.core.CollectionFactory; import org.springframework.core.GenericCollectionTypeResolver; -import org.springframework.core.JdkVersion; /** * A converter that can convert from one collection type to another. @@ -21,6 +15,8 @@ import org.springframework.core.JdkVersion; */ public class CollectionToCollection implements Converter { + private static final int DEFAULT_INITIAL_SIZE = 16; + private ConversionService conversionService; private ConversionExecutor elementConverter; @@ -42,21 +38,21 @@ public class CollectionToCollection implements Converter { this.elementConverter = elementConverter; } - public Class getSourceClass() { + public Class getSourceClass() { return Collection.class; } - public Class getTargetClass() { + public Class getTargetClass() { return Collection.class; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { if (source == null) { return null; } - Class targetCollectionImpl = getCollectionImplClass(targetClass); - Collection targetCollection = (Collection) targetCollectionImpl.getConstructor(null).newInstance(null); - ConversionExecutor elementConverter = getElementConverter(source, targetClass); + Collection targetCollection = CollectionFactory.createCollection(targetClass, DEFAULT_INITIAL_SIZE); + ConversionExecutor elementConverter = getElementConverter(source, (Class>) targetClass); Collection sourceCollection = (Collection) source; Iterator it = sourceCollection.iterator(); while (it.hasNext()) { @@ -69,33 +65,14 @@ public class CollectionToCollection implements Converter { return targetCollection; } - // this code is duplicated in ArrayToCollection.java and ObjectToCollection too - private Class getCollectionImplClass(Class targetClass) { - if (targetClass.isInterface()) { - if (List.class.equals(targetClass)) { - return ArrayList.class; - } else if (Set.class.equals(targetClass)) { - return LinkedHashSet.class; - } else if (SortedSet.class.equals(targetClass)) { - return TreeSet.class; - } else { - throw new IllegalArgumentException("Unsupported collection interface [" + targetClass.getName() + "]"); - } - } else { - return targetClass; - } - } - - private ConversionExecutor getElementConverter(Object source, Class targetClass) { + private ConversionExecutor getElementConverter(Object source, Class> targetClass) { if (elementConverter != null) { return elementConverter; } else { - if (JdkVersion.isAtLeastJava15()) { - Class elementType = GenericCollectionTypeResolver.getCollectionType(targetClass); - if (elementType != null) { - Class componentType = source.getClass().getComponentType(); - return conversionService.getConversionExecutor(componentType, elementType); - } + Class elementType = GenericCollectionTypeResolver.getCollectionType(targetClass); + if (elementType != null) { + Class componentType = source.getClass().getComponentType(); + return conversionService.getConversionExecutor(componentType, elementType); } return null; } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/Converter.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/Converter.java index 4f1cae41..0e822183 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/Converter.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/Converter.java @@ -17,8 +17,8 @@ package org.springframework.binding.convert.converters; /** * A converter is capable of converting a source object of type {@link #getSourceClass()} to a target type of type - * {@link #getTargetClass()}. If the converter is a {@link TwoWayConverter}, it can also convert from the target back - * to the source. + * {@link #getTargetClass()}. If the converter is a {@link TwoWayConverter}, it can also convert from the target back to + * the source. *

* Implementations of this interface are thread-safe and can be shared. *

@@ -31,14 +31,14 @@ public interface Converter { * convert specific subclasses as well. * @return the source type */ - public Class getSourceClass(); + public Class getSourceClass(); /** * The target class this converter can convert to. May be an interface or abstract type to allow this converter to * convert specific subclasses as well. * @return the target type */ - public Class getTargetClass(); + public Class getTargetClass(); /** * Convert the provided source object argument to an instance of the specified target class. @@ -48,6 +48,6 @@ public interface Converter { * @return the converted object, which must be an instance of the targetClass * @throws Exception an exception occurred performing the conversion */ - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception; + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception; } \ No newline at end of file diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/FormattedStringToNumber.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/FormattedStringToNumber.java index 0a7073f2..4a42fa30 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/FormattedStringToNumber.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/FormattedStringToNumber.java @@ -54,7 +54,7 @@ public class FormattedStringToNumber extends StringToObject { super(Number.class); } - public FormattedStringToNumber(Class numberClass) { + public FormattedStringToNumber(Class numberClass) { super(numberClass); } @@ -84,7 +84,8 @@ public class FormattedStringToNumber extends StringToObject { this.lenient = lenient; } - protected Object toObject(String string, Class targetClass) throws Exception { + @SuppressWarnings("unchecked") + protected Object toObject(String string, Class targetClass) throws Exception { ParsePosition parsePosition = new ParsePosition(0); NumberFormat format = numberFormatFactory.getNumberFormat(); Number number = format.parse(string, parsePosition); @@ -98,7 +99,7 @@ public class FormattedStringToNumber extends StringToObject { throw new InvalidFormatException(string, getPattern(format)); } } - return convertToNumberClass(number, targetClass); + return convertToNumberClass(number, (Class) targetClass); } protected String toString(Object object) throws Exception { @@ -112,7 +113,8 @@ public class FormattedStringToNumber extends StringToObject { * @return the coersed number * @throws IllegalArgumentException when an overflow condition occurs during coersion */ - protected Number convertToNumberClass(Number number, Class numberClass) throws IllegalArgumentException { + protected Number convertToNumberClass(Number number, Class numberClass) + throws IllegalArgumentException { return NumberUtils.convertNumberToTargetClass(number, numberClass); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/NumberToNumber.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/NumberToNumber.java index fac0469d..0d6c87b9 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/NumberToNumber.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/NumberToNumber.java @@ -22,16 +22,16 @@ import org.springframework.util.NumberUtils; */ public class NumberToNumber implements Converter { - public Class getSourceClass() { + public Class getSourceClass() { return Number.class; } - public Class getTargetClass() { + public Class getTargetClass() { return Number.class; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { - return NumberUtils.convertNumberToTargetClass((Number) source, targetClass); + @SuppressWarnings("unchecked") + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + return NumberUtils.convertNumberToTargetClass((Number) source, (Class) targetClass); } - } \ No newline at end of file diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ObjectToArray.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ObjectToArray.java index 84bdb8f4..bad03a2b 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ObjectToArray.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ObjectToArray.java @@ -49,19 +49,19 @@ public class ObjectToArray implements Converter { this.elementConverter = elementConverter; } - public Class getSourceClass() { + public Class getSourceClass() { return Object.class; } - public Class getTargetClass() { + public Class getTargetClass() { return Object[].class; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { if (source == null) { return null; } - Class componentType = targetClass.getComponentType(); + Class componentType = targetClass.getComponentType(); Object array = Array.newInstance(componentType, 1); ConversionExecutor converter; if (elementConverter != null) { diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ObjectToCollection.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ObjectToCollection.java index 6228685a..dc1a8ff2 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ObjectToCollection.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ObjectToCollection.java @@ -15,19 +15,12 @@ */ package org.springframework.binding.convert.converters; -import java.lang.reflect.Constructor; -import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; import org.springframework.binding.convert.ConversionExecutor; import org.springframework.binding.convert.ConversionService; +import org.springframework.core.CollectionFactory; import org.springframework.core.GenericCollectionTypeResolver; -import org.springframework.core.JdkVersion; /** * Special two-way converter that converts an object to an single-element collection. Supports type conversion of the @@ -37,6 +30,8 @@ import org.springframework.core.JdkVersion; */ public class ObjectToCollection implements Converter { + private static final int DEFAULT_INITIAL_CAPACITY = 16; + private ConversionService conversionService; private ConversionExecutor elementConverter; @@ -58,22 +53,21 @@ public class ObjectToCollection implements Converter { this.elementConverter = elementConverter; } - public Class getSourceClass() { + public Class getSourceClass() { return Object.class; } - public Class getTargetClass() { + public Class getTargetClass() { return Collection.class; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { if (source == null) { return null; } - Class collectionImplClass = getCollectionImplClass(targetClass); - Constructor constructor = collectionImplClass.getConstructor(null); - Collection collection = (Collection) constructor.newInstance(null); - ConversionExecutor converter = getElementConverter(source, targetClass); + Collection collection = CollectionFactory.createCollection(targetClass, DEFAULT_INITIAL_CAPACITY); + ConversionExecutor converter = getElementConverter(source, (Class>) targetClass); Object value; if (converter != null) { value = converter.execute(source); @@ -84,33 +78,14 @@ public class ObjectToCollection implements Converter { return collection; } - // this code is duplicated in ArrayToCollection and CollectionToCollection - private Class getCollectionImplClass(Class targetClass) { - if (targetClass.isInterface()) { - if (List.class.equals(targetClass)) { - return ArrayList.class; - } else if (Set.class.equals(targetClass)) { - return LinkedHashSet.class; - } else if (SortedSet.class.equals(targetClass)) { - return TreeSet.class; - } else { - throw new IllegalArgumentException("Unsupported collection interface [" + targetClass.getName() + "]"); - } - } else { - return targetClass; - } - } - - private ConversionExecutor getElementConverter(Object source, Class targetClass) { + private ConversionExecutor getElementConverter(Object source, Class> targetClass) { if (elementConverter != null) { return elementConverter; } else { - if (JdkVersion.isAtLeastJava15()) { - Class elementType = GenericCollectionTypeResolver.getCollectionType(targetClass); - if (elementType != null) { - Class componentType = source.getClass().getComponentType(); - return conversionService.getConversionExecutor(componentType, elementType); - } + Class elementType = GenericCollectionTypeResolver.getCollectionType(targetClass); + if (elementType != null) { + Class componentType = source.getClass().getComponentType(); + return conversionService.getConversionExecutor(componentType, elementType); } return null; } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/PropertyEditorConverter.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/PropertyEditorConverter.java index 426151a8..8043152b 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/PropertyEditorConverter.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/PropertyEditorConverter.java @@ -30,12 +30,12 @@ public class PropertyEditorConverter extends StringToObject { * @param propertyEditor the property editor to adapt * @param targetClass the {@link PropertyEditor#getValue() value class} this property editor converts to from string */ - public PropertyEditorConverter(PropertyEditor propertyEditor, Class targetClass) { + public PropertyEditorConverter(PropertyEditor propertyEditor, Class targetClass) { super(targetClass); this.propertyEditor = propertyEditor; } - protected Object toObject(String string, Class targetClass) throws Exception { + protected Object toObject(String string, Class targetClass) throws Exception { synchronized (propertyEditor) { propertyEditor.setAsText(string); return propertyEditor.getValue(); diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ReverseConverter.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ReverseConverter.java index a304cd06..eb71a8de 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/ReverseConverter.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/ReverseConverter.java @@ -30,15 +30,15 @@ public class ReverseConverter implements Converter { this.converter = converter; } - public Class getSourceClass() { + public Class getSourceClass() { return converter.getTargetClass(); } - public Class getTargetClass() { + public Class getTargetClass() { return converter.getSourceClass(); } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { return converter.convertTargetToSourceClass(source, targetClass); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/SpringConvertingConverterAdapter.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/SpringConvertingConverterAdapter.java index 51663417..51c14d75 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/SpringConvertingConverterAdapter.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/SpringConvertingConverterAdapter.java @@ -28,19 +28,20 @@ public class SpringConvertingConverterAdapter implements Converter { /** * The source value type to convert from. */ - private final Class sourceClass; + private final Class sourceClass; /** * The target value type to convert to. */ - private final Class targetClass; + private final Class targetClass; /** * The ConversionService that will perform the conversion. */ private ConversionService conversionService; - public SpringConvertingConverterAdapter(Class sourceClass, Class targetClass, ConversionService conversionService) { + public SpringConvertingConverterAdapter(Class sourceClass, Class targetClass, + ConversionService conversionService) { Assert.notNull(sourceClass, "The source class to convert from is required."); Assert.notNull(targetClass, "The target class to convert to is required."); Assert.notNull(conversionService, "A Spring ConversionService is required."); @@ -49,15 +50,15 @@ public class SpringConvertingConverterAdapter implements Converter { this.conversionService = conversionService; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { return conversionService.convert(source, targetClass); } - public Class getSourceClass() { + public Class getSourceClass() { return sourceClass; } - public Class getTargetClass() { + public Class getTargetClass() { return targetClass; } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBigDecimal.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBigDecimal.java index 4dd9da09..5335e556 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBigDecimal.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBigDecimal.java @@ -28,7 +28,7 @@ public class StringToBigDecimal extends StringToObject { super(BigDecimal.class); } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return new BigDecimal(string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBigInteger.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBigInteger.java index a0887fb1..655c8772 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBigInteger.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBigInteger.java @@ -28,7 +28,7 @@ public class StringToBigInteger extends StringToObject { super(BigInteger.class); } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return new BigInteger(string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBoolean.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBoolean.java index caff4c92..5af73d23 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBoolean.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToBoolean.java @@ -48,7 +48,7 @@ public class StringToBoolean extends StringToObject { this.falseString = falseString; } - protected Object toObject(String string, Class targetClass) throws Exception { + protected Object toObject(String string, Class targetClass) throws Exception { if (trueString != null && string.equals(trueString)) { return Boolean.TRUE; } else if (falseString != null && string.equals(falseString)) { diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToByte.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToByte.java index 4a505317..ba6484a3 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToByte.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToByte.java @@ -26,7 +26,7 @@ public class StringToByte extends StringToObject { super(Byte.class); } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return Byte.valueOf(string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToCharacter.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToCharacter.java index cc282a40..0cec1dab 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToCharacter.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToCharacter.java @@ -21,7 +21,7 @@ public class StringToCharacter extends StringToObject { super(Character.class); } - protected Object toObject(String string, Class targetClass) throws Exception { + protected Object toObject(String string, Class targetClass) throws Exception { return new Character(string.charAt(0)); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToClass.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToClass.java index 006d22ec..8ca78b88 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToClass.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToClass.java @@ -31,12 +31,12 @@ public class StringToClass extends StringToObject { this.classLoader = classLoader; } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return ClassUtils.forName(string, classLoader); } public String toString(Object object) throws Exception { - Class clazz = (Class) object; + Class clazz = (Class) object; return clazz.getName(); } } \ No newline at end of file diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToDate.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToDate.java index c3a1f903..a9f5e159 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToDate.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToDate.java @@ -81,7 +81,7 @@ public class StringToDate extends StringToObject { this.locale = locale; } - public Object toObject(String string, Class targetClass) throws Exception { + public Object toObject(String string, Class targetClass) throws Exception { if (!StringUtils.hasText(string)) { return null; } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToDouble.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToDouble.java index 8533ebc4..5be50541 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToDouble.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToDouble.java @@ -26,7 +26,7 @@ public class StringToDouble extends StringToObject { super(Double.class); } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return Double.valueOf(string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToEnum.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToEnum.java index 9aaf7193..4ff1fb71 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToEnum.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToEnum.java @@ -26,8 +26,9 @@ public class StringToEnum extends StringToObject { super(Enum.class); } - protected Object toObject(String string, Class targetClass) throws Exception { - return Enum.valueOf(targetClass, string); + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected Object toObject(String string, Class targetClass) throws Exception { + return Enum.valueOf((Class) targetClass, string); } protected String toString(Object object) throws Exception { diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToFloat.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToFloat.java index 190b2965..7b46cdd3 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToFloat.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToFloat.java @@ -26,7 +26,7 @@ public class StringToFloat extends StringToObject { super(Float.class); } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return Float.valueOf(string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToInteger.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToInteger.java index 3135e341..c871fdae 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToInteger.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToInteger.java @@ -26,7 +26,7 @@ public class StringToInteger extends StringToObject { super(Integer.class); } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return Integer.valueOf(string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLabeledEnum.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLabeledEnum.java index 3baab27a..c050d95d 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLabeledEnum.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLabeledEnum.java @@ -24,6 +24,7 @@ import org.springframework.core.enums.StaticLabeledEnumResolver; * * @author Keith Donald */ +@Deprecated public class StringToLabeledEnum extends StringToObject { private LabeledEnumResolver labeledEnumResolver = StaticLabeledEnumResolver.instance(); @@ -32,7 +33,7 @@ public class StringToLabeledEnum extends StringToObject { super(LabeledEnum.class); } - protected Object toObject(String string, Class targetClass) throws Exception { + protected Object toObject(String string, Class targetClass) throws Exception { return labeledEnumResolver.getLabeledEnumByLabel(targetClass, string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLocale.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLocale.java index dffcd757..e7ee75d3 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLocale.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLocale.java @@ -30,7 +30,7 @@ public class StringToLocale extends StringToObject { super(Locale.class); } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return StringUtils.parseLocaleString(string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLong.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLong.java index 0b141f9e..ba2f7e1b 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLong.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToLong.java @@ -26,7 +26,7 @@ public class StringToLong extends StringToObject { super(Long.class); } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return Long.valueOf(string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToObject.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToObject.java index be358d32..3c7603cb 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToObject.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToObject.java @@ -17,21 +17,21 @@ package org.springframework.binding.convert.converters; public abstract class StringToObject implements TwoWayConverter { - private Class objectClass; + private Class objectClass; - public StringToObject(Class objectClass) { + public StringToObject(Class objectClass) { this.objectClass = objectClass; } - public final Class getSourceClass() { + public final Class getSourceClass() { return String.class; } - public final Class getTargetClass() { + public final Class getTargetClass() { return objectClass; } - public final Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public final Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { String string = (String) source; if (string != null && string.length() > 0) { return toObject(string, targetClass); @@ -40,7 +40,7 @@ public abstract class StringToObject implements TwoWayConverter { } } - public final Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception { + public final Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception { if (target != null) { return toString(target); } else { @@ -48,7 +48,7 @@ public abstract class StringToObject implements TwoWayConverter { } } - protected abstract Object toObject(String string, Class targetClass) throws Exception; + protected abstract Object toObject(String string, Class targetClass) throws Exception; protected abstract String toString(Object object) throws Exception; diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToShort.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToShort.java index e0ad50f9..69c90256 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToShort.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/StringToShort.java @@ -26,7 +26,7 @@ public class StringToShort extends StringToObject { super(Short.class); } - public Object toObject(String string, Class objectClass) throws Exception { + public Object toObject(String string, Class objectClass) throws Exception { return Short.valueOf(string); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/converters/TwoWayConverter.java b/spring-binding/src/main/java/org/springframework/binding/convert/converters/TwoWayConverter.java index 57ec4c3d..cf13fafa 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/converters/TwoWayConverter.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/converters/TwoWayConverter.java @@ -30,6 +30,6 @@ public interface TwoWayConverter extends Converter { * @return the converted object, which must be an instance of the sourceClass * @throws Exception an exception occurred performing the conversion */ - public Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception; + public Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception; } \ No newline at end of file diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/service/GenericConversionService.java b/spring-binding/src/main/java/org/springframework/binding/convert/service/GenericConversionService.java index d9253050..f45dd00f 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/service/GenericConversionService.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/service/GenericConversionService.java @@ -53,12 +53,12 @@ public class GenericConversionService implements ConversionService { * A map of custom converters. Custom converters are assigned a unique identifier that can be used to lookup the * converter. This allows multiple converters for the same source->target class to be registered. */ - private final Map customConverters = new HashMap(); + private final Map customConverters = new HashMap(); /** * Indexes classes by well-known aliases. */ - private final Map aliasMap = new HashMap(); + private final Map> aliasMap = new HashMap>(); /** * An optional parent conversion service. @@ -143,11 +143,11 @@ public class GenericConversionService implements ConversionService { /** * Add an alias for given target type. */ - public void addAlias(String alias, Class targetType) { + public void addAlias(String alias, Class targetType) { aliasMap.put(alias, targetType); } - public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) throws ConversionExecutorNotFoundException { Assert.notNull(sourceClass, "The source class to convert from is required"); Assert.notNull(targetClass, "The target class to convert to is required"); @@ -168,12 +168,12 @@ public class GenericConversionService implements ConversionService { } } - public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) throws ConversionExecutorNotFoundException { Assert.hasText(id, "The id of the custom converter is required"); Assert.notNull(sourceClass, "The source class to convert from is required"); Assert.notNull(targetClass, "The target class to convert to is required"); - Converter converter = (Converter) customConverters.get(id); + Converter converter = customConverters.get(id); if (converter == null) { if (parent != null) { return parent.getConversionExecutor(id, sourceClass, targetClass); @@ -186,9 +186,9 @@ public class GenericConversionService implements ConversionService { sourceClass = convertToWrapperClassIfNecessary(sourceClass); targetClass = convertToWrapperClassIfNecessary(targetClass); if (sourceClass.isArray()) { - Class sourceComponentType = sourceClass.getComponentType(); + Class sourceComponentType = sourceClass.getComponentType(); if (targetClass.isArray()) { - Class targetComponentType = targetClass.getComponentType(); + Class targetComponentType = targetClass.getComponentType(); if (converter.getSourceClass().isAssignableFrom(sourceComponentType)) { if (!converter.getTargetClass().isAssignableFrom(targetComponentType)) { throw new ConversionExecutorNotFoundException(sourceClass, targetClass, @@ -221,15 +221,15 @@ public class GenericConversionService implements ConversionService { } if (converter.getSourceClass().isAssignableFrom(sourceComponentType)) { // type erasure has prevented us from getting the concrete type, this is best we can do for now - ConversionExecutor elementConverter = new StaticConversionExecutor(sourceComponentType, converter - .getTargetClass(), converter); + ConversionExecutor elementConverter = new StaticConversionExecutor(sourceComponentType, + converter.getTargetClass(), converter); return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToCollection( elementConverter)); } else if (converter.getTargetClass().isAssignableFrom(sourceComponentType) && converter instanceof TwoWayConverter) { TwoWayConverter twoWay = (TwoWayConverter) converter; - ConversionExecutor elementConverter = new StaticConversionExecutor(sourceComponentType, converter - .getSourceClass(), new ReverseConverter(twoWay)); + ConversionExecutor elementConverter = new StaticConversionExecutor(sourceComponentType, + converter.getSourceClass(), new ReverseConverter(twoWay)); return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToCollection( elementConverter)); } else { @@ -242,7 +242,7 @@ public class GenericConversionService implements ConversionService { } } if (targetClass.isArray()) { - Class targetComponentType = targetClass.getComponentType(); + Class targetComponentType = targetClass.getComponentType(); if (Collection.class.isAssignableFrom(sourceClass)) { // type erasure limits us here as well if (converter.getTargetClass().isAssignableFrom(targetComponentType)) { @@ -294,11 +294,11 @@ public class GenericConversionService implements ConversionService { ConversionExecutor elementConverter; // type erasure forces us to do runtime checks of list elements if (converter instanceof TwoWayConverter) { - elementConverter = new TwoWayCapableConversionExecutor(converter.getSourceClass(), converter - .getTargetClass(), (TwoWayConverter) converter); + elementConverter = new TwoWayCapableConversionExecutor(converter.getSourceClass(), + converter.getTargetClass(), (TwoWayConverter) converter); } else { - elementConverter = new StaticConversionExecutor(converter.getSourceClass(), converter - .getTargetClass(), converter); + elementConverter = new StaticConversionExecutor(converter.getSourceClass(), + converter.getTargetClass(), converter); } return new StaticConversionExecutor(sourceClass, targetClass, new CollectionToCollection( elementConverter)); @@ -340,7 +340,7 @@ public class GenericConversionService implements ConversionService { } } - public Object executeConversion(Object source, Class targetClass) throws ConversionException { + public Object executeConversion(Object source, Class targetClass) throws ConversionException { if (source != null) { ConversionExecutor conversionExecutor = getConversionExecutor(source.getClass(), targetClass); return conversionExecutor.execute(source); @@ -349,7 +349,7 @@ public class GenericConversionService implements ConversionService { } } - public Object executeConversion(String converterId, Object source, Class targetClass) throws ConversionException { + public Object executeConversion(String converterId, Object source, Class targetClass) throws ConversionException { if (source != null) { ConversionExecutor conversionExecutor = getConversionExecutor(converterId, source.getClass(), targetClass); return conversionExecutor.execute(source); @@ -358,8 +358,8 @@ public class GenericConversionService implements ConversionService { } } - public Class getClassForAlias(String name) throws IllegalArgumentException { - Class clazz = (Class) aliasMap.get(name); + public Class getClassForAlias(String name) throws IllegalArgumentException { + Class clazz = aliasMap.get(name); if (clazz != null) { return clazz; } else { @@ -373,7 +373,7 @@ public class GenericConversionService implements ConversionService { // internal helpers - private Class convertToWrapperClassIfNecessary(Class targetType) { + private Class convertToWrapperClassIfNecessary(Class targetType) { if (targetType.isPrimitive()) { if (targetType.equals(int.class)) { return Integer.class; diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/service/NoOpConverter.java b/spring-binding/src/main/java/org/springframework/binding/convert/service/NoOpConverter.java index 3c331480..df9a8475 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/service/NoOpConverter.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/service/NoOpConverter.java @@ -24,27 +24,27 @@ import org.springframework.binding.convert.converters.Converter; */ class NoOpConverter implements Converter { - private Class sourceClass; + private Class sourceClass; - private Class targetClass; + private Class targetClass; /** * Create a "no op" converter from given source to given target class. */ - public NoOpConverter(Class sourceClass, Class targetClass) { + public NoOpConverter(Class sourceClass, Class targetClass) { this.sourceClass = sourceClass; this.targetClass = targetClass; } - public Class getSourceClass() { + public Class getSourceClass() { return sourceClass; } - public Class getTargetClass() { + public Class getTargetClass() { return targetClass; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { return source; } @@ -52,7 +52,7 @@ class NoOpConverter implements Converter { return true; } - public Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception, + public Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception, UnsupportedOperationException { return target; } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/service/RuntimeBindingConversionExecutor.java b/spring-binding/src/main/java/org/springframework/binding/convert/service/RuntimeBindingConversionExecutor.java index 4caf8768..f32dd86d 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/service/RuntimeBindingConversionExecutor.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/service/RuntimeBindingConversionExecutor.java @@ -26,7 +26,7 @@ import org.springframework.util.Assert; */ public class RuntimeBindingConversionExecutor implements ConversionExecutor { - private Class targetClass; + private Class targetClass; private ConversionService conversionService; @@ -35,18 +35,18 @@ public class RuntimeBindingConversionExecutor implements ConversionExecutor { * @param targetClass the target type to convert to * @param conversionService the conversion service to get converters from */ - public RuntimeBindingConversionExecutor(Class targetClass, ConversionService conversionService) { + public RuntimeBindingConversionExecutor(Class targetClass, ConversionService conversionService) { Assert.notNull(targetClass, "The target class of the conversion is required"); Assert.notNull(conversionService, "The conversion service is required"); this.targetClass = targetClass; this.conversionService = conversionService; } - public Class getSourceClass() { + public Class getSourceClass() { return null; } - public Class getTargetClass() { + public Class getTargetClass() { return targetClass; } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/service/SpringBindingConverterAdapter.java b/spring-binding/src/main/java/org/springframework/binding/convert/service/SpringBindingConverterAdapter.java index 6a65eed7..87672a63 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/service/SpringBindingConverterAdapter.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/service/SpringBindingConverterAdapter.java @@ -47,7 +47,7 @@ public class SpringBindingConverterAdapter implements GenericConverter { } } - public Set getConvertibleTypes() { + public Set getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(converter.getSourceClass(), converter.getTargetClass())); } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/service/StaticConversionExecutor.java b/spring-binding/src/main/java/org/springframework/binding/convert/service/StaticConversionExecutor.java index bea609ad..8ab423d1 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/service/StaticConversionExecutor.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/service/StaticConversionExecutor.java @@ -35,12 +35,12 @@ public class StaticConversionExecutor implements ConversionExecutor { /** * The source value type this executor will attempt to convert from. */ - private final Class sourceClass; + private final Class sourceClass; /** * The target value type this executor will attempt to convert to. */ - private final Class targetClass; + private final Class targetClass; /** * The converter that will perform the conversion. @@ -53,7 +53,7 @@ public class StaticConversionExecutor implements ConversionExecutor { * @param targetClass the target type that the converter will convert to * @param converter the converter that will perform the conversion */ - public StaticConversionExecutor(Class sourceClass, Class targetClass, Converter converter) { + public StaticConversionExecutor(Class sourceClass, Class targetClass, Converter converter) { Assert.notNull(sourceClass, "The source class is required"); Assert.notNull(targetClass, "The target class is required"); Assert.notNull(converter, "The converter is required"); @@ -66,7 +66,7 @@ public class StaticConversionExecutor implements ConversionExecutor { * Returns the source class of conversions performed by this executor. * @return the source class */ - public Class getSourceClass() { + public Class getSourceClass() { return sourceClass; } @@ -74,7 +74,7 @@ public class StaticConversionExecutor implements ConversionExecutor { * Returns the target class of conversions performed by this executor. * @return the target class */ - public Class getTargetClass() { + public Class getTargetClass() { return targetClass; } diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/service/TwoWayCapableConversionExecutor.java b/spring-binding/src/main/java/org/springframework/binding/convert/service/TwoWayCapableConversionExecutor.java index 1d98ed8e..ace6e838 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/service/TwoWayCapableConversionExecutor.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/service/TwoWayCapableConversionExecutor.java @@ -27,9 +27,9 @@ import org.springframework.binding.convert.converters.TwoWayConverter; */ class TwoWayCapableConversionExecutor implements ConversionExecutor { - private Class sourceClass; + private Class sourceClass; - private Class targetClass; + private Class targetClass; private TwoWayConverter converter; @@ -39,17 +39,17 @@ class TwoWayCapableConversionExecutor implements ConversionExecutor { * @param targetClass the target class to convert from (or to) * @param converter the two way converter */ - public TwoWayCapableConversionExecutor(Class sourceClass, Class targetClass, TwoWayConverter converter) { + public TwoWayCapableConversionExecutor(Class sourceClass, Class targetClass, TwoWayConverter converter) { this.sourceClass = sourceClass; this.targetClass = targetClass; this.converter = converter; } - public Class getSourceClass() { + public Class getSourceClass() { return sourceClass; } - public Class getTargetClass() { + public Class getTargetClass() { return targetClass; } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationException.java b/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationException.java index 65ca8613..3fc1f6d8 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationException.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationException.java @@ -22,7 +22,7 @@ package org.springframework.binding.expression; */ public class EvaluationException extends RuntimeException { - private Class contextClass; + private Class contextClass; private String expressionString; @@ -32,7 +32,7 @@ public class EvaluationException extends RuntimeException { * @param expressionString the string form of the expression that failed to evaluate * @param message the exception message */ - public EvaluationException(Class contextClass, String expressionString, String message) { + public EvaluationException(Class contextClass, String expressionString, String message) { this(contextClass, expressionString, message, null); } @@ -43,7 +43,7 @@ public class EvaluationException extends RuntimeException { * @param message the exception message * @param cause the underlying cause of this evaluation exception */ - public EvaluationException(Class contextClass, String expressionString, String message, Throwable cause) { + public EvaluationException(Class contextClass, String expressionString, String message, Throwable cause) { super(message, cause); } @@ -51,7 +51,7 @@ public class EvaluationException extends RuntimeException { * The class of object upon which evaluation was attempted and failed. * @return the context class */ - public Class getContextClass() { + public Class getContextClass() { return contextClass; } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/Expression.java b/spring-binding/src/main/java/org/springframework/binding/expression/Expression.java index 8d9d429b..b39d86e1 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/Expression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/Expression.java @@ -48,7 +48,7 @@ public interface Expression { * information cannot be determined * @throws EvaluationException an exception occurred during expression evaluation */ - public Class getValueType(Object context) throws EvaluationException; + public Class getValueType(Object context) throws EvaluationException; /** * Returns the original string used to create this expression, unmodified. diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/ParserContext.java b/spring-binding/src/main/java/org/springframework/binding/expression/ParserContext.java index 3ea7b556..3bcf560d 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/ParserContext.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/ParserContext.java @@ -26,14 +26,14 @@ public interface ParserContext { * value to install custom variable resolves for that particular type of context. * @return the evaluation context type */ - public Class getEvaluationContextType(); + public Class getEvaluationContextType(); /** * Returns the expected type of object returned from evaluating the parsed expression. An expression parser may use * this value to coerce an raw evaluation result before it is returned. * @return the expected evaluation result type */ - public Class getExpectedEvaluationResultType(); + public Class getExpectedEvaluationResultType(); /** * Returns additional expression variables or aliases that can be referenced during expression evaluation. An diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/PropertyNotFoundException.java b/spring-binding/src/main/java/org/springframework/binding/expression/PropertyNotFoundException.java index 33f7466b..335558f0 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/PropertyNotFoundException.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/PropertyNotFoundException.java @@ -28,7 +28,7 @@ public class PropertyNotFoundException extends EvaluationException { * @param property the property that could not be found * @param cause root cause of the failure */ - public PropertyNotFoundException(Class contextClass, String property, Throwable cause) { + public PropertyNotFoundException(Class contextClass, String property, Throwable cause) { super(contextClass, property, "Property not found", cause); } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/ValueCoercionException.java b/spring-binding/src/main/java/org/springframework/binding/expression/ValueCoercionException.java index c7b595af..6d5f3bfb 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/ValueCoercionException.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/ValueCoercionException.java @@ -24,7 +24,7 @@ public class ValueCoercionException extends EvaluationException { private transient Object value; - private Class targetClass; + private Class targetClass; /** * Creates a new property not found exception @@ -33,7 +33,7 @@ public class ValueCoercionException extends EvaluationException { * @param value the value that could not be coerced * @param targetClass the class the value could not be coerced to */ - public ValueCoercionException(Class contextClass, String property, Object value, Class targetClass) { + public ValueCoercionException(Class contextClass, String property, Object value, Class targetClass) { this(contextClass, property, value, targetClass, null); this.value = value; this.targetClass = targetClass; @@ -47,7 +47,8 @@ public class ValueCoercionException extends EvaluationException { * @param targetClass the class the value could not be coerced to * @param cause root cause of the failure */ - public ValueCoercionException(Class contextClass, String property, Object value, Class targetClass, Throwable cause) { + public ValueCoercionException(Class contextClass, String property, Object value, Class targetClass, + Throwable cause) { super(contextClass, property, "Value could not be converted to target class; is a suitable type converter registered?", cause); this.value = value; @@ -64,7 +65,7 @@ public class ValueCoercionException extends EvaluationException { /** * @return the class the value could not be coerced to */ - public Class getTargetClass() { + public Class getTargetClass() { return targetClass; } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/beanwrapper/BeanWrapperExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/beanwrapper/BeanWrapperExpression.java index 88042b79..7c3a056c 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/beanwrapper/BeanWrapperExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/beanwrapper/BeanWrapperExpression.java @@ -101,7 +101,7 @@ public class BeanWrapperExpression implements Expression { } } - public Class getValueType(Object context) { + public Class getValueType(Object context) { try { BeanWrapperImpl beanWrapper = new BeanWrapperImpl(context); return beanWrapper.getPropertyType(expression); diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/el/BindingValueExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/el/BindingValueExpression.java index f604c305..b17780f6 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/el/BindingValueExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/el/BindingValueExpression.java @@ -25,13 +25,13 @@ class BindingValueExpression extends ValueExpression { private ValueExpression targetExpression; - private Class expectedType; + private Class expectedType; private ConversionService conversionService; private boolean template; - public BindingValueExpression(ValueExpression targetExpression, Class expectedType, + public BindingValueExpression(ValueExpression targetExpression, Class expectedType, ConversionService conversionService, boolean template) { Assert.notNull(expectedType, "The expectedType Class is required"); Assert.notNull(conversionService, "The ConversionService to perform type coersions is required"); @@ -41,11 +41,11 @@ class BindingValueExpression extends ValueExpression { this.template = template; } - public Class getExpectedType() { + public Class getExpectedType() { return targetExpression.getExpectedType(); } - public Class getType(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException { + public Class getType(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException { return targetExpression.getType(context); } @@ -90,7 +90,7 @@ class BindingValueExpression extends ValueExpression { return targetExpression.hashCode(); } - private Object convertValueIfNecessary(Object value, Class expectedType, Object context) + private Object convertValueIfNecessary(Object value, Class expectedType, Object context) throws ValueCoercionException { if (expectedType == null) { return value; diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/el/DefaultELResolver.java b/spring-binding/src/main/java/org/springframework/binding/expression/el/DefaultELResolver.java index b6ab0878..8bf63233 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/el/DefaultELResolver.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/el/DefaultELResolver.java @@ -47,7 +47,7 @@ public class DefaultELResolver extends CompositeELResolver { * that the base object has already been resolved by the time this resolver runs. * @param customResolvers the custom resolvers to apply before this resolver */ - public DefaultELResolver(List customResolvers) { + public DefaultELResolver(List customResolvers) { this(null, customResolvers); } @@ -56,7 +56,7 @@ public class DefaultELResolver extends CompositeELResolver { * @param target the target, or "root", object of the expression * @param customResolvers the custom resolvers to apply before this resolver */ - public DefaultELResolver(Object target, List customResolvers) { + public DefaultELResolver(Object target, List customResolvers) { this.target = target; configureResolvers(customResolvers); } @@ -65,7 +65,7 @@ public class DefaultELResolver extends CompositeELResolver { return target; } - public Class getType(ELContext context, Object base, Object property) { + public Class getType(ELContext context, Object base, Object property) { if (base == null) { return super.getType(context, target, property); } else { @@ -89,11 +89,11 @@ public class DefaultELResolver extends CompositeELResolver { } } - private void configureResolvers(List customResolvers) { + private void configureResolvers(List customResolvers) { if (customResolvers != null) { - Iterator i = customResolvers.iterator(); + Iterator i = customResolvers.iterator(); while (i.hasNext()) { - ELResolver resolver = (ELResolver) i.next(); + ELResolver resolver = i.next(); add(resolver); } } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/el/ELExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/el/ELExpression.java index 1a43e2ff..1bd164c7 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/el/ELExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/el/ELExpression.java @@ -90,7 +90,7 @@ public class ELExpression implements Expression { } } - public Class getValueType(Object context) { + public Class getValueType(Object context) { ELContext ctx = elContextFactory.getELContext(context); try { return valueExpression.getType(ctx); diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/el/ELExpressionParser.java b/spring-binding/src/main/java/org/springframework/binding/expression/el/ELExpressionParser.java index a015062b..a1655abb 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/el/ELExpressionParser.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/el/ELExpressionParser.java @@ -46,7 +46,7 @@ public class ELExpressionParser implements ExpressionParser { private ExpressionFactory expressionFactory; - private Map contextFactories = new HashMap(); + private Map, ELContextFactory> contextFactories = new HashMap, ELContextFactory>(); private ConversionService conversionService = new DefaultConversionService(); @@ -79,7 +79,7 @@ public class ELExpressionParser implements ExpressionParser { * @param contextType the expression context class * @param contextFactory the context factory to use for expressions that evaluate those types of contexts */ - public void putContextFactory(Class contextType, ELContextFactory contextFactory) { + public void putContextFactory(Class contextType, ELContextFactory contextFactory) { Assert.notNull(contextFactory, "The EL context factory cannot be null"); contextFactories.put(contextType, contextFactory); } @@ -117,16 +117,16 @@ public class ELExpressionParser implements ExpressionParser { return new BindingValueExpression(expression, getExpectedType(context), conversionService, context.isTemplate()); } - private Class getExpectedType(ParserContext context) { - Class expectedType = context.getExpectedEvaluationResultType(); + private Class getExpectedType(ParserContext context) { + Class expectedType = context.getExpectedEvaluationResultType(); return expectedType != null ? expectedType : Object.class; } - private ELContextFactory getContextFactory(Class expressionTargetType, String expressionString) { + private ELContextFactory getContextFactory(Class expressionTargetType, String expressionString) { if (contextFactories.containsKey(expressionTargetType)) { - return (ELContextFactory) contextFactories.get(expressionTargetType); + return contextFactories.get(expressionTargetType); } else { - return (ELContextFactory) contextFactories.get(Object.class); + return contextFactories.get(Object.class); } } @@ -172,8 +172,7 @@ public class ELExpressionParser implements ExpressionParser { public void mapVariables(ExpressionVariable[] variables, ExpressionFactory expressionFactory) { if (variables != null && variables.length > 0) { variableMapper = new VariableMapperImpl(); - for (int i = 0; i < variables.length; i++) { - ExpressionVariable var = variables[i]; + for (ExpressionVariable var : variables) { ParserContext context = var.getParserContext() != null ? var.getParserContext() : NullParserContext.INSTANCE; ValueExpression expr; @@ -191,14 +190,14 @@ public class ELExpressionParser implements ExpressionParser { } private static class VariableMapperImpl extends VariableMapper { - private Map variables = new HashMap(); + private Map variables = new HashMap(); public ValueExpression resolveVariable(String name) { - return (ValueExpression) variables.get(name); + return variables.get(name); } public ValueExpression setVariable(String name, ValueExpression value) { - return (ValueExpression) variables.put(name, value); + return variables.put(name, value); } public String toString() { diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/el/MapAdaptableELResolver.java b/spring-binding/src/main/java/org/springframework/binding/expression/el/MapAdaptableELResolver.java index 3fdc6225..c08d8bec 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/el/MapAdaptableELResolver.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/el/MapAdaptableELResolver.java @@ -15,6 +15,7 @@ */ package org.springframework.binding.expression.el; +import java.beans.FeatureDescriptor; import java.util.Iterator; import java.util.Map; @@ -32,18 +33,18 @@ import org.springframework.binding.collection.MapAdaptable; */ public class MapAdaptableELResolver extends ELResolver { - public Class getCommonPropertyType(ELContext context, Object base) { + public Class getCommonPropertyType(ELContext context, Object base) { if (base instanceof MapAdaptable) { return Object.class; } return null; } - public Iterator getFeatureDescriptors(ELContext context, Object base) { + public Iterator getFeatureDescriptors(ELContext context, Object base) { return null; } - public Class getType(ELContext context, Object base, Object property) throws NullPointerException, + public Class getType(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { if (context == null) { throw new NullPointerException("The ELContext is null."); @@ -102,8 +103,9 @@ public class MapAdaptableELResolver extends ELResolver { } } - private Map adapt(Object base) { - MapAdaptable adaptable = (MapAdaptable) base; + @SuppressWarnings("unchecked") + private Map adapt(Object base) { + MapAdaptable adaptable = (MapAdaptable) base; return adaptable.asMap(); } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpression.java index 8e66c23a..380c2bf3 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpression.java @@ -18,7 +18,6 @@ package org.springframework.binding.expression.ognl; import java.lang.reflect.Member; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import ognl.NoSuchPropertyException; @@ -46,9 +45,9 @@ class OgnlExpression implements Expression { private Object expression; - private Map variableExpressions; + private Map variableExpressions; - private Class expectedResultType; + private Class expectedResultType; private String expressionString; @@ -57,7 +56,7 @@ class OgnlExpression implements Expression { /** * Creates a new OGNL expression. */ - public OgnlExpression(Object expression, Map variableExpressions, Class expectedResultType, + public OgnlExpression(Object expression, Map variableExpressions, Class expectedResultType, String expressionString, ConversionService conversionService) { this.expression = expression; this.variableExpressions = variableExpressions; @@ -78,6 +77,7 @@ class OgnlExpression implements Expression { return expressionString.hashCode(); } + @SuppressWarnings("rawtypes") public Object getValue(Object context) throws EvaluationException { try { Map evaluationContext = Ognl.addDefaultContext(context, getVariables(context)); @@ -96,6 +96,7 @@ class OgnlExpression implements Expression { } } + @SuppressWarnings("rawtypes") public void setValue(Object context, Object value) { try { Map evaluationContext = Ognl.addDefaultContext(context, getVariables(context)); @@ -114,7 +115,7 @@ class OgnlExpression implements Expression { } } - public Class getValueType(Object context) { + public Class getValueType(Object context) { try { // OGNL has no native way to get this information return new BeanWrapperImpl(context).getPropertyType(expressionString); @@ -148,6 +149,7 @@ class OgnlExpression implements Expression { } } + @SuppressWarnings("rawtypes") private TypeConverter createTypeConverter() { return new TypeConverter() { public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, @@ -161,14 +163,13 @@ class OgnlExpression implements Expression { }; } - private Map getVariables(Object context) { + private Map getVariables(Object context) { if (variableExpressions == null) { - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } - Map variables = new HashMap(variableExpressions.size(), 1); - for (Iterator it = variableExpressions.entrySet().iterator(); it.hasNext();) { - Map.Entry var = (Map.Entry) it.next(); - Expression valueExpression = (Expression) var.getValue(); + Map variables = new HashMap(variableExpressions.size(), 1); + for (Map.Entry var : variableExpressions.entrySet()) { + Expression valueExpression = var.getValue(); variables.put(var.getKey(), valueExpression.getValue(context)); } return variables; diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpressionParser.java b/spring-binding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpressionParser.java index 7fb28a5c..f18672f9 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpressionParser.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/ognl/OgnlExpressionParser.java @@ -57,15 +57,15 @@ public class OgnlExpressionParser extends AbstractExpressionParser { * @param clazz the class that contains properties needing access * @param propertyAccessor the property access strategy */ - public void addPropertyAccessor(Class clazz, PropertyAccessor propertyAccessor) { + public void addPropertyAccessor(Class clazz, PropertyAccessor propertyAccessor) { OgnlRuntime.setPropertyAccessor(clazz, propertyAccessor); } protected Expression doParseExpression(String expressionString, ParserContext context) throws ParserException { try { - return new OgnlExpression(Ognl.parseExpression(expressionString), parseVariableExpressions(context - .getExpressionVariables()), context.getExpectedEvaluationResultType(), expressionString, - conversionService); + return new OgnlExpression(Ognl.parseExpression(expressionString), + parseVariableExpressions(context.getExpressionVariables()), + context.getExpectedEvaluationResultType(), expressionString, conversionService); } catch (OgnlException e) { throw new ParserException(expressionString, e); } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/spel/SpringELExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/spel/SpringELExpression.java index a3cde964..ef7ad185 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/spel/SpringELExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/spel/SpringELExpression.java @@ -17,7 +17,6 @@ package org.springframework.binding.expression.spel; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -48,7 +47,7 @@ public class SpringELExpression implements Expression { private Class expectedType; - private Map expressionVariables; + private Map expressionVariables; private ConversionService conversionService; @@ -65,8 +64,9 @@ public class SpringELExpression implements Expression { * @param conversionService the Spring ConversionService instance to use for type conversion * @param propertyAccessors propertyAccessors for Spring EL to use when evaluating expressions */ - public SpringELExpression(org.springframework.expression.Expression expression, Map expressionVariables, - Class expectedType, ConversionService conversionService, List propertyAccessors) { + public SpringELExpression(org.springframework.expression.Expression expression, + Map expressionVariables, Class expectedType, ConversionService conversionService, + List propertyAccessors) { Assert.notNull(expression, "The SpelExpression is required for evaluation"); this.expression = expression; this.expressionVariables = expressionVariables; @@ -95,7 +95,7 @@ public class SpringELExpression implements Expression { } } - public Class getValueType(Object rootObject) throws EvaluationException { + public Class getValueType(Object rootObject) throws EvaluationException { try { return expression.getValueType(newEvaluationContext(rootObject)); } catch (SpelEvaluationException e) { @@ -150,9 +150,8 @@ public class SpringELExpression implements Expression { return Collections.emptyMap(); } Map variableValues = new HashMap(expressionVariables.size()); - for (Iterator iterator = expressionVariables.entrySet().iterator(); iterator.hasNext();) { - Map.Entry var = (Map.Entry) iterator.next(); - variableValues.put((String) var.getKey(), ((Expression) var.getValue()).getValue(rootObject)); + for (Map.Entry var : expressionVariables.entrySet()) { + variableValues.put(var.getKey(), var.getValue().getValue(rootObject)); } return variableValues; } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/spel/SpringELExpressionParser.java b/spring-binding/src/main/java/org/springframework/binding/expression/spel/SpringELExpressionParser.java index 97c37bab..6e1f13bb 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/spel/SpringELExpressionParser.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/spel/SpringELExpressionParser.java @@ -71,7 +71,8 @@ public class SpringELExpressionParser implements ExpressionParser { public Expression parseExpression(String expressionString, ParserContext parserContext) throws ParserException { Assert.hasText(expressionString, "The expression string to parse is required and must not be empty"); parserContext = (parserContext == null) ? NullParserContext.INSTANCE : parserContext; - Map spelExpressionVariables = parseSpelExpressionVariables(parserContext.getExpressionVariables()); + Map spelExpressionVariables = parseSpelExpressionVariables(parserContext + .getExpressionVariables()); return new SpringELExpression(parseSpelExpression(expressionString, parserContext), spelExpressionVariables, parserContext.getExpectedEvaluationResultType(), conversionService.getDelegateConversionService(), propertyAccessors); @@ -93,13 +94,12 @@ public class SpringELExpressionParser implements ExpressionParser { * @param expressionVariables an array of ExpressionVariable instances. * @return a Map or null if the input array is empty. */ - private Map parseSpelExpressionVariables(ExpressionVariable[] expressionVariables) { + private Map parseSpelExpressionVariables(ExpressionVariable[] expressionVariables) { if (expressionVariables == null || expressionVariables.length == 0) { return null; } - Map spelExpressionVariables = new HashMap(expressionVariables.length); - for (int i = 0; i < expressionVariables.length; i++) { - ExpressionVariable var = expressionVariables[i]; + Map spelExpressionVariables = new HashMap(expressionVariables.length); + for (ExpressionVariable var : expressionVariables) { spelExpressionVariables.put(var.getName(), parseExpression(var.getValueExpression(), var.getParserContext())); } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/AbstractExpressionParser.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/AbstractExpressionParser.java index 242c9b79..0582a749 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/support/AbstractExpressionParser.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/AbstractExpressionParser.java @@ -170,7 +170,7 @@ public abstract class AbstractExpressionParser implements ExpressionParser { * @throws ParserException when the expressions cannot be parsed */ private Expression[] parseExpressions(String expressionString, ParserContext context) throws ParserException { - List expressions = new LinkedList(); + List expressions = new LinkedList(); int startIdx = 0; while (startIdx < expressionString.length()) { int prefixIndex = expressionString.indexOf(getExpressionPrefix(), startIdx); @@ -218,16 +218,15 @@ public abstract class AbstractExpressionParser implements ExpressionParser { startIdx = expressionString.length(); } } - return (Expression[]) expressions.toArray(new Expression[expressions.size()]); + return expressions.toArray(new Expression[expressions.size()]); } - protected Map parseVariableExpressions(ExpressionVariable[] variables) throws ParserException { + protected Map parseVariableExpressions(ExpressionVariable[] variables) throws ParserException { if (variables == null || variables.length == 0) { return null; } - Map variableExpressions = new HashMap(variables.length, 1); - for (int i = 0; i < variables.length; i++) { - ExpressionVariable var = variables[i]; + Map variableExpressions = new HashMap(variables.length, 1); + for (ExpressionVariable var : variables) { variableExpressions.put(var.getName(), parseExpression(var.getValueExpression(), var.getParserContext())); } return variableExpressions; diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/AbstractGetValueExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/AbstractGetValueExpression.java index d0b7cbfa..e53f96c0 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/support/AbstractGetValueExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/AbstractGetValueExpression.java @@ -34,7 +34,7 @@ public abstract class AbstractGetValueExpression implements Expression { throw new UnsupportedOperationException("Setting this expression's value is not supported"); } - public Class getValueType(Object context) { + public Class getValueType(Object context) { return null; } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/CollectionAddingExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/CollectionAddingExpression.java index 3e0dfa33..60a761bc 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/support/CollectionAddingExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/CollectionAddingExpression.java @@ -46,6 +46,7 @@ public class CollectionAddingExpression implements Expression { return collectionExpression.getValue(context); } + @SuppressWarnings("unchecked") public void setValue(Object context, Object value) throws EvaluationException { Object result = getValue(context); if (result == null) { @@ -57,11 +58,11 @@ public class CollectionAddingExpression implements Expression { Assert.isInstanceOf(Collection.class, result, "Not a collection: "); if (value != null) { // add the value to the collection - ((Collection) result).add(value); + ((Collection) result).add(value); } } - public Class getValueType(Object context) { + public Class getValueType(Object context) { return Object.class; } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/CompositeStringExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/CompositeStringExpression.java index 813872cd..99497e3c 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/support/CompositeStringExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/CompositeStringExpression.java @@ -42,8 +42,8 @@ public class CompositeStringExpression implements Expression { public Object getValue(Object context) throws EvaluationException { StringBuffer buffer = new StringBuffer(128); - for (int i = 0; i < expressions.length; i++) { - buffer.append(expressions[i].getValue(context)); + for (Expression expression : expressions) { + buffer.append(expression.getValue(context)); } return buffer.toString(); } @@ -52,7 +52,7 @@ public class CompositeStringExpression implements Expression { throw new UnsupportedOperationException("Cannot set a composite string expression value"); } - public Class getValueType(Object context) { + public Class getValueType(Object context) { return String.class; } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/FluentParserContext.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/FluentParserContext.java index cae34b98..1c7955cb 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/support/FluentParserContext.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/FluentParserContext.java @@ -28,11 +28,11 @@ import org.springframework.binding.expression.ParserContext; */ public class FluentParserContext implements ParserContext { - private Class evaluationContextType; + private Class evaluationContextType; - private Class evaluationResultType; + private Class evaluationResultType; - private List expressionVariables; + private List expressionVariables; private boolean template; @@ -48,16 +48,16 @@ public class FluentParserContext implements ParserContext { init(); } - public Class getEvaluationContextType() { + public Class getEvaluationContextType() { return evaluationContextType; } - public Class getExpectedEvaluationResultType() { + public Class getExpectedEvaluationResultType() { return evaluationResultType; } public ExpressionVariable[] getExpressionVariables() { - return (ExpressionVariable[]) expressionVariables.toArray(new ExpressionVariable[expressionVariables.size()]); + return expressionVariables.toArray(new ExpressionVariable[expressionVariables.size()]); } public boolean isTemplate() { @@ -69,7 +69,7 @@ public class FluentParserContext implements ParserContext { * @param contextType the type of context object the parsed expression will evaluate in * @return this */ - public FluentParserContext evaluate(Class contextType) { + public FluentParserContext evaluate(Class contextType) { evaluationContextType = contextType; return this; } @@ -79,7 +79,7 @@ public class FluentParserContext implements ParserContext { * @param resultType the type of result object the parsed expression should return when evaluated * @return this */ - public FluentParserContext expectResult(Class resultType) { + public FluentParserContext expectResult(Class resultType) { evaluationResultType = resultType; return this; } @@ -114,6 +114,6 @@ public class FluentParserContext implements ParserContext { } private void init() { - expressionVariables = new ArrayList(); + expressionVariables = new ArrayList(); } } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/LiteralExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/LiteralExpression.java index dd887d79..0914c4e8 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/support/LiteralExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/LiteralExpression.java @@ -57,7 +57,7 @@ public class LiteralExpression implements Expression { + "If so, should the expression string be enclosed in eval delimiters?"); } - public Class getValueType(Object context) { + public Class getValueType(Object context) { return String.class; } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/NullParserContext.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/NullParserContext.java index 4e6f3d03..8a1c24b7 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/support/NullParserContext.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/NullParserContext.java @@ -33,11 +33,11 @@ public final class NullParserContext implements ParserContext { private NullParserContext() { } - public Class getEvaluationContextType() { + public Class getEvaluationContextType() { return null; } - public Class getExpectedEvaluationResultType() { + public Class getExpectedEvaluationResultType() { return null; } diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/StaticExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/StaticExpression.java index aa08a8d4..4899c7da 100644 --- a/spring-binding/src/main/java/org/springframework/binding/expression/support/StaticExpression.java +++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/StaticExpression.java @@ -62,7 +62,7 @@ public final class StaticExpression implements Expression { this.value = value; } - public Class getValueType(Object context) { + public Class getValueType(Object context) { return value.getClass(); } diff --git a/spring-binding/src/main/java/org/springframework/binding/mapping/MappingResults.java b/spring-binding/src/main/java/org/springframework/binding/mapping/MappingResults.java index 1e1262e0..1a71d14b 100644 --- a/spring-binding/src/main/java/org/springframework/binding/mapping/MappingResults.java +++ b/spring-binding/src/main/java/org/springframework/binding/mapping/MappingResults.java @@ -37,7 +37,7 @@ public interface MappingResults { /** * A list of all the mapping results between the source and target. */ - public List getAllResults(); + public List getAllResults(); /** * Whether some results were errors. Returns true if mapping errors occurred. @@ -47,12 +47,12 @@ public interface MappingResults { /** * A list of all error results that occurred. */ - public List getErrorResults(); + public List getErrorResults(); /** * Get all results that meet the given result criteria. * @param criteria the mapping result criteria */ - public List getResults(MappingResultsCriteria criteria); + public List getResults(MappingResultsCriteria criteria); } \ No newline at end of file diff --git a/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMapper.java b/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMapper.java index 92c6cb64..d5b4332f 100644 --- a/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMapper.java +++ b/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMapper.java @@ -36,7 +36,7 @@ public class DefaultMapper implements Mapper { private static final Log logger = LogFactory.getLog(DefaultMapper.class); - private List mappings = new ArrayList(); + private List mappings = new ArrayList(); /** * Add a mapping to this mapper. @@ -53,7 +53,7 @@ public class DefaultMapper implements Mapper { * @return the list of mappings */ public Mapping[] getMappings() { - return (Mapping[]) mappings.toArray(new Mapping[mappings.size()]); + return mappings.toArray(new Mapping[mappings.size()]); } public MappingResults map(Object source, Object target) { @@ -62,9 +62,9 @@ public class DefaultMapper implements Mapper { + target.getClass().getName() + "]"); } DefaultMappingContext context = new DefaultMappingContext(source, target); - Iterator it = mappings.iterator(); + Iterator it = mappings.iterator(); while (it.hasNext()) { - DefaultMapping mapping = (DefaultMapping) it.next(); + DefaultMapping mapping = it.next(); mapping.map(context); } MappingResults results = context.getMappingResults(); diff --git a/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingContext.java b/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingContext.java index 58be2bfe..79e17ea8 100644 --- a/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingContext.java +++ b/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingContext.java @@ -45,12 +45,12 @@ public class DefaultMappingContext { private Mapping currentMapping; - private List mappingResults; + private List mappingResults; public DefaultMappingContext(Object source, Object target) { this.source = source; this.target = target; - this.mappingResults = new ArrayList(); + this.mappingResults = new ArrayList(); } /** diff --git a/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingResults.java b/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingResults.java index ec1900ff..4266d03a 100644 --- a/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingResults.java +++ b/spring-binding/src/main/java/org/springframework/binding/mapping/impl/DefaultMappingResults.java @@ -34,7 +34,7 @@ public class DefaultMappingResults implements MappingResults { private Object target; - private List mappingResults; + private List mappingResults; /** * Creates a new mapping results object. @@ -42,7 +42,7 @@ public class DefaultMappingResults implements MappingResults { * @param target the target * @param mappingResults the actual results produced by {@link DefaultMapper} */ - public DefaultMappingResults(Object source, Object target, List mappingResults) { + public DefaultMappingResults(Object source, Object target, List mappingResults) { this.source = source; this.target = target; this.mappingResults = mappingResults; @@ -56,14 +56,14 @@ public class DefaultMappingResults implements MappingResults { return target; } - public List getAllResults() { + public List getAllResults() { return Collections.unmodifiableList(mappingResults); } public boolean hasErrorResults() { - Iterator it = mappingResults.iterator(); + Iterator it = mappingResults.iterator(); while (it.hasNext()) { - MappingResult result = (MappingResult) it.next(); + MappingResult result = it.next(); if (result.isError()) { return true; } @@ -71,11 +71,11 @@ public class DefaultMappingResults implements MappingResults { return false; } - public List getErrorResults() { - List errorResults = new ArrayList(); - Iterator it = mappingResults.iterator(); + public List getErrorResults() { + List errorResults = new ArrayList(); + Iterator it = mappingResults.iterator(); while (it.hasNext()) { - MappingResult result = (MappingResult) it.next(); + MappingResult result = it.next(); if (result.isError()) { errorResults.add(result); } @@ -83,11 +83,11 @@ public class DefaultMappingResults implements MappingResults { return Collections.unmodifiableList(errorResults); } - public List getResults(MappingResultsCriteria criteria) { - List results = new ArrayList(); - Iterator it = mappingResults.iterator(); + public List getResults(MappingResultsCriteria criteria) { + List results = new ArrayList(); + Iterator it = mappingResults.iterator(); while (it.hasNext()) { - MappingResult result = (MappingResult) it.next(); + MappingResult result = it.next(); if (criteria.test(result)) { results.add(result); } diff --git a/spring-binding/src/main/java/org/springframework/binding/message/DefaultMessageContext.java b/spring-binding/src/main/java/org/springframework/binding/message/DefaultMessageContext.java index 0be57f58..3ba89039 100644 --- a/spring-binding/src/main/java/org/springframework/binding/message/DefaultMessageContext.java +++ b/spring-binding/src/main/java/org/springframework/binding/message/DefaultMessageContext.java @@ -44,9 +44,10 @@ public class DefaultMessageContext implements StateManageableMessageContext { private MessageSource messageSource; - private Map sourceMessages = new CachingMapDecorator(new LinkedHashMap()) { - protected Object create(Object source) { - return new ArrayList(); + private Map> sourceMessages = new CachingMapDecorator>( + new LinkedHashMap>()) { + protected List create(Object source) { + return new ArrayList(); } }; @@ -73,39 +74,37 @@ public class DefaultMessageContext implements StateManageableMessageContext { // implementing message context public Message[] getAllMessages() { - List messages = new ArrayList(); - for (Iterator it = sourceMessages.values().iterator(); it.hasNext();) { - messages.addAll((List) it.next()); + List messages = new ArrayList(); + for (List list : sourceMessages.values()) { + messages.addAll(list); } - return (Message[]) messages.toArray(new Message[messages.size()]); + return messages.toArray(new Message[messages.size()]); } public Message[] getMessagesBySource(Object source) { - List messages = (List) sourceMessages.get(source); - return (Message[]) messages.toArray(new Message[messages.size()]); + List messages = sourceMessages.get(source); + return messages.toArray(new Message[messages.size()]); } public Message[] getMessagesByCriteria(MessageCriteria criteria) { - List messages = new ArrayList(); - Iterator it = sourceMessages.values().iterator(); + List messages = new ArrayList(); + Iterator> it = sourceMessages.values().iterator(); while (it.hasNext()) { - List sourceMessages = (List) it.next(); - for (Iterator it2 = sourceMessages.iterator(); it2.hasNext();) { - Message message = (Message) it2.next(); + List sourceMessages = it.next(); + for (Message message : sourceMessages) { if (criteria.test(message)) { messages.add(message); } } } - return (Message[]) messages.toArray(new Message[messages.size()]); + return messages.toArray(new Message[messages.size()]); } public boolean hasErrorMessages() { - Iterator it = sourceMessages.values().iterator(); + Iterator> it = sourceMessages.values().iterator(); while (it.hasNext()) { - List sourceMessages = (List) it.next(); - for (Iterator it2 = sourceMessages.iterator(); it2.hasNext();) { - Message message = (Message) it2.next(); + List sourceMessages = it.next(); + for (Message message : sourceMessages) { if (message.getSeverity() == Severity.ERROR) { return true; } @@ -120,7 +119,7 @@ public class DefaultMessageContext implements StateManageableMessageContext { logger.debug("Resolving message using " + messageResolver); } Message message = messageResolver.resolveMessage(messageSource, currentLocale); - List messages = (List) sourceMessages.get(message.getSource()); + List messages = sourceMessages.get(message.getSource()); if (logger.isDebugEnabled()) { logger.debug("Adding resolved message " + message); } @@ -134,11 +133,12 @@ public class DefaultMessageContext implements StateManageableMessageContext { // implementing state manageable message context public Serializable createMessagesMemento() { - return new LinkedHashMap(sourceMessages); + return new LinkedHashMap>(sourceMessages); } + @SuppressWarnings("unchecked") public void restoreMessages(Serializable messagesMemento) { - sourceMessages.putAll((Map) messagesMemento); + sourceMessages.putAll((Map>) messagesMemento); } public void setMessageSource(MessageSource messageSource) { diff --git a/spring-binding/src/main/java/org/springframework/binding/message/MessageBuilder.java b/spring-binding/src/main/java/org/springframework/binding/message/MessageBuilder.java index 34140612..3c1fafa7 100644 --- a/spring-binding/src/main/java/org/springframework/binding/message/MessageBuilder.java +++ b/spring-binding/src/main/java/org/springframework/binding/message/MessageBuilder.java @@ -44,11 +44,11 @@ public class MessageBuilder { private Object source; - private Set codes = new LinkedHashSet(); + private Set codes = new LinkedHashSet(); private Severity severity; - private List args = new ArrayList(); + private List args = new ArrayList(); private String defaultText; @@ -173,8 +173,8 @@ public class MessageBuilder { if (args == null) { return this; } - for (int i = 0; i < args.length; i++) { - this.args.add(new ResolvableArgument(args[i])); + for (Object arg : args) { + this.args.add(new ResolvableArgument(arg)); } return this; } @@ -202,7 +202,7 @@ public class MessageBuilder { throw new IllegalArgumentException( "A message code or the message text is required to build this message resolver"); } - String[] codesArray = (String[]) codes.toArray(new String[codes.size()]); + String[] codesArray = codes.toArray(new String[codes.size()]); Object[] argsArray = args.toArray(new Object[args.size()]); return new DefaultMessageResolver(source, codesArray, severity, argsArray, defaultText); } diff --git a/spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java b/spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java index 79b08a9d..359d688e 100644 --- a/spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java +++ b/spring-binding/src/main/java/org/springframework/binding/message/MessageContextErrors.java @@ -81,7 +81,7 @@ public class MessageContextErrors extends AbstractErrors { public void rejectValue(String field, String errorCode, Object[] errorArgs, String defaultMessage) { field = fixedField(field); - Class fieldType; + Class fieldType; if (StringUtils.hasLength(field) && (expressionParser != null)) { FluentParserContext parserContext = new FluentParserContext().evaluate(boundObject.getClass()); fieldType = expressionParser.parseExpression(field, parserContext).getValueType(boundObject); @@ -100,9 +100,9 @@ public class MessageContextErrors extends AbstractErrors { } public void addAllErrors(Errors errors) { - Iterator it = errors.getAllErrors().iterator(); + Iterator it = errors.getAllErrors().iterator(); while (it.hasNext()) { - ObjectError error = (ObjectError) it.next(); + ObjectError error = it.next(); MessageBuilder builder = new MessageBuilder().error().codes(error.getCodes()).args(error.getArguments()) .defaultText(error.getDefaultMessage()); if (error instanceof FieldError) { @@ -117,27 +117,25 @@ public class MessageContextErrors extends AbstractErrors { return objectName; } - public List getGlobalErrors() { + public List getGlobalErrors() { Message[] messages = messageContext.getMessagesByCriteria(GLOBAL_ERROR); if (messages.length == 0) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } - List errors = new ArrayList(messages.length); - for (int i = 0; i < messages.length; i++) { - Message message = messages[i]; + List errors = new ArrayList(messages.length); + for (Message message : messages) { errors.add(new ObjectError(objectName, message.getText())); } return Collections.unmodifiableList(errors); } - public List getFieldErrors() { + public List getFieldErrors() { Message[] messages = messageContext.getMessagesByCriteria(FIELD_ERROR); if (messages.length == 0) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } - List errors = new ArrayList(messages.length); - for (int i = 0; i < messages.length; i++) { - Message message = messages[i]; + List errors = new ArrayList(messages.length); + for (Message message : messages) { errors.add(new FieldError(objectName, (String) message.getSource(), message.getText())); } return Collections.unmodifiableList(errors); @@ -147,9 +145,9 @@ public class MessageContextErrors extends AbstractErrors { field = fixedField(field); // requires boundObject and expressionParser to be set to work if (mappingResults != null) { - List results = mappingResults.getResults(new PropertyErrorMappingResult(field)); + List results = mappingResults.getResults(new PropertyErrorMappingResult(field)); if (!results.isEmpty()) { - MappingResult fieldError = (MappingResult) results.get(0); + MappingResult fieldError = results.get(0); return fieldError.getOriginalValue(); } } diff --git a/spring-binding/src/main/java/org/springframework/binding/message/MessageResolver.java b/spring-binding/src/main/java/org/springframework/binding/message/MessageResolver.java index 4f8842e4..9af20280 100644 --- a/spring-binding/src/main/java/org/springframework/binding/message/MessageResolver.java +++ b/spring-binding/src/main/java/org/springframework/binding/message/MessageResolver.java @@ -20,8 +20,8 @@ import java.util.Locale; import org.springframework.context.MessageSource; /** - * A factory for a Message. Allows a Message to be internationalized and to be resolved from a - * {@link MessageSource message resource bundle}. + * A factory for a Message. Allows a Message to be internationalized and to be resolved from a {@link MessageSource + * message resource bundle}. * * @author Keith Donald * @see Message diff --git a/spring-binding/src/main/java/org/springframework/binding/method/InvalidMethodKeyException.java b/spring-binding/src/main/java/org/springframework/binding/method/InvalidMethodKeyException.java index 49f02982..08613c94 100644 --- a/spring-binding/src/main/java/org/springframework/binding/method/InvalidMethodKeyException.java +++ b/spring-binding/src/main/java/org/springframework/binding/method/InvalidMethodKeyException.java @@ -15,7 +15,6 @@ */ package org.springframework.binding.method; - /** * Thrown when a method key could not be resolved to an invokable java Method on a Class. * diff --git a/spring-binding/src/main/java/org/springframework/binding/method/MethodInvoker.java b/spring-binding/src/main/java/org/springframework/binding/method/MethodInvoker.java index 49f4dd1c..0478a1e1 100644 --- a/spring-binding/src/main/java/org/springframework/binding/method/MethodInvoker.java +++ b/spring-binding/src/main/java/org/springframework/binding/method/MethodInvoker.java @@ -44,9 +44,9 @@ public class MethodInvoker { /** * A cache of invoked bean methods, keyed weakly. */ - private CachingMapDecorator methodCache = new CachingMapDecorator(true) { - public Object create(Object key) { - return ((MethodKey) key).getMethod(); + private CachingMapDecorator methodCache = new CachingMapDecorator(true) { + public Method create(MethodKey key) { + return key.getMethod(); } }; @@ -74,7 +74,7 @@ public class MethodInvoker { Object argument = parameter.evaluateArgument(argumentSource); arguments[i] = applyTypeConversion(argument, parameter.getType()); } - Class[] parameterTypes = parameters.getTypesArray(); + Class[] parameterTypes = parameters.getTypesArray(); for (int i = 0; i < parameterTypes.length; i++) { if (parameterTypes[i] == null) { Object argument = arguments[i]; @@ -85,7 +85,7 @@ public class MethodInvoker { } MethodKey key = new MethodKey(bean.getClass(), signature.getMethodName(), parameterTypes); try { - Method method = (Method) methodCache.get(key); + Method method = methodCache.get(key); if (logger.isDebugEnabled()) { logger.debug("Invoking method with signature [" + key + "] with arguments " + StylerUtils.style(arguments) + " on bean [" + bean + "]"); @@ -110,7 +110,7 @@ public class MethodInvoker { * @param targetType the target type for the conversion * @return the converted result */ - protected Object applyTypeConversion(Object value, Class targetType) { + protected Object applyTypeConversion(Object value, Class targetType) { if (value == null || targetType == null) { return value; } diff --git a/spring-binding/src/main/java/org/springframework/binding/method/MethodKey.java b/spring-binding/src/main/java/org/springframework/binding/method/MethodKey.java index 04b8a442..7966c395 100644 --- a/spring-binding/src/main/java/org/springframework/binding/method/MethodKey.java +++ b/spring-binding/src/main/java/org/springframework/binding/method/MethodKey.java @@ -34,7 +34,7 @@ public class MethodKey implements Serializable { /** * The class the method is a member of. */ - private Class declaredType; + private Class declaredType; /** * The method name. @@ -45,7 +45,7 @@ public class MethodKey implements Serializable { * The method's actual parameter types. Could contain null values if the user did not specify a parameter type for * the corresponding parameter */ - private Class[] parameterTypes; + private Class[] parameterTypes; /** * A cached handle to the resolved method (may be null). @@ -58,7 +58,7 @@ public class MethodKey implements Serializable { * @param methodName the method name * @param parameterTypes the method's parameter types, or null if the method has no parameters */ - public MethodKey(Class declaredType, String methodName, Class[] parameterTypes) { + public MethodKey(Class declaredType, String methodName, Class[] parameterTypes) { Assert.notNull(declaredType, "The method's declared type is required"); Assert.notNull(methodName, "The method name is required"); this.declaredType = declaredType; @@ -69,7 +69,7 @@ public class MethodKey implements Serializable { /** * Return the class the method is a member of. */ - public Class getDeclaredType() { + public Class getDeclaredType() { return declaredType; } @@ -84,7 +84,7 @@ public class MethodKey implements Serializable { * Returns the method parameter types. Could contain null values if no type was specified for the corresponding * parameter. */ - public Class[] getParameterTypes() { + public Class[] getParameterTypes() { return parameterTypes; } @@ -121,17 +121,17 @@ public class MethodKey implements Serializable { */ protected Method findMethodConsiderAssignableParameterTypes() { Method[] candidateMethods = getDeclaredType().getMethods(); - for (int i = 0; i < candidateMethods.length; i++) { - if (candidateMethods[i].getName().equals(methodName)) { + for (Method candidateMethod : candidateMethods) { + if (candidateMethod.getName().equals(methodName)) { // Check if the method has the correct number of parameters. - Class[] candidateParameterTypes = candidateMethods[i].getParameterTypes(); + Class[] candidateParameterTypes = candidateMethod.getParameterTypes(); if (candidateParameterTypes.length == parameterTypes.length) { int numberOfCorrectArguments = 0; for (int j = 0; j < candidateParameterTypes.length; j++) { // Check if the candidate type is assignable to the sig // parameter type. - Class candidateType = candidateParameterTypes[j]; - Class parameterType = parameterTypes[j]; + Class candidateType = candidateParameterTypes[j]; + Class parameterType = parameterTypes[j]; if (parameterType != null) { if (isAssignable(candidateType, parameterType)) { numberOfCorrectArguments++; @@ -142,7 +142,7 @@ public class MethodKey implements Serializable { } } if (numberOfCorrectArguments == parameterTypes.length) { - return candidateMethods[i]; + return candidateMethod; } } } @@ -159,7 +159,7 @@ public class MethodKey implements Serializable { && parameterTypesEqual(other.parameterTypes); } - private boolean parameterTypesEqual(Class[] other) { + private boolean parameterTypesEqual(Class[] other) { if (parameterTypes == other) { return true; } @@ -183,10 +183,9 @@ public class MethodKey implements Serializable { return 0; } int hash = 0; - for (int i = 0; i < parameterTypes.length; i++) { - Class parameterType = parameterTypes[i]; + for (Class parameterType : parameterTypes) { if (parameterType != null) { - hash += parameterTypes[i].hashCode(); + hash += parameterType.hashCode(); } } return hash; @@ -225,24 +224,23 @@ public class MethodKey implements Serializable { * @param valueType the value type that should be assigned to the target type * @return if the target type is assignable from the value type */ - private static boolean isAssignable(Class targetType, Class valueType) { - return (targetType.isAssignableFrom(valueType) || targetType.equals(primitiveWrapperTypeMap.get(valueType))); + private static boolean isAssignable(Class targetType, Class valueType) { + return (targetType.isAssignableFrom(valueType) || targetType.equals(PRIMITIVE_WRAPPER_TYPE_MAP.get(valueType))); } /** * Map with primitive wrapper type as key and corresponding primitive type as value, for example: Integer.class -> * int.class. */ - private static final Map primitiveWrapperTypeMap = new HashMap(8); - + private static final Map, Class> PRIMITIVE_WRAPPER_TYPE_MAP = new HashMap, Class>(8); static { - primitiveWrapperTypeMap.put(Boolean.class, boolean.class); - primitiveWrapperTypeMap.put(Byte.class, byte.class); - primitiveWrapperTypeMap.put(Character.class, char.class); - primitiveWrapperTypeMap.put(Double.class, double.class); - primitiveWrapperTypeMap.put(Float.class, float.class); - primitiveWrapperTypeMap.put(Integer.class, int.class); - primitiveWrapperTypeMap.put(Long.class, long.class); - primitiveWrapperTypeMap.put(Short.class, short.class); + PRIMITIVE_WRAPPER_TYPE_MAP.put(Boolean.class, boolean.class); + PRIMITIVE_WRAPPER_TYPE_MAP.put(Byte.class, byte.class); + PRIMITIVE_WRAPPER_TYPE_MAP.put(Character.class, char.class); + PRIMITIVE_WRAPPER_TYPE_MAP.put(Double.class, double.class); + PRIMITIVE_WRAPPER_TYPE_MAP.put(Float.class, float.class); + PRIMITIVE_WRAPPER_TYPE_MAP.put(Integer.class, int.class); + PRIMITIVE_WRAPPER_TYPE_MAP.put(Long.class, long.class); + PRIMITIVE_WRAPPER_TYPE_MAP.put(Short.class, short.class); } } \ No newline at end of file diff --git a/spring-binding/src/main/java/org/springframework/binding/method/MethodSignature.java b/spring-binding/src/main/java/org/springframework/binding/method/MethodSignature.java index 6e0832a8..90c50fa4 100644 --- a/spring-binding/src/main/java/org/springframework/binding/method/MethodSignature.java +++ b/spring-binding/src/main/java/org/springframework/binding/method/MethodSignature.java @@ -20,8 +20,8 @@ import org.springframework.util.Assert; /** * A specification for a method consisting of the methodName and an optional set of named arguments. This class provides - * the ability to resolve a method with parameters and evaluate its argument values as part of a - * {@link MethodInvoker method invoker attempt}. + * the ability to resolve a method with parameters and evaluate its argument values as part of a {@link MethodInvoker + * method invoker attempt}. * * @author Keith Donald * @author Jeremy Grelle diff --git a/spring-binding/src/main/java/org/springframework/binding/method/Parameter.java b/spring-binding/src/main/java/org/springframework/binding/method/Parameter.java index f750162e..6056350a 100644 --- a/spring-binding/src/main/java/org/springframework/binding/method/Parameter.java +++ b/spring-binding/src/main/java/org/springframework/binding/method/Parameter.java @@ -30,7 +30,7 @@ public class Parameter { /** * The class of the parameter, e.g "springbank.AccountNumber". */ - private Class type; + private Class type; /** * The name of the parameter as an evaluatable expression, e.g "accountNumber". @@ -43,7 +43,7 @@ public class Parameter { * @param type the parameter type, may be null * @param name the name the method argument expression (required) */ - public Parameter(Class type, Expression name) { + public Parameter(Class type, Expression name) { Assert.notNull(name, "The parameter name expression is required"); this.type = type; this.name = name; @@ -52,7 +52,7 @@ public class Parameter { /** * Returns the parameter type. Could be null if no parameter type was specified. */ - public Class getType() { + public Class getType() { return type; } diff --git a/spring-binding/src/main/java/org/springframework/binding/method/Parameters.java b/spring-binding/src/main/java/org/springframework/binding/method/Parameters.java index d5242fb1..8a23cc00 100644 --- a/spring-binding/src/main/java/org/springframework/binding/method/Parameters.java +++ b/spring-binding/src/main/java/org/springframework/binding/method/Parameters.java @@ -23,7 +23,7 @@ import java.util.List; /** * An ordered list of method parameters. * - * @author Keith + * @author Keith Donald */ public class Parameters { @@ -35,7 +35,7 @@ public class Parameters { /** * The list. */ - private List parameters; + private List parameters; /** * Create a parameter list of the default size (3 elements). @@ -49,7 +49,7 @@ public class Parameters { * @param size the size */ public Parameters(int size) { - this.parameters = new ArrayList(size); + this.parameters = new ArrayList(size); } /** @@ -57,7 +57,7 @@ public class Parameters { * @param parameter the single parameter */ public Parameters(Parameter parameter) { - this.parameters = new ArrayList(1); + this.parameters = new ArrayList(1); add(parameter); } @@ -66,7 +66,7 @@ public class Parameters { * @param parameters the parameters */ public Parameters(Parameter[] parameters) { - this.parameters = new ArrayList(parameters.length); + this.parameters = new ArrayList(parameters.length); addAll(parameters); } @@ -90,7 +90,7 @@ public class Parameters { * Return a parameter iterator. * @return the iterator */ - public Iterator iterator() { + public Iterator iterator() { return parameters.iterator(); } @@ -99,11 +99,10 @@ public class Parameters { * parameters did not specify a parameter type. * @return the types */ - public Class[] getTypesArray() { + public Class[] getTypesArray() { int i = 0; - Class[] types = new Class[parameters.size()]; - for (Iterator it = parameters.iterator(); it.hasNext();) { - Parameter param = (Parameter) it.next(); + Class[] types = new Class[parameters.size()]; + for (Parameter param : parameters) { types[i] = param.getType(); i++; } @@ -125,7 +124,7 @@ public class Parameters { * @throws IndexOutOfBoundsException if the provided index is out of bounds */ public Parameter getParameter(int index) throws IndexOutOfBoundsException { - return (Parameter) parameters.get(index); + return parameters.get(index); } public boolean equals(Object obj) { diff --git a/spring-binding/src/test/java/org/springframework/binding/collection/CompositeIteratorTests.java b/spring-binding/src/test/java/org/springframework/binding/collection/CompositeIteratorTests.java index 941a9adc..7566bb51 100644 --- a/spring-binding/src/test/java/org/springframework/binding/collection/CompositeIteratorTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/collection/CompositeIteratorTests.java @@ -30,7 +30,7 @@ import junit.framework.TestCase; public class CompositeIteratorTests extends TestCase { public void testNoIterators() { - CompositeIterator it = new CompositeIterator(); + CompositeIterator it = new CompositeIterator(); assertFalse(it.hasNext()); try { it.next(); @@ -41,7 +41,7 @@ public class CompositeIteratorTests extends TestCase { } public void testSingleIterator() { - CompositeIterator it = new CompositeIterator(); + CompositeIterator it = new CompositeIterator(); it.add(Arrays.asList(new String[] { "0", "1" }).iterator()); for (int i = 0; i < 2; i++) { assertTrue(it.hasNext()); @@ -57,7 +57,7 @@ public class CompositeIteratorTests extends TestCase { } public void testMultipleIterators() { - CompositeIterator it = new CompositeIterator(); + CompositeIterator it = new CompositeIterator(); it.add(Arrays.asList(new String[] { "0", "1" }).iterator()); it.add(Arrays.asList(new String[] { "2" }).iterator()); it.add(Arrays.asList(new String[] { "3", "4" }).iterator()); @@ -75,8 +75,8 @@ public class CompositeIteratorTests extends TestCase { } public void testInUse() { - List list = Arrays.asList(new String[] { "0", "1" }); - CompositeIterator it = new CompositeIterator(); + List list = Arrays.asList(new String[] { "0", "1" }); + CompositeIterator it = new CompositeIterator(); it.add(list.iterator()); it.hasNext(); try { @@ -85,7 +85,7 @@ public class CompositeIteratorTests extends TestCase { } catch (IllegalStateException e) { // expected } - it = new CompositeIterator(); + it = new CompositeIterator(); it.add(list.iterator()); it.next(); try { @@ -97,9 +97,9 @@ public class CompositeIteratorTests extends TestCase { } public void testDuplicateIterators() { - List list = Arrays.asList(new String[] { "0", "1" }); - Iterator iterator = list.iterator(); - CompositeIterator it = new CompositeIterator(); + List list = Arrays.asList(new String[] { "0", "1" }); + Iterator iterator = list.iterator(); + CompositeIterator it = new CompositeIterator(); it.add(iterator); it.add(list.iterator()); try { diff --git a/spring-binding/src/test/java/org/springframework/binding/collection/MapAccessorTests.java b/spring-binding/src/test/java/org/springframework/binding/collection/MapAccessorTests.java index 8d3a1df1..7947aecb 100644 --- a/spring-binding/src/test/java/org/springframework/binding/collection/MapAccessorTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/collection/MapAccessorTests.java @@ -6,14 +6,14 @@ import java.util.Map; import junit.framework.TestCase; public class MapAccessorTests extends TestCase { - private MapAccessor accessor; + private MapAccessor accessor; protected void setUp() throws Exception { - Map map = new HashMap(); + Map map = new HashMap(); map.put("string", "hello"); map.put("integer", new Integer(9)); map.put("null", null); - this.accessor = new MapAccessor(map); + this.accessor = new MapAccessor(map); } public void testAccessNullAttribute() { diff --git a/spring-binding/src/test/java/org/springframework/binding/collection/SharedMapDecoratorTests.java b/spring-binding/src/test/java/org/springframework/binding/collection/SharedMapDecoratorTests.java index 11fb05b3..dab5803c 100644 --- a/spring-binding/src/test/java/org/springframework/binding/collection/SharedMapDecoratorTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/collection/SharedMapDecoratorTests.java @@ -27,7 +27,8 @@ import junit.framework.TestCase; */ public class SharedMapDecoratorTests extends TestCase { - private SharedMapDecorator map = new SharedMapDecorator(new HashMap()); + private SharedMapDecorator map = new SharedMapDecorator( + new HashMap()); public void testGetPutRemove() { assertTrue(map.size() == 0); @@ -47,7 +48,7 @@ public class SharedMapDecoratorTests extends TestCase { } public void testPutAll() { - Map all = new HashMap(); + Map all = new HashMap(); all.put("foo", "bar"); all.put("bar", "baz"); map.putAll(all); @@ -57,21 +58,21 @@ public class SharedMapDecoratorTests extends TestCase { public void testEntrySet() { map.put("foo", "bar"); map.put("bar", "baz"); - Set entrySet = map.entrySet(); + Set> entrySet = map.entrySet(); assertTrue(entrySet.size() == 2); } public void testKeySet() { map.put("foo", "bar"); map.put("bar", "baz"); - Set keySet = map.keySet(); + Set keySet = map.keySet(); assertTrue(keySet.size() == 2); } public void testValues() { map.put("foo", "bar"); map.put("bar", "baz"); - Collection values = map.values(); + Collection values = map.values(); assertTrue(values.size() == 2); } } diff --git a/spring-binding/src/test/java/org/springframework/binding/collection/StringKeyedMapAdapterTests.java b/spring-binding/src/test/java/org/springframework/binding/collection/StringKeyedMapAdapterTests.java index 45692dda..3564eed4 100644 --- a/spring-binding/src/test/java/org/springframework/binding/collection/StringKeyedMapAdapterTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/collection/StringKeyedMapAdapterTests.java @@ -28,15 +28,15 @@ import junit.framework.TestCase; */ public class StringKeyedMapAdapterTests extends TestCase { - private Map contents = new HashMap(); + private Map contents = new HashMap(); - private StringKeyedMapAdapter map = new StringKeyedMapAdapter() { + private StringKeyedMapAdapter map = new StringKeyedMapAdapter() { - protected Object getAttribute(String key) { + protected String getAttribute(String key) { return contents.get(key); } - protected Iterator getAttributeNames() { + protected Iterator getAttributeNames() { return contents.keySet().iterator(); } @@ -44,7 +44,7 @@ public class StringKeyedMapAdapterTests extends TestCase { contents.remove(key); } - protected void setAttribute(String key, Object value) { + protected void setAttribute(String key, String value) { contents.put(key, value); } }; @@ -67,7 +67,7 @@ public class StringKeyedMapAdapterTests extends TestCase { } public void testPutAll() { - Map all = new HashMap(); + Map all = new HashMap(); all.put("foo", "bar"); all.put("bar", "baz"); map.putAll(all); @@ -77,21 +77,21 @@ public class StringKeyedMapAdapterTests extends TestCase { public void testEntrySet() { map.put("foo", "bar"); map.put("bar", "baz"); - Set entrySet = map.entrySet(); + Set> entrySet = map.entrySet(); assertTrue(entrySet.size() == 2); } public void testKeySet() { map.put("foo", "bar"); map.put("bar", "baz"); - Set keySet = map.keySet(); + Set keySet = map.keySet(); assertTrue(keySet.size() == 2); } public void testValues() { map.put("foo", "bar"); map.put("bar", "baz"); - Collection values = map.values(); + Collection values = map.values(); assertTrue(values.size() == 2); } } diff --git a/spring-binding/src/test/java/org/springframework/binding/convert/service/DefaultConversionServiceTests.java b/spring-binding/src/test/java/org/springframework/binding/convert/service/DefaultConversionServiceTests.java index d3db754a..85b3ea2d 100644 --- a/spring-binding/src/test/java/org/springframework/binding/convert/service/DefaultConversionServiceTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/convert/service/DefaultConversionServiceTests.java @@ -45,11 +45,12 @@ import org.springframework.binding.format.DefaultNumberFormatFactory; * * @author Keith Donald */ +@SuppressWarnings("deprecation") public class DefaultConversionServiceTests extends TestCase { public void testConvertCompatibleTypes() { DefaultConversionService service = new DefaultConversionService(); - List lst = new ArrayList(); + List lst = new ArrayList(); assertSame(lst, service.getConversionExecutor(ArrayList.class, List.class).execute(lst)); } @@ -205,15 +206,17 @@ public class DefaultConversionServiceTests extends TestCase { } } + @SuppressWarnings("unchecked") public void testRegisterCustomConverterArrayToList() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", String[].class, List.class); - List list = (List) executor.execute(new String[] { "princy1", "princy2" }); - assertEquals("princy1", ((Principal) list.get(0)).getName()); - assertEquals("princy2", ((Principal) list.get(1)).getName()); + List list = (List) executor.execute(new String[] { "princy1", "princy2" }); + assertEquals("princy1", (list.get(0)).getName()); + assertEquals("princy2", (list.get(1)).getName()); } + @SuppressWarnings("unchecked") public void testRegisterCustomConverterArrayToListReverse() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); @@ -228,7 +231,7 @@ public class DefaultConversionServiceTests extends TestCase { return "princy2"; } }; - List p = (List) executor.execute(new Principal[] { princy1, princy2 }); + List p = (List) executor.execute(new Principal[] { princy1, princy2 }); assertEquals("princy1", p.get(0)); assertEquals("princy2", p.get(1)); } @@ -248,7 +251,7 @@ public class DefaultConversionServiceTests extends TestCase { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", List.class, Principal[].class); - List princyList = new ArrayList(); + List princyList = new ArrayList(); princyList.add("princy1"); princyList.add("princy2"); Principal[] p = (Principal[]) executor.execute(princyList); @@ -270,7 +273,7 @@ public class DefaultConversionServiceTests extends TestCase { return "princy2"; } }; - List princyList = new ArrayList(); + List princyList = new ArrayList(); princyList.add(princy1); princyList.add(princy2); String[] p = (String[]) executor.execute(princyList); @@ -321,21 +324,23 @@ public class DefaultConversionServiceTests extends TestCase { } } + @SuppressWarnings("unchecked") public void testRegisterCustomConverterObjectToList() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", String.class, List.class); - List list = (List) executor.execute("princy1"); - assertEquals("princy1", ((Principal) list.get(0)).getName()); + List list = (List) executor.execute("princy1"); + assertEquals("princy1", list.get(0).getName()); } + @SuppressWarnings("unchecked") public void testRegisterCustomConverterCsvStringToList() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new PrincipalCsvStringToListConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", String.class, List.class); - List list = (List) executor.execute("princy1,princy2"); - assertEquals("princy1", ((Principal) list.get(0)).getName()); - assertEquals("princy2", ((Principal) list.get(1)).getName()); + List list = (List) executor.execute("princy1,princy2"); + assertEquals("princy1", list.get(0).getName()); + assertEquals("princy2", list.get(1).getName()); } public void testRegisterCustomConverterObjectToListBogus() { @@ -350,6 +355,7 @@ public class DefaultConversionServiceTests extends TestCase { } } + @SuppressWarnings("unchecked") public void testRegisterCustomConverterObjectToListReverse() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); @@ -359,22 +365,24 @@ public class DefaultConversionServiceTests extends TestCase { return "princy1"; } }; - List list = (List) executor.execute(princy1); + List list = (List) executor.execute(princy1); assertEquals("princy1", list.get(0)); } + @SuppressWarnings("unchecked") public void testRegisterCustomConverterListToList() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", List.class, List.class); - List princyList = new ArrayList(); + List princyList = new ArrayList(); princyList.add("princy1"); princyList.add("princy2"); - List list = (List) executor.execute(princyList); - assertEquals("princy1", ((Principal) list.get(0)).getName()); - assertEquals("princy2", ((Principal) list.get(1)).getName()); + List list = (List) executor.execute(princyList); + assertEquals("princy1", list.get(0).getName()); + assertEquals("princy2", list.get(1).getName()); } + @SuppressWarnings("unchecked") public void testRegisterCustomConverterListToListReverse() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); @@ -389,10 +397,10 @@ public class DefaultConversionServiceTests extends TestCase { return "princy2"; } }; - List princyList = new ArrayList(); + List princyList = new ArrayList(); princyList.add(princy1); princyList.add(princy2); - List list = (List) executor.execute(princyList); + List list = (List) executor.execute(princyList); assertEquals("princy1", list.get(0)); assertEquals("princy2", list.get(1)); } @@ -401,8 +409,8 @@ public class DefaultConversionServiceTests extends TestCase { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", List.class, List.class); - List princyList = new ArrayList(); - princyList.add(new Integer(1)); + List princyList = new ArrayList(); + princyList.add(1); try { executor.execute(princyList); fail("Should have failed"); @@ -436,10 +444,11 @@ public class DefaultConversionServiceTests extends TestCase { assertEquals(3, result[2]); } + @SuppressWarnings("unchecked") public void testArrayToListConversion() { DefaultConversionService service = new DefaultConversionService(); ConversionExecutor executor = service.getConversionExecutor(String[].class, List.class); - List result = (List) executor.execute(new String[] { "1", "2", "3" }); + List result = (List) executor.execute(new String[] { "1", "2", "3" }); assertEquals("1", result.get(0)); assertEquals("2", result.get(1)); assertEquals("3", result.get(2)); @@ -448,7 +457,7 @@ public class DefaultConversionServiceTests extends TestCase { public void testListToArrayConversion() { DefaultConversionService service = new DefaultConversionService(); ConversionExecutor executor = service.getConversionExecutor(Collection.class, String[].class); - List list = new ArrayList(); + List list = new ArrayList(); list.add("1"); list.add("2"); list.add("3"); @@ -458,14 +467,15 @@ public class DefaultConversionServiceTests extends TestCase { assertEquals("3", result[2]); } + @SuppressWarnings("unchecked") public void testSetToListConversion() { DefaultConversionService service = new DefaultConversionService(); ConversionExecutor executor = service.getConversionExecutor(Set.class, List.class); - Set set = new LinkedHashSet(); + Set set = new LinkedHashSet(); set.add("1"); set.add("2"); set.add("3"); - List result = (List) executor.execute(set); + List result = (List) executor.execute(set); assertEquals("1", result.get(0)); assertEquals("2", result.get(1)); assertEquals("3", result.get(2)); @@ -474,7 +484,7 @@ public class DefaultConversionServiceTests extends TestCase { public void testListToArrayConversionWithComponentConversion() { try { DefaultConversionService service = new DefaultConversionService(); - ConversionExecutor executor = service.getConversionExecutor(Collection.class, Integer[].class); + service.getConversionExecutor(Collection.class, Integer[].class); // This test case is no longer supported: // https://jira.springframework.org/browse/SPR-7496 @@ -493,10 +503,11 @@ public class DefaultConversionServiceTests extends TestCase { } } + @SuppressWarnings("unchecked") public void testArrayToLinkedListConversion() { DefaultConversionService service = new DefaultConversionService(); ConversionExecutor executor = service.getConversionExecutor(String[].class, LinkedList.class); - LinkedList result = (LinkedList) executor.execute(new String[] { "1", "2", "3" }); + LinkedList result = (LinkedList) executor.execute(new String[] { "1", "2", "3" }); assertEquals("1", result.get(0)); assertEquals("2", result.get(1)); assertEquals("3", result.get(2)); @@ -521,10 +532,11 @@ public class DefaultConversionServiceTests extends TestCase { assertEquals("3", result[2]); } + @SuppressWarnings("unchecked") public void testStringToListConversion() { DefaultConversionService service = new DefaultConversionService(); ConversionExecutor executor = service.getConversionExecutor(String.class, List.class); - List result = (List) executor.execute("1,2,3"); + List result = (List) executor.execute("1,2,3"); assertEquals(3, result.size()); assertEquals("1", result.get(0)); assertEquals("2", result.get(1)); @@ -541,7 +553,7 @@ public class DefaultConversionServiceTests extends TestCase { private static class CustomConverter implements Converter { - public Object convertSourceToTargetClass(final Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(final Object source, Class targetClass) throws Exception { return new Principal() { public String getName() { return (String) source; @@ -549,33 +561,33 @@ public class DefaultConversionServiceTests extends TestCase { }; } - public Class getSourceClass() { + public Class getSourceClass() { return String.class; } - public Class getTargetClass() { + public Class getTargetClass() { return Principal.class; } } private static class CustomTwoWayConverter extends CustomConverter implements TwoWayConverter { - public Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception { + public Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception { return ((Principal) target).getName(); } } private static class Trimmer implements Converter { - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { return ((String) source).trim(); } - public Class getSourceClass() { + public Class getSourceClass() { return String.class; } - public Class getTargetClass() { + public Class getTargetClass() { return String.class; } @@ -587,8 +599,8 @@ public class DefaultConversionServiceTests extends TestCase { super(List.class); } - protected Object toObject(String string, Class targetClass) throws Exception { - List principals = new ArrayList(); + protected Object toObject(String string, Class targetClass) throws Exception { + List principals = new ArrayList(); StringTokenizer tokenizer = new StringTokenizer(string, ","); while (tokenizer.hasMoreTokens()) { final String name = tokenizer.nextToken(); diff --git a/spring-binding/src/test/java/org/springframework/binding/expression/el/ELExpressionParserTests.java b/spring-binding/src/test/java/org/springframework/binding/expression/el/ELExpressionParserTests.java index 1ff18cfc..99747224 100644 --- a/spring-binding/src/test/java/org/springframework/binding/expression/el/ELExpressionParserTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/expression/el/ELExpressionParserTests.java @@ -1,5 +1,6 @@ package org.springframework.binding.expression.el; +import java.beans.FeatureDescriptor; import java.util.Iterator; import javax.el.ELContext; @@ -84,8 +85,8 @@ public class ELExpressionParserTests extends TestCase { public void testParseBeanEvalExpressionInvalidELVariable() { try { String expressionString = "bogus"; - Expression exp = parser.parseExpression(expressionString, new FluentParserContext() - .evaluate(TestBean.class)); + Expression exp = parser.parseExpression(expressionString, + new FluentParserContext().evaluate(TestBean.class)); exp.getValue(new TestBean()); fail("Should have failed"); } catch (EvaluationException e) { @@ -108,8 +109,8 @@ public class ELExpressionParserTests extends TestCase { public void testParseTemplateExpressionWithVariables() { String expressionString = "#{value}#{max}"; - Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable( - new ExpressionVariable("max", "maximum"))); + Expression exp = parser.parseExpression(expressionString, + new FluentParserContext().template().variable(new ExpressionVariable("max", "maximum"))); TestBean target = new TestBean(); assertEquals("foo2", exp.getValue(target)); } @@ -123,9 +124,11 @@ public class ELExpressionParserTests extends TestCase { public void testTemplateNestedVariables() { String expressionString = "#{value}#{max}"; - Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable( - new ExpressionVariable("max", "#{maximum}#{var}", new FluentParserContext().template().variable( - new ExpressionVariable("var", "'bar'"))))); + Expression exp = parser.parseExpression( + expressionString, + new FluentParserContext().template().variable( + new ExpressionVariable("max", "#{maximum}#{var}", new FluentParserContext().template() + .variable(new ExpressionVariable("var", "'bar'"))))); TestBean target = new TestBean(); assertEquals("foo2bar", exp.getValue(target)); } @@ -159,8 +162,8 @@ public class ELExpressionParserTests extends TestCase { public void testGetValueCoersionError() { String expressionString = "maximum"; - Expression exp = parser.parseExpression(expressionString, new FluentParserContext() - .expectResult(TestBean.class)); + Expression exp = parser.parseExpression(expressionString, + new FluentParserContext().expectResult(TestBean.class)); TestBean context = new TestBean(); try { exp.getValue(context); @@ -201,15 +204,15 @@ public class ELExpressionParserTests extends TestCase { return new ELContext() { public ELResolver getELResolver() { return new ELResolver() { - public Class getCommonPropertyType(ELContext arg0, Object arg1) { + public Class getCommonPropertyType(ELContext arg0, Object arg1) { return Object.class; } - public Iterator getFeatureDescriptors(ELContext arg0, Object arg1) { + public Iterator getFeatureDescriptors(ELContext arg0, Object arg1) { return null; } - public Class getType(ELContext arg0, Object arg1, Object arg2) { + public Class getType(ELContext arg0, Object arg1, Object arg2) { return String.class; } diff --git a/spring-binding/src/test/java/org/springframework/binding/expression/el/MapAdaptableELResolverTests.java b/spring-binding/src/test/java/org/springframework/binding/expression/el/MapAdaptableELResolverTests.java index b35319d0..e848d429 100644 --- a/spring-binding/src/test/java/org/springframework/binding/expression/el/MapAdaptableELResolverTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/expression/el/MapAdaptableELResolverTests.java @@ -18,13 +18,13 @@ public class MapAdaptableELResolverTests extends TestCase { } public void testGetType() { - Class type = context.getELResolver().getType(context, new TestMapAdaptable(), "bar"); + Class type = context.getELResolver().getType(context, new TestMapAdaptable(), "bar"); assertTrue(context.isPropertyResolved()); assertEquals(String.class, type); } public void testGetType_UnknownProperty() { - Class type = context.getELResolver().getType(context, new TestMapAdaptable(), "foo"); + Class type = context.getELResolver().getType(context, new TestMapAdaptable(), "foo"); assertTrue(context.isPropertyResolved()); assertEquals(null, type); } @@ -42,27 +42,27 @@ public class MapAdaptableELResolverTests extends TestCase { } public void testSetValue() { - MapAdaptable testMap = new TestMapAdaptable(); + MapAdaptable testMap = new TestMapAdaptable(); context.getELResolver().setValue(context, testMap, "foo", "foo"); assertTrue(context.isPropertyResolved()); assertEquals("foo", testMap.asMap().get("foo")); } public void testSetValue_OverWrite() { - MapAdaptable testMap = new TestMapAdaptable(); + MapAdaptable testMap = new TestMapAdaptable(); context.getELResolver().setValue(context, testMap, "bar", "foo"); assertTrue(context.isPropertyResolved()); assertEquals("foo", testMap.asMap().get("bar")); } - private class TestMapAdaptable implements MapAdaptable { - private Map map = new HashMap(); + private class TestMapAdaptable implements MapAdaptable { + private Map map = new HashMap(); public TestMapAdaptable() { map.put("bar", "bar"); } - public Map asMap() { + public Map asMap() { return map; } } diff --git a/spring-binding/src/test/java/org/springframework/binding/expression/el/TestBean.java b/spring-binding/src/test/java/org/springframework/binding/expression/el/TestBean.java index 4851e24b..0e297e9f 100644 --- a/spring-binding/src/test/java/org/springframework/binding/expression/el/TestBean.java +++ b/spring-binding/src/test/java/org/springframework/binding/expression/el/TestBean.java @@ -23,7 +23,7 @@ public class TestBean { private String value = "foo"; private int maximum = 2; private TestBean bean; - private List list = new ArrayList(); + private List list = new ArrayList(); public TestBean() { initList(); @@ -65,7 +65,7 @@ public class TestBean { this.maximum = maximum; } - public List getList() { + public List getList() { return list; } } \ No newline at end of file diff --git a/spring-binding/src/test/java/org/springframework/binding/expression/ognl/OgnlExpressionParserTests.java b/spring-binding/src/test/java/org/springframework/binding/expression/ognl/OgnlExpressionParserTests.java index 19c75b40..8e45acf7 100644 --- a/spring-binding/src/test/java/org/springframework/binding/expression/ognl/OgnlExpressionParserTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/expression/ognl/OgnlExpressionParserTests.java @@ -127,9 +127,7 @@ public class OgnlExpressionParserTests extends TestCase { // maps parser.parseExpression("#{ 'foo' : 'foo value', 'bar' : 'bar value' }", null); - parser - .parseExpression("${#{ 'foo' : 'foo value', 'bar' : 'bar value' }}", new FluentParserContext() - .template()); + parser.parseExpression("${#{ 'foo' : 'foo value', 'bar' : 'bar value' }}", new FluentParserContext().template()); parser.parseExpression("#@java.util.LinkedHashMap@{ 'foo' : 'foo value', 'bar' : 'bar value' }", null); parser.parseExpression("${#@java.util.LinkedHashMap@{ 'foo' : 'foo value', 'bar' : 'bar value' }}", new FluentParserContext().template()); @@ -141,8 +139,8 @@ public class OgnlExpressionParserTests extends TestCase { } public void testVariables() { - Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable( - "var", "flag"))); + Expression exp = parser.parseExpression("#var", + new FluentParserContext().variable(new ExpressionVariable("var", "flag"))); assertEquals(false, ((Boolean) exp.getValue(bean)).booleanValue()); } @@ -186,8 +184,8 @@ public class OgnlExpressionParserTests extends TestCase { public void testGetValueCoersionError() { String expressionString = "number"; - Expression exp = parser.parseExpression(expressionString, new FluentParserContext() - .expectResult(TestBean.class)); + Expression exp = parser.parseExpression(expressionString, + new FluentParserContext().expectResult(TestBean.class)); TestBean context = new TestBean(); try { exp.getValue(context); diff --git a/spring-binding/src/test/java/org/springframework/binding/expression/ognl/TestBean.java b/spring-binding/src/test/java/org/springframework/binding/expression/ognl/TestBean.java index 5ce43be7..28777269 100644 --- a/spring-binding/src/test/java/org/springframework/binding/expression/ognl/TestBean.java +++ b/spring-binding/src/test/java/org/springframework/binding/expression/ognl/TestBean.java @@ -27,7 +27,7 @@ public class TestBean { private Date date; - private List list = new ArrayList(); + private List list = new ArrayList(); public boolean isFlag() { return flag; @@ -45,11 +45,11 @@ public class TestBean { this.number = number; } - public List getList() { + public List getList() { return list; } - public void setList(List list) { + public void setList(List list) { this.list = list; } diff --git a/spring-binding/src/test/java/org/springframework/binding/expression/spel/ELExpressionParserCompatibilityTests.java b/spring-binding/src/test/java/org/springframework/binding/expression/spel/ELExpressionParserCompatibilityTests.java index 955ba3e6..4d75a57a 100644 --- a/spring-binding/src/test/java/org/springframework/binding/expression/spel/ELExpressionParserCompatibilityTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/expression/spel/ELExpressionParserCompatibilityTests.java @@ -147,7 +147,7 @@ public class ELExpressionParserCompatibilityTests extends TestCase { String expressionString = "maximum"; Expression exp = parser.parseExpression(expressionString, null); TestBean context = new TestBean(); - Class clazz = exp.getValueType(context); + Class clazz = exp.getValueType(context); assertTrue(int.class.equals(clazz) || Integer.class.equals(clazz)); } @@ -207,7 +207,7 @@ public class ELExpressionParserCompatibilityTests extends TestCase { TypeDescriptor.valueOf(String.class)); } - public Class[] getSpecificTargetClasses() { + public Class[] getSpecificTargetClasses() { return null; } diff --git a/spring-binding/src/test/java/org/springframework/binding/mapping/DefaultMapperTests.java b/spring-binding/src/test/java/org/springframework/binding/mapping/DefaultMapperTests.java index 163539bb..151b565f 100644 --- a/spring-binding/src/test/java/org/springframework/binding/mapping/DefaultMapperTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/mapping/DefaultMapperTests.java @@ -49,7 +49,7 @@ public class DefaultMapperTests extends TestCase { DefaultMapping mapping1 = new DefaultMapping(parser.parseExpression("beep", null), parser.parseExpression( "beep", null)); mapper.addMapping(mapping1); - Map bean1 = new HashMap(); + Map bean1 = new HashMap(); bean1.put("beep", "en"); TestBean2 bean2 = new TestBean2(); MappingResults results = mapper.map(bean1, bean2); @@ -61,11 +61,11 @@ public class DefaultMapperTests extends TestCase { DefaultMapping mapping1 = new DefaultMapping(parser.parseExpression("boop", null), parser.parseExpression( "boop", null)); mapper.addMapping(mapping1); - Map bean1 = new HashMap(); + Map bean1 = new HashMap(); bean1.put("boop", "bogus"); TestBean2 bean2 = new TestBean2(); MappingResults results = mapper.map(bean1, bean2); - assertEquals("typeMismatch", ((MappingResult) results.getErrorResults().get(0)).getCode()); + assertEquals("typeMismatch", results.getErrorResults().get(0).getCode()); } public static class TestBean { diff --git a/spring-binding/src/test/java/org/springframework/binding/message/DefaultMessageContextTests.java b/spring-binding/src/test/java/org/springframework/binding/message/DefaultMessageContextTests.java index af972d39..7d04cee6 100644 --- a/spring-binding/src/test/java/org/springframework/binding/message/DefaultMessageContextTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/message/DefaultMessageContextTests.java @@ -45,8 +45,8 @@ public class DefaultMessageContextTests extends TestCase { } public void testResolveMessageWithArgs() { - context.addMessage(new MessageBuilder().error().source(this).code("argmessage").arg("Keith").defaultText( - "Hello world fallback!").build()); + context.addMessage(new MessageBuilder().error().source(this).code("argmessage").arg("Keith") + .defaultText("Hello world fallback!").build()); Message[] messages = context.getAllMessages(); assertEquals(1, messages.length); assertEquals("Hello world Keith!", messages[0].getText()); diff --git a/spring-binding/src/test/java/org/springframework/binding/message/MessageContextErrorsTests.java b/spring-binding/src/test/java/org/springframework/binding/message/MessageContextErrorsTests.java index 4faac37c..a6928ef8 100644 --- a/spring-binding/src/test/java/org/springframework/binding/message/MessageContextErrorsTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/message/MessageContextErrorsTests.java @@ -80,7 +80,7 @@ public class MessageContextErrorsTests extends TestCase { } public void testAddAllErrors() { - MapBindingResult result = new MapBindingResult(new HashMap(), "object"); + MapBindingResult result = new MapBindingResult(new HashMap(), "object"); result.reject("bar", new Object[] { "boop" }, null); result.rejectValue("field", "bar", new Object[] { "boop" }, null); errors.addAllErrors(result); diff --git a/spring-binding/src/test/java/org/springframework/binding/method/MethodInvokerTests.java b/spring-binding/src/test/java/org/springframework/binding/method/MethodInvokerTests.java index 3f7e692f..d0573fb9 100644 --- a/spring-binding/src/test/java/org/springframework/binding/method/MethodInvokerTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/method/MethodInvokerTests.java @@ -67,7 +67,7 @@ public class MethodInvokerTests extends TestCase { assertEquals(Boolean.TRUE, methodInvoker.invoke(method, new TestObject(), null)); } - private static class TestObject { + static class TestObject { public void test() { throw new IllegalArgumentException("just testing"); @@ -82,7 +82,7 @@ public class MethodInvokerTests extends TestCase { } } - private static class Bean { + static class Bean { String value; } } diff --git a/spring-binding/src/test/java/org/springframework/binding/method/MethodKeyTests.java b/spring-binding/src/test/java/org/springframework/binding/method/MethodKeyTests.java index 96443834..3dd0e812 100644 --- a/spring-binding/src/test/java/org/springframework/binding/method/MethodKeyTests.java +++ b/spring-binding/src/test/java/org/springframework/binding/method/MethodKeyTests.java @@ -59,7 +59,7 @@ public class MethodKeyTests extends TestCase { new MethodKey(File.class, "listFiles", new Class[] { null }); } - private static final Method safeGetMethod(Class type, String name, Class[] argTypes) { + private static final Method safeGetMethod(Class type, String name, Class[] argTypes) { try { return type.getMethod(name, argTypes); } catch (NoSuchMethodException e) { diff --git a/spring-faces/.settings/org.eclipse.jdt.core.prefs b/spring-faces/.settings/org.eclipse.jdt.core.prefs index ae652523..09de6202 100644 --- a/spring-faces/.settings/org.eclipse.jdt.core.prefs +++ b/spring-faces/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Fri May 14 17:56:46 BST 2010 +#Sat Jan 28 13:20:21 PST 2012 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -19,6 +19,8 @@ org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled @@ -26,11 +28,13 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore @@ -42,6 +46,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public @@ -49,7 +54,9 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore @@ -57,12 +64,20 @@ org.eclipse.jdt.core.compiler.problem.nullReference=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning @@ -70,14 +85,19 @@ org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false diff --git a/spring-faces/src/main/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParser.java b/spring-faces/src/main/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParser.java index 0b1d1c66..be6c3657 100644 --- a/spring-faces/src/main/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParser.java +++ b/spring-faces/src/main/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParser.java @@ -65,8 +65,8 @@ public class FacesFlowBuilderServicesBeanDefinitionParser extends AbstractSingle parserContext.pushContainingComponent(componentDefinition); parseConversionService(element, parserContext, definitionBuilder); - parseExpressionParser(element, parserContext, definitionBuilder, parseEnableManagedBeans(element, - definitionBuilder)); + parseExpressionParser(element, parserContext, definitionBuilder, + parseEnableManagedBeans(element, definitionBuilder)); parseViewFactoryCreator(element, parserContext, definitionBuilder); parseDevelopment(element, definitionBuilder); diff --git a/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingPropertyResolver.java b/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingPropertyResolver.java index 71bc0877..bafc6718 100644 --- a/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingPropertyResolver.java +++ b/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingPropertyResolver.java @@ -25,7 +25,9 @@ import javax.faces.el.PropertyResolver; * A JSF 1.1 {@link PropertyResolver} that delegates to a wrapped Unified EL resolver chain for property resolution. * * @author Jeremy Grelle + * @deprecated Upgrade to JSF 2.0 */ +@Deprecated public abstract class ELDelegatingPropertyResolver extends PropertyResolver { private PropertyResolver nextResolver; @@ -37,9 +39,9 @@ public abstract class ELDelegatingPropertyResolver extends PropertyResolver { this.delegate = delegate; } - public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException { + public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException { ELContext elContext = new SimpleELContext(delegate); - Class type = elContext.getELResolver().getType(elContext, base, new Integer(index)); + Class type = elContext.getELResolver().getType(elContext, base, new Integer(index)); if (elContext.isPropertyResolved()) { return type; } else { @@ -47,9 +49,9 @@ public abstract class ELDelegatingPropertyResolver extends PropertyResolver { } } - public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException { + public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException { ELContext elContext = new SimpleELContext(delegate); - Class type = elContext.getELResolver().getType(elContext, base, property); + Class type = elContext.getELResolver().getType(elContext, base, property); if (elContext.isPropertyResolved()) { return type; } else { diff --git a/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingVariableResolver.java b/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingVariableResolver.java index 8671b2b1..56f60f08 100644 --- a/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingVariableResolver.java +++ b/spring-faces/src/main/java/org/springframework/faces/expression/ELDelegatingVariableResolver.java @@ -25,7 +25,9 @@ import javax.faces.el.VariableResolver; * A JSF 1.1 {@link VariableResolver} that delegates to a wrapped Unified EL resolver chain for variable resolution. * * @author Jeremy Grelle + * @deprecated Upgrade to JSF 2.0 */ +@Deprecated public abstract class ELDelegatingVariableResolver extends VariableResolver { private VariableResolver nextResolver; diff --git a/spring-faces/src/main/java/org/springframework/faces/model/ManySelectionTrackingListDataModel.java b/spring-faces/src/main/java/org/springframework/faces/model/ManySelectionTrackingListDataModel.java index c6e9b3d3..5d0e533e 100644 --- a/spring-faces/src/main/java/org/springframework/faces/model/ManySelectionTrackingListDataModel.java +++ b/spring-faces/src/main/java/org/springframework/faces/model/ManySelectionTrackingListDataModel.java @@ -28,19 +28,19 @@ import org.springframework.util.Assert; * * @author Jeremy Grelle */ -public class ManySelectionTrackingListDataModel extends SerializableListDataModel implements SelectionAware { +public class ManySelectionTrackingListDataModel extends SerializableListDataModel implements SelectionAware { - private List selections = new ArrayList(); + private List selections = new ArrayList(); public ManySelectionTrackingListDataModel() { super(); } - public ManySelectionTrackingListDataModel(List list) { + public ManySelectionTrackingListDataModel(List list) { super(list); } - public List getSelections() { + public List getSelections() { return selections; } @@ -50,7 +50,7 @@ public class ManySelectionTrackingListDataModel extends SerializableListDataMode public void selectAll() { selections.clear(); - selections.addAll((List) getWrappedData()); + selections.addAll(getWrappedData()); } public void setCurrentRowSelected(boolean rowSelected) { @@ -64,13 +64,12 @@ public class ManySelectionTrackingListDataModel extends SerializableListDataMode } } - public void setSelections(List selections) { + public void setSelections(List selections) { this.selections = selections; } - public void select(Object rowData) { - Assert.isTrue(((List) getWrappedData()).contains(rowData), - "The object to select is not contained in this DataModel."); + public void select(T rowData) { + Assert.isTrue((getWrappedData()).contains(rowData), "The object to select is not contained in this DataModel."); if (!selections.contains(rowData)) { selections.add(rowData); } diff --git a/spring-faces/src/main/java/org/springframework/faces/model/OneSelectionTrackingListDataModel.java b/spring-faces/src/main/java/org/springframework/faces/model/OneSelectionTrackingListDataModel.java index ea53a843..23d0768d 100644 --- a/spring-faces/src/main/java/org/springframework/faces/model/OneSelectionTrackingListDataModel.java +++ b/spring-faces/src/main/java/org/springframework/faces/model/OneSelectionTrackingListDataModel.java @@ -27,22 +27,22 @@ import org.springframework.util.Assert; * * @author Jeremy Grelle */ -public class OneSelectionTrackingListDataModel extends SerializableListDataModel implements SelectionAware { +public class OneSelectionTrackingListDataModel extends SerializableListDataModel implements SelectionAware { /** * The list of currently selected row data objects. */ - private List selections = new ArrayList(); + private List selections = new ArrayList(); public OneSelectionTrackingListDataModel() { super(); } - public OneSelectionTrackingListDataModel(List list) { + public OneSelectionTrackingListDataModel(List list) { super(list); } - public List getSelections() { + public List getSelections() { return selections; } @@ -50,15 +50,14 @@ public class OneSelectionTrackingListDataModel extends SerializableListDataModel return selections.contains(getRowData()); } - public void select(Object rowData) { - Assert.isTrue(((List) getWrappedData()).contains(rowData), - "The object to select is not contained in this DataModel."); + public void select(T rowData) { + Assert.isTrue((getWrappedData()).contains(rowData), "The object to select is not contained in this DataModel."); selections.clear(); selections.add(rowData); } public void selectAll() { - if (((List) getWrappedData()).size() > 1) { + if ((getWrappedData()).size() > 1) { throw new UnsupportedOperationException("This DataModel only allows one selection."); } } @@ -76,7 +75,7 @@ public class OneSelectionTrackingListDataModel extends SerializableListDataModel } } - public void setSelections(List selections) { + public void setSelections(List selections) { Assert.isTrue(selections.size() <= 1, "This DataModel only allows one selection."); this.selections = selections; } diff --git a/spring-faces/src/main/java/org/springframework/faces/model/SelectionAware.java b/spring-faces/src/main/java/org/springframework/faces/model/SelectionAware.java index ccf78ec8..3f6f00dc 100644 --- a/spring-faces/src/main/java/org/springframework/faces/model/SelectionAware.java +++ b/spring-faces/src/main/java/org/springframework/faces/model/SelectionAware.java @@ -24,7 +24,7 @@ import javax.faces.model.DataModel; * * @author Jeremy Grelle */ -public interface SelectionAware { +public interface SelectionAware { /** * Checks whether the row pointed to by the model's current index is selected. @@ -42,13 +42,13 @@ public interface SelectionAware { * Sets the list of selected row data objects for the model. * @param selections the list of selected row data objects */ - public void setSelections(List selections); + public void setSelections(List selections); /** * Returns the list of selected row data objects for the model. * @return the list of selected row data objects */ - public List getSelections(); + public List getSelections(); /** * Selects all row data objects in the model. @@ -59,5 +59,5 @@ public interface SelectionAware { * Selects the given row data object in the model. * @param rowData the row data object to select. */ - public void select(Object rowData); + public void select(T rowData); } diff --git a/spring-faces/src/main/java/org/springframework/faces/model/SelectionTrackingActionListener.java b/spring-faces/src/main/java/org/springframework/faces/model/SelectionTrackingActionListener.java index 211cee37..7c69853c 100644 --- a/spring-faces/src/main/java/org/springframework/faces/model/SelectionTrackingActionListener.java +++ b/spring-faces/src/main/java/org/springframework/faces/model/SelectionTrackingActionListener.java @@ -64,7 +64,7 @@ public class SelectionTrackingActionListener implements ActionListener { if (valueAccessor != null) { Object value = ReflectionUtils.invokeMethod(valueAccessor, parent); if (value != null && value instanceof SelectionAware) { - ((SelectionAware) value).setCurrentRowSelected(true); + ((SelectionAware) value).setCurrentRowSelected(true); if (logger.isDebugEnabled()) { logger.debug("Row selection has been set on the current SelectionAware data model."); } diff --git a/spring-faces/src/main/java/org/springframework/faces/model/SerializableListDataModel.java b/spring-faces/src/main/java/org/springframework/faces/model/SerializableListDataModel.java index 7b791e7a..a1591d3f 100644 --- a/spring-faces/src/main/java/org/springframework/faces/model/SerializableListDataModel.java +++ b/spring-faces/src/main/java/org/springframework/faces/model/SerializableListDataModel.java @@ -30,23 +30,23 @@ import org.springframework.util.Assert; * * @author Jeremy Grelle */ -public class SerializableListDataModel extends DataModel implements Serializable { +public class SerializableListDataModel extends DataModel implements Serializable { private int rowIndex = 0; - private List data; + private List data; public SerializableListDataModel() { - this(new ArrayList()); + this(new ArrayList()); } /** * Adapt the list to a data model; * @param list the list */ - public SerializableListDataModel(List list) { + public SerializableListDataModel(List list) { if (list == null) { - list = new ArrayList(); + list = new ArrayList(); } setWrappedData(list); } @@ -55,7 +55,7 @@ public class SerializableListDataModel extends DataModel implements Serializable return data.size(); } - public Object getRowData() { + public T getRowData() { Assert.isTrue(isRowAvailable(), getClass() + " is in an illegal state - no row is available at the current index."); return data.get(rowIndex); @@ -65,7 +65,7 @@ public class SerializableListDataModel extends DataModel implements Serializable return rowIndex; } - public Object getWrappedData() { + public List getWrappedData() { return data; } @@ -83,18 +83,19 @@ public class SerializableListDataModel extends DataModel implements Serializable Object row = isRowAvailable() ? getRowData() : null; DataModelEvent event = new DataModelEvent(this, rowIndex, row); DataModelListener[] listeners = getDataModelListeners(); - for (int i = 0; i < listeners.length; i++) { - listeners[i].rowSelected(event); + for (DataModelListener listener : listeners) { + listener.rowSelected(event); } } } + @SuppressWarnings("unchecked") public void setWrappedData(Object data) { if (data == null) { - data = new ArrayList(); + data = new ArrayList(); } Assert.isInstanceOf(List.class, data, "The data object for " + getClass() + " must be a List"); - this.data = (List) data; + this.data = (List) data; int newRowIndex = 0; setRowIndex(newRowIndex); } diff --git a/spring-faces/src/main/java/org/springframework/faces/model/converter/DataModelConverter.java b/spring-faces/src/main/java/org/springframework/faces/model/converter/DataModelConverter.java index af804548..67d3da7a 100644 --- a/spring-faces/src/main/java/org/springframework/faces/model/converter/DataModelConverter.java +++ b/spring-faces/src/main/java/org/springframework/faces/model/converter/DataModelConverter.java @@ -32,20 +32,20 @@ import org.springframework.util.ClassUtils; */ public class DataModelConverter implements Converter { - public Class getSourceClass() { + public Class getSourceClass() { return List.class; } - public Class getTargetClass() { + public Class getTargetClass() { return DataModel.class; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { if (targetClass.equals(DataModel.class)) { targetClass = OneSelectionTrackingListDataModel.class; } - Constructor emptyConstructor = ClassUtils.getConstructorIfAvailable(targetClass, new Class[] {}); - DataModel model = (DataModel) emptyConstructor.newInstance(new Object[] {}); + Constructor emptyConstructor = ClassUtils.getConstructorIfAvailable(targetClass, new Class[] {}); + DataModel model = (DataModel) emptyConstructor.newInstance(new Object[] {}); model.setWrappedData(source); return model; } diff --git a/spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java b/spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java index d0e15289..57ecf62b 100644 --- a/spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java +++ b/spring-faces/src/main/java/org/springframework/faces/mvc/JsfView.java @@ -25,7 +25,6 @@ import javax.faces.FactoryFinder; import javax.faces.application.ViewHandler; import javax.faces.component.UIViewRoot; import javax.faces.context.FacesContext; -import javax.faces.context.FacesContextFactory; import javax.faces.event.PhaseId; import javax.faces.lifecycle.Lifecycle; import javax.faces.lifecycle.LifecycleFactory; @@ -53,8 +52,8 @@ public class JsfView extends AbstractUrlBasedView { facesLifecycle = createFacesLifecycle(); } - protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) - throws Exception { + protected void renderMergedOutputModel(Map model, HttpServletRequest request, + HttpServletResponse response) throws Exception { FacesContextHelper facesContextHelper = new FacesContextHelper(); FacesContext facesContext = facesContextHelper.getFacesContext(getServletContext(), request, response); @@ -89,20 +88,14 @@ public class JsfView extends AbstractUrlBasedView { } } - private void populateRequestMap(FacesContext facesContext, Map model) { - Iterator i = model.keySet().iterator(); + private void populateRequestMap(FacesContext facesContext, Map model) { + Iterator i = model.keySet().iterator(); while (i.hasNext()) { String key = i.next().toString(); facesContext.getExternalContext().getRequestMap().put(key, model.get(key)); } } - private FacesContext createFacesContext(HttpServletRequest request, HttpServletResponse response) { - FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder - .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); - return facesContextFactory.getFacesContext(getServletContext(), request, response, facesLifecycle); - } - private Lifecycle createFacesLifecycle() { LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder .getFactory(FactoryFinder.LIFECYCLE_FACTORY); diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/AjaxEventInterceptorRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/AjaxEventInterceptorRenderer.java index acd131eb..2fe8c678 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/AjaxEventInterceptorRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/AjaxEventInterceptorRenderer.java @@ -68,7 +68,7 @@ public class AjaxEventInterceptorRenderer extends DojoElementDecorationRenderer private String getElementId(FacesContext context, UIComponent component) { if (component.getChildCount() > 0) { - UIComponent child = (UIComponent) component.getChildren().get(0); + UIComponent child = component.getChildren().get(0); if (!(child instanceof SpringJavascriptElementDecoration)) { return child.getClientId(context); } else { @@ -81,8 +81,8 @@ public class AjaxEventInterceptorRenderer extends DojoElementDecorationRenderer public void decode(FacesContext context, UIComponent component) { if (context.getExternalContext().getRequestParameterMap().containsKey("ajaxSource") - && context.getExternalContext().getRequestParameterMap().get("ajaxSource").equals( - component.getClientId(context))) { + && context.getExternalContext().getRequestParameterMap().get("ajaxSource") + .equals(component.getClientId(context))) { component.queueEvent(new ActionEvent(component)); } } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java b/spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java index 53b57c55..90dcb0ac 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/AjaxViewRoot.java @@ -61,7 +61,7 @@ public class AjaxViewRoot extends DelegatingViewRoot { protected static final String PROCESS_ALL = "*"; - private List events = new ArrayList(); + private List events = new ArrayList(); private String[] processIds; @@ -165,8 +165,7 @@ public class AjaxViewRoot extends DelegatingViewRoot { protected String[] getProcessIds() { if (processIds == null) { FacesContext context = FacesContext.getCurrentInstance(); - String processIdsParam = (String) context.getExternalContext().getRequestParameterMap().get( - PROCESS_IDS_PARAM); + String processIdsParam = context.getExternalContext().getRequestParameterMap().get(PROCESS_IDS_PARAM); if (StringUtils.hasText(processIdsParam) && processIdsParam.indexOf(PROCESS_ALL) != -1) { processIds = new String[] { getOriginalViewRoot().getClientId(context) }; } else { @@ -203,9 +202,9 @@ public class AjaxViewRoot extends DelegatingViewRoot { // 3.2. adds outputScript to it // 3.3. the parent of outputScript is changed from ViewRoot to "head" Panel component // 4. outputScript is therefore no longer a child of ViewRoot - List children = new ArrayList(target.getChildren()); + List children = new ArrayList(target.getChildren()); for (int i = 0; i < children.size(); i++) { - UIComponent child = (UIComponent) children.get(i); + UIComponent child = children.get(i); child.setParent(target); } } @@ -242,10 +241,10 @@ public class AjaxViewRoot extends DelegatingViewRoot { } private String[] removeNestedChildren(FacesContext context, String[] ids) { - List idList = Arrays.asList(ids); - final List trimmedIds = new ArrayList(idList); - for (final ListIterator i = trimmedIds.listIterator(); i.hasNext();) { - String id = (String) i.next(); + List idList = Arrays.asList(ids); + final List trimmedIds = new ArrayList(idList); + for (final ListIterator i = trimmedIds.listIterator(); i.hasNext();) { + String id = i.next(); invokeOnComponent(context, id, new ContextCallback() { public void invokeContextCallback(FacesContext context, UIComponent component) { while (!(component.getParent() instanceof UIViewRoot)) { @@ -257,18 +256,19 @@ public class AjaxViewRoot extends DelegatingViewRoot { } }); } - return (String[]) trimmedIds.toArray(new String[trimmedIds.size()]); + return trimmedIds.toArray(new String[trimmedIds.size()]); } private void broadCastEvents(FacesContext context, PhaseId phaseId) { - List processedEvents = new ArrayList(); - if (events.size() == 0) + List processedEvents = new ArrayList(); + if (events.size() == 0) { return; + } boolean abort = false; int phaseIdOrdinal = phaseId.getOrdinal(); - Iterator i = events.iterator(); + Iterator i = events.iterator(); while (i.hasNext()) { - FacesEvent event = (FacesEvent) i.next(); + FacesEvent event = i.next(); int ordinal = event.getPhaseId().getOrdinal(); if (ordinal == PhaseId.ANY_PHASE.getOrdinal() || ordinal == phaseIdOrdinal) { UIComponent source = event.getComponent(); diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/BaseComponentRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/BaseComponentRenderer.java index 449a270a..ac6045d7 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/BaseComponentRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/BaseComponentRenderer.java @@ -32,7 +32,7 @@ import javax.faces.render.Renderer; */ public abstract class BaseComponentRenderer extends BaseHtmlTagRenderer { - private Map attributeCallbacks; + private Map attributeCallbacks; private RenderAttributeCallback idCallback = new RenderAttributeCallback() { public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute, @@ -50,9 +50,9 @@ public abstract class BaseComponentRenderer extends BaseHtmlTagRenderer { } }; - protected Map getAttributeCallbacks(UIComponent component) { + protected Map getAttributeCallbacks(UIComponent component) { if (attributeCallbacks == null) { - attributeCallbacks = new HashMap(); + attributeCallbacks = new HashMap(); attributeCallbacks.put("id", idCallback); attributeCallbacks.put("name", idCallback); attributeCallbacks.put("disabled", disabledCallback); diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/BaseHtmlTagRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/BaseHtmlTagRenderer.java index 802d1baa..2070045f 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/BaseHtmlTagRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/BaseHtmlTagRenderer.java @@ -75,13 +75,13 @@ abstract class BaseHtmlTagRenderer extends Renderer { String attribute = getAttributesToRender(component)[i]; String property = attribute; if (getAttributeAliases(component).containsKey(attribute)) { - property = (String) getAttributeAliases(component).get(attribute); + property = getAttributeAliases(component).get(attribute); } Object attributeValue = component.getAttributes().get(property); RenderAttributeCallback callback = defaultRenderAttributeCallback; if (getAttributeCallbacks(null).containsKey(attribute)) { - callback = (RenderAttributeCallback) getAttributeCallbacks(component).get(attribute); + callback = getAttributeCallbacks(component).get(attribute); } callback.doRender(context, context.getResponseWriter(), component, attribute, attributeValue, property); } catch (IllegalArgumentException ex) { @@ -113,15 +113,15 @@ abstract class BaseHtmlTagRenderer extends Renderer { * @return a map that returns the bean property name for any attribute that doesn't map directly (i.e., the 'class' * attribute maps to the 'styleClass' bean property) */ - protected Map getAttributeAliases(UIComponent component) { + protected Map getAttributeAliases(UIComponent component) { return HTML.STANDARD_ATTRIBUTE_ALIASES; }; /** * @return a map of registered RenderAttributeCallbacks for attributes that require special rendering logic */ - protected Map getAttributeCallbacks(UIComponent component) { - return Collections.EMPTY_MAP; + protected Map getAttributeCallbacks(UIComponent component) { + return Collections.emptyMap(); } } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DelegatingViewRoot.java b/spring-faces/src/main/java/org/springframework/faces/ui/DelegatingViewRoot.java index 29a197b6..eceb72eb 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DelegatingViewRoot.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DelegatingViewRoot.java @@ -136,7 +136,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot { /** * @see javax.faces.component.UIComponentBase#getAttributes() */ - public Map getAttributes() { + public Map getAttributes() { return original.getAttributes(); } @@ -157,7 +157,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot { /** * @see javax.faces.component.UIComponentBase#getChildren() */ - public List getChildren() { + public List getChildren() { return original.getChildren(); } @@ -195,14 +195,14 @@ public abstract class DelegatingViewRoot extends UIViewRoot { /** * @see javax.faces.component.UIComponentBase#getFacets() */ - public Map getFacets() { + public Map getFacets() { return original.getFacets(); } /** * @see javax.faces.component.UIComponentBase#getFacetsAndChildren() */ - public Iterator getFacetsAndChildren() { + public Iterator getFacetsAndChildren() { return original.getFacetsAndChildren(); } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java index 59d32fdd..b78a5810 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java @@ -41,8 +41,7 @@ public class DojoClientDateValidator extends DojoWidget { static { DOJO_ATTRS = new String[DojoWidget.DOJO_ATTRS.length + DOJO_ATTRS_INTERNAL.length]; System.arraycopy(DojoWidget.DOJO_ATTRS, 0, DOJO_ATTRS, 0, DojoWidget.DOJO_ATTRS.length); - System.arraycopy(DOJO_ATTRS_INTERNAL, 0, DOJO_ATTRS, DojoWidget.DOJO_ATTRS.length, - DOJO_ATTRS_INTERNAL.length); + System.arraycopy(DOJO_ATTRS_INTERNAL, 0, DOJO_ATTRS, DojoWidget.DOJO_ATTRS.length, DOJO_ATTRS_INTERNAL.length); } public String getDatePattern() { diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoElementDecorationRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoElementDecorationRenderer.java index 7d224642..4938b201 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoElementDecorationRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoElementDecorationRenderer.java @@ -60,10 +60,11 @@ public class DojoElementDecorationRenderer extends BaseSpringJavascriptDecoratio if (component.getAttributes().containsKey("selector")) { selector = "\"" + (String) component.getAttributes().get("selector") + "\""; } else { - if (component.getChildCount() == 0) + if (component.getChildCount() == 0) { throw new FacesException( "A Spring Faces elementDecoration expects either have a specified selector or at least one child component."); - selector = "dojo.byId('" + ((UIComponent) component.getChildren().get(0)).getClientId(context) + "')"; + } + selector = "dojo.byId('" + component.getChildren().get(0).getClientId(context) + "')"; } ResourceHelper.beginScriptBlock(context); diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java index 2071c25c..df8e64e0 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidget.java @@ -24,7 +24,6 @@ import javax.faces.el.ValueBinding; * component with enhanced client-side behavior. * * @author Jeremy Grelle - * */ public abstract class DojoWidget extends SpringJavascriptElementDecoration { diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidgetRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidgetRenderer.java index 493a6421..6d8f4014 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidgetRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoWidgetRenderer.java @@ -17,8 +17,9 @@ public class DojoWidgetRenderer extends DojoElementDecorationRenderer { if (value != null) { - if (attrs.length() > 0) + if (attrs.length() > 0) { attrs.append(", "); + } attrs.append(key + " : "); diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/HTML.java b/spring-faces/src/main/java/org/springframework/faces/ui/HTML.java index 8e132df1..a111f930 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/HTML.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/HTML.java @@ -31,7 +31,7 @@ final class HTML { public static final String[] STANDARD_ATTRIBUTES = new String[] { "id", "class", "style", "title", "dir", "lang", "accesskey", "tabindex" }; - public static final Map STANDARD_ATTRIBUTE_ALIASES = new HashMap(); + public static final Map STANDARD_ATTRIBUTE_ALIASES = new HashMap(); /** * Standard window events - only valid in body and frameset elements @@ -67,7 +67,7 @@ final class HTML { /** * Anchor attributes */ - public static final Object[] ANCHOR_ATTRIBUTES = new String[] { "charset", "coords", "href", "hreflang", "name", + public static final String[] ANCHOR_ATTRIBUTES = new String[] { "charset", "coords", "href", "hreflang", "name", "rel", "rev", "shape", "target", "type" }; static { diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java index 406c9784..2bc2f783 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandButtonRenderer.java @@ -46,20 +46,20 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer private static String INPUT_TAG_NAME = "input"; static { - List tempList = new ArrayList(); + List tempList = new ArrayList(); tempList.addAll(Arrays.asList(HTML.STANDARD_ATTRIBUTES)); tempList.addAll(Arrays.asList(HTML.BUTTON_ATTRIBUTES)); tempList.addAll(Arrays.asList(HTML.COMMON_ELEMENT_EVENTS)); tempList.addAll(Arrays.asList(HTML.KEYBOARD_EVENTS)); tempList.addAll(Arrays.asList(HTML.MOUSE_EVENTS)); ATTRIBUTES_TO_RENDER = new String[tempList.size()]; - ListIterator i = tempList.listIterator(); + ListIterator i = tempList.listIterator(); while (i.hasNext()) { - ATTRIBUTES_TO_RENDER[i.nextIndex()] = (String) i.next(); + ATTRIBUTES_TO_RENDER[i.nextIndex()] = i.next(); } } - private Map attributeCallbacks; + private Map attributeCallbacks; private RenderAttributeCallback onclickCallback = new RenderAttributeCallback() { @@ -98,9 +98,9 @@ public class ProgressiveCommandButtonRenderer extends BaseDojoComponentRenderer }; - protected Map getAttributeCallbacks(UIComponent component) { + protected Map getAttributeCallbacks(UIComponent component) { if (attributeCallbacks == null) { - attributeCallbacks = new HashMap(); + attributeCallbacks = new HashMap(); attributeCallbacks.putAll(super.getAttributeCallbacks(component)); attributeCallbacks.put("onclick", onclickCallback); } diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java index d858e701..3eb43bf1 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveCommandLinkRenderer.java @@ -59,26 +59,26 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend static { - List tempList = new ArrayList(); + List tempList = new ArrayList(); tempList.addAll(Arrays.asList(HTML.STANDARD_ATTRIBUTES)); tempList.addAll(Arrays.asList(HTML.COMMON_ELEMENT_EVENTS)); tempList.addAll(Arrays.asList(HTML.KEYBOARD_EVENTS)); tempList.addAll(Arrays.asList(HTML.MOUSE_EVENTS)); ATTRIBUTES_TO_RENDER_WHEN_DISABLED = new String[tempList.size()]; - ListIterator i = tempList.listIterator(); + ListIterator i = tempList.listIterator(); while (i.hasNext()) { - ATTRIBUTES_TO_RENDER_WHEN_DISABLED[i.nextIndex()] = (String) i.next(); + ATTRIBUTES_TO_RENDER_WHEN_DISABLED[i.nextIndex()] = i.next(); } tempList.addAll(Arrays.asList(HTML.ANCHOR_ATTRIBUTES)); ATTRIBUTES_TO_RENDER = new String[tempList.size()]; i = tempList.listIterator(); while (i.hasNext()) { - ATTRIBUTES_TO_RENDER[i.nextIndex()] = (String) i.next(); + ATTRIBUTES_TO_RENDER[i.nextIndex()] = i.next(); } } - private Map attributeCallbacks; + private Map attributeCallbacks; private RenderAttributeCallback hrefCallback = new RenderAttributeCallback() { public void doRender(FacesContext context, ResponseWriter writer, UIComponent component, String attribute, @@ -204,9 +204,9 @@ public class ProgressiveCommandLinkRenderer extends ProgressiveCommandButtonRend return isProgressiveCommandDisabled(component) ? TAG_NAME_WHEN_DISABLED : TAG_NAME; } - protected Map getAttributeCallbacks(UIComponent component) { + protected Map getAttributeCallbacks(UIComponent component) { if (attributeCallbacks == null) { - attributeCallbacks = new HashMap(); + attributeCallbacks = new HashMap(); attributeCallbacks.putAll(super.getAttributeCallbacks(component)); attributeCallbacks.put("href", hrefCallback); attributeCallbacks.put("class", classCallback); diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveUICommand.java b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveUICommand.java index 32ad39a6..c5c3ddc4 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveUICommand.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/ProgressiveUICommand.java @@ -31,7 +31,6 @@ import org.springframework.webflow.execution.RequestContextHolder; * type conversion. * * @author Jeremy Grelle - * */ public class ProgressiveUICommand extends UICommand { diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ResourceRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/ResourceRenderer.java index abe149e1..f2874ce1 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ResourceRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/ResourceRenderer.java @@ -33,7 +33,6 @@ import org.springframework.util.Assert; *

* * @author Jeremy Grelle - * */ public class ResourceRenderer extends Renderer { diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/ValidateAllRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/ValidateAllRenderer.java index 2f57e345..fe606f4b 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/ValidateAllRenderer.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/ValidateAllRenderer.java @@ -46,7 +46,7 @@ public class ValidateAllRenderer extends BaseSpringJavascriptDecorationRenderer throw new FacesException("ValidateAll expects to have a child of type UICommand."); } - UIComponent advisedChild = (UIComponent) component.getChildren().get(0); + UIComponent advisedChild = component.getChildren().get(0); ResourceHelper.beginScriptBlock(context); diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/resource/ResourceHelper.java b/spring-faces/src/main/java/org/springframework/faces/ui/resource/ResourceHelper.java index abb3ad83..af3c5463 100644 --- a/spring-faces/src/main/java/org/springframework/faces/ui/resource/ResourceHelper.java +++ b/spring-faces/src/main/java/org/springframework/faces/ui/resource/ResourceHelper.java @@ -74,7 +74,7 @@ public class ResourceHelper { * @throws IOException */ public static void renderScriptLink(FacesContext facesContext, String scriptPath) throws IOException { - renderScriptLink(facesContext, scriptPath, Collections.EMPTY_MAP); + renderScriptLink(facesContext, scriptPath, Collections. emptyMap()); } /** @@ -84,7 +84,7 @@ public class ResourceHelper { * @param attributes - a map of additional attributes to render on the script tag * @throws IOException */ - public static void renderScriptLink(FacesContext facesContext, String scriptPath, Map attributes) + public static void renderScriptLink(FacesContext facesContext, String scriptPath, Map attributes) throws IOException { if (alreadyRendered(facesContext, scriptPath)) { return; @@ -92,9 +92,9 @@ public class ResourceHelper { ResponseWriter writer = facesContext.getResponseWriter(); writer.startElement(SCRIPT_ELEMENT, null); writer.writeAttribute("type", "text/javascript", null); - Iterator i = attributes.keySet().iterator(); + Iterator i = attributes.keySet().iterator(); while (i.hasNext()) { - String key = (String) i.next(); + String key = i.next(); writer.writeAttribute(key, attributes.get(key), null); } String src = facesContext.getExternalContext().getRequestContextPath() + "/resources" + scriptPath; @@ -145,7 +145,7 @@ public class ResourceHelper { } public static void beginCombineStyles(FacesContext facesContext) { - List combinedResources = new ArrayList(); + List combinedResources = new ArrayList(); facesContext.getExternalContext().getRequestMap().put(COMBINED_RESOURCES_KEY, combinedResources); } @@ -154,16 +154,15 @@ public class ResourceHelper { } private static void addStyle(FacesContext facesContext, String stylePath) { - List combinedResources = (List) facesContext.getExternalContext().getRequestMap().get(COMBINED_RESOURCES_KEY); + List combinedResources = getCombinedResources(facesContext); combinedResources.add(stylePath); } public static void endCombineStyles(FacesContext facesContext) throws IOException { - List combinedResources = (List) facesContext.getExternalContext().getRequestMap() - .remove(COMBINED_RESOURCES_KEY); + List combinedResources = getCombinedResources(facesContext); StringBuffer combinedPath = new StringBuffer(); for (int i = 0; i < combinedResources.size(); i++) { - String resourcePath = (String) combinedResources.get(i); + String resourcePath = combinedResources.get(i); if (i == 1) { combinedPath.append("?appended="); } @@ -189,17 +188,28 @@ public class ResourceHelper { } private static void markRendered(FacesContext facesContext, String scriptPath) { - Set renderedResources = (Set) facesContext.getExternalContext().getRequestMap().get(RENDERED_RESOURCES_KEY); + Set renderedResources = getRenderedResources(facesContext); if (renderedResources == null) { - renderedResources = new HashSet(); + renderedResources = new HashSet(); facesContext.getExternalContext().getRequestMap().put(RENDERED_RESOURCES_KEY, renderedResources); } renderedResources.add(scriptPath); } private static boolean alreadyRendered(FacesContext facesContext, String scriptPath) { - Set renderedResources = (Set) facesContext.getExternalContext().getRequestMap().get(RENDERED_RESOURCES_KEY); + Set renderedResources = getRenderedResources(facesContext); return renderedResources != null && renderedResources.contains(scriptPath); } + @SuppressWarnings("unchecked") + private static List getCombinedResources(FacesContext facesContext) { + return (List) facesContext.getExternalContext().getRequestMap().get(COMBINED_RESOURCES_KEY); + } + + @SuppressWarnings("unchecked") + private static Set getRenderedResources(FacesContext facesContext) { + return (Set) facesContext.getExternalContext().getRequestMap().get(RENDERED_RESOURCES_KEY); + + } + } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/ExternalContextWrapper.java b/spring-faces/src/main/java/org/springframework/faces/webflow/ExternalContextWrapper.java index 0a77fa50..5ffd1655 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/ExternalContextWrapper.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/ExternalContextWrapper.java @@ -37,7 +37,7 @@ class ExternalContextWrapper extends ExternalContext { return delegate.encodeResourceURL(url); } - public Map getApplicationMap() { + public Map getApplicationMap() { return delegate.getApplicationMap(); } @@ -53,6 +53,7 @@ class ExternalContextWrapper extends ExternalContext { return delegate.getInitParameter(name); } + @SuppressWarnings("rawtypes") public Map getInitParameterMap() { return delegate.getInitParameterMap(); } @@ -77,15 +78,15 @@ class ExternalContextWrapper extends ExternalContext { return delegate.getRequestContextPath(); } - public Map getRequestCookieMap() { + public Map getRequestCookieMap() { return delegate.getRequestCookieMap(); } - public Map getRequestHeaderMap() { + public Map getRequestHeaderMap() { return delegate.getRequestHeaderMap(); } - public Map getRequestHeaderValuesMap() { + public Map getRequestHeaderValuesMap() { return delegate.getRequestHeaderValuesMap(); } @@ -93,23 +94,23 @@ class ExternalContextWrapper extends ExternalContext { return delegate.getRequestLocale(); } - public Iterator getRequestLocales() { + public Iterator getRequestLocales() { return delegate.getRequestLocales(); } - public Map getRequestMap() { + public Map getRequestMap() { return delegate.getRequestMap(); } - public Map getRequestParameterMap() { + public Map getRequestParameterMap() { return delegate.getRequestParameterMap(); } - public Iterator getRequestParameterNames() { + public Iterator getRequestParameterNames() { return delegate.getRequestParameterNames(); } - public Map getRequestParameterValuesMap() { + public Map getRequestParameterValuesMap() { return delegate.getRequestParameterValuesMap(); } @@ -129,7 +130,7 @@ class ExternalContextWrapper extends ExternalContext { return delegate.getResourceAsStream(path); } - public Set getResourcePaths(String path) { + public Set getResourcePaths(String path) { return delegate.getResourcePaths(path); } @@ -149,7 +150,7 @@ class ExternalContextWrapper extends ExternalContext { return delegate.getSession(create); } - public Map getSessionMap() { + public Map getSessionMap() { return delegate.getSessionMap(); } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowActionListener.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowActionListener.java index e47da3d8..4c69690a 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowActionListener.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowActionListener.java @@ -107,7 +107,7 @@ public class FlowActionListener implements ActionListener { if (requestContext.getMessageContext().hasErrorMessages()) { isValid = false; if (requestContext.getExternalContext().isAjaxRequest()) { - List fragments = new ArrayList(); + List fragments = new ArrayList(); String formId = getModelExpression(requestContext).getExpressionString(); if (facesContext.getViewRoot().findComponent(formId) != null) { fragments.add(formId); @@ -118,7 +118,7 @@ public class FlowActionListener implements ActionListener { if (fragments.size() > 0) { String[] fragmentsArray = new String[fragments.size()]; for (int i = 0; i < fragments.size(); i++) { - fragmentsArray[i] = (String) fragments.get(i); + fragmentsArray[i] = fragments.get(i); } requestContext.getFlashScope().put(View.RENDER_FRAGMENTS_ATTRIBUTE, fragmentsArray); } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java index d945da6c..e673f195 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java @@ -46,7 +46,7 @@ import org.springframework.webflow.execution.RequestContext; * requests in the case of the POST+REDIRECT+GET pattern being enabled. * * @author Jeremy Grelle - * @author Phil Webb + * @author Phillip Webb */ public class FlowFacesContext extends FacesContext { @@ -109,10 +109,10 @@ public class FlowFacesContext extends FacesContext { } public ELContext getELContext() { - Method delegateMethod = ClassUtils.getMethodIfAvailable(delegate.getClass(), "getELContext", null); + Method delegateMethod = ClassUtils.getMethodIfAvailable(delegate.getClass(), "getELContext"); if (delegateMethod != null) { try { - ELContext context = (ELContext) delegateMethod.invoke(delegate, null); + ELContext context = (ELContext) delegateMethod.invoke(delegate); context.putContext(FacesContext.class, this); return context; } catch (Exception e) { diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java index 5c90b05d..901a626e 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContextMessageDelegate.java @@ -29,7 +29,7 @@ import org.springframework.webflow.execution.RequestContext; * Helper delegate class for use with the {@link FlowFacesContext} that handles all faces message methods. * * @author Jeremy Grelle - * @author Phil Webb + * @author Phillip Webb */ public class FlowFacesContextMessageDelegate { @@ -48,9 +48,9 @@ public class FlowFacesContextMessageDelegate { /** * Mappings between {@link FacesMessage} and {@link Severity}. */ - private static final Map FACESSEVERITY_TO_SPRINGSEVERITY; + private static final Map FACESSEVERITY_TO_SPRINGSEVERITY; static { - FACESSEVERITY_TO_SPRINGSEVERITY = new HashMap(); + FACESSEVERITY_TO_SPRINGSEVERITY = new HashMap(); FACESSEVERITY_TO_SPRINGSEVERITY.put(FacesMessage.SEVERITY_INFO, Severity.INFO); FACESSEVERITY_TO_SPRINGSEVERITY.put(FacesMessage.SEVERITY_WARN, Severity.WARNING); FACESSEVERITY_TO_SPRINGSEVERITY.put(FacesMessage.SEVERITY_ERROR, Severity.ERROR); @@ -95,14 +95,15 @@ public class FlowFacesContextMessageDelegate { return null; } FacesMessage.Severity max = FacesMessage.SEVERITY_INFO; - Iterator i = getMessages(); + Iterator i = getMessages(); while (i.hasNext()) { - FacesMessage message = (FacesMessage) i.next(); + FacesMessage message = i.next(); if (message.getSeverity().getOrdinal() > max.getOrdinal()) { max = message.getSeverity(); } - if (max.getOrdinal() == FacesMessage.SEVERITY_FATAL.getOrdinal()) + if (max.getOrdinal() == FacesMessage.SEVERITY_FATAL.getOrdinal()) { break; + } } return max; } @@ -174,8 +175,8 @@ public class FlowFacesContextMessageDelegate { for (int i = 0; i < summaryMessages.length; i++) { messages.add(toFacesMessage(summaryMessages[i], detailMessages[i])); } - for (int z = 0; z < userMessages.length; z++) { - messages.add(toFacesMessage(userMessages[z], userMessages[z])); + for (Message userMessage : userMessages) { + messages.add(toFacesMessage(userMessage, userMessage)); } } @@ -188,8 +189,8 @@ public class FlowFacesContextMessageDelegate { for (int i = 0; i < summaryMessages.length; i++) { messages.add(toFacesMessage(summaryMessages[i], detailMessages[i])); } - for (int z = 0; z < userMessages.length; z++) { - messages.add(toFacesMessage(userMessages[z], userMessages[z])); + for (Message userMessage : userMessages) { + messages.add(toFacesMessage(userMessage, userMessage)); } } @@ -336,7 +337,7 @@ public class FlowFacesContextMessageDelegate { String detail = (String) ois.readObject(); int severityOrdinal = ois.readInt(); FacesMessage.Severity severity = FacesMessage.SEVERITY_INFO; - for (Iterator iterator = FacesMessage.VALUES.iterator(); iterator.hasNext();) { + for (Iterator iterator = FacesMessage.VALUES.iterator(); iterator.hasNext();) { FacesMessage.Severity value = (FacesMessage.Severity) iterator.next(); if (value.getOrdinal() == severityOrdinal) { severity = value; @@ -381,7 +382,7 @@ public class FlowFacesContextMessageDelegate { public Severity getSeverity() { Severity severity = null; if (facesMessage.getSeverity() != null) { - severity = (Severity) FACESSEVERITY_TO_SPRINGSEVERITY.get(facesMessage.getSeverity()); + severity = FACESSEVERITY_TO_SPRINGSEVERITY.get(facesMessage.getSeverity()); } return (severity == null ? Severity.INFO : severity); } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowLifecycle.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowLifecycle.java index 2f652307..97c02afb 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowLifecycle.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowLifecycle.java @@ -62,7 +62,7 @@ public class FlowLifecycle extends Lifecycle { public void execute(FacesContext context) throws FacesException { logger.debug("Executing view post back lifecycle"); for (int p = PhaseId.APPLY_REQUEST_VALUES.getOrdinal(); p <= PhaseId.INVOKE_APPLICATION.getOrdinal(); p++) { - PhaseId phaseId = (PhaseId) PhaseId.VALUES.get(p); + PhaseId phaseId = PhaseId.VALUES.get(p); if (!skipPhase(context, phaseId)) { if (isAtLeastJsf20()) { context.setCurrentPhaseId(phaseId); diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowFacesContext.java b/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowFacesContext.java index eee23d44..3e3a3203 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowFacesContext.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowFacesContext.java @@ -156,7 +156,7 @@ public class Jsf2FlowFacesContext extends FlowFacesContext { return delegate.getContextName(); } - public void addResponseCookie(String name, String value, Map properties) { + public void addResponseCookie(String name, String value, Map properties) { delegate.addResponseCookie(name, value, properties); } @@ -240,11 +240,11 @@ public class Jsf2FlowFacesContext extends FlowFacesContext { delegate.setResponseContentLength(length); } - public String encodeBookmarkableURL(String baseUrl, Map parameters) { + public String encodeBookmarkableURL(String baseUrl, Map> parameters) { return delegate.encodeBookmarkableURL(baseUrl, parameters); } - public String encodeRedirectURL(String baseUrl, Map parameters) { + public String encodeRedirectURL(String baseUrl, Map> parameters) { return delegate.encodeRedirectURL(baseUrl, parameters); } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowViewHandler.java b/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowViewHandler.java index a0099921..4845bff5 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowViewHandler.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/Jsf2FlowViewHandler.java @@ -15,6 +15,7 @@ */ package org.springframework.faces.webflow; +import java.util.List; import java.util.Map; import javax.faces.FacesException; @@ -40,11 +41,13 @@ public class Jsf2FlowViewHandler extends FlowViewHandler { return getDelegate().calculateCharacterEncoding(context); } - public String getBookmarkableURL(FacesContext context, String viewId, Map parameters, boolean includeViewParams) { + public String getBookmarkableURL(FacesContext context, String viewId, Map> parameters, + boolean includeViewParams) { return getDelegate().getBookmarkableURL(context, viewId, parameters, includeViewParams); } - public String getRedirectURL(FacesContext context, String viewId, Map parameters, boolean includeViewParams) { + public String getRedirectURL(FacesContext context, String viewId, Map> parameters, + boolean includeViewParams) { return getDelegate().getRedirectURL(context, viewId, parameters, includeViewParams); } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanAwareELExpressionParser.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanAwareELExpressionParser.java index e4eddaef..04bf4e41 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanAwareELExpressionParser.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanAwareELExpressionParser.java @@ -51,7 +51,7 @@ public class JsfManagedBeanAwareELExpressionParser extends ELExpressionParser { private static class RequestContextELContextFactory implements ELContextFactory { public ELContext getELContext(Object target) { RequestContext context = (RequestContext) target; - List customResolvers = new ArrayList(); + List customResolvers = new ArrayList(); customResolvers.add(new RequestContextELResolver(context)); customResolvers.add(new FlowResourceELResolver(context)); customResolvers.add(new ImplicitFlowVariableELResolver(context)); diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanPropertyAccessor.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanPropertyAccessor.java index 4843324f..bba93390 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanPropertyAccessor.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanPropertyAccessor.java @@ -52,7 +52,7 @@ import org.springframework.webflow.execution.RequestContextHolder; */ public class JsfManagedBeanPropertyAccessor implements PropertyAccessor { - public Class[] getSpecificTargetClasses() { + public Class[] getSpecificTargetClasses() { return null; } @@ -69,7 +69,7 @@ public class JsfManagedBeanPropertyAccessor implements PropertyAccessor { } public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException { - MutableAttributeMap map = getScopeForBean(name); + MutableAttributeMap map = getScopeForBean(name); if (map != null) { map.put(name, newValue); } @@ -97,7 +97,7 @@ public class JsfManagedBeanPropertyAccessor implements PropertyAccessor { } } - private MutableAttributeMap getScopeForBean(String name) { + private MutableAttributeMap getScopeForBean(String name) { ExternalContext externalContext = RequestContextHolder.getRequestContext().getExternalContext(); if (externalContext.getRequestMap().contains(name)) { return externalContext.getRequestMap(); diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanResolver.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanResolver.java index cfb3e73d..c3bb936a 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanResolver.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfManagedBeanResolver.java @@ -15,6 +15,7 @@ */ package org.springframework.faces.webflow; +import java.beans.FeatureDescriptor; import java.util.Iterator; import javax.el.ELContext; @@ -37,15 +38,15 @@ import org.springframework.webflow.execution.RequestContextHolder; */ public class JsfManagedBeanResolver extends ELResolver { - public Class getCommonPropertyType(ELContext context, Object base) { + public Class getCommonPropertyType(ELContext context, Object base) { return Object.class; } - public Iterator getFeatureDescriptors(ELContext context, Object base) { + public Iterator getFeatureDescriptors(ELContext context, Object base) { return null; } - public Class getType(ELContext context, Object base, Object property) { + public Class getType(ELContext context, Object base, Object property) { if (base == null) { Object bean = getFacesBean(property); if (bean != null) { diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfRuntimeInformation.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfRuntimeInformation.java index 84b5042e..b49a0f0f 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfRuntimeInformation.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfRuntimeInformation.java @@ -24,7 +24,7 @@ import org.springframework.webflow.execution.RequestContext; /** * Helper class to provide information about the JSF runtime environment such as JSF version and implementation. * - * @author Phil Webb + * @author Phillip Webb */ public class JsfRuntimeInformation { diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactory.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactory.java index 5cfa83c9..43b074f5 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactory.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactory.java @@ -179,9 +179,9 @@ public class JsfViewFactory implements ViewFactory { if (binding != null) { binding.setValue(context, component); } - Iterator it = component.getFacetsAndChildren(); + Iterator it = component.getFacetsAndChildren(); while (it.hasNext()) { - UIComponent child = (UIComponent) it.next(); + UIComponent child = it.next(); processTree(context, child); } } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/TreeStructureManager.java b/spring-faces/src/main/java/org/springframework/faces/webflow/TreeStructureManager.java index 853c508c..d9cc55ad 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/TreeStructureManager.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/TreeStructureManager.java @@ -17,7 +17,6 @@ package org.springframework.faces.webflow; import java.io.Serializable; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -47,29 +46,27 @@ class TreeStructureManager { // children if (component.getChildCount() > 0) { - List childList = component.getChildren(); - List structChildList = new ArrayList(); + List childList = component.getChildren(); + List structChildList = new ArrayList(); for (int i = 0, len = childList.size(); i < len; i++) { - UIComponent child = (UIComponent) childList.get(i); + UIComponent child = childList.get(i); if (!child.isTransient()) { TreeStructComponent structChild = internalBuildTreeStructureToSave(child); structChildList.add(structChild); } } - TreeStructComponent[] childArray = (TreeStructComponent[]) structChildList - .toArray(new TreeStructComponent[structChildList.size()]); + TreeStructComponent[] childArray = structChildList.toArray(new TreeStructComponent[structChildList.size()]); structComp.setChildren(childArray); } // facets - Map facetMap = component.getFacets(); + Map facetMap = component.getFacets(); if (!facetMap.isEmpty()) { - List structFacetList = new ArrayList(); - for (Iterator it = facetMap.entrySet().iterator(); it.hasNext();) { - Map.Entry entry = (Map.Entry) it.next(); - UIComponent child = (UIComponent) entry.getValue(); + List structFacetList = new ArrayList(); + for (Map.Entry entry : facetMap.entrySet()) { + UIComponent child = entry.getValue(); if (!child.isTransient()) { - String facetName = (String) entry.getKey(); + String facetName = entry.getKey(); TreeStructComponent structChild = internalBuildTreeStructureToSave(child); structFacetList.add(new Object[] { facetName, structChild }); } @@ -103,9 +100,9 @@ class TreeStructureManager { // children TreeStructComponent[] childArray = treeStructComp.getChildren(); if (childArray != null) { - List childList = component.getChildren(); - for (int i = 0, len = childArray.length; i < len; i++) { - UIComponent child = internalRestoreTreeStructure(childArray[i]); + List childList = component.getChildren(); + for (TreeStructComponent element : childArray) { + UIComponent child = internalRestoreTreeStructure(element); childList.add(child); } } @@ -113,9 +110,9 @@ class TreeStructureManager { // facets Object[] facetArray = treeStructComp.getFacets(); if (facetArray != null) { - Map facetMap = component.getFacets(); - for (int i = 0, len = facetArray.length; i < len; i++) { - Object[] tuple = (Object[]) facetArray[i]; + Map facetMap = component.getFacets(); + for (Object element : facetArray) { + Object[] tuple = (Object[]) element; String facetName = (String) tuple[0]; TreeStructComponent structChild = (TreeStructComponent) tuple[1]; UIComponent child = internalRestoreTreeStructure(structChild); diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/application/portlet/PortletFaceletViewHandler.java b/spring-faces/src/main/java/org/springframework/faces/webflow/application/portlet/PortletFaceletViewHandler.java index d8e2f232..bc681cce 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/application/portlet/PortletFaceletViewHandler.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/application/portlet/PortletFaceletViewHandler.java @@ -92,12 +92,11 @@ public class PortletFaceletViewHandler extends FaceletViewHandler { return writer; } - @SuppressWarnings("unchecked") protected String getResponseEncoding(FacesContext context, String originalEncoding) { String encoding = originalEncoding; - Map requestMap = context.getExternalContext().getRequestMap(); - Map sessionMap = context.getExternalContext().getSessionMap(); + Map requestMap = context.getExternalContext().getRequestMap(); + Map sessionMap = context.getExternalContext().getSessionMap(); // 1. check the request attribute if (requestMap.containsKey(FACELETS_ENCODING_KEY)) { diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/InitParameterMap.java b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/InitParameterMap.java index 421e44d9..a698de92 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/InitParameterMap.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/InitParameterMap.java @@ -28,7 +28,7 @@ import org.springframework.webflow.core.collection.CollectionUtils; * @author Rossen Stoyanchev * @since 2.2.0 */ -public class InitParameterMap extends StringKeyedMapAdapter { +public class InitParameterMap extends StringKeyedMapAdapter { final private PortletContext portletContext; @@ -42,7 +42,7 @@ public class InitParameterMap extends StringKeyedMapAdapter { } @Override - protected void setAttribute(String key, Object value) { + protected void setAttribute(String key, String value) { throw new UnsupportedOperationException("Cannot set PortletContext InitParameter"); } @@ -52,7 +52,6 @@ public class InitParameterMap extends StringKeyedMapAdapter { } @Override - @SuppressWarnings("unchecked") protected Iterator getAttributeNames() { return CollectionUtils.toIterator(portletContext.getInitParameterNames()); } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestParameterMap.java b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestParameterMap.java new file mode 100644 index 00000000..a4a9ac45 --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestParameterMap.java @@ -0,0 +1,26 @@ +package org.springframework.faces.webflow.context.portlet; + +import java.util.Map; + +import javax.portlet.PortletContext; +import javax.portlet.PortletRequest; + +/** + * A {@link Map} for accessing to {@link PortletContext} request parameters as a String array. + * + * @author Rossen Stoyanchev + * @author Phillip Webb + * @since 2.4.0 + * + * @see PortletRequest#getParameterValues(String) + */ +public class MultiValueRequestParameterMap extends RequestParameterMap { + + public MultiValueRequestParameterMap(PortletRequest portletRequest) { + super(portletRequest); + } + + protected String[] getAttribute(String key) { + return getPortletRequest().getParameterValues(key); + } +} diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestPropertyMap.java b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestPropertyMap.java new file mode 100644 index 00000000..243c19df --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestPropertyMap.java @@ -0,0 +1,29 @@ +package org.springframework.faces.webflow.context.portlet; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import javax.portlet.PortletContext; +import javax.portlet.PortletRequest; + +/** + * A {@link Map} for accessing to {@link PortletContext} request properties as a String array. + * + * @author Rossen Stoyanchev + * @author Phillip Webb + * @since 2.4.0 + * + * @see PortletRequest#getProperties(String) + */ +public class MultiValueRequestPropertyMap extends RequestPropertyMap { + + public MultiValueRequestPropertyMap(PortletRequest portletRequest) { + super(portletRequest); + } + + protected String[] getAttribute(String key) { + List list = Collections.list(getPortletRequest().getProperties(key)); + return list.toArray(new String[list.size()]); + } +} diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/PortletExternalContextImpl.java b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/PortletExternalContextImpl.java index bfd05c4f..2c9d36b4 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/PortletExternalContextImpl.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/PortletExternalContextImpl.java @@ -79,7 +79,7 @@ public class PortletExternalContextImpl extends ExternalContext { private Map requestParameterValuesMap; - private MapAdaptable sessionMap; + private MapAdaptable sessionMap; public PortletExternalContextImpl(PortletContext portletContext, PortletRequest portletRequest, PortletResponse portletResponse) { @@ -122,7 +122,6 @@ public class PortletExternalContextImpl extends ExternalContext { } @Override - @SuppressWarnings("unchecked") public Map getApplicationMap() { if (applicationMap == null) { applicationMap = new PortletContextMap(portletContext); @@ -146,7 +145,6 @@ public class PortletExternalContextImpl extends ExternalContext { } @Override - @SuppressWarnings("unchecked") public Map getInitParameterMap() { if (initParameterMap == null) { initParameterMap = new InitParameterMap(portletContext); @@ -175,29 +173,22 @@ public class PortletExternalContextImpl extends ExternalContext { } @Override - @SuppressWarnings("unchecked") public Map getRequestCookieMap() { - return Collections.EMPTY_MAP; + return Collections.emptyMap(); } @Override - @SuppressWarnings("unchecked") public Map getRequestHeaderMap() { if (requestHeaderMap == null) { - RequestPropertyMap map = new RequestPropertyMap(portletRequest); - map.setUseArrayForMultiValueAttributes(Boolean.FALSE); - requestHeaderMap = map; + requestHeaderMap = new SingleValueRequestPropertyMap(portletRequest); } return requestHeaderMap; } @Override - @SuppressWarnings("unchecked") public Map getRequestHeaderValuesMap() { if (requestHeaderValuesMap == null) { - RequestPropertyMap map = new RequestPropertyMap(portletRequest); - map.setUseArrayForMultiValueAttributes(Boolean.TRUE); - requestHeaderValuesMap = map; + requestHeaderValuesMap = new MultiValueRequestPropertyMap(portletRequest); } return requestHeaderValuesMap; } @@ -208,13 +199,11 @@ public class PortletExternalContextImpl extends ExternalContext { } @Override - @SuppressWarnings("unchecked") public Iterator getRequestLocales() { return CollectionUtils.toIterator(portletRequest.getLocales()); } @Override - @SuppressWarnings("unchecked") public Map getRequestMap() { if (requestMap == null) { requestMap = new PortletRequestMap(portletRequest); @@ -223,29 +212,22 @@ public class PortletExternalContextImpl extends ExternalContext { } @Override - @SuppressWarnings("unchecked") public Map getRequestParameterMap() { if (requestParameterMap == null) { - RequestParameterMap map = new RequestParameterMap(portletRequest); - map.setUseArrayForMultiValueAttributes(Boolean.FALSE); - requestParameterMap = map; + requestParameterMap = new SingleValueRequestParameterMap(portletRequest); } return requestParameterMap; } @Override - @SuppressWarnings("unchecked") public Iterator getRequestParameterNames() { return CollectionUtils.toIterator(portletRequest.getParameterNames()); } @Override - @SuppressWarnings("unchecked") public Map getRequestParameterValuesMap() { if (requestParameterValuesMap == null) { - RequestParameterMap map = new RequestParameterMap(portletRequest); - map.setUseArrayForMultiValueAttributes(Boolean.TRUE); - requestParameterValuesMap = map; + requestParameterValuesMap = new MultiValueRequestParameterMap(portletRequest); } return requestParameterValuesMap; } @@ -302,10 +284,9 @@ public class PortletExternalContextImpl extends ExternalContext { } @Override - @SuppressWarnings("unchecked") public Map getSessionMap() { if (sessionMap == null) { - sessionMap = new LocalAttributeMap(new PortletSessionMap(portletRequest)); + sessionMap = new LocalAttributeMap(new PortletSessionMap(portletRequest)); } return sessionMap.asMap(); } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/PortletFacesContextImpl.java b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/PortletFacesContextImpl.java index 279f8c6b..18ef48b3 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/PortletFacesContextImpl.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/PortletFacesContextImpl.java @@ -141,8 +141,9 @@ public class PortletFacesContextImpl extends FacesContext { list.add(messages.get(i)); } } else { - if (clientId.equals(current)) + if (clientId.equals(current)) { list.add(messages.get(i)); + } } } return list.iterator(); diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/RequestParameterMap.java b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/RequestParameterMap.java index e8f26f06..29212837 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/RequestParameterMap.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/RequestParameterMap.java @@ -15,71 +15,72 @@ */ package org.springframework.faces.webflow.context.portlet; +import java.util.Iterator; +import java.util.Map; + +import javax.portlet.PortletContext; import javax.portlet.PortletRequest; +import org.springframework.binding.collection.StringKeyedMapAdapter; import org.springframework.webflow.context.portlet.PortletRequestParameterMap; /** - * Map backed by a PortletContext for accessing Portlet request parameters. Request parameters can have multiple values. - * The {@link RequestParameterMap#setUseArrayForMultiValueAttributes(Boolean)} property allows choosing whether the map - * will return: - *
    - *
  • String - selects the first value in case of multiple value parameters
  • - *
  • String[] - wraps single-values parameters as array
  • - *
  • String or String[] - depends on the values of the parameter
  • - *
+ * /** Base class for {@link Map}s allowing access to {@link PortletContext} request paramters. * * @author Rossen Stoyanchev + * @author Phillip Webb * @since 2.2.0 * - * @see PortletRequest#getParameter(String) - * @see PortletRequest#getParameterValues(String) + * @see SingleValueRequestParameterMap + * @see MultiValueRequestParameterMap */ -public class RequestParameterMap extends PortletRequestParameterMap { - - private Boolean useArrayForMultiValueAttributes; +public abstract class RequestParameterMap extends StringKeyedMapAdapter { private PortletRequest portletRequest; + private Delegate delegate; + public RequestParameterMap(PortletRequest portletRequest) { - super(portletRequest); this.portletRequest = portletRequest; + this.delegate = new Delegate(portletRequest); } - public void setUseArrayForMultiValueAttributes(Boolean useArrayForMultiValueAttributes) { - this.useArrayForMultiValueAttributes = useArrayForMultiValueAttributes; + protected final PortletRequest getPortletRequest() { + return portletRequest; } - /** - * This property allows choosing what kind of attributes the map will return: - *
    - *
  1. String - selects the first value in case of multiple value parameters
  2. - *
  3. String[] - wraps single-values parameters as array
  4. - *
  5. String or String[] - depends on the values of the parameter
  6. - *
- * The above choices correspond to the following values for useArrayForMultiValueAttributes: - *
    - *
  1. False
  2. - *
  3. True
  4. - *
  5. null
  6. - *
- * - * @param useArrayForMultiValueAttributes - */ - public Boolean useArrayForMultiValueAttributes() { - return useArrayForMultiValueAttributes; + protected void setAttribute(String key, V value) { + delegate.setAttribute(key, value); } - @Override - protected Object getAttribute(String key) { - if (null == useArrayForMultiValueAttributes) { + protected void removeAttribute(String key) { + delegate.removeAttribute(key); + } + + protected Iterator getAttributeNames() { + return delegate.getAttributeNames(); + } + + private static class Delegate extends PortletRequestParameterMap { + + public Delegate(PortletRequest request) { + super(request); + } + + public Object getAttribute(String key) { return super.getAttribute(key); - } else { - if (useArrayForMultiValueAttributes) { - return portletRequest.getParameterValues(key); - } else { - return portletRequest.getParameter(key); - } + } + + public void setAttribute(String key, Object value) { + super.setAttribute(key, value); + } + + public void removeAttribute(String key) { + super.removeAttribute(key); + } + + public Iterator getAttributeNames() { + return super.getAttributeNames(); } } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/RequestPropertyMap.java b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/RequestPropertyMap.java index b8e9ac67..e5cf9883 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/RequestPropertyMap.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/RequestPropertyMap.java @@ -15,34 +15,26 @@ */ package org.springframework.faces.webflow.context.portlet; -import java.util.Collections; import java.util.Iterator; -import java.util.List; +import java.util.Map; +import javax.portlet.PortletContext; import javax.portlet.PortletRequest; import org.springframework.binding.collection.StringKeyedMapAdapter; import org.springframework.webflow.core.collection.CollectionUtils; /** - * Map backed by a PortletContext for accessing Portlet request properties. Request properties can have multiple values. - * The {@link RequestPropertyMap#setUseArrayForMultiValueAttributes(Boolean)} property allows choosing whether the map - * will return: - *
    - *
  • String - selects the first element in case of multiple values
  • - *
  • String[] - wraps single-values attributes as array
  • - *
  • String or String[] - depends on the values of the property
  • - *
+ * Base class for {@link Map}s allowing access to {@link PortletContext} request properties. * * @author Rossen Stoyanchev + * @author Phillip Webb * @since 2.2.0 * - * @see PortletRequest#getProperty(String) - * @see PortletRequest#getProperties(String) + * @see SingleValueRequestPropertyMap + * @see MultiValueRequestPropertyMap */ -public class RequestPropertyMap extends StringKeyedMapAdapter { - - private Boolean useArrayForMultiValueAttributes; +public abstract class RequestPropertyMap extends StringKeyedMapAdapter { private final PortletRequest portletRequest; @@ -50,51 +42,12 @@ public class RequestPropertyMap extends StringKeyedMapAdapter { this.portletRequest = portletRequest; } - /** - * This property allows choosing what kind of attributes the map will return: - *
    - *
  1. String - selects the first element in case of multiple values
  2. - *
  3. String[] - wraps single-values attributes as array
  4. - *
  5. String or String[] - depends on the values of the property
  6. - *
- * The above choices correspond to the following values for useArrayForMultiValueAttributes: - *
    - *
  1. False
  2. - *
  3. True
  4. - *
  5. null
  6. - *
- * - * @param useArrayForMultiValueAttributes - */ - public void setUseArrayForMultiValueAttributes(Boolean useArrayForMultiValueAttributes) { - this.useArrayForMultiValueAttributes = useArrayForMultiValueAttributes; - } - - public Boolean useArrayForMultiValueAttributes() { - return useArrayForMultiValueAttributes; + protected final PortletRequest getPortletRequest() { + return portletRequest; } @Override - protected Object getAttribute(String key) { - if (null == useArrayForMultiValueAttributes) { - List list = Collections.list(portletRequest.getProperties(key)); - if (1 == list.size()) { - return list.get(0); - } else { - return list.toArray(new String[list.size()]); - } - } else { - if (useArrayForMultiValueAttributes) { - List list = Collections.list(portletRequest.getProperties(key)); - return list.toArray(new String[list.size()]); - } else { - return portletRequest.getProperty(key); - } - } - } - - @Override - protected void setAttribute(String key, Object value) { + protected void setAttribute(String key, V value) { throw new UnsupportedOperationException("Cannot set PortletRequest property"); } @@ -104,9 +57,7 @@ public class RequestPropertyMap extends StringKeyedMapAdapter { } @Override - @SuppressWarnings("unchecked") protected Iterator getAttributeNames() { return CollectionUtils.toIterator(portletRequest.getPropertyNames()); } - } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestParameterMap.java b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestParameterMap.java new file mode 100644 index 00000000..aa5e65b7 --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestParameterMap.java @@ -0,0 +1,26 @@ +package org.springframework.faces.webflow.context.portlet; + +import java.util.Map; + +import javax.portlet.PortletContext; +import javax.portlet.PortletRequest; + +/** + * A {@link Map} for accessing to {@link PortletContext} request parameters containing single String values. + * + * @author Rossen Stoyanchev + * @author Phillip Webb + * @since 2.4.0 + * + * @see PortletRequest#getParameterValues(String) + */ +public class SingleValueRequestParameterMap extends RequestParameterMap { + + public SingleValueRequestParameterMap(PortletRequest portletRequest) { + super(portletRequest); + } + + protected String getAttribute(String key) { + return getPortletRequest().getParameter(key); + } +} diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestPropertyMap.java b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestPropertyMap.java new file mode 100644 index 00000000..ff02228a --- /dev/null +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestPropertyMap.java @@ -0,0 +1,26 @@ +package org.springframework.faces.webflow.context.portlet; + +import java.util.Map; + +import javax.portlet.PortletContext; +import javax.portlet.PortletRequest; + +/** + * A {@link Map} for accessing to {@link PortletContext} request properties containing single String values. + * + * @author Rossen Stoyanchev + * @author Phillip Webb + * @since 2.4.0 + * + * @see PortletRequest#getProperties(String) + */ +public class SingleValueRequestPropertyMap extends RequestPropertyMap { + + public SingleValueRequestPropertyMap(PortletRequest portletRequest) { + super(portletRequest); + } + + protected String getAttribute(String key) { + return getPortletRequest().getProperty(key); + } +} diff --git a/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java b/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java index 44715ad7..32ab52e1 100644 --- a/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/config/FacesFlowBuilderServicesBeanDefinitionParserTests.java @@ -1,7 +1,5 @@ package org.springframework.faces.config; -import java.util.Set; - import junit.framework.TestCase; import org.springframework.binding.convert.ConversionException; @@ -91,29 +89,25 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase public static class TestConversionService implements ConversionService { - public Object executeConversion(Object source, Class targetClass) throws ConversionException { + public Object executeConversion(Object source, Class targetClass) throws ConversionException { throw new UnsupportedOperationException("Auto-generated method stub"); } - public Object executeConversion(String converterId, Object source, Class targetClass) { + public Object executeConversion(String converterId, Object source, Class targetClass) { throw new UnsupportedOperationException("Auto-generated method stub"); } - public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) throws ConversionExecutionException { throw new UnsupportedOperationException("Auto-generated method stub"); } - public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) throws ConversionExecutorNotFoundException { throw new UnsupportedOperationException("Auto-generated method stub"); } - public Set getConversionExecutors(Class sourceClass) { - throw new UnsupportedOperationException("Auto-generated method stub"); - } - - public Class getClassForAlias(String name) throws ConversionExecutionException { + public Class getClassForAlias(String name) throws ConversionExecutionException { throw new UnsupportedOperationException("Auto-generated method stub"); } diff --git a/spring-faces/src/test/java/org/springframework/faces/config/ResourcesBeanDefinitionParserTests.java b/spring-faces/src/test/java/org/springframework/faces/config/ResourcesBeanDefinitionParserTests.java index 041018c4..157f660e 100644 --- a/spring-faces/src/test/java/org/springframework/faces/config/ResourcesBeanDefinitionParserTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/config/ResourcesBeanDefinitionParserTests.java @@ -21,7 +21,7 @@ public class ResourcesBeanDefinitionParserTests extends TestCase { } public void testConfigureDefaults() { - Map map = context.getBeansOfType(HttpRequestHandlerAdapter.class); + Map map = context.getBeansOfType(HttpRequestHandlerAdapter.class); assertEquals(1, map.values().size()); Object resourceHandler = context.getBean(ResourcesBeanDefinitionParser.RESOURCE_HANDLER_BEAN_NAME); @@ -31,8 +31,8 @@ public class ResourcesBeanDefinitionParserTests extends TestCase { map = context.getBeansOfType(SimpleUrlHandlerMapping.class); assertEquals(1, map.values().size()); SimpleUrlHandlerMapping handlerMapping = (SimpleUrlHandlerMapping) map.values().iterator().next(); - assertEquals(ResourcesBeanDefinitionParser.RESOURCE_HANDLER_BEAN_NAME, handlerMapping.getUrlMap().get( - "/javax.faces.resource/**")); + assertEquals(ResourcesBeanDefinitionParser.RESOURCE_HANDLER_BEAN_NAME, + handlerMapping.getUrlMap().get("/javax.faces.resource/**")); assertEquals(0, handlerMapping.getOrder()); } diff --git a/spring-faces/src/test/java/org/springframework/faces/model/SelectionTrackingActionListenerTests.java b/spring-faces/src/test/java/org/springframework/faces/model/SelectionTrackingActionListenerTests.java index 1a677241..7ddaf041 100644 --- a/spring-faces/src/test/java/org/springframework/faces/model/SelectionTrackingActionListenerTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/model/SelectionTrackingActionListenerTests.java @@ -36,7 +36,7 @@ public class SelectionTrackingActionListenerTests extends TestCase { /** * The list of row data objects to */ - private OneSelectionTrackingListDataModel dataModel; + private OneSelectionTrackingListDataModel dataModel; /** * The delegate action listener that should be called @@ -51,11 +51,11 @@ public class SelectionTrackingActionListenerTests extends TestCase { public void setUp() throws Exception { jsfMockHelper.setUp(); viewToTest = new UIViewRoot(); - List rows = new ArrayList(); + List rows = new ArrayList(); rows.add(new TestRowData()); rows.add(new TestRowData()); rows.add(new TestRowData()); - dataModel = new OneSelectionTrackingListDataModel(rows); + dataModel = new OneSelectionTrackingListDataModel(rows); } protected void tearDown() throws Exception { diff --git a/spring-faces/src/test/java/org/springframework/faces/model/converter/DataModelConverterTests.java b/spring-faces/src/test/java/org/springframework/faces/model/converter/DataModelConverterTests.java index 5d73c7c8..19bd0ecf 100644 --- a/spring-faces/src/test/java/org/springframework/faces/model/converter/DataModelConverterTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/model/converter/DataModelConverterTests.java @@ -16,28 +16,33 @@ public class DataModelConverterTests extends TestCase { Converter converter = new DataModelConverter(); + @SuppressWarnings("unchecked") public void testConvertListToDataModel() throws Exception { - List sourceList = new ArrayList(); + List sourceList = new ArrayList(); - DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, DataModel.class); + DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, + DataModel.class); assertNotNull(resultModel); assertSame(sourceList, resultModel.getWrappedData()); } + @SuppressWarnings("unchecked") public void testConvertListToListDataModel() throws Exception { - List sourceList = new ArrayList(); + List sourceList = new ArrayList(); - DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, ListDataModel.class); + DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, + ListDataModel.class); assertNotNull(resultModel); assertSame(sourceList, resultModel.getWrappedData()); } + @SuppressWarnings("unchecked") public void testConvertListToSerializableListDataModel() throws Exception { - List sourceList = new ArrayList(); + List sourceList = new ArrayList(); - DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, + DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, SerializableListDataModel.class); assertNotNull(resultModel); @@ -45,10 +50,11 @@ public class DataModelConverterTests extends TestCase { assertTrue(resultModel instanceof Serializable); } + @SuppressWarnings("unchecked") public void testConvertListToSerializableListDataModelNullSource() throws Exception { - List sourceList = null; + List sourceList = null; - DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, + DataModel resultModel = (DataModel) converter.convertSourceToTargetClass(sourceList, SerializableListDataModel.class); assertNotNull(resultModel); diff --git a/spring-faces/src/test/java/org/springframework/faces/model/converter/FacesConversionServiceTests.java b/spring-faces/src/test/java/org/springframework/faces/model/converter/FacesConversionServiceTests.java index 4b0c7f8b..d1ac3713 100644 --- a/spring-faces/src/test/java/org/springframework/faces/model/converter/FacesConversionServiceTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/model/converter/FacesConversionServiceTests.java @@ -18,7 +18,7 @@ public class FacesConversionServiceTests extends TestCase { public void testGetAbstractType() { ConversionExecutor executor = service.getConversionExecutor(List.class, DataModel.class); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); list.add("foo"); executor.execute(list); } diff --git a/spring-faces/src/test/java/org/springframework/faces/mvc/JsfViewTests.java b/spring-faces/src/test/java/org/springframework/faces/mvc/JsfViewTests.java index 46e9790d..9ddfced2 100644 --- a/spring-faces/src/test/java/org/springframework/faces/mvc/JsfViewTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/mvc/JsfViewTests.java @@ -47,7 +47,7 @@ public class JsfViewTests extends TestCase { JsfView view = (JsfView) resolver.resolveViewName("intro", new Locale("EN")); view.setApplicationContext(new StaticWebApplicationContext()); view.setServletContext(new MockServletContext()); - view.render(new HashMap(), new MockHttpServletRequest(), new MockHttpServletResponse()); + view.render(new HashMap(), new MockHttpServletRequest(), new MockHttpServletResponse()); } private class ResourceCheckingViewHandler extends MockViewHandler { diff --git a/spring-faces/src/test/java/org/springframework/faces/ui/AjaxViewRootTests.java b/spring-faces/src/test/java/org/springframework/faces/ui/AjaxViewRootTests.java index 5f709753..bc63cbae 100644 --- a/spring-faces/src/test/java/org/springframework/faces/ui/AjaxViewRootTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/ui/AjaxViewRootTests.java @@ -67,14 +67,16 @@ public class AjaxViewRootTests extends TestCase { assertEquals(1, ajaxRoot.getProcessIds().length); assertEquals(1, ajaxRoot.getRenderIds().length); - assertEquals(StringUtils.arrayToCommaDelimitedString(ajaxRoot.getProcessIds()), StringUtils - .arrayToCommaDelimitedString(ajaxRoot.getRenderIds())); + assertEquals(StringUtils.arrayToCommaDelimitedString(ajaxRoot.getProcessIds()), + StringUtils.arrayToCommaDelimitedString(ajaxRoot.getRenderIds())); } public void testEncodeAll_RenderIdsExpr() throws IOException { - jsf.externalContext().getRequestMap().put(View.RENDER_FRAGMENTS_ATTRIBUTE, - StringUtils.delimitedListToStringArray("foo:bar,foo:baz", ",", " ")); + jsf.externalContext() + .getRequestMap() + .put(View.RENDER_FRAGMENTS_ATTRIBUTE, + StringUtils.delimitedListToStringArray("foo:bar,foo:baz", ",", " ")); AjaxViewRoot ajaxRoot = new AjaxViewRoot(testTree); diff --git a/spring-faces/src/test/java/org/springframework/faces/ui/ProgressiveCommandLinkRendererTests.java b/spring-faces/src/test/java/org/springframework/faces/ui/ProgressiveCommandLinkRendererTests.java index cedb8036..3a149555 100644 --- a/spring-faces/src/test/java/org/springframework/faces/ui/ProgressiveCommandLinkRendererTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/ui/ProgressiveCommandLinkRendererTests.java @@ -31,8 +31,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase { link.setId("foo"); form.getChildren().add(link); - RenderAttributeCallback callback = (RenderAttributeCallback) renderer.getAttributeCallbacks(link) - .get("onclick"); + RenderAttributeCallback callback = renderer.getAttributeCallbacks(link).get("onclick"); jsf.facesContext().getResponseWriter().startElement("a", link); @@ -62,8 +61,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase { link.getChildren().add(param1); link.getChildren().add(param2); - RenderAttributeCallback callback = (RenderAttributeCallback) renderer.getAttributeCallbacks(link) - .get("onclick"); + RenderAttributeCallback callback = renderer.getAttributeCallbacks(link).get("onclick"); jsf.facesContext().getResponseWriter().startElement("a", link); @@ -84,8 +82,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase { link.setAjaxEnabled(Boolean.FALSE); form.getChildren().add(link); - RenderAttributeCallback callback = (RenderAttributeCallback) renderer.getAttributeCallbacks(link) - .get("onclick"); + RenderAttributeCallback callback = renderer.getAttributeCallbacks(link).get("onclick"); jsf.facesContext().getResponseWriter().startElement("a", link); @@ -116,8 +113,7 @@ public class ProgressiveCommandLinkRendererTests extends TestCase { link.getChildren().add(param1); link.getChildren().add(param2); - RenderAttributeCallback callback = (RenderAttributeCallback) renderer.getAttributeCallbacks(link) - .get("onclick"); + RenderAttributeCallback callback = renderer.getAttributeCallbacks(link).get("onclick"); jsf.facesContext().getResponseWriter().startElement("a", link); diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowActionListenerTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowActionListenerTests.java index c7ab1f78..2c90045f 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowActionListenerTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowActionListenerTests.java @@ -24,14 +24,14 @@ public class FlowActionListenerTests extends TestCase { JSFMockHelper jsfMock = new JSFMockHelper(); - RequestContext context = (RequestContext) EasyMock.createMock(RequestContext.class); + RequestContext context = EasyMock.createMock(RequestContext.class); protected void setUp() throws Exception { jsfMock.setUp(); listener = new FlowActionListener(jsfMock.application().getActionListener()); RequestContextHolder.setRequestContext(context); - LocalAttributeMap flash = new LocalAttributeMap(); + LocalAttributeMap flash = new LocalAttributeMap(); EasyMock.expect(context.getFlashScope()).andStubReturn(flash); EasyMock.expect(context.getCurrentState()).andStubReturn(new MockViewState()); EasyMock.replay(new Object[] { context }); @@ -79,7 +79,7 @@ public class FlowActionListenerTests extends TestCase { this.result = result; } - public Class getType(FacesContext context) throws MethodNotFoundException { + public Class getType(FacesContext context) throws MethodNotFoundException { return String.class; } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowFacesContextTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowFacesContextTests.java index ea15bf0d..428961fc 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowFacesContextTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowFacesContextTests.java @@ -73,9 +73,9 @@ public class FlowFacesContextTests extends TestCase { facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "FOO", "BAR")); int iterationCount = 0; - Iterator i = facesContext.getMessages(null); + Iterator i = facesContext.getMessages(null); while (i.hasNext()) { - FacesMessage message = (FacesMessage) i.next(); + FacesMessage message = i.next(); assertNotNull(message); iterationCount++; } @@ -91,9 +91,9 @@ public class FlowFacesContextTests extends TestCase { facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "FOO", "BAR")); int iterationCount = 0; - Iterator i = facesContext.getMessages(); + Iterator i = facesContext.getMessages(); while (i.hasNext()) { - FacesMessage message = (FacesMessage) i.next(); + FacesMessage message = i.next(); assertNotNull(message); iterationCount++; } @@ -125,7 +125,7 @@ public class FlowFacesContextTests extends TestCase { EasyMock.replay(new Object[] { requestContext }); int iterationCount = 0; - Iterator i = facesContext.getMessages(); + Iterator i = facesContext.getMessages(); while (i.hasNext()) { assertNotNull(i.next()); iterationCount++; @@ -139,7 +139,7 @@ public class FlowFacesContextTests extends TestCase { EasyMock.replay(new Object[] { requestContext }); facesContext.addMessage("TESTID", new FacesMessage("summary1")); - FacesMessage soruceMessage = (FacesMessage) facesContext.getMessages("TESTID").next(); + FacesMessage soruceMessage = facesContext.getMessages("TESTID").next(); soruceMessage.setSummary("summary2"); // check that message sticks around even when the facesContext has been torn down and re-created during the @@ -147,7 +147,7 @@ public class FlowFacesContextTests extends TestCase { FacesContext newFacesContext = new FlowFacesContext(requestContext, jsf.facesContext()); assertSame(FacesContext.getCurrentInstance(), newFacesContext); - FacesMessage gotMessage = (FacesMessage) newFacesContext.getMessages("TESTID").next(); + FacesMessage gotMessage = newFacesContext.getMessages("TESTID").next(); assertEquals("summary2", gotMessage.getSummary()); } @@ -157,9 +157,9 @@ public class FlowFacesContextTests extends TestCase { EasyMock.replay(new Object[] { requestContext }); int iterationCount = 0; - Iterator i = facesContext.getMessages("componentId"); + Iterator i = facesContext.getMessages("componentId"); while (i.hasNext()) { - FacesMessage message = (FacesMessage) i.next(); + FacesMessage message = i.next(); assertNotNull(message); assertEquals("componentId_summary" + (iterationCount + 1), message.getSummary()); assertEquals("componentId_detail" + (iterationCount + 1), message.getDetail()); @@ -174,9 +174,9 @@ public class FlowFacesContextTests extends TestCase { EasyMock.replay(new Object[] { requestContext }); int iterationCount = 0; - Iterator i = facesContext.getMessages("userMessage"); + Iterator i = facesContext.getMessages("userMessage"); while (i.hasNext()) { - FacesMessage message = (FacesMessage) i.next(); + FacesMessage message = i.next(); assertNotNull(message); assertEquals("userMessage", message.getSummary()); assertEquals("userMessage", message.getDetail()); @@ -190,7 +190,7 @@ public class FlowFacesContextTests extends TestCase { EasyMock.expect(requestContext.getMessageContext()).andStubReturn(messageContext); EasyMock.replay(new Object[] { requestContext }); - Iterator i = facesContext.getMessages("unknown"); + Iterator i = facesContext.getMessages("unknown"); assertFalse(i.hasNext()); } @@ -199,15 +199,15 @@ public class FlowFacesContextTests extends TestCase { EasyMock.expect(requestContext.getMessageContext()).andStubReturn(messageContext); EasyMock.replay(new Object[] { requestContext }); - List expectedOrderedIds = new ArrayList(); + List expectedOrderedIds = new ArrayList(); expectedOrderedIds.add(null); expectedOrderedIds.add("componentId"); expectedOrderedIds.add("userMessage"); int iterationCount = 0; - Iterator i = facesContext.getClientIdsWithMessages(); + Iterator i = facesContext.getClientIdsWithMessages(); while (i.hasNext()) { - String clientId = (String) i.next(); + String clientId = i.next(); assertEquals("Client id not expected", expectedOrderedIds.get(iterationCount), clientId); iterationCount++; } @@ -220,7 +220,7 @@ public class FlowFacesContextTests extends TestCase { EasyMock.replay(new Object[] { requestContext }); facesContext.addMessage("TESTID", new FacesMessage("summary1")); - FacesMessage sourceMessage = (FacesMessage) facesContext.getMessages("TESTID").next(); + FacesMessage sourceMessage = facesContext.getMessages("TESTID").next(); sourceMessage.setSummary("summary2"); sourceMessage.setSeverity(FacesMessage.SEVERITY_FATAL); @@ -244,7 +244,7 @@ public class FlowFacesContextTests extends TestCase { FacesContext newFacesContext = new FlowFacesContext(requestContext, jsf.facesContext()); assertSame(FacesContext.getCurrentInstance(), newFacesContext); - FacesMessage gotMessage = (FacesMessage) newFacesContext.getMessages("TESTID").next(); + FacesMessage gotMessage = newFacesContext.getMessages("TESTID").next(); assertEquals("summary2", gotMessage.getSummary()); assertEquals(FacesMessage.SEVERITY_FATAL, gotMessage.getSeverity()); } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowPartialViewContextTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowPartialViewContextTests.java index e8102221..da15aa35 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowPartialViewContextTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowPartialViewContextTests.java @@ -16,7 +16,6 @@ import org.springframework.webflow.test.MockRequestContext; public class FlowPartialViewContextTests extends TestCase { - @SuppressWarnings("unchecked") public void testReturnFragmentIds() throws Exception { String[] fragmentIds = new String[] { "foo", "bar" }; @@ -47,7 +46,6 @@ public class FlowPartialViewContextTests extends TestCase { assertEquals(renderIds, context.getRenderIds()); } - @SuppressWarnings("unchecked") public void testReturnFragmentIdsMutable() throws Exception { String[] fragmentIds = new String[] { "foo", "bar" }; diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowViewResponseStateManagerTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowViewResponseStateManagerTests.java index 6ca1b5b4..ca196478 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowViewResponseStateManagerTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowViewResponseStateManagerTests.java @@ -37,7 +37,7 @@ public class FlowViewResponseStateManagerTests extends TestCase { public void testWriteFlowSerializedView() throws Exception { EasyMock.expect(flowExecutionContext.getKey()).andReturn(new MockFlowExecutionKey("e1s1")); - LocalAttributeMap viewMap = new LocalAttributeMap(); + LocalAttributeMap viewMap = new LocalAttributeMap(); EasyMock.expect(requestContext.getViewScope()).andStubReturn(viewMap); EasyMock.expect(requestContext.getFlowExecutionContext()).andReturn(flowExecutionContext); EasyMock.replay(requestContext, flowExecutionContext); @@ -57,7 +57,7 @@ public class FlowViewResponseStateManagerTests extends TestCase { Object componentState = new Object(); FlowSerializedView flowSerializedView = new FlowSerializedView("viewId", treeStructure, componentState); - LocalAttributeMap viewMap = new LocalAttributeMap(); + LocalAttributeMap viewMap = new LocalAttributeMap(); viewMap.put(FlowViewStateManager.SERIALIZED_VIEW_STATE, flowSerializedView); EasyMock.expect(requestContext.getViewScope()).andStubReturn(viewMap); EasyMock.replay(requestContext); diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JSFManagedBean.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JSFManagedBean.java index 113e418a..d9b3ca9a 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JSFManagedBean.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JSFManagedBean.java @@ -7,7 +7,7 @@ public class JSFManagedBean { String prop1; JSFModel model; - List values = new ArrayList(); + List values = new ArrayList(); public JSFModel getModel() { return model; @@ -29,7 +29,7 @@ public class JSFManagedBean { values.add(value); } - public List getValues() { + public List getValues() { return values; } } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfFinalResponseActionTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfFinalResponseActionTests.java index 679a47b0..9b237fe5 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfFinalResponseActionTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfFinalResponseActionTests.java @@ -39,7 +39,7 @@ public class JsfFinalResponseActionTests extends TestCase { private JSFMockHelper jsfMock = new JSFMockHelper(); - private RequestContext context = (RequestContext) EasyMock.createMock(RequestContext.class); + private RequestContext context = EasyMock.createMock(RequestContext.class); private ViewHandler viewHandler = new NoRenderViewHandler(); @@ -74,9 +74,10 @@ public class JsfFinalResponseActionTests extends TestCase { ext.setNativeRequest(new MockHttpServletRequest()); ext.setNativeResponse(new MockHttpServletResponse()); EasyMock.expect(context.getExternalContext()).andStubReturn(ext); - LocalAttributeMap requestMap = new LocalAttributeMap(); + LocalAttributeMap requestMap = new LocalAttributeMap(); EasyMock.expect(context.getFlashScope()).andStubReturn(requestMap); - EasyMock.expect(context.getRequestParameters()).andStubReturn(new LocalParameterMap(new HashMap())); + EasyMock.expect(context.getRequestParameters()).andStubReturn( + new LocalParameterMap(new HashMap())); } public void testRender() throws Exception { @@ -116,7 +117,7 @@ public class JsfFinalResponseActionTests extends TestCase { private class TrackingPhaseListener implements PhaseListener { - private List phaseCallbacks = new ArrayList(); + private List phaseCallbacks = new ArrayList(); public void afterPhase(PhaseEvent event) { String phaseCallback = "AFTER_" + event.getPhaseId(); @@ -135,11 +136,6 @@ public class JsfFinalResponseActionTests extends TestCase { public PhaseId getPhaseId() { return PhaseId.ANY_PHASE; } - - public List getPhaseCallbacks() { - return phaseCallbacks; - } - } private class NoRenderViewHandler extends MockViewHandler { diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfFlowHandlerAdapterTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfFlowHandlerAdapterTests.java index 540cfe51..ee1522fe 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfFlowHandlerAdapterTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfFlowHandlerAdapterTests.java @@ -43,7 +43,7 @@ public class JsfFlowHandlerAdapterTests extends TestCase { throw new UnsupportedOperationException("Not expected"); } - public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context) + public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context) throws FlowException { throw new UnsupportedOperationException("Not expected"); } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfManagedBeanPropertyAccessorTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfManagedBeanPropertyAccessorTests.java index 2af12a81..82a0e510 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfManagedBeanPropertyAccessorTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfManagedBeanPropertyAccessorTests.java @@ -53,7 +53,7 @@ public class JsfManagedBeanPropertyAccessorTests extends TestCase { public void testCanWrite() throws Exception { assertFalse(accessor.canWrite(null, null, "myJsfBean")); - MutableAttributeMap map = requestContext.getExternalContext().getRequestMap(); + MutableAttributeMap map = requestContext.getExternalContext().getRequestMap(); map.put("myJsfBean", new Object()); assertTrue(accessor.canWrite(null, null, "myJsfBean")); map.clear(); @@ -73,7 +73,7 @@ public class JsfManagedBeanPropertyAccessorTests extends TestCase { Object jsfBean1 = new Object(); Object jsfBean2 = new Object(); - MutableAttributeMap map = requestContext.getExternalContext().getRequestMap(); + MutableAttributeMap map = requestContext.getExternalContext().getRequestMap(); accessor.write(null, null, "myJsfBean", jsfBean1); assertNull("Write occurs only if bean is present in the map", map.get("myJsfBean")); diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfUtilsTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfUtilsTests.java index 66fd694f..ac3d6fcc 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfUtilsTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfUtilsTests.java @@ -15,7 +15,7 @@ import org.apache.myfaces.test.mock.lifecycle.MockLifecycle; public class JsfUtilsTests extends TestCase { public void testBeforeListenersCalledInForwardOrder() throws Exception { - List list = new ArrayList(); + List list = new ArrayList(); MockLifecycle lifecycle = new MockLifecycle(); PhaseListener listener1 = new OrderVerifyingPhaseListener(null, list); lifecycle.addPhaseListener(listener1); @@ -30,7 +30,7 @@ public class JsfUtilsTests extends TestCase { } public void testAfterListenersCalledInReverseOrder() throws Exception { - List list = new ArrayList(); + List list = new ArrayList(); MockLifecycle lifecycle = new MockLifecycle(); PhaseListener listener1 = new OrderVerifyingPhaseListener(list, null); lifecycle.addPhaseListener(listener1); @@ -46,10 +46,11 @@ public class JsfUtilsTests extends TestCase { private class OrderVerifyingPhaseListener implements PhaseListener { - private List afterPhaseList; - private List beforePhaseList; + private List afterPhaseList; + private List beforePhaseList; - public OrderVerifyingPhaseListener(List afterPhaseList, List beforePhaseList) { + public OrderVerifyingPhaseListener(List afterPhaseList, + List beforePhaseList) { this.afterPhaseList = afterPhaseList; this.beforePhaseList = beforePhaseList; } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewFactoryTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewFactoryTests.java index 1e8a4c36..264dfa24 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewFactoryTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewFactoryTests.java @@ -54,7 +54,7 @@ public class JsfViewFactoryTests extends TestCase { private RequestContext context = EasyMock.createMock(RequestContext.class); - private LocalAttributeMap flashMap = new LocalAttributeMap(); + private LocalAttributeMap flashMap = new LocalAttributeMap(); private ViewHandler viewHandler = new MockViewHandler(); @@ -80,7 +80,8 @@ public class JsfViewFactoryTests extends TestCase { RequestContextHolder.setRequestContext(context); EasyMock.expect(context.getFlashScope()).andStubReturn(flashMap); EasyMock.expect(context.getExternalContext()).andStubReturn(extContext); - EasyMock.expect(context.getRequestParameters()).andStubReturn(new LocalParameterMap(new HashMap())); + EasyMock.expect(context.getRequestParameters()).andStubReturn( + new LocalParameterMap(new HashMap())); } protected void tearDown() throws Exception { @@ -299,7 +300,7 @@ public class JsfViewFactoryTests extends TestCase { private class TrackingPhaseListener implements PhaseListener { - private List phaseCallbacks = new ArrayList(); + private List phaseCallbacks = new ArrayList(); public void afterPhase(PhaseEvent event) { String phaseCallback = "AFTER_" + event.getPhaseId(); @@ -318,11 +319,6 @@ public class JsfViewFactoryTests extends TestCase { public PhaseId getPhaseId() { return PhaseId.ANY_PHASE; } - - public List getPhaseCallbacks() { - return phaseCallbacks; - } - } private class NormalViewState implements StateDefinition { @@ -339,7 +335,7 @@ public class JsfViewFactoryTests extends TestCase { throw new UnsupportedOperationException("Auto-generated method stub"); } - public MutableAttributeMap getAttributes() { + public MutableAttributeMap getAttributes() { throw new UnsupportedOperationException("Auto-generated method stub"); } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java index f4df7b0d..04768494 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java @@ -40,11 +40,12 @@ public class JsfViewTests extends TestCase { private String event = "foo"; - private RequestContext context = (RequestContext) EasyMock.createMock(RequestContext.class); - private FlowExecutionContext flowExecutionContext = (FlowExecutionContext) EasyMock - .createMock(FlowExecutionContext.class); - private MutableAttributeMap flashScope = (MutableAttributeMap) EasyMock.createMock(MutableAttributeMap.class); - private MutableAttributeMap flowMap = (MutableAttributeMap) EasyMock.createMock(MutableAttributeMap.class); + private RequestContext context = EasyMock.createMock(RequestContext.class); + private FlowExecutionContext flowExecutionContext = EasyMock.createMock(FlowExecutionContext.class); + @SuppressWarnings("unchecked") + private MutableAttributeMap flashScope = EasyMock.createMock(MutableAttributeMap.class); + @SuppressWarnings("unchecked") + private MutableAttributeMap flowMap = EasyMock.createMock(MutableAttributeMap.class); private FlowExecutionKey key = new FlowExecutionKey() { diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/MockApplication.java b/spring-faces/src/test/java/org/springframework/faces/webflow/MockApplication.java index ea486e70..fa217662 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/MockApplication.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/MockApplication.java @@ -115,41 +115,41 @@ public class MockApplication extends Application { return null; } - public Iterator getComponentTypes() { + public Iterator getComponentTypes() { return null; } public void addConverter(String converterId, String converterClass) { } - public void addConverter(Class targetClass, String converterClass) { + public void addConverter(Class targetClass, String converterClass) { } public Converter createConverter(String converterId) { return null; } - public Converter createConverter(Class targetClass) { + public Converter createConverter(Class targetClass) { return null; } - public Iterator getConverterIds() { + public Iterator getConverterIds() { return null; } - public Iterator getConverterTypes() { + public Iterator> getConverterTypes() { return null; } - public MethodBinding createMethodBinding(String ref, Class[] params) throws ReferenceSyntaxException { + public MethodBinding createMethodBinding(String ref, Class[] params) throws ReferenceSyntaxException { return null; } - public Iterator getSupportedLocales() { + public Iterator getSupportedLocales() { return null; } - public void setSupportedLocales(Collection locales) { + public void setSupportedLocales(Collection locales) { } public void addValidator(String validatorId, String validatorClass) { @@ -159,7 +159,7 @@ public class MockApplication extends Application { return null; } - public Iterator getValidatorIds() { + public Iterator getValidatorIds() { return null; } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/MockBaseFacesContext.java b/spring-faces/src/test/java/org/springframework/faces/webflow/MockBaseFacesContext.java index 1a891a0b..36842bfc 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/MockBaseFacesContext.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/MockBaseFacesContext.java @@ -26,7 +26,7 @@ public class MockBaseFacesContext extends MockFacesContext20 { super(externalContext, lifecycle); } - public Map getAttributes() { + public Map getAttributes() { return super.getAttributes(); } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/MockFacesContext.java b/spring-faces/src/test/java/org/springframework/faces/webflow/MockFacesContext.java index bb98075e..26a4d9d6 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/MockFacesContext.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/MockFacesContext.java @@ -58,7 +58,7 @@ public class MockFacesContext extends FacesContext { this.application = application; } - public Iterator getClientIdsWithMessages() { + public Iterator getClientIdsWithMessages() { return null; } @@ -78,11 +78,11 @@ public class MockFacesContext extends FacesContext { return null; } - public Iterator getMessages() { + public Iterator getMessages() { return null; } - public Iterator getMessages(String arg0) { + public Iterator getMessages(String arg0) { return null; } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/MockJsfExternalContext.java b/spring-faces/src/test/java/org/springframework/faces/webflow/MockJsfExternalContext.java index 0062844f..73ae4411 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/MockJsfExternalContext.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/MockJsfExternalContext.java @@ -32,13 +32,13 @@ import javax.faces.context.ExternalContext; public class MockJsfExternalContext extends ExternalContext { - private Map applicationMap = new HashMap(); + private Map applicationMap = new HashMap(); - private Map sessionMap = new HashMap(); + private Map sessionMap = new HashMap(); - private Map requestMap = new HashMap(); + private Map requestMap = new HashMap(); - private Map requestParameterMap = Collections.EMPTY_MAP; + private Map requestParameterMap = Collections.emptyMap(); public void dispatch(String arg0) throws IOException { } @@ -55,7 +55,7 @@ public class MockJsfExternalContext extends ExternalContext { return null; } - public Map getApplicationMap() { + public Map getApplicationMap() { return applicationMap; } @@ -71,7 +71,7 @@ public class MockJsfExternalContext extends ExternalContext { return null; } - public Map getInitParameterMap() { + public Map getInitParameterMap() { return null; } @@ -87,15 +87,15 @@ public class MockJsfExternalContext extends ExternalContext { return null; } - public Map getRequestCookieMap() { + public Map getRequestCookieMap() { return null; } - public Map getRequestHeaderMap() { + public Map getRequestHeaderMap() { return null; } - public Map getRequestHeaderValuesMap() { + public Map getRequestHeaderValuesMap() { return null; } @@ -103,11 +103,11 @@ public class MockJsfExternalContext extends ExternalContext { return null; } - public Iterator getRequestLocales() { + public Iterator getRequestLocales() { return null; } - public Map getRequestMap() { + public Map getRequestMap() { return requestMap; } @@ -115,11 +115,11 @@ public class MockJsfExternalContext extends ExternalContext { * Set the request map for this external context. * @param requestMap The requestMap to set. */ - public void setRequestMap(Map requestMap) { + public void setRequestMap(Map requestMap) { this.requestMap = requestMap; } - public Map getRequestParameterMap() { + public Map getRequestParameterMap() { return requestParameterMap; } @@ -127,15 +127,15 @@ public class MockJsfExternalContext extends ExternalContext { * Set the request parameter map for this external context. * @param requestParameterMap the request parameter map to set. */ - public void setRequestParameterMap(Map requestParameterMap) { + public void setRequestParameterMap(Map requestParameterMap) { this.requestParameterMap = requestParameterMap; } - public Iterator getRequestParameterNames() { + public Iterator getRequestParameterNames() { return requestParameterMap.keySet().iterator(); } - public Map getRequestParameterValuesMap() { + public Map getRequestParameterValuesMap() { return null; } @@ -155,7 +155,7 @@ public class MockJsfExternalContext extends ExternalContext { return null; } - public Set getResourcePaths(String arg0) { + public Set getResourcePaths(String arg0) { return null; } @@ -167,7 +167,7 @@ public class MockJsfExternalContext extends ExternalContext { return null; } - public Map getSessionMap() { + public Map getSessionMap() { return sessionMap; } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/RequestParameterMapTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestParameterMapTests.java similarity index 55% rename from spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/RequestParameterMapTests.java rename to spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestParameterMapTests.java index 766d823e..4101f7fe 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/RequestParameterMapTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestParameterMapTests.java @@ -4,27 +4,16 @@ import junit.framework.TestCase; import org.springframework.mock.web.portlet.MockPortletRequest; -public class RequestParameterMapTests extends TestCase { +public class MultiValueRequestParameterMapTests extends TestCase { - private RequestParameterMap requestMap; + private MultiValueRequestParameterMap requestMap; private MockPortletRequest request; protected void setUp() throws Exception { super.setUp(); request = new MockPortletRequest(); - requestMap = new RequestParameterMap(request); - } - - protected void tearDown() throws Exception { - super.tearDown(); - request = null; - requestMap = null; - } - - public void testSingleValueParameter() throws Exception { - request.setParameter("key", "value"); - assertEquals("value", requestMap.getAttribute("key")); + requestMap = new MultiValueRequestParameterMap(request); } public void testMultiValueParameter() throws Exception { @@ -39,19 +28,10 @@ public class RequestParameterMapTests extends TestCase { public void testSingleValueParameterAsArray() throws Exception { request.setParameter("key", "value"); - requestMap.setUseArrayForMultiValueAttributes(Boolean.TRUE); Object actual = requestMap.getAttribute("key"); assertTrue(actual.getClass().isArray()); assertEquals(1, ((String[]) actual).length); assertEquals("value", ((String[]) actual)[0]); } - public void testMultiValueParameterAsString() throws Exception { - request.setParameter("key", "value"); - request.addParameter("key", "value2"); - requestMap.setUseArrayForMultiValueAttributes(Boolean.FALSE); - Object actual = requestMap.getAttribute("key"); - assertEquals("value", actual); - } - } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/RequestPropertyMapTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestPropertyMapTest.java similarity index 51% rename from spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/RequestPropertyMapTests.java rename to spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestPropertyMapTest.java index b36c312a..ba116e72 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/RequestPropertyMapTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/MultiValueRequestPropertyMapTest.java @@ -4,34 +4,22 @@ import junit.framework.TestCase; import org.springframework.mock.web.portlet.MockPortletRequest; -public class RequestPropertyMapTests extends TestCase { +public class MultiValueRequestPropertyMapTest extends TestCase { - private RequestPropertyMap requestMap; + private MultiValueRequestPropertyMap requestMap; private MockPortletRequest request; protected void setUp() throws Exception { super.setUp(); request = new MockPortletRequest(); - requestMap = new RequestPropertyMap(request); - } - - protected void tearDown() throws Exception { - super.tearDown(); - request = null; - requestMap = null; - } - - public void testSingleValueProperty() throws Exception { - request.setProperty("key", "value"); - assertEquals("value", requestMap.getAttribute("key")); + requestMap = new MultiValueRequestPropertyMap(request); } public void testMultiValueProperty() throws Exception { request.setProperty("key", "value"); request.addProperty("key", "value2"); Object actual = requestMap.getAttribute("key"); - assertTrue(actual.getClass().isArray()); assertEquals(2, ((String[]) actual).length); assertEquals("value", ((String[]) actual)[0]); assertEquals("value2", ((String[]) actual)[1]); @@ -39,18 +27,8 @@ public class RequestPropertyMapTests extends TestCase { public void testSingleValuePropertyAsArray() throws Exception { request.setProperty("key", "value"); - requestMap.setUseArrayForMultiValueAttributes(Boolean.TRUE); Object actual = requestMap.getAttribute("key"); - assertTrue(actual.getClass().isArray()); assertEquals(1, ((String[]) actual).length); assertEquals("value", ((String[]) actual)[0]); } - - public void testMultiValuePropertyAsString() throws Exception { - request.setProperty("key", "value"); - request.addProperty("key", "value2"); - requestMap.setUseArrayForMultiValueAttributes(Boolean.FALSE); - Object actual = requestMap.getAttribute("key"); - assertEquals("value", actual); - } } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestParameterMapTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestParameterMapTests.java new file mode 100644 index 00000000..d2d35a38 --- /dev/null +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestParameterMapTests.java @@ -0,0 +1,30 @@ +package org.springframework.faces.webflow.context.portlet; + +import junit.framework.TestCase; + +import org.springframework.mock.web.portlet.MockPortletRequest; + +public class SingleValueRequestParameterMapTests extends TestCase { + + private SingleValueRequestParameterMap requestMap; + + private MockPortletRequest request; + + protected void setUp() throws Exception { + super.setUp(); + request = new MockPortletRequest(); + requestMap = new SingleValueRequestParameterMap(request); + } + + public void testSingleValueParameter() throws Exception { + request.setParameter("key", "value"); + assertEquals("value", requestMap.getAttribute("key")); + } + + public void testMultiValueParameterAsString() throws Exception { + request.setParameter("key", "value"); + request.addParameter("key", "value2"); + Object actual = requestMap.getAttribute("key"); + assertEquals("value", actual); + } +} diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestPropertyMapTest.java b/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestPropertyMapTest.java new file mode 100644 index 00000000..b28f7ca4 --- /dev/null +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/context/portlet/SingleValueRequestPropertyMapTest.java @@ -0,0 +1,30 @@ +package org.springframework.faces.webflow.context.portlet; + +import junit.framework.TestCase; + +import org.springframework.mock.web.portlet.MockPortletRequest; + +public class SingleValueRequestPropertyMapTest extends TestCase { + + private SingleValueRequestPropertyMap requestMap; + + private MockPortletRequest request; + + protected void setUp() throws Exception { + super.setUp(); + request = new MockPortletRequest(); + requestMap = new SingleValueRequestPropertyMap(request); + } + + public void testSingleValueProperty() throws Exception { + request.setProperty("key", "value"); + assertEquals("value", requestMap.getAttribute("key")); + } + + public void testMultiValuePropertyAsString() throws Exception { + request.setProperty("key", "value"); + request.addProperty("key", "value2"); + Object actual = requestMap.getAttribute("key"); + assertEquals("value", actual); + } +} diff --git a/spring-js-resources/.settings/org.eclipse.jdt.core.prefs b/spring-js-resources/.settings/org.eclipse.jdt.core.prefs index 2fdeadfc..98c1827b 100644 --- a/spring-js-resources/.settings/org.eclipse.jdt.core.prefs +++ b/spring-js-resources/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Wed Jun 09 09:15:58 BST 2010 +#Wed Mar 28 15:14:41 PDT 2012 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -19,6 +19,8 @@ org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled @@ -26,11 +28,13 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore @@ -42,6 +46,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public @@ -49,7 +54,9 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore @@ -57,12 +64,20 @@ org.eclipse.jdt.core.compiler.problem.nullReference=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning @@ -70,14 +85,19 @@ org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false diff --git a/spring-js/.settings/org.eclipse.jdt.core.prefs b/spring-js/.settings/org.eclipse.jdt.core.prefs index 2fdeadfc..4cdd60d3 100644 --- a/spring-js/.settings/org.eclipse.jdt.core.prefs +++ b/spring-js/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Wed Jun 09 09:15:58 BST 2010 +#Wed Mar 28 15:13:55 PDT 2012 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -19,6 +19,8 @@ org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled @@ -26,11 +28,13 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore @@ -42,6 +46,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public @@ -49,7 +54,9 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore @@ -57,12 +64,20 @@ org.eclipse.jdt.core.compiler.problem.nullReference=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning @@ -70,14 +85,19 @@ org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false diff --git a/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java b/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java index 92239089..bd4c4ca3 100644 --- a/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java +++ b/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java @@ -65,7 +65,7 @@ public class AjaxTilesView extends TilesView { public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); tilesRequestContextFactory = new ServletTilesRequestContextFactory(); - tilesRequestContextFactory.init(new HashMap()); + tilesRequestContextFactory.init(new HashMap()); } public AjaxHandler getAjaxHandler() { @@ -76,8 +76,8 @@ public class AjaxTilesView extends TilesView { this.ajaxHandler = ajaxHandler; } - protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) - throws Exception { + protected void renderMergedOutputModel(Map model, HttpServletRequest request, + HttpServletResponse response) throws Exception { ServletContext servletContext = getServletContext(); if (ajaxHandler.isAjaxRequest(request, response)) { @@ -101,12 +101,12 @@ public class AjaxTilesView extends TilesView { exposeModelAsRequestAttributes(model, request); JstlUtils.exposeLocalizationContext(new RequestContext(request, servletContext)); - TilesRequestContext tilesRequestContext = tilesRequestContextFactory.createRequestContext(container - .getApplicationContext(), new Object[] { request, response }); + TilesRequestContext tilesRequestContext = tilesRequestContextFactory.createRequestContext( + container.getApplicationContext(), new Object[] { request, response }); Definition compositeDefinition = container.getDefinitionsFactory().getDefinition(getUrl(), tilesRequestContext); - Map flattenedAttributeMap = new HashMap(); + Map flattenedAttributeMap = new HashMap(); flattenAttributeMap(container, tilesRequestContext, flattenedAttributeMap, compositeDefinition, request, response); addRuntimeAttributes(container, flattenedAttributeMap, request, response); @@ -115,11 +115,11 @@ public class AjaxTilesView extends TilesView { request.setAttribute(ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME, true); } - for (int i = 0; i < fragmentsToRender.length; i++) { - Attribute attributeToRender = (Attribute) flattenedAttributeMap.get(fragmentsToRender[i]); + for (String element : fragmentsToRender) { + Attribute attributeToRender = flattenedAttributeMap.get(element); if (attributeToRender == null) { - throw new ServletException("No tiles attribute with a name of '" + fragmentsToRender[i] + throw new ServletException("No tiles attribute with a name of '" + element + "' could be found for the current view: " + this); } else { container.startContext(request, response).inheritCascadedAttributes(compositeDefinition); @@ -132,7 +132,8 @@ public class AjaxTilesView extends TilesView { } } - protected String[] getRenderFragments(Map model, HttpServletRequest request, HttpServletResponse response) { + protected String[] getRenderFragments(Map model, HttpServletRequest request, + HttpServletResponse response) { String attrName = request.getParameter(FRAGMENTS_PARAM); String[] renderFragments = StringUtils.commaDelimitedListToStringArray(attrName); return StringUtils.trimArrayElements(renderFragments); @@ -153,10 +154,11 @@ public class AjaxTilesView extends TilesView { * @param response the servlet response */ protected void flattenAttributeMap(BasicTilesContainer container, TilesRequestContext requestContext, - Map resultMap, Definition compositeDefinition, HttpServletRequest request, HttpServletResponse response) { - Iterator iterator = compositeDefinition.getAttributeNames(); + Map resultMap, Definition compositeDefinition, HttpServletRequest request, + HttpServletResponse response) { + Iterator iterator = compositeDefinition.getAttributeNames(); while (iterator.hasNext()) { - String attributeName = (String) iterator.next(); + String attributeName = iterator.next(); Attribute attribute = compositeDefinition.getAttribute(attributeName); if (attribute.getValue() == null || !(attribute.getValue() instanceof String)) { continue; @@ -184,19 +186,19 @@ public class AjaxTilesView extends TilesView { * @param request the Servlet request * @param response the Servlet response */ - protected void addRuntimeAttributes(BasicTilesContainer container, Map resultMap, HttpServletRequest request, - HttpServletResponse response) { + protected void addRuntimeAttributes(BasicTilesContainer container, Map resultMap, + HttpServletRequest request, HttpServletResponse response) { AttributeContext attributeContext = container.getAttributeContext(new Object[] { request, response }); - Set attributeNames = new HashSet(); + Set attributeNames = new HashSet(); if (attributeContext.getLocalAttributeNames() != null) { attributeNames.addAll(attributeContext.getLocalAttributeNames()); } if (attributeContext.getCascadedAttributeNames() != null) { attributeNames.addAll(attributeContext.getCascadedAttributeNames()); } - Iterator iterator = attributeNames.iterator(); + Iterator iterator = attributeNames.iterator(); while (iterator.hasNext()) { - String name = (String) iterator.next(); + String name = iterator.next(); Attribute attr = attributeContext.getAttribute(name); resultMap.put(name, attr); } diff --git a/spring-js/src/main/java/org/springframework/js/resource/ResourceServlet.java b/spring-js/src/main/java/org/springframework/js/resource/ResourceServlet.java index 7df548ef..cf9f0947 100644 --- a/spring-js/src/main/java/org/springframework/js/resource/ResourceServlet.java +++ b/spring-js/src/main/java/org/springframework/js/resource/ResourceServlet.java @@ -72,7 +72,7 @@ public class ResourceServlet extends HttpServletBean { private boolean gzipEnabled = true; - private Set allowedResourcePaths = new HashSet(); + private Set allowedResourcePaths = new HashSet(); { allowedResourcePaths.add("/**/*.css"); allowedResourcePaths.add("/**/*.gif"); @@ -90,7 +90,7 @@ public class ResourceServlet extends HttpServletBean { allowedResourcePaths.add("META-INF/**/*.png"); }; - private Map defaultMimeTypes = new HashMap(); + private Map defaultMimeTypes = new HashMap(); { defaultMimeTypes.put(".css", "text/css"); defaultMimeTypes.put(".gif", "image/gif"); @@ -101,7 +101,7 @@ public class ResourceServlet extends HttpServletBean { defaultMimeTypes.put(".png", "image/png"); } - private Set compressedMimeTypes = new HashSet(); + private Set compressedMimeTypes = new HashSet(); { compressedMimeTypes.add("text/*"); } @@ -131,8 +131,8 @@ public class ResourceServlet extends HttpServletBean { OutputStream out = selectOutputStream(request, response); try { - for (int i = 0; i < resources.length; i++) { - URLConnection resourceConn = resources[i].openConnection(); + for (URL resource : resources) { + URLConnection resourceConn = resource.openConnection(); InputStream in = resourceConn.getInputStream(); try { byte[] buffer = new byte[1024]; @@ -166,9 +166,9 @@ public class ResourceServlet extends HttpServletBean { private boolean matchesCompressedMimeTypes(String mimeType) { PathMatcher pathMatcher = new AntPathMatcher(); - Iterator compressedMimeTypesIt = compressedMimeTypes.iterator(); + Iterator compressedMimeTypesIt = compressedMimeTypes.iterator(); while (compressedMimeTypesIt.hasNext()) { - String compressedMimeType = (String) compressedMimeTypesIt.next(); + String compressedMimeType = compressedMimeTypesIt.next(); if (pathMatcher.match(compressedMimeType, mimeType)) { return true; } @@ -181,16 +181,16 @@ public class ResourceServlet extends HttpServletBean { long lastModified = -1; int contentLength = 0; String mimeType = null; - for (int i = 0; i < resources.length; i++) { - URLConnection resourceConn = resources[i].openConnection(); + for (URL resource : resources) { + URLConnection resourceConn = resource.openConnection(); if (resourceConn.getLastModified() > lastModified) { lastModified = resourceConn.getLastModified(); } - String currentMimeType = getServletContext().getMimeType(resources[i].getPath()); + String currentMimeType = getServletContext().getMimeType(resource.getPath()); if (currentMimeType == null) { - String extension = resources[i].getPath().substring(resources[i].getPath().lastIndexOf('.')); - currentMimeType = (String) defaultMimeTypes.get(extension); + String extension = resource.getPath().substring(resource.getPath().lastIndexOf('.')); + currentMimeType = defaultMimeTypes.get(extension); } if (mimeType == null) { mimeType = currentMimeType; @@ -226,10 +226,10 @@ public class ResourceServlet extends HttpServletBean { long lastModified = -1; - for (int i = 0; i < resources.length; i++) { + for (URL resource : resources) { URLConnection resourceConn; try { - resourceConn = resources[i].openConnection(); + resourceConn = resource.openConnection(); } catch (IOException e) { return -1; } @@ -298,9 +298,9 @@ public class ResourceServlet extends HttpServletBean { return false; } PathMatcher pathMatcher = new AntPathMatcher(); - Iterator allowedResourcePathsIt = allowedResourcePaths.iterator(); + Iterator allowedResourcePathsIt = allowedResourcePaths.iterator(); while (allowedResourcePathsIt.hasNext()) { - String pattern = (String) allowedResourcePathsIt.next(); + String pattern = allowedResourcePathsIt.next(); if (pathMatcher.match(pattern, resourcePath)) { return true; } @@ -380,14 +380,6 @@ public class ResourceServlet extends HttpServletBean { } gzipStream.write(b, off, len); } - - public boolean closed() { - return (this.closed); - } - - public void reset() { - // noop - } } /** @@ -404,8 +396,8 @@ public class ResourceServlet extends HttpServletBean { * @see AntPathMatcher */ public void setAllowedResourcePaths(String allowedResourcePaths) { - this.allowedResourcePaths = new HashSet(Arrays.asList(StringUtils.tokenizeToStringArray(allowedResourcePaths, - ",", true, true))); + this.allowedResourcePaths = new HashSet(Arrays.asList(StringUtils.tokenizeToStringArray( + allowedResourcePaths, ",", true, true))); } /** @@ -415,8 +407,8 @@ public class ResourceServlet extends HttpServletBean { * @see AntPathMatcher */ public void setCompressedMimeTypes(String compressedMimeTypes) { - this.compressedMimeTypes = new HashSet(Arrays.asList(StringUtils.tokenizeToStringArray(compressedMimeTypes, - ",", true, true))); + this.compressedMimeTypes = new HashSet(Arrays.asList(StringUtils.tokenizeToStringArray( + compressedMimeTypes, ",", true, true))); } /** diff --git a/spring-js/src/test/java/org/springframework/js/ajax/tiles2/AjaxTilesViewTests.java b/spring-js/src/test/java/org/springframework/js/ajax/tiles2/AjaxTilesViewTests.java index 1ab9d27c..cfdcece9 100644 --- a/spring-js/src/test/java/org/springframework/js/ajax/tiles2/AjaxTilesViewTests.java +++ b/spring-js/src/test/java/org/springframework/js/ajax/tiles2/AjaxTilesViewTests.java @@ -59,7 +59,7 @@ public class AjaxTilesViewTests extends TestCase { setupStaticWebApplicationContext(); ajaxTilesView.setUrl("search"); ajaxTilesView.afterPropertiesSet(); - ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); + ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); assertEquals("/WEB-INF/layout.jsp", response.getForwardedUrl()); } @@ -68,7 +68,7 @@ public class AjaxTilesViewTests extends TestCase { request.addHeader("Accept", SpringJavascriptAjaxHandler.AJAX_ACCEPT_CONTENT_TYPE); ajaxTilesView.setUrl("search"); ajaxTilesView.afterPropertiesSet(); - ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); + ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); assertEquals("/WEB-INF/layout.jsp", response.getForwardedUrl()); } @@ -78,7 +78,7 @@ public class AjaxTilesViewTests extends TestCase { request.addParameter("fragments", "searchResults"); ajaxTilesView.setUrl("search"); ajaxTilesView.afterPropertiesSet(); - ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); + ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); assertEquals("/WEB-INF/searchResults.jsp", response.getForwardedUrl()); } @@ -88,7 +88,7 @@ public class AjaxTilesViewTests extends TestCase { request.addParameter("fragments", "body"); ajaxTilesView.setUrl("search"); ajaxTilesView.afterPropertiesSet(); - ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); + ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); assertEquals("/WEB-INF/search.jsp", response.getForwardedUrl()); } @@ -98,16 +98,16 @@ public class AjaxTilesViewTests extends TestCase { request.addParameter("fragments", "searchNavigation"); ajaxTilesView.setUrl("search"); ajaxTilesView.afterPropertiesSet(); - ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); + ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); assertEquals("/WEB-INF/searchNavigation.jsp", response.getForwardedUrl()); } public void testRenderFragment_InheritCascadedAttribute() throws Exception { BasicTilesContainer container = (BasicTilesContainer) ServletUtil.getCurrentContainer(request, servletContext); ServletTilesRequestContextFactory tilesRequestContextFactory = new ServletTilesRequestContextFactory(); - tilesRequestContextFactory.init(new HashMap()); - TilesRequestContext tilesRequestContext = tilesRequestContextFactory.createRequestContext(container - .getApplicationContext(), new Object[] { request, response }); + tilesRequestContextFactory.init(new HashMap()); + TilesRequestContext tilesRequestContext = tilesRequestContextFactory.createRequestContext( + container.getApplicationContext(), new Object[] { request, response }); Definition definition = container.getDefinitionsFactory().getDefinition("search.body", tilesRequestContext); definition.setPreparer("org.springframework.js.ajax.tiles2.AjaxTilesViewTests$AttributeTestingPreparer"); @@ -116,7 +116,7 @@ public class AjaxTilesViewTests extends TestCase { request.addParameter("fragments", "body"); ajaxTilesView.setUrl("search"); ajaxTilesView.afterPropertiesSet(); - ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); + ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); assertTrue(AttributeTestingPreparer.invoked); } @@ -125,7 +125,7 @@ public class AjaxTilesViewTests extends TestCase { Object[] requestItems = new Object[] { request, response }; AttributeContext attributeContext = container.startContext(requestItems); attributeContext.putAttribute("body", new Attribute("/WEB-INF/dynamicTemplate.jsp")); - Map resultMap = new HashMap(); + Map resultMap = new HashMap(); ajaxTilesView.addRuntimeAttributes(container, resultMap, request, response); assertNotNull(resultMap.get("body")); assertEquals("/WEB-INF/dynamicTemplate.jsp", resultMap.get("body").toString()); @@ -138,7 +138,7 @@ public class AjaxTilesViewTests extends TestCase { request.addParameter("fragments", "body,searchNavigation"); ajaxTilesView.setUrl("search"); ajaxTilesView.afterPropertiesSet(); - ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); + ajaxTilesView.renderMergedOutputModel(new HashMap(), request, response); assertTrue("Multiple fragments should result in include, not forward", response.getIncludedUrls().size() == 2); assertEquals("/WEB-INF/search.jsp", response.getIncludedUrls().get(0)); assertEquals("/WEB-INF/searchNavigation.jsp", response.getIncludedUrls().get(1)); @@ -146,12 +146,12 @@ public class AjaxTilesViewTests extends TestCase { public void testFlattenAttributeMap() throws Exception { TilesRequestContextFactory tilesRequestContextFactory = new ServletTilesRequestContextFactory(); - tilesRequestContextFactory.init(new HashMap()); + tilesRequestContextFactory.init(new HashMap()); BasicTilesContainer container = (BasicTilesContainer) ServletUtil.getCurrentContainer(request, servletContext); - TilesRequestContext tilesRequestContext = tilesRequestContextFactory.createRequestContext(container - .getApplicationContext(), new Object[] { request, response }); + TilesRequestContext tilesRequestContext = tilesRequestContextFactory.createRequestContext( + container.getApplicationContext(), new Object[] { request, response }); Definition compositeDefinition = container.getDefinitionsFactory().getDefinition("search", tilesRequestContext); - Map resultMap = new HashMap(); + Map resultMap = new HashMap(); ajaxTilesView.flattenAttributeMap(container, tilesRequestContext, resultMap, compositeDefinition, request, response); assertNotNull(resultMap.get("body")); @@ -161,7 +161,7 @@ public class AjaxTilesViewTests extends TestCase { } public void testGetRenderFragments() throws Exception { - Map model = new HashMap(); + Map model = new HashMap(); request.setParameter("fragments", "f1,f2, f3"); String[] fragments = ajaxTilesView.getRenderFragments(model, request, response); assertEquals("f1", fragments[0]); diff --git a/spring-js/src/test/java/org/springframework/js/resource/ResourceServletTests.java b/spring-js/src/test/java/org/springframework/js/resource/ResourceServletTests.java index fce7e9a9..e170e9fa 100644 --- a/spring-js/src/test/java/org/springframework/js/resource/ResourceServletTests.java +++ b/spring-js/src/test/java/org/springframework/js/resource/ResourceServletTests.java @@ -13,6 +13,7 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockServletConfig; import org.springframework.mock.web.MockServletContext; +@SuppressWarnings("deprecation") public class ResourceServletTests extends TestCase { ServletContext servletContext = new ResourceTestMockServletContext(); @@ -43,7 +44,7 @@ public class ResourceServletTests extends TestCase { String requestPath = "/org/springframework/js/resource/TestResource1.js"; request.setPathInfo(requestPath); - Map params = new HashMap(); + Map params = new HashMap(); params.put("appended", "/org/springframework/js/resource/TestResource2.js"); request.setParameters(params); servlet.doGet(request, response); diff --git a/spring-webflow/.settings/org.eclipse.jdt.core.prefs b/spring-webflow/.settings/org.eclipse.jdt.core.prefs index f2415669..e7a67d36 100644 --- a/spring-webflow/.settings/org.eclipse.jdt.core.prefs +++ b/spring-webflow/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,4 @@ -#Wed Jun 09 09:15:34 BST 2010 +#Wed Jan 18 07:22:49 PST 2012 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -19,6 +19,8 @@ org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled @@ -26,11 +28,13 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=error org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore @@ -42,6 +46,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public @@ -49,7 +54,9 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore @@ -57,12 +64,20 @@ org.eclipse.jdt.core.compiler.problem.nullReference=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning @@ -70,14 +85,19 @@ org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/AbstractAction.java b/spring-webflow/src/main/java/org/springframework/webflow/action/AbstractAction.java index e5e9e87d..1adae255 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/AbstractAction.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/AbstractAction.java @@ -167,7 +167,7 @@ public abstract class AbstractAction implements Action, InitializingBean { * @param resultAttributes the event attributes * @return the action result event */ - protected Event result(String eventId, AttributeMap resultAttributes) { + protected Event result(String eventId, AttributeMap resultAttributes) { return getEventFactorySupport().event(this, eventId, resultAttributes); } @@ -213,9 +213,8 @@ public abstract class AbstractAction implements Action, InitializingBean { *

* This implementation just returns null. * @param context the action execution context, for accessing and setting data in "flow scope" or "request scope" - * @return the non-null action result, in which case the doExecute() will not be - * called, or null if the doExecute() method should be called to obtain the action - * result + * @return the non-null action result, in which case the doExecute() will not be called, + * or null if the doExecute() method should be called to obtain the action result * @throws Exception an unrecoverable exception occured, either checked or unchecked */ protected Event doPreExecute(RequestContext context) throws Exception { @@ -231,8 +230,8 @@ public abstract class AbstractAction implements Action, InitializingBean { protected abstract Event doExecute(RequestContext context) throws Exception; /** - * Post-action execution hook, subclasses may override. Will only be called if doExecute() was - * called, e.g. when doPreExecute() returned null. + * Post-action execution hook, subclasses may override. Will only be called if doExecute() was called, + * e.g. when doPreExecute() returned null. *

* This implementation does nothing. * @param context the action execution context, for accessing and setting data in "flow scope" or "request scope" diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/CompositeAction.java b/spring-webflow/src/main/java/org/springframework/webflow/action/CompositeAction.java index 19162b80..eb07e211 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/CompositeAction.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/CompositeAction.java @@ -93,10 +93,10 @@ public class CompositeAction extends AbstractAction { public Event doExecute(RequestContext context) throws Exception { Action[] actions = getActions(); String eventId = getEventFactorySupport().getSuccessEventId(); - MutableAttributeMap eventAttributes = new LocalAttributeMap(); - List actionResults = new ArrayList(actions.length); - for (int i = 0; i < actions.length; i++) { - Event result = actions[i].execute(context); + MutableAttributeMap eventAttributes = new LocalAttributeMap(); + List actionResults = new ArrayList(actions.length); + for (Action action : actions) { + Event result = action.execute(context); actionResults.add(result); if (result != null) { eventId = result.getId(); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/DispatchMethodInvoker.java b/spring-webflow/src/main/java/org/springframework/webflow/action/DispatchMethodInvoker.java index 9f0278fb..a590b84e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/DispatchMethodInvoker.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/DispatchMethodInvoker.java @@ -41,14 +41,14 @@ class DispatchMethodInvoker { /** * The parameter types describing the dispatch method signature. */ - private Class[] parameterTypes; + private Class[] parameterTypes; /** * The resolved method cache. */ - private Map methodCache = new CachingMapDecorator() { - public Object create(Object key) { - String methodName = (String) key; + private Map methodCache = new CachingMapDecorator() { + public Method create(String key) { + String methodName = key; try { return new MethodKey(target.getClass(), methodName, parameterTypes).getMethod(); } catch (InvalidMethodKeyException e) { @@ -64,7 +64,7 @@ class DispatchMethodInvoker { * @param target the target to dispatch to * @param parameterTypes the parameter types defining the argument signature of the dispatch methods */ - public DispatchMethodInvoker(Object target, Class[] parameterTypes) { + public DispatchMethodInvoker(Object target, Class[] parameterTypes) { Assert.notNull(target, "The target of a dispatch method invocation is required"); this.target = target; this.parameterTypes = parameterTypes; @@ -80,7 +80,7 @@ class DispatchMethodInvoker { /** * Returns the parameter types defining the argument signature of the dispatch methods. */ - public Class[] getParameterTypes() { + public Class[] getParameterTypes() { return parameterTypes; } @@ -115,7 +115,7 @@ class DispatchMethodInvoker { * @throws MethodLookupException when the method cannot be resolved */ private Method getDispatchMethod(String methodName) throws MethodLookupException { - return (Method) methodCache.get(methodName); + return methodCache.get(methodName); } /** diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/EvaluateAction.java b/spring-webflow/src/main/java/org/springframework/webflow/action/EvaluateAction.java index a16e1846..37879053 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/EvaluateAction.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/EvaluateAction.java @@ -64,7 +64,7 @@ public class EvaluateAction extends AbstractAction { /** * Create a new evaluate action. * @param expression the expression to evaluate (required) - * @param evaluationResultExposer the strategy for how the expression result will be exposed to the flow (optional) + * @param resultExpression the strategy for how the expression result will be exposed to the flow (optional) * @param resultEventFactory the factory that will map the evaluation result to a Web Flow event (optional) */ public EvaluateAction(Expression expression, Expression resultExpression, ResultEventFactory resultEventFactory) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/EventFactorySupport.java b/spring-webflow/src/main/java/org/springframework/webflow/action/EventFactorySupport.java index 6d8710cf..4838d5ee 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/EventFactorySupport.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/EventFactorySupport.java @@ -239,7 +239,7 @@ public class EventFactorySupport { * @param attributes the event payload attributes * @return the event */ - public Event event(Object source, String eventId, AttributeMap attributes) { + public Event event(Object source, String eventId, AttributeMap attributes) { return new Event(source, eventId, attributes); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/FlowDefinitionRedirectAction.java b/spring-webflow/src/main/java/org/springframework/webflow/action/FlowDefinitionRedirectAction.java index 49e853f7..1bd5db51 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/FlowDefinitionRedirectAction.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/FlowDefinitionRedirectAction.java @@ -51,13 +51,12 @@ public class FlowDefinitionRedirectAction extends AbstractAction { // now parse that and build a corresponding view selection int index = encodedRedirect.indexOf('?'); String flowDefinitionId; - LocalAttributeMap executionInput = null; + LocalAttributeMap executionInput = null; if (index != -1) { flowDefinitionId = encodedRedirect.substring(0, index); String[] parameters = StringUtils.delimitedListToStringArray(encodedRedirect.substring(index + 1), "&"); - executionInput = new LocalAttributeMap(parameters.length, 1); - for (int i = 0; i < parameters.length; i++) { - String nameAndValue = parameters[i]; + executionInput = new LocalAttributeMap(parameters.length, 1); + for (String nameAndValue : parameters) { index = nameAndValue.indexOf('='); if (index != -1) { executionInput.put(nameAndValue.substring(0, index), nameAndValue.substring(index + 1)); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/FormAction.java b/spring-webflow/src/main/java/org/springframework/webflow/action/FormAction.java index d1feff1d..8b52f3b3 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/FormAction.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/FormAction.java @@ -43,22 +43,21 @@ import org.springframework.webflow.execution.ScopeType; *
    *
  • {@link #setupForm(RequestContext)} - Prepares the form object for display on a form, * {@link #createFormObject(RequestContext) creating it} and an associated {@link Errors errors} if necessary, then - * caching them in the configured {@link #getFormObjectScope() form object scope} and - * {@link #getFormErrorsScope() form errors scope}, respectively. Also - * {@link #registerPropertyEditors(PropertyEditorRegistry) installs} any custom property editors for formatting form - * object field values. This action method will return the "success" event unless an exception is thrown.
  • + * caching them in the configured {@link #getFormObjectScope() form object scope} and {@link #getFormErrorsScope() form + * errors scope}, respectively. Also {@link #registerPropertyEditors(PropertyEditorRegistry) installs} any custom + * property editors for formatting form object field values. This action method will return the "success" event unless + * an exception is thrown. *
  • {@link #bindAndValidate(RequestContext)} - Binds all incoming request parameters to the form object and then * validates the form object using a {@link #setValidator(Validator) registered validator}. This action method will - * return the "success" event if there are no binding or validation errors, otherwise it will return the "error" event. - *
  • + * return the "success" event if there are no binding or validation errors, otherwise it will return the "error" event. *
  • {@link #bind(RequestContext)} - Binds all incoming request parameters to the form object. No additional * validation is performed. This action method will return the "success" event if there are no binding errors, otherwise - * it will return the "error" event.
  • + * it will return the "error" event. *
  • {@link #validate(RequestContext)} - Validates the form object using a registered validator. No data binding is * performed. This action method will return the "success" event if there are no validation errors, otherwise it will - * return the "error" event.
  • + * return the "error" event. *
  • {@link #resetForm(RequestContext)} - Resets the form by reloading the backing form object and reinstalling any - * custom property editors. Returns "success" on completion, an exception is thrown when a failure occurs.
  • + * custom property editors. Returns "success" on completion, an exception is thrown when a failure occurs. *
*

* Since this is a multi-action a subclass could add any number of additional action execution methods, e.g. @@ -67,17 +66,16 @@ import org.springframework.webflow.execution.ScopeType; * Using this action, it becomes very easy to implement form preparation and submission logic in your flow. One way to * do this follows: *

    - *
  1. Create a view state to display the form. In a render action of that state, invoke - * {@link #setupForm(RequestContext) setupForm} to prepare the new form for display.
  2. - *
  3. On a matching "submit" transition execute an action that invokes - * {@link #bindAndValidate(RequestContext) bindAndValidate} to bind incoming request parameters to the form object and - * validate the form object.
  4. - *
  5. If there are binding or validation errors, the transition will not be allowed and the view state will + *
  6. Create a view state to display the form. In a render action of that state, invoke + * {@link #setupForm(RequestContext) setupForm} to prepare the new form for display.
  7. + *
  8. On a matching "submit" transition execute an action that invokes {@link #bindAndValidate(RequestContext) + * bindAndValidate} to bind incoming request parameters to the form object and validate the form object.
  9. + *
  10. If there are binding or validation errors, the transition will not be allowed and the view state will * automatically be re-entered. - *
  11. If binding and validation are successful go to an action state called "processSubmit" (or any other appropriate + *
  12. If binding and validation are successful go to an action state called "processSubmit" (or any other appropriate * name). This will invoke an action method called "processSubmit" you must provide on a subclass to process form - * submission, e.g. interacting with the business logic.
  13. - *
  14. If business processing is ok, continue to a view state to display the success view.
  15. + * submission, e.g. interacting with the business logic. + *
  16. If business processing is ok, continue to a view state to display the success view.
  17. *
*

* Here is an example implementation of such a form flow: @@ -94,11 +92,11 @@ import org.springframework.webflow.execution.ScopeType; * * *

- * When you need additional flexibility consider splitting the view state above acting as a single logical form state - * into multiple states. For example, you could have one action state handle form setup, a view state trigger form - * display, another action state handle data binding and validation, and another process form submission. This would be - * a bit more verbose but would also give you more control over how you respond to specific results of fine-grained - * actions that occur within the flow. + * When you need additional flexibility consider splitting the view state above acting as a single logical form + * state into multiple states. For example, you could have one action state handle form setup, a view state trigger + * form display, another action state handle data binding and validation, and another process form submission. This + * would be a bit more verbose but would also give you more control over how you respond to specific results of + * fine-grained actions that occur within the flow. *

* Subclassing hooks: *

    @@ -116,9 +114,9 @@ import org.springframework.webflow.execution.ScopeType; *
*

* Note that this action does not provide a referenceData() hook method similar to that of Spring MVC's - * SimpleFormController. If you wish to expose reference data to populate form drop downs you can define - * a custom action method in your FormAction subclass that does just that. Simply invoke it as either a chained action - * as part of the setupForm state, or as a fine grained state definition itself. + * SimpleFormController. If you wish to expose reference data to populate form drop downs you can define a + * custom action method in your FormAction subclass that does just that. Simply invoke it as either a chained action as + * part of the setupForm state, or as a fine grained state definition itself. *

* For example, you might create this method in your subclass: * @@ -170,8 +168,8 @@ import org.springframework.webflow.execution.ScopeType; * Would result in the public void validateSearchCriteria(SearchCriteria, Errors) method of the registered * validator being called if the form object class would be SearchCriteria. *

  • If you want to do full validation using the - * {@link org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors) validate} - * method of the registered validator, call {@link #bindAndValidate(RequestContext)} or + * {@link org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors) + * validate} method of the registered validator, call {@link #bindAndValidate(RequestContext)} or * {@link #validate(RequestContext)} without specifying a "validatorMethod" action execution attribute.
  • * * @@ -205,23 +203,23 @@ import org.springframework.webflow.execution.ScopeType; * formErrorsScope * {@link org.springframework.webflow.execution.ScopeType#FLASH flash} * The scope in which the form object errors instance will be put. If put in flash scope form errors will be cached - * until the next user event is signaled. + * until the next user event is signaled. * * * propertyEditorRegistrar * null * The strategy used to register custom property editors with the data binder. This is an alternative to overriding - * the {@link #registerPropertyEditors(PropertyEditorRegistry)} hook method. + * the {@link #registerPropertyEditors(PropertyEditorRegistry)} hook method. * * * validator * null - * The validator for this action. The validator must support the specified form object class. + * The validator for this action. The validator must support the specified form object class. * * * messageCodesResolver * null - * Set the strategy to use for resolving errors into message codes. + * Set the strategy to use for resolving errors into message codes. * * * @@ -254,7 +252,7 @@ public class FormAction extends MultiAction implements InitializingBean { * The type of form object, typically an instantiable class. Required if {@link #createFormObject(RequestContext)} * is not overridden or when a validator is used. */ - private Class formObjectClass; + private Class formObjectClass; /** * The scope in which the form object should be exposed. Default is {@link ScopeType#FLOW}. @@ -300,7 +298,7 @@ public class FormAction extends MultiAction implements InitializingBean { * Creates a new form action that manages instance(s) of the specified form object class. * @param formObjectClass the class of the form object (must be instantiable) */ - public FormAction(Class formObjectClass) { + public FormAction(Class formObjectClass) { setFormObjectClass(formObjectClass); } @@ -322,7 +320,7 @@ public class FormAction extends MultiAction implements InitializingBean { /** * Return the form object class for this action. */ - public Class getFormObjectClass() { + public Class getFormObjectClass() { return formObjectClass; } @@ -334,7 +332,7 @@ public class FormAction extends MultiAction implements InitializingBean { * generated based on the provided form object class using * {@link ClassUtils#getShortNameAsProperty(java.lang.Class)}. */ - public void setFormObjectClass(Class formObjectClass) { + public void setFormObjectClass(Class formObjectClass) { this.formObjectClass = formObjectClass; // generate a default form object name if ((getFormObjectName() == null || getFormObjectName() == DEFAULT_FORM_OBJECT_NAME) && formObjectClass != null) { @@ -350,8 +348,8 @@ public class FormAction extends MultiAction implements InitializingBean { } /** - * Set the scope in which the form object will be placed. The default if not set is - * {@link ScopeType#FLOW flow scope}. + * Set the scope in which the form object will be placed. The default if not set is {@link ScopeType#FLOW flow + * scope}. */ public void setFormObjectScope(ScopeType scopeType) { this.formObjectScope = scopeType; @@ -365,8 +363,8 @@ public class FormAction extends MultiAction implements InitializingBean { } /** - * Set the scope in which the Errors object will be placed. The default if not set is - * {@link ScopeType#FLASH flash scope}. + * Set the scope in which the Errors object will be placed. The default if not set is {@link ScopeType#FLASH flash + * scope}. */ public void setFormErrorsScope(ScopeType errorsScope) { this.formErrorsScope = errorsScope; @@ -396,8 +394,7 @@ public class FormAction extends MultiAction implements InitializingBean { /** * Set the validator for this action. When setting a validator, you must also set the - * {@link #setFormObjectClass(Class) form object class}. The validator must support the specified form object - * class. + * {@link #setFormObjectClass(Class) form object class}. The validator must support the specified form object class. */ public void setValidator(Validator validator) { this.validator = validator; @@ -446,9 +443,9 @@ public class FormAction extends MultiAction implements InitializingBean { * {@link #getFormObjectScope() scope}. If you want to reset the form handling machinery, including creation or * loading of a fresh form object instance, call {@link #resetForm(RequestContext)} instead. *

    - * NOTE: This action method is not designed to be overridden and might become final in a future - * version of Spring Web Flow. If you need to execute custom form setup logic have your flow call this method along - * with your own custom methods as part of a single action chain. + * NOTE: This action method is not designed to be overridden and might become final in a future version + * of Spring Web Flow. If you need to execute custom form setup logic have your flow call this method along with + * your own custom methods as part of a single action chain. * @param context the action execution context, for accessing and setting data in "flow scope" or "request scope" * @return "success" when binding and validation is successful * @throws Exception an unrecoverable exception occurs, either checked or unchecked @@ -468,9 +465,9 @@ public class FormAction extends MultiAction implements InitializingBean { * Bind incoming request parameters to allowed fields of the form object and then validate the bound form object if * a validator is configured. *

    - * NOTE: This action method is not designed to be overridden and might become final in a future - * version of Spring Web Flow. If you need to execute custom bind and validate logic have your flow call this method - * along with your own custom methods as part of a single action chain. Alternatively, override the + * NOTE: This action method is not designed to be overridden and might become final in a future version + * of Spring Web Flow. If you need to execute custom bind and validate logic have your flow call this method along + * with your own custom methods as part of a single action chain. Alternatively, override the * {@link #doBind(RequestContext, DataBinder)} or {@link #doValidate(RequestContext, Object, Errors)} hooks. * @param context the action execution context, for accessing and setting data in "flow scope" or "request scope" * @return "success" when binding and validation is successful, "error" if there were binding and/or validation @@ -505,9 +502,9 @@ public class FormAction extends MultiAction implements InitializingBean { /** * Bind incoming request parameters to allowed fields of the form object. *

    - * NOTE: This action method is not designed to be overridden and might become final in a future - * version of Spring Web Flow. If you need to execute custom data binding logic have your flow call this method - * along with your own custom methods as part of a single action chain. Alternatively, override the + * NOTE: This action method is not designed to be overridden and might become final in a future version + * of Spring Web Flow. If you need to execute custom data binding logic have your flow call this method along with + * your own custom methods as part of a single action chain. Alternatively, override the * {@link #doBind(RequestContext, DataBinder)} hook. * @param context the action execution context, for accessing and setting data in "flow scope" or "request scope" * @return "success" if there are no binding errors, "error" otherwise @@ -527,9 +524,9 @@ public class FormAction extends MultiAction implements InitializingBean { /** * Validate the form object by invoking the validator if configured. *

    - * NOTE: This action method is not designed to be overridden and might become final in a future - * version of Spring Web Flow. If you need to execute custom validation logic have your flow call this method along - * with your own custom methods as part of a single action chain. Alternatively, override the + * NOTE: This action method is not designed to be overridden and might become final in a future version + * of Spring Web Flow. If you need to execute custom validation logic have your flow call this method along with + * your own custom methods as part of a single action chain. Alternatively, override the * {@link #doValidate(RequestContext, Object, Errors)} hook. * @param context the action execution context, for accessing and setting data in "flow scope" or "request scope" * @return "success" if there are no validation errors, "error" otherwise @@ -560,9 +557,9 @@ public class FormAction extends MultiAction implements InitializingBean { /** * Resets the form by clearing out the form object in the specified scope and recreating it. *

    - * NOTE: This action method is not designed to be overridden and might become final in a future - * version of Spring Web Flow. If you need to execute custom reset logic have your flow call this method along with - * your own custom methods as part of a single action chain. + * NOTE: This action method is not designed to be overridden and might become final in a future version + * of Spring Web Flow. If you need to execute custom reset logic have your flow call this method along with your own + * custom methods as part of a single action chain. * @param context the request context * @return "success" if the reset action completed successfully * @throws Exception if an exception occured @@ -603,8 +600,8 @@ public class FormAction extends MultiAction implements InitializingBean { } /** - * Initialize a new form object {@link Errors errors} instance in the configured {@link #getFormErrorsScope() scope}. - * This method also registers any {@link PropertiesEditor property editors} used to format form object property + * Initialize a new form object {@link Errors errors} instance in the configured {@link #getFormErrorsScope() scope} + * . This method also registers any {@link PropertiesEditor property editors} used to format form object property * values. * @param context the current flow execution request context * @param formObject the form object for which errors will be tracked @@ -726,8 +723,8 @@ public class FormAction extends MultiAction implements InitializingBean { * form object will be created by a call to {@link #createFormObject(RequestContext)} and exposed in the configured * {@link #getFormObjectScope() scope}. *

    - * The returned form object will become the - * {@link FormObjectAccessor#setCurrentFormObject(Object, ScopeType) current} form object. + * The returned form object will become the {@link FormObjectAccessor#setCurrentFormObject(Object, ScopeType) + * current} form object. * @param context the flow execution request context * @return the form object * @throws Exception when an unrecoverable exception occurs @@ -907,8 +904,8 @@ public class FormAction extends MultiAction implements InitializingBean { /** * Register custom editors to perform type conversion on fields of your form object during data binding and form - * display. This method is called on form errors initialization and - * {@link #initBinder(RequestContext, DataBinder) data binder} initialization. + * display. This method is called on form errors initialization and {@link #initBinder(RequestContext, DataBinder) + * data binder} initialization. *

    * Property editors give you full control over how objects are transformed to and from a formatted String form for * display on a user interface such as a HTML page. @@ -925,8 +922,8 @@ public class FormAction extends MultiAction implements InitializingBean { /** * Register custom editors to perform type conversion on fields of your form object during data binding and form - * display. This method is called on form errors initialization and - * {@link #initBinder(RequestContext, DataBinder) data binder} initialization. + * display. This method is called on form errors initialization and {@link #initBinder(RequestContext, DataBinder) + * data binder} initialization. *

    * Property editors give you full control over how objects are transformed to and from a formatted String form for * display on a user interface such as a HTML page. @@ -959,7 +956,7 @@ public class FormAction extends MultiAction implements InitializingBean { } public String toString() { - return new ToStringCreator(this).append("formObjectName", formObjectName).append("formObjectClass", - formObjectClass).append("formObjectScope", formObjectScope).toString(); + return new ToStringCreator(this).append("formObjectName", formObjectName) + .append("formObjectClass", formObjectClass).append("formObjectScope", formObjectScope).toString(); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/FormObjectAccessor.java b/spring-webflow/src/main/java/org/springframework/webflow/action/FormObjectAccessor.java index 804009ac..b518a575 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/FormObjectAccessor.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/FormObjectAccessor.java @@ -140,7 +140,7 @@ public class FormObjectAccessor { * @param scopeType the scope to obtain the form object from * @return the form object, or null if not found */ - public Object getFormObject(String formObjectName, Class formObjectClass, ScopeType scopeType) { + public Object getFormObject(String formObjectName, Class formObjectClass, ScopeType scopeType) { return scopeType.getScope(context).get(formObjectName, formObjectClass); } @@ -203,7 +203,7 @@ public class FormObjectAccessor { * @return the form object errors instance, or null if not found */ public Errors getFormErrors(String formObjectName, ScopeType scopeType) { - return (Errors) scopeType.getScope(context).get(ERRORS_PREFIX + formObjectName, Errors.class); + return scopeType.getScope(context).get(ERRORS_PREFIX + formObjectName, Errors.class); } /** diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/ResultEventFactorySelector.java b/spring-webflow/src/main/java/org/springframework/webflow/action/ResultEventFactorySelector.java index f4ebc569..20f9b2ea 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/ResultEventFactorySelector.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/ResultEventFactorySelector.java @@ -67,7 +67,7 @@ public class ResultEventFactorySelector { * @param resultType the result type * @return the result event factory */ - protected ResultEventFactory forType(Class resultType) { + protected ResultEventFactory forType(Class resultType) { if (resultObjectBasedEventFactory.isMappedValueType(resultType)) { return resultObjectBasedEventFactory; } else { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/action/ResultObjectBasedEventFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/action/ResultObjectBasedEventFactory.java index a4df2342..9257d4d9 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/action/ResultObjectBasedEventFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/action/ResultObjectBasedEventFactory.java @@ -100,21 +100,21 @@ public class ResultObjectBasedEventFactory extends EventFactorySupport implement /** * Check whether or not given type is mapped to a corresponding event using special mapping rules. */ - public boolean isMappedValueType(Class type) { + public boolean isMappedValueType(Class type) { return isBoolean(type) || isLabeledEnum(type) || isJdk5Enum(type) || isString(type) || isEvent(type); } // internal helpers to determine the 'type' of a class - private boolean isBoolean(Class type) { + private boolean isBoolean(Class type) { return Boolean.class.equals(type) || boolean.class.equals(type); } - private boolean isLabeledEnum(Class type) { + private boolean isLabeledEnum(Class type) { return LabeledEnum.class.isAssignableFrom(type); } - private boolean isJdk5Enum(Class type) { + private boolean isJdk5Enum(Class type) { if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_15) { return EnumUtils.isEnum(type); } else { @@ -122,11 +122,11 @@ public class ResultObjectBasedEventFactory extends EventFactorySupport implement } } - private boolean isString(Class type) { + private boolean isString(Class type) { return String.class.equals(type); } - private boolean isEvent(Class type) { + private boolean isEvent(Class type) { return Event.class.isAssignableFrom(type); } @@ -135,10 +135,10 @@ public class ResultObjectBasedEventFactory extends EventFactorySupport implement */ private static class EnumUtils { public static String getEnumName(Object enumValue) { - return ((java.lang.Enum) enumValue).name(); + return ((java.lang.Enum) enumValue).name(); } - public static boolean isEnum(Class type) { + public static boolean isEnum(Class type) { return java.lang.Enum.class.isAssignableFrom(type); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowBuilderInfo.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowBuilderInfo.java index c073b509..56c56897 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowBuilderInfo.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowBuilderInfo.java @@ -43,13 +43,13 @@ class FlowBuilderInfo { /** * Attributes to assign to the flow definition. */ - private Set attributes; + private Set attributes; - public FlowBuilderInfo(String id, String className, Set attributes) { + public FlowBuilderInfo(String id, String className, Set attributes) { Assert.hasText(className, "The fully-qualified FlowBuilder class name is required"); this.className = className; setId(id); - this.attributes = (attributes != null ? attributes : Collections.EMPTY_SET); + this.attributes = (attributes != null ? attributes : Collections. emptySet()); } private void setId(String id) { @@ -68,7 +68,7 @@ class FlowBuilderInfo { return className; } - public Set getAttributes() { + public Set getAttributes() { return attributes; } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowDefinitionResource.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowDefinitionResource.java index 077d4547..ba7328aa 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowDefinitionResource.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowDefinitionResource.java @@ -33,7 +33,7 @@ public class FlowDefinitionResource { private Resource path; - private AttributeMap attributes; + private AttributeMap attributes; /** * Creates a new flow definition resource @@ -41,7 +41,7 @@ public class FlowDefinitionResource { * @param path the location of the resource * @param attributes meta-attributes describing the flow resource */ - public FlowDefinitionResource(String flowId, Resource path, AttributeMap attributes) { + public FlowDefinitionResource(String flowId, Resource path, AttributeMap attributes) { this.id = flowId; this.path = path; this.attributes = attributes; @@ -67,7 +67,7 @@ public class FlowDefinitionResource { * Returns attributes to assign the flow definition. * @return flow definition attributes */ - public AttributeMap getAttributes() { + public AttributeMap getAttributes() { return attributes; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowDefinitionResourceFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowDefinitionResourceFactory.java index 69bac45a..d2dfcf0d 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowDefinitionResourceFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowDefinitionResourceFactory.java @@ -90,7 +90,7 @@ public class FlowDefinitionResourceFactory { * @param attributes the flow definition meta attributes to configure * @return the flow definition resource */ - public FlowDefinitionResource createResource(String path, AttributeMap attributes) { + public FlowDefinitionResource createResource(String path, AttributeMap attributes) { return createResource(path, attributes, null); } @@ -102,7 +102,7 @@ public class FlowDefinitionResourceFactory { * @param flowId the flow definition id to configure * @return the flow definition resource */ - public FlowDefinitionResource createResource(String path, AttributeMap attributes, String flowId) { + public FlowDefinitionResource createResource(String path, AttributeMap attributes, String flowId) { Resource resource; if (basePath == null) { resource = resourceLoader.getResource(path); @@ -131,7 +131,7 @@ public class FlowDefinitionResourceFactory { * @param attributes meta attributes to apply to each flow definition resource * @return the flow definition resources */ - public FlowDefinitionResource[] createResources(String pattern, AttributeMap attributes) throws IOException { + public FlowDefinitionResource[] createResources(String pattern, AttributeMap attributes) throws IOException { if (resourceLoader instanceof ResourcePatternResolver) { ResourcePatternResolver resolver = (ResourcePatternResolver) resourceLoader; Resource[] resources; @@ -172,7 +172,7 @@ public class FlowDefinitionResourceFactory { * @param clazz to specify if the path should be relative to another class * @return the classpath-based flow definition resource */ - public FlowDefinitionResource createClassPathResource(String path, Class clazz) { + public FlowDefinitionResource createClassPathResource(String path, Class clazz) { Resource resource = new ClassPathResource(path, clazz); return new FlowDefinitionResource(getFlowId(resource), resource, null); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderBeanDefinitionParser.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderBeanDefinitionParser.java index 95967bc6..bc7d2004 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderBeanDefinitionParser.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderBeanDefinitionParser.java @@ -15,7 +15,6 @@ */ package org.springframework.webflow.config; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -41,7 +40,7 @@ class FlowExecutionListenerLoaderBeanDefinitionParser extends AbstractSingleBean } protected void doParse(Element element, BeanDefinitionBuilder definitionBuilder) { - List listenerElements = DomUtils.getChildElementsByTagName(element, "listener"); + List listenerElements = DomUtils.getChildElementsByTagName(element, "listener"); definitionBuilder.addPropertyValue("listeners", parseListenersWithCriteria(listenerElements)); } @@ -51,10 +50,10 @@ class FlowExecutionListenerLoaderBeanDefinitionParser extends AbstractSingleBean * @return a map containing keys that are references to given listeners and values of string that represent the * criteria */ - private Map parseListenersWithCriteria(List listeners) { - Map listenersWithCriteria = new ManagedMap(listeners.size()); - for (Iterator i = listeners.iterator(); i.hasNext();) { - Element listenerElement = (Element) i.next(); + private Map parseListenersWithCriteria(List listeners) { + Map listenersWithCriteria = new ManagedMap( + listeners.size()); + for (Element listenerElement : listeners) { RuntimeBeanReference ref = new RuntimeBeanReference(listenerElement.getAttribute("ref")); String criteria = listenerElement.getAttribute("criteria"); listenersWithCriteria.put(ref, criteria); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderFactoryBean.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderFactoryBean.java index 566a904f..f7b40409 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderFactoryBean.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutionListenerLoaderFactoryBean.java @@ -32,12 +32,12 @@ import org.springframework.webflow.execution.factory.FlowExecutionListenerLoader * * @author Keith Donald */ -class FlowExecutionListenerLoaderFactoryBean implements FactoryBean, InitializingBean { +class FlowExecutionListenerLoaderFactoryBean implements FactoryBean, InitializingBean { /** * The configured execution listeners and the criteria determining when they apply. */ - private Map listenersWithCriteria; + private Map listenersWithCriteria; /** * The listener loader created by this factory. Is conditional, allowing listeners to apply to flow executions @@ -54,26 +54,26 @@ class FlowExecutionListenerLoaderFactoryBean implements FactoryBean, Initializin * Sets the listeners eligible for loading, and the criteria for when they should be loaded. * @param listenersWithCriteria the listener-to-criteria map */ - public void setListeners(Map listenersWithCriteria) { + public void setListeners(Map listenersWithCriteria) { this.listenersWithCriteria = listenersWithCriteria; } public void afterPropertiesSet() { listenerLoader = new ConditionalFlowExecutionListenerLoader(); - Iterator it = listenersWithCriteria.entrySet().iterator(); + Iterator> it = listenersWithCriteria.entrySet().iterator(); while (it.hasNext()) { - Map.Entry entry = (Map.Entry) it.next(); - FlowExecutionListener listener = (FlowExecutionListener) entry.getKey(); - String criteria = (String) entry.getValue(); + Map.Entry entry = it.next(); + FlowExecutionListener listener = entry.getKey(); + String criteria = entry.getValue(); listenerLoader.addListener(listener, listenerCriteriaFactory.getListenerCriteria(criteria)); } } - public Object getObject() throws Exception { + public FlowExecutionListenerLoader getObject() throws Exception { return listenerLoader; } - public Class getObjectType() { + public Class getObjectType() { return FlowExecutionListenerLoader.class; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorBeanDefinitionParser.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorBeanDefinitionParser.java index bd108a86..7d65359c 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorBeanDefinitionParser.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorBeanDefinitionParser.java @@ -16,7 +16,6 @@ package org.springframework.webflow.config; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -105,9 +104,9 @@ class FlowExecutorBeanDefinitionParser extends AbstractSingleBeanDefinitionParse String value = redirectInSameStateElement.getAttribute("value"); attributes.add(new FlowElementAttribute("redirectInSameState", value, "boolean")); } - List attributeElements = DomUtils.getChildElementsByTagName(executionAttributesElement, "attribute"); - for (Iterator it = attributeElements.iterator(); it.hasNext();) { - Element attributeElement = (Element) it.next(); + List attributeElements = DomUtils.getChildElementsByTagName(executionAttributesElement, + "attribute"); + for (Element attributeElement : attributeElements) { String name = attributeElement.getAttribute("name"); String value = attributeElement.getAttribute("value"); String type = attributeElement.getAttribute("type"); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorFactoryBean.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorFactoryBean.java index 43aee271..249f197b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorFactoryBean.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorFactoryBean.java @@ -15,7 +15,6 @@ */ package org.springframework.webflow.config; -import java.util.Iterator; import java.util.Set; import org.springframework.beans.BeansException; @@ -58,7 +57,8 @@ import org.springframework.webflow.mvc.builder.MvcEnvironment; * @author Keith Donald * @author Erwin Vervaet */ -class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, BeanClassLoaderAware, InitializingBean { +class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, BeanClassLoaderAware, + InitializingBean { private static final String ALWAYS_REDIRECT_ON_PAUSE = "alwaysRedirectOnPause"; @@ -70,7 +70,7 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, B private Integer maxFlowExecutionSnapshots; - private Set flowExecutionAttributes; + private Set flowExecutionAttributes; private FlowExecutionListenerLoader flowExecutionListenerLoader; @@ -112,7 +112,7 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, B * Execution attributes may affect flow execution behavior. * @param flowExecutionAttributes the flow execution system attributes */ - public void setFlowExecutionAttributes(Set flowExecutionAttributes) { + public void setFlowExecutionAttributes(Set flowExecutionAttributes) { this.flowExecutionAttributes = flowExecutionAttributes; } @@ -152,7 +152,7 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, B if (conversionService == null) { conversionService = new DefaultConversionService(); } - MutableAttributeMap executionAttributes = createFlowExecutionAttributes(); + MutableAttributeMap executionAttributes = createFlowExecutionAttributes(); FlowExecutionImplFactory executionFactory = createFlowExecutionFactory(executionAttributes); DefaultFlowExecutionRepository executionRepository = createFlowExecutionRepository(executionFactory); executionFactory.setExecutionKeyFactory(executionRepository); @@ -161,7 +161,7 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, B // implementing FactoryBean - public Class getObjectType() { + public Class getObjectType() { return FlowExecutor.class; } @@ -169,15 +169,14 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, B return true; } - public Object getObject() throws Exception { + public FlowExecutor getObject() throws Exception { return flowExecutor; } - private MutableAttributeMap createFlowExecutionAttributes() { - LocalAttributeMap executionAttributes = new LocalAttributeMap(); + private MutableAttributeMap createFlowExecutionAttributes() { + LocalAttributeMap executionAttributes = new LocalAttributeMap(); if (flowExecutionAttributes != null) { - for (Iterator it = flowExecutionAttributes.iterator(); it.hasNext();) { - FlowElementAttribute attribute = (FlowElementAttribute) it.next(); + for (FlowElementAttribute attribute : flowExecutionAttributes) { executionAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } @@ -185,13 +184,13 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, B return executionAttributes; } - private void putDefaultFlowExecutionAttributes(LocalAttributeMap executionAttributes) { + private void putDefaultFlowExecutionAttributes(LocalAttributeMap executionAttributes) { if (!executionAttributes.contains(ALWAYS_REDIRECT_ON_PAUSE)) { - boolean redirect = (environment == MvcEnvironment.PORTLET) ? Boolean.FALSE : Boolean.TRUE; + Boolean redirect = (environment == MvcEnvironment.PORTLET) ? Boolean.FALSE : Boolean.TRUE; executionAttributes.put(ALWAYS_REDIRECT_ON_PAUSE, redirect); } if (!executionAttributes.contains(REDIRECT_IN_SAME_STATE)) { - boolean redirect = (environment == MvcEnvironment.PORTLET) ? Boolean.FALSE : Boolean.TRUE; + Boolean redirect = (environment == MvcEnvironment.PORTLET) ? Boolean.FALSE : Boolean.TRUE; executionAttributes.put(REDIRECT_IN_SAME_STATE, redirect); } } @@ -226,7 +225,7 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, B } } - private FlowExecutionImplFactory createFlowExecutionFactory(AttributeMap executionAttributes) { + private FlowExecutionImplFactory createFlowExecutionFactory(AttributeMap executionAttributes) { FlowExecutionImplFactory executionFactory = new FlowExecutionImplFactory(); executionFactory.setExecutionAttributes(executionAttributes); if (flowExecutionListenerLoader != null) { @@ -239,7 +238,7 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, B private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { - Class targetType = fromStringToClass(attribute.getType()); + Class targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = conversionService.getConversionExecutor(String.class, targetType); return converter.execute(attribute.getValue()); } else { @@ -247,8 +246,8 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, B } } - private Class fromStringToClass(String name) { - Class clazz = conversionService.getClassForAlias(name); + private Class fromStringToClass(String name) { + Class clazz = conversionService.getClassForAlias(name); if (clazz != null) { return clazz; } else { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowLocation.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowLocation.java index d38556db..3f84d362 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowLocation.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowLocation.java @@ -41,13 +41,13 @@ class FlowLocation { /** * Attributes to assign to the flow definition. */ - private Set attributes; + private Set attributes; - public FlowLocation(String id, String path, Set attributes) { + public FlowLocation(String id, String path, Set attributes) { Assert.hasText(path, "The path is required"); this.id = id; this.path = path; - this.attributes = (attributes != null ? attributes : Collections.EMPTY_SET); + this.attributes = (attributes != null ? attributes : Collections. emptySet()); } public String getId() { @@ -58,7 +58,7 @@ class FlowLocation { return path; } - public Set getAttributes() { + public Set getAttributes() { return attributes; } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParser.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParser.java index 08936215..41f745a0 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParser.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParser.java @@ -18,7 +18,6 @@ package org.springframework.webflow.config; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -77,14 +76,13 @@ class FlowRegistryBeanDefinitionParser extends AbstractSingleBeanDefinitionParse parserContext.popAndRegisterContainingComponent(); } - private List parseLocations(Element element) { - List locationElements = DomUtils.getChildElementsByTagName(element, "flow-location"); + private List parseLocations(Element element) { + List locationElements = DomUtils.getChildElementsByTagName(element, "flow-location"); if (locationElements.isEmpty()) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } - List locations = new ArrayList(locationElements.size()); - for (Iterator it = locationElements.iterator(); it.hasNext();) { - Element locationElement = (Element) it.next(); + List locations = new ArrayList(locationElements.size()); + for (Element locationElement : locationElements) { String id = locationElement.getAttribute("id"); String path = locationElement.getAttribute("path"); locations.add(new FlowLocation(id, path, parseAttributes(locationElement))); @@ -92,27 +90,26 @@ class FlowRegistryBeanDefinitionParser extends AbstractSingleBeanDefinitionParse return locations; } - private List parseLocationPatterns(Element element) { - List locationPatternElements = DomUtils.getChildElementsByTagName(element, "flow-location-pattern"); + private List parseLocationPatterns(Element element) { + List locationPatternElements = DomUtils.getChildElementsByTagName(element, "flow-location-pattern"); if (locationPatternElements.isEmpty()) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } - List locationPatterns = new ArrayList(locationPatternElements.size()); - for (Iterator it = locationPatternElements.iterator(); it.hasNext();) { - Element locationPatternElement = (Element) it.next(); + List locationPatterns = new ArrayList(locationPatternElements.size()); + for (Element locationPatternElement : locationPatternElements) { String value = locationPatternElement.getAttribute("value"); locationPatterns.add(value); } return locationPatterns; } - private Set parseAttributes(Element element) { + private Set parseAttributes(Element element) { Element definitionAttributesElement = DomUtils.getChildElementByTagName(element, "flow-definition-attributes"); if (definitionAttributesElement != null) { - List attributeElements = DomUtils.getChildElementsByTagName(definitionAttributesElement, "attribute"); - HashSet attributes = new HashSet(attributeElements.size()); - for (Iterator it = attributeElements.iterator(); it.hasNext();) { - Element attributeElement = (Element) it.next(); + List attributeElements = DomUtils.getChildElementsByTagName(definitionAttributesElement, + "attribute"); + Set attributes = new HashSet(attributeElements.size()); + for (Element attributeElement : attributeElements) { String name = attributeElement.getAttribute("name"); String value = attributeElement.getAttribute("value"); String type = attributeElement.getAttribute("type"); @@ -124,14 +121,13 @@ class FlowRegistryBeanDefinitionParser extends AbstractSingleBeanDefinitionParse } } - private List parseFlowBuilders(Element element) { - List builderElements = DomUtils.getChildElementsByTagName(element, "flow-builder"); + private List parseFlowBuilders(Element element) { + List builderElements = DomUtils.getChildElementsByTagName(element, "flow-builder"); if (builderElements.isEmpty()) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } - List builders = new ArrayList(builderElements.size()); - for (Iterator it = builderElements.iterator(); it.hasNext();) { - Element builderElement = (Element) it.next(); + List builders = new ArrayList(builderElements.size()); + for (Element builderElement : builderElements) { String id = builderElement.getAttribute("id"); String className = builderElement.getAttribute("class"); builders.add(new FlowBuilderInfo(id, className, parseAttributes(builderElement))); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowRegistryFactoryBean.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowRegistryFactoryBean.java index 48d536d0..cb1e4a47 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowRegistryFactoryBean.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowRegistryFactoryBean.java @@ -17,7 +17,6 @@ package org.springframework.webflow.config; import java.io.IOException; import java.util.Collections; -import java.util.Iterator; import java.util.Set; import org.springframework.beans.factory.BeanClassLoaderAware; @@ -55,7 +54,8 @@ import org.springframework.webflow.engine.model.registry.FlowModelHolder; * @author Jeremy Grelle * @author Scott Andrews */ -class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, InitializingBean, DisposableBean { +class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, InitializingBean, + DisposableBean { private FlowLocation[] flowLocations; @@ -143,11 +143,11 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init registerFlowBuilders(); } - public Object getObject() throws Exception { + public FlowDefinitionRegistry getObject() throws Exception { return flowRegistry; } - public Class getObjectType() { + public Class getObjectType() { return FlowDefinitionRegistry.class; } @@ -163,8 +163,7 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init private void registerFlowLocations() { if (flowLocations != null) { - for (int i = 0; i < flowLocations.length; i++) { - FlowLocation location = flowLocations[i]; + for (FlowLocation location : flowLocations) { flowRegistry.registerFlowDefinition(createFlowDefinitionHolder(createResource(location))); } } @@ -172,10 +171,9 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init private void registerFlowLocationPatterns() { if (flowLocationPatterns != null) { - for (int i = 0; i < flowLocationPatterns.length; i++) { - String pattern = flowLocationPatterns[i]; + for (String pattern : flowLocationPatterns) { FlowDefinitionResource[] resources; - AttributeMap attributes = getFlowAttributes(Collections.EMPTY_SET); + AttributeMap attributes = getFlowAttributes(Collections. emptySet()); try { resources = flowResourceFactory.createResources(pattern, attributes); } catch (IOException e) { @@ -184,8 +182,8 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init ise.initCause(e); throw ise; } - for (int j = 0; j < resources.length; j++) { - flowRegistry.registerFlowDefinition(createFlowDefinitionHolder(resources[j])); + for (FlowDefinitionResource resource : resources) { + flowRegistry.registerFlowDefinition(createFlowDefinitionHolder(resource)); } } } @@ -193,8 +191,7 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init private void registerFlowBuilders() { if (flowBuilders != null) { - for (int i = 0; i < flowBuilders.length; i++) { - FlowBuilderInfo builderInfo = flowBuilders[i]; + for (FlowBuilderInfo builderInfo : flowBuilders) { flowRegistry.registerFlowDefinition(buildFlowDefinition(builderInfo)); } } @@ -202,29 +199,28 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init private FlowDefinitionHolder createFlowDefinitionHolder(FlowDefinitionResource flowResource) { FlowBuilder builder = createFlowBuilder(flowResource); - FlowBuilderContext builderContext = new FlowBuilderContextImpl(flowResource.getId(), flowResource - .getAttributes(), flowRegistry, flowBuilderServices); + FlowBuilderContext builderContext = new FlowBuilderContextImpl(flowResource.getId(), + flowResource.getAttributes(), flowRegistry, flowBuilderServices); FlowAssembler assembler = new FlowAssembler(builder, builderContext); return new DefaultFlowHolder(assembler); } private FlowDefinitionResource createResource(FlowLocation location) { - AttributeMap flowAttributes = getFlowAttributes(location.getAttributes()); + AttributeMap flowAttributes = getFlowAttributes(location.getAttributes()); return flowResourceFactory.createResource(location.getPath(), flowAttributes, location.getId()); } - private AttributeMap getFlowAttributes(Set attributes) { - MutableAttributeMap flowAttributes = null; + private AttributeMap getFlowAttributes(Set attributes) { + MutableAttributeMap flowAttributes = null; if (flowBuilderServices.getDevelopment()) { - flowAttributes = new LocalAttributeMap(1 + attributes.size(), 1); + flowAttributes = new LocalAttributeMap(1 + attributes.size(), 1); flowAttributes.put("development", Boolean.TRUE); } if (!attributes.isEmpty()) { if (flowAttributes == null) { - flowAttributes = new LocalAttributeMap(attributes.size(), 1); + flowAttributes = new LocalAttributeMap(attributes.size(), 1); } - for (Iterator it = attributes.iterator(); it.hasNext();) { - FlowElementAttribute attribute = (FlowElementAttribute) it.next(); + for (FlowElementAttribute attribute : attributes) { flowAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } @@ -258,7 +254,7 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { - Class targetType = fromStringToClass(attribute.getType()); + Class targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = flowBuilderServices.getConversionService().getConversionExecutor( String.class, targetType); return converter.execute(attribute.getValue()); @@ -267,8 +263,8 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init } } - private Class fromStringToClass(String name) { - Class clazz = flowBuilderServices.getConversionService().getClassForAlias(name); + private Class fromStringToClass(String name) { + Class clazz = flowBuilderServices.getConversionService().getClassForAlias(name); if (clazz != null) { return clazz; } else { @@ -276,7 +272,7 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init } } - private Class loadClass(String name) { + private Class loadClass(String name) { try { return ClassUtils.forName(name, classLoader); } catch (ClassNotFoundException e) { @@ -286,9 +282,9 @@ class FlowRegistryFactoryBean implements FactoryBean, BeanClassLoaderAware, Init private FlowDefinition buildFlowDefinition(FlowBuilderInfo builderInfo) { try { - Class flowBuilderClass = loadClass(builderInfo.getClassName()); + Class flowBuilderClass = loadClass(builderInfo.getClassName()); FlowBuilder builder = (FlowBuilder) flowBuilderClass.newInstance(); - AttributeMap flowAttributes = getFlowAttributes(builderInfo.getAttributes()); + AttributeMap flowAttributes = getFlowAttributes(builderInfo.getAttributes()); FlowBuilderContext builderContext = new FlowBuilderContextImpl(builderInfo.getId(), flowAttributes, flowRegistry, flowBuilderServices); FlowAssembler assembler = new FlowAssembler(builder, builderContext); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java index abb99af1..e1c68fc5 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java @@ -59,14 +59,14 @@ public interface ExternalContext { * request and accessible to both internal and external SWF artifacts. * @return the mutable request attribute map */ - public MutableAttributeMap getRequestMap(); + public MutableAttributeMap getRequestMap(); /** * Provides access to the external session map, providing a storage for data local to the current user session and * accessible to both internal and external SWF artifacts. * @return the mutable session attribute map */ - public SharedAttributeMap getSessionMap(); + public SharedAttributeMap getSessionMap(); /** * Provides access to the global external session map, providing a storage for data globally accross the user @@ -77,14 +77,14 @@ public interface ExternalContext { * calling this method returns the same map as calling {@link #getSessionMap()}. * @return the mutable global session attribute map */ - public SharedAttributeMap getGlobalSessionMap(); + public SharedAttributeMap getGlobalSessionMap(); /** * Provides access to the external application map, providing a storage for data local to the current user * application and accessible to both internal and external SWF artifacts. * @return the mutable application attribute map */ - public SharedAttributeMap getApplicationMap(); + public SharedAttributeMap getApplicationMap(); /** * Returns true if the current request is an asynchronous Ajax request. @@ -164,7 +164,7 @@ public interface ExternalContext { * @param input input to pass the flow; this input is generally encoded the url to launch the flow * @throws IllegalStateException if the response has completed */ - public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException; + public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException; /** * Request a redirect to an arbitrary resource location. May not be supported in some environments. Calling this diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContextHolder.java b/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContextHolder.java index 301f137a..3088fded 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContextHolder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContextHolder.java @@ -30,7 +30,8 @@ import org.springframework.core.NamedThreadLocal; */ public final class ExternalContextHolder { - private static final ThreadLocal externalContextHolder = new NamedThreadLocal("Flow ExternalContext"); + private static final ThreadLocal externalContextHolder = new NamedThreadLocal( + "Flow ExternalContext"); /** * Associate the given ExternalContext with the current thread. @@ -45,7 +46,7 @@ public final class ExternalContextHolder { * @return the current ExternalContext */ public static ExternalContext getExternalContext() { - return (ExternalContext) externalContextHolder.get(); + return externalContextHolder.get(); } // not instantiable diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletContextMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletContextMap.java index 2a969e5f..beddcfae 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletContextMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletContextMap.java @@ -29,7 +29,7 @@ import org.springframework.webflow.core.collection.CollectionUtils; * @author Keith Donald * @author Scott Andrews */ -public class PortletContextMap extends StringKeyedMapAdapter implements SharedMap { +public class PortletContextMap extends StringKeyedMapAdapter implements SharedMap { /** * The wrapped portlet context. @@ -55,7 +55,7 @@ public class PortletContextMap extends StringKeyedMapAdapter implements SharedMa context.removeAttribute(key); } - protected Iterator getAttributeNames() { + protected Iterator getAttributeNames() { return CollectionUtils.toIterator(context.getAttributeNames()); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java index 0cc58af2..ebfc03ff 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java @@ -83,17 +83,17 @@ public class PortletExternalContext implements ExternalContext { /** * An accessor for the HTTP request attribute map. */ - private MutableAttributeMap requestMap; + private MutableAttributeMap requestMap; /** * An accessor for the HTTP session map. */ - private SharedAttributeMap sessionMap; + private SharedAttributeMap sessionMap; /** * An accessor for the servlet context application map. */ - private SharedAttributeMap applicationMap; + private SharedAttributeMap applicationMap; /** * A flag indicating if the flow committed the response. Set to true by requesting an execution redirect, definition @@ -116,7 +116,7 @@ public class PortletExternalContext implements ExternalContext { * Input to pass the flow definition upon redirecting. May be null. Never set unless * {@link #flowDefinitionRedirectFlowId} has been set. */ - private MutableAttributeMap flowDefinitionRedirectFlowInput; + private MutableAttributeMap flowDefinitionRedirectFlowInput; /** * A string specifying an arbitrary @@ -166,19 +166,19 @@ public class PortletExternalContext implements ExternalContext { return requestParameterMap; } - public MutableAttributeMap getRequestMap() { + public MutableAttributeMap getRequestMap() { return requestMap; } - public SharedAttributeMap getSessionMap() { + public SharedAttributeMap getSessionMap() { return sessionMap; } - public SharedAttributeMap getGlobalSessionMap() { + public SharedAttributeMap getGlobalSessionMap() { return getSessionMap(); } - public SharedAttributeMap getApplicationMap() { + public SharedAttributeMap getApplicationMap() { return applicationMap; } @@ -250,10 +250,13 @@ public class PortletExternalContext implements ExternalContext { recordResponseComplete(); } - public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException { + public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException { assertRedirectResponseAllowed(); flowDefinitionRedirectFlowId = flowId; - flowDefinitionRedirectFlowInput = input != null ? input : new LocalAttributeMap(); + flowDefinitionRedirectFlowInput = new LocalAttributeMap(); + if (input != null) { + flowDefinitionRedirectFlowInput.putAll(input); + } recordResponseComplete(); } @@ -300,7 +303,7 @@ public class PortletExternalContext implements ExternalContext { * Returns the input to pass the flow definition through the redirect. Only set when * {@link #getFlowDefinitionRedirectRequested()} returns true. */ - public MutableAttributeMap getFlowRedirectFlowInput() { + public MutableAttributeMap getFlowRedirectFlowInput() { return flowDefinitionRedirectFlowInput; } @@ -354,9 +357,9 @@ public class PortletExternalContext implements ExternalContext { this.request = request; this.response = response; this.requestParameterMap = new LocalParameterMap(new PortletRequestParameterMap(request)); - this.requestMap = new LocalAttributeMap(new PortletRequestMap(request)); - this.sessionMap = new LocalSharedAttributeMap(new PortletSessionMap(request)); - this.applicationMap = new LocalSharedAttributeMap(new PortletContextMap(context)); + this.requestMap = new LocalAttributeMap(new PortletRequestMap(request)); + this.sessionMap = new LocalSharedAttributeMap(new PortletSessionMap(request)); + this.applicationMap = new LocalSharedAttributeMap(new PortletContextMap(context)); this.flowUrlHandler = flowUrlHandler; if (request instanceof ActionRequest && response instanceof ActionResponse) { requestPhase = ACTION_PHASE; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestMap.java index cef5cfe0..b359130c 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestMap.java @@ -28,7 +28,7 @@ import org.springframework.webflow.core.collection.CollectionUtils; * @author Keith Donald * @author Scott Andrews */ -public class PortletRequestMap extends StringKeyedMapAdapter { +public class PortletRequestMap extends StringKeyedMapAdapter { /** * The wrapped portlet request. @@ -54,7 +54,7 @@ public class PortletRequestMap extends StringKeyedMapAdapter { request.removeAttribute(key); } - protected Iterator getAttributeNames() { + protected Iterator getAttributeNames() { return CollectionUtils.toIterator(request.getAttributeNames()); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestParameterMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestParameterMap.java index 338fb63d..1226509e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestParameterMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletRequestParameterMap.java @@ -22,6 +22,7 @@ import javax.portlet.PortletRequest; import org.springframework.binding.collection.CompositeIterator; import org.springframework.binding.collection.StringKeyedMapAdapter; import org.springframework.util.Assert; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.portlet.multipart.MultipartActionRequest; import org.springframework.webflow.core.collection.CollectionUtils; @@ -32,7 +33,7 @@ import org.springframework.webflow.core.collection.CollectionUtils; * @author Keith Donald * @author Scott Andrews */ -public class PortletRequestParameterMap extends StringKeyedMapAdapter { +public class PortletRequestParameterMap extends StringKeyedMapAdapter { /** * The wrapped Portlet request. @@ -50,7 +51,7 @@ public class PortletRequestParameterMap extends StringKeyedMapAdapter { protected Object getAttribute(String key) { if (request instanceof MultipartActionRequest) { MultipartActionRequest multipartRequest = (MultipartActionRequest) request; - Object data = multipartRequest.getFileMap().get(key); + MultipartFile data = multipartRequest.getFileMap().get(key); if (data != null) { return data; } @@ -73,10 +74,10 @@ public class PortletRequestParameterMap extends StringKeyedMapAdapter { throw new UnsupportedOperationException("PortletRequest parameter maps are immutable"); } - protected Iterator getAttributeNames() { + protected Iterator getAttributeNames() { if (request instanceof MultipartActionRequest) { MultipartActionRequest multipartRequest = (MultipartActionRequest) request; - CompositeIterator iterator = new CompositeIterator(); + CompositeIterator iterator = new CompositeIterator(); iterator.add(multipartRequest.getFileMap().keySet().iterator()); iterator.add(CollectionUtils.toIterator(request.getParameterNames())); return iterator; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletSessionMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletSessionMap.java index 2d99de99..697a40d8 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletSessionMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletSessionMap.java @@ -33,7 +33,7 @@ import org.springframework.webflow.core.collection.CollectionUtils; * @author Keith Donald * @author Scott Andrews */ -public class PortletSessionMap extends StringKeyedMapAdapter implements SharedMap { +public class PortletSessionMap extends StringKeyedMapAdapter implements SharedMap { /** * The wrapped portlet request, providing access to the session. @@ -89,9 +89,9 @@ public class PortletSessionMap extends StringKeyedMapAdapter implements SharedMa } } - protected Iterator getAttributeNames() { + protected Iterator getAttributeNames() { PortletSession session = getSession(); - return session == null ? CollectionUtils.EMPTY_ITERATOR : CollectionUtils.toIterator(session + return session == null ? CollectionUtils. emptyIterator() : CollectionUtils.toIterator(session .getAttributeNames()); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/DefaultFlowUrlHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/DefaultFlowUrlHandler.java index 40a1c574..c3815055 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/DefaultFlowUrlHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/DefaultFlowUrlHandler.java @@ -127,7 +127,7 @@ public class DefaultFlowUrlHandler implements FlowUrlHandler { * http://someHost/someApp/someServlet/nestedPath/bar * */ - public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request) { + public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request) { StringBuffer url = new StringBuffer(); if (request.getPathInfo() != null) { url.append(request.getContextPath()); @@ -168,10 +168,10 @@ public class DefaultFlowUrlHandler implements FlowUrlHandler { } } - protected void appendQueryParameters(StringBuffer url, Map parameters, String encodingScheme) { - Iterator entries = parameters.entrySet().iterator(); + protected void appendQueryParameters(StringBuffer url, Map parameters, String encodingScheme) { + Iterator> entries = parameters.entrySet().iterator(); while (entries.hasNext()) { - Map.Entry entry = (Map.Entry) entries.next(); + Map.Entry entry = entries.next(); appendQueryParameter(url, entry.getKey(), entry.getValue(), encodingScheme); if (entries.hasNext()) { url.append('&'); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/FilenameFlowUrlHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/FilenameFlowUrlHandler.java index d00c9a22..f9e30bd2 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/FilenameFlowUrlHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/FilenameFlowUrlHandler.java @@ -88,7 +88,7 @@ public class FilenameFlowUrlHandler extends DefaultFlowUrlHandler { * http://someHost/someApp/someServlet/nestedPath/bar.html * */ - public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request) { + public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request) { StringBuffer url = new StringBuffer(); String pathInfo = request.getPathInfo(); if (pathInfo != null) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/FlowUrlHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/FlowUrlHandler.java index 23fbf909..a7dce64b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/FlowUrlHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/FlowUrlHandler.java @@ -47,7 +47,7 @@ public interface FlowUrlHandler { * @param request the current request * @return the flow definition url */ - public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request); + public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request); /** * Create a URL that when addressed will resume an existing execution of a flow. diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletContextMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletContextMap.java index af235c63..59b8f2a7 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletContextMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletContextMap.java @@ -28,7 +28,7 @@ import org.springframework.webflow.core.collection.CollectionUtils; * * @author Keith Donald */ -public class HttpServletContextMap extends StringKeyedMapAdapter implements SharedMap { +public class HttpServletContextMap extends StringKeyedMapAdapter implements SharedMap { /** * The wrapped servlet context. @@ -54,7 +54,8 @@ public class HttpServletContextMap extends StringKeyedMapAdapter implements Shar context.removeAttribute(key); } - protected Iterator getAttributeNames() { + @SuppressWarnings("unchecked") + protected Iterator getAttributeNames() { return CollectionUtils.toIterator(context.getAttributeNames()); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletRequestMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletRequestMap.java index c058dbd4..14db3105 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletRequestMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletRequestMap.java @@ -27,7 +27,7 @@ import org.springframework.webflow.core.collection.CollectionUtils; * * @author Keith Donald */ -public class HttpServletRequestMap extends StringKeyedMapAdapter { +public class HttpServletRequestMap extends StringKeyedMapAdapter { /** * The wrapped HTTP request. @@ -53,7 +53,8 @@ public class HttpServletRequestMap extends StringKeyedMapAdapter { request.removeAttribute(key); } - protected Iterator getAttributeNames() { + @SuppressWarnings("unchecked") + protected Iterator getAttributeNames() { return CollectionUtils.toIterator(request.getAttributeNames()); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletRequestParameterMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletRequestParameterMap.java index 713664d5..99781647 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletRequestParameterMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpServletRequestParameterMap.java @@ -31,7 +31,7 @@ import org.springframework.webflow.core.collection.CollectionUtils; * * @author Keith Donald */ -public class HttpServletRequestParameterMap extends StringKeyedMapAdapter { +public class HttpServletRequestParameterMap extends StringKeyedMapAdapter { /** * The wrapped HTTP request. @@ -72,15 +72,20 @@ public class HttpServletRequestParameterMap extends StringKeyedMapAdapter { throw new UnsupportedOperationException("HttpServletRequest parameter maps are immutable"); } - protected Iterator getAttributeNames() { + protected Iterator getAttributeNames() { if (request instanceof MultipartHttpServletRequest) { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; - CompositeIterator iterator = new CompositeIterator(); + CompositeIterator iterator = new CompositeIterator(); iterator.add(multipartRequest.getFileMap().keySet().iterator()); - iterator.add(CollectionUtils.toIterator(request.getParameterNames())); + iterator.add(getRequestParameterNames()); return iterator; } else { - return CollectionUtils.toIterator(request.getParameterNames()); + return getRequestParameterNames(); } } + + @SuppressWarnings("unchecked") + private Iterator getRequestParameterNames() { + return CollectionUtils.toIterator(request.getParameterNames()); + } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpSessionMap.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpSessionMap.java index 976c0d61..fa08a0d9 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpSessionMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/HttpSessionMap.java @@ -32,7 +32,7 @@ import org.springframework.webflow.core.collection.CollectionUtils; * * @author Keith Donald */ -public class HttpSessionMap extends StringKeyedMapAdapter implements SharedMap { +public class HttpSessionMap extends StringKeyedMapAdapter implements SharedMap { /** * The wrapped HTTP request, providing access to the session. @@ -87,9 +87,10 @@ public class HttpSessionMap extends StringKeyedMapAdapter implements SharedMap { } } - protected Iterator getAttributeNames() { + @SuppressWarnings("unchecked") + protected Iterator getAttributeNames() { HttpSession session = getSession(); - return session == null ? CollectionUtils.EMPTY_ITERATOR : CollectionUtils.toIterator(session + return session == null ? CollectionUtils.emptyIterator() : CollectionUtils.toIterator(session .getAttributeNames()); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java index 5a2f5e66..63a5ddbb 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java @@ -64,17 +64,17 @@ public class ServletExternalContext implements ExternalContext { /** * An accessor for the HTTP request attribute map. */ - private MutableAttributeMap requestMap; + private MutableAttributeMap requestMap; /** * An accessor for the HTTP session map. */ - private SharedAttributeMap sessionMap; + private SharedAttributeMap sessionMap; /** * An accessor for the servlet context application map. */ - private SharedAttributeMap applicationMap; + private SharedAttributeMap applicationMap; /** * A flag indicating if the flow committed the response. Set to true by requesting an execution redirect, definition @@ -97,7 +97,7 @@ public class ServletExternalContext implements ExternalContext { * Input to pass the flow definition upon redirecting. May be null. Never set unless * {@link #flowDefinitionRedirectFlowId} has been set. */ - private MutableAttributeMap flowDefinitionRedirectFlowInput; + private MutableAttributeMap flowDefinitionRedirectFlowInput; /** * A string specifying an arbitrary @@ -161,19 +161,19 @@ public class ServletExternalContext implements ExternalContext { return requestParameterMap; } - public MutableAttributeMap getRequestMap() { + public MutableAttributeMap getRequestMap() { return requestMap; } - public SharedAttributeMap getSessionMap() { + public SharedAttributeMap getSessionMap() { return sessionMap; } - public SharedAttributeMap getGlobalSessionMap() { + public SharedAttributeMap getGlobalSessionMap() { return getSessionMap(); } - public SharedAttributeMap getApplicationMap() { + public SharedAttributeMap getApplicationMap() { return applicationMap; } @@ -238,10 +238,13 @@ public class ServletExternalContext implements ExternalContext { recordResponseComplete(); } - public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException { + public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException { assertResponseAllowed(); flowDefinitionRedirectFlowId = flowId; - flowDefinitionRedirectFlowInput = input != null ? input : new LocalAttributeMap(); + flowDefinitionRedirectFlowInput = new LocalAttributeMap(); + if (input != null) { + flowDefinitionRedirectFlowInput.putAll(input); + } recordResponseComplete(); } @@ -288,7 +291,7 @@ public class ServletExternalContext implements ExternalContext { * Returns the input to pass the flow definition through the redirect. Only set when * {@link #getFlowDefinitionRedirectRequested()} returns true. */ - public MutableAttributeMap getFlowRedirectFlowInput() { + public MutableAttributeMap getFlowRedirectFlowInput() { return flowDefinitionRedirectFlowInput; } @@ -351,9 +354,9 @@ public class ServletExternalContext implements ExternalContext { this.request = request; this.response = response; this.requestParameterMap = new LocalParameterMap(new HttpServletRequestParameterMap(request)); - this.requestMap = new LocalAttributeMap(new HttpServletRequestMap(request)); - this.sessionMap = new LocalSharedAttributeMap(new HttpSessionMap(request)); - this.applicationMap = new LocalSharedAttributeMap(new HttpServletContextMap(context)); + this.requestMap = new LocalAttributeMap(new HttpServletRequestMap(request)); + this.sessionMap = new LocalSharedAttributeMap(new HttpSessionMap(request)); + this.applicationMap = new LocalSharedAttributeMap(new HttpServletContextMap(context)); this.flowUrlHandler = flowUrlHandler; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/WebFlow1FlowUrlHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/WebFlow1FlowUrlHandler.java index b745dbed..41034a2e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/WebFlow1FlowUrlHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/WebFlow1FlowUrlHandler.java @@ -53,7 +53,7 @@ public class WebFlow1FlowUrlHandler implements FlowUrlHandler { return url.toString(); } - public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request) { + public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request) { StringBuffer url = new StringBuffer(); url.append(request.getRequestURI()); url.append('?'); @@ -65,10 +65,10 @@ public class WebFlow1FlowUrlHandler implements FlowUrlHandler { return url.toString(); } - private void appendQueryParameters(StringBuffer url, Map parameters) { - Iterator entries = parameters.entrySet().iterator(); + private void appendQueryParameters(StringBuffer url, Map parameters) { + Iterator> entries = parameters.entrySet().iterator(); while (entries.hasNext()) { - Map.Entry entry = (Map.Entry) entries.next(); + Map.Entry entry = entries.next(); appendQueryParameter(url, entry.getKey(), entry.getValue()); if (entries.hasNext()) { url.append('&'); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/web/HttpSessionMapBindingListener.java b/spring-webflow/src/main/java/org/springframework/webflow/context/web/HttpSessionMapBindingListener.java index e52b7c26..1c7c804a 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/web/HttpSessionMapBindingListener.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/web/HttpSessionMapBindingListener.java @@ -34,14 +34,14 @@ public class HttpSessionMapBindingListener implements HttpSessionBindingListener private AttributeMapBindingListener listener; - private Map sessionMap; + private Map sessionMap; /** * Create a new wrapper for given listener. * @param listener the listener to wrap * @param sessionMap the session map containing the listener */ - public HttpSessionMapBindingListener(AttributeMapBindingListener listener, Map sessionMap) { + public HttpSessionMapBindingListener(AttributeMapBindingListener listener, Map sessionMap) { this.listener = listener; this.sessionMap = sessionMap; } @@ -56,7 +56,7 @@ public class HttpSessionMapBindingListener implements HttpSessionBindingListener /** * Returns the session map containing the listener. */ - public Map getSessionMap() { + public Map getSessionMap() { return sessionMap; } @@ -72,6 +72,6 @@ public class HttpSessionMapBindingListener implements HttpSessionBindingListener * Create a attribute map binding event for given HTTP session binding event. */ private AttributeMapBindingEvent getContextBindingEvent(HttpSessionBindingEvent event) { - return new AttributeMapBindingEvent(new LocalAttributeMap(sessionMap), event.getName(), listener); + return new AttributeMapBindingEvent(new LocalAttributeMap(sessionMap), event.getName(), listener); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/conversation/ConversationLockException.java b/spring-webflow/src/main/java/org/springframework/webflow/conversation/ConversationLockException.java index d46b5030..3abfb54c 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/conversation/ConversationLockException.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/conversation/ConversationLockException.java @@ -1,6 +1,5 @@ package org.springframework.webflow.conversation; - /** * An exception occurred within the conversation locking system. * diff --git a/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ContainedConversation.java b/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ContainedConversation.java index a603098d..3f079cfa 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ContainedConversation.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ContainedConversation.java @@ -43,7 +43,7 @@ class ContainedConversation implements Conversation, Serializable { private ConversationLock lock; - private Map attributes; + private Map attributes; /** * Create a new contained conversation. @@ -55,7 +55,7 @@ class ContainedConversation implements Conversation, Serializable { this.container = container; this.id = id; this.lock = lock; - this.attributes = new HashMap(); + this.attributes = new HashMap(); } public ConversationId getId() { @@ -104,7 +104,7 @@ class ContainedConversation implements Conversation, Serializable { // a clustered environment // we do this after releasing the lock since we're no longer // manipulating the contents of the conversation - SharedAttributeMap sessionMap = ExternalContextHolder.getExternalContext().getSessionMap(); + SharedAttributeMap sessionMap = ExternalContextHolder.getExternalContext().getSessionMap(); synchronized (sessionMap.getMutex()) { sessionMap.put(container.getSessionKey(), container); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ConversationContainer.java b/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ConversationContainer.java index 2a52b777..9e1ab625 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ConversationContainer.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/ConversationContainer.java @@ -22,7 +22,6 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.core.JdkVersion; import org.springframework.webflow.conversation.Conversation; import org.springframework.webflow.conversation.ConversationId; import org.springframework.webflow.conversation.ConversationParameters; @@ -53,7 +52,7 @@ class ConversationContainer implements Serializable { /** * The contained conversations. A list of {@link ContainedConversation} objects. */ - private List conversations; + private List conversations; /** * The sequence for unique conversation identifiers within this container. @@ -68,7 +67,7 @@ class ConversationContainer implements Serializable { public ConversationContainer(int maxConversations, String sessionKey) { this.maxConversations = maxConversations; this.sessionKey = sessionKey; - this.conversations = new ArrayList(); + this.conversations = new ArrayList(); } /** @@ -100,9 +99,8 @@ class ConversationContainer implements Serializable { conversations.add(conversation); if (maxExceeded()) { if (logger.isDebugEnabled()) { - logger - .debug("The maximum number of flow executions has been exceeded for the current user. Removing the oldest conversation with id: " - + ((Conversation) conversations.get(0)).getId()); + logger.debug("The maximum number of flow executions has been exceeded for the current user. Removing the oldest conversation with id: " + + ((Conversation) conversations.get(0)).getId()); } // end oldest conversation ((Conversation) conversations.get(0)).end(); @@ -111,11 +109,7 @@ class ConversationContainer implements Serializable { } private ConversationId nextId() { - if (JdkVersion.isAtLeastJava15()) { - return new SimpleConversationId(Integer.valueOf(++conversationIdSequence)); - } else { - return new SimpleConversationId(new Integer(++conversationIdSequence)); - } + return new SimpleConversationId(Integer.valueOf(++conversationIdSequence)); } /** @@ -125,8 +119,7 @@ class ConversationContainer implements Serializable { * @throws NoSuchConversationException if the conversation cannot be found */ public synchronized Conversation getConversation(ConversationId id) throws NoSuchConversationException { - for (Iterator it = conversations.iterator(); it.hasNext();) { - ContainedConversation conversation = (ContainedConversation) it.next(); + for (ContainedConversation conversation : conversations) { if (conversation.getId().equals(id)) { return conversation; } @@ -138,8 +131,8 @@ class ConversationContainer implements Serializable { * Remove identified conversation from this container. */ public synchronized void removeConversation(ConversationId id) { - for (Iterator it = conversations.iterator(); it.hasNext();) { - ContainedConversation conversation = (ContainedConversation) it.next(); + for (Iterator it = conversations.iterator(); it.hasNext();) { + ContainedConversation conversation = it.next(); if (conversation.getId().equals(id)) { it.remove(); break; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/SessionBindingConversationManager.java b/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/SessionBindingConversationManager.java index 93e46c28..1cd37878 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/SessionBindingConversationManager.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/conversation/impl/SessionBindingConversationManager.java @@ -137,7 +137,7 @@ public class SessionBindingConversationManager implements ConversationManager { * existing container can be found. */ private ConversationContainer getConversationContainer() { - SharedAttributeMap sessionMap = ExternalContextHolder.getExternalContext().getSessionMap(); + SharedAttributeMap sessionMap = ExternalContextHolder.getExternalContext().getSessionMap(); synchronized (sessionMap.getMutex()) { ConversationContainer container = (ConversationContainer) sessionMap.get(sessionKey); if (container == null) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/Annotated.java b/spring-webflow/src/main/java/org/springframework/webflow/core/Annotated.java index 273fe0e9..f1b2d80f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/Annotated.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/Annotated.java @@ -42,6 +42,6 @@ public interface Annotated { * characteristics or properties that may affect object behavior. * @return the attribute map */ - public MutableAttributeMap getAttributes(); + public MutableAttributeMap getAttributes(); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/AnnotatedObject.java b/spring-webflow/src/main/java/org/springframework/webflow/core/AnnotatedObject.java index 71635d30..90660ec3 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/AnnotatedObject.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/AnnotatedObject.java @@ -42,7 +42,7 @@ public abstract class AnnotatedObject implements Annotated { /** * Additional properties further describing this object. The properties set in this map may be arbitrary. */ - private LocalAttributeMap attributes = new LocalAttributeMap(); + private LocalAttributeMap attributes = new LocalAttributeMap(); // implementing Annotated @@ -54,7 +54,7 @@ public abstract class AnnotatedObject implements Annotated { return attributes.getString(DESCRIPTION_PROPERTY); } - public MutableAttributeMap getAttributes() { + public MutableAttributeMap getAttributes() { return attributes; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/AttributeMap.java b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/AttributeMap.java index cee93d0e..15b8928f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/AttributeMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/AttributeMap.java @@ -27,14 +27,14 @@ import org.springframework.binding.collection.MapAdaptable; * * @author Keith Donald */ -public interface AttributeMap extends MapAdaptable { +public interface AttributeMap extends MapAdaptable { /** * Get an attribute value out of this map, returning null if not found. * @param attributeName the attribute name * @return the attribute value */ - public Object get(String attributeName); + public V get(String attributeName); /** * Returns the size of this map. @@ -62,7 +62,7 @@ public interface AttributeMap extends MapAdaptable { * @return true if so, false otherwise * @throws IllegalArgumentException when the value is not of the required type */ - public boolean contains(String attributeName, Class requiredType) throws IllegalArgumentException; + public boolean contains(String attributeName, Class requiredType) throws IllegalArgumentException; /** * Get an attribute value, returning the default value if no value is found. @@ -70,7 +70,7 @@ public interface AttributeMap extends MapAdaptable { * @param defaultValue the default value * @return the attribute value, falling back to the default if no such attribute exists */ - public Object get(String attributeName, Object defaultValue); + public V get(String attributeName, V defaultValue); /** * Get an attribute value, asserting the value is of the required type. @@ -79,7 +79,7 @@ public interface AttributeMap extends MapAdaptable { * @return the attribute value, or null if not found * @throws IllegalArgumentException when the value is not of the required type */ - public Object get(String attributeName, Class requiredType) throws IllegalArgumentException; + public T get(String attributeName, Class requiredType) throws IllegalArgumentException; /** * Get an attribute value, asserting the value is of the required type and returning the default value if not found. @@ -89,7 +89,8 @@ public interface AttributeMap extends MapAdaptable { * @return the attribute value, or the default if not found * @throws IllegalArgumentException when the value (if found) is not of the required type */ - public Object get(String attributeName, Class requiredType, Object defaultValue) throws IllegalStateException; + public T get(String attributeName, Class requiredType, T defaultValue) + throws IllegalStateException; /** * Get the value of a required attribute, throwing an exception of no attribute is found. @@ -97,7 +98,7 @@ public interface AttributeMap extends MapAdaptable { * @return the attribute value * @throws IllegalArgumentException when the attribute is not found */ - public Object getRequired(String attributeName) throws IllegalArgumentException; + public V getRequired(String attributeName) throws IllegalArgumentException; /** * Get the value of a required attribute and make sure it is of the required type. @@ -106,7 +107,7 @@ public interface AttributeMap extends MapAdaptable { * @return the attribute value * @throws IllegalArgumentException when the attribute is not found or not of the required type */ - public Object getRequired(String attributeName, Class requiredType) throws IllegalArgumentException; + public T getRequired(String attributeName, Class requiredType) throws IllegalArgumentException; /** * Returns a string attribute value in the map, returning null if no value was found. @@ -140,7 +141,7 @@ public interface AttributeMap extends MapAdaptable { * @return the collection attribute value * @throws IllegalArgumentException if the attribute is present but not a collection */ - public Collection getCollection(String attributeName) throws IllegalArgumentException; + public Collection getCollection(String attributeName) throws IllegalArgumentException; /** * Returns a collection attribute value in the map and make sure it is of the required type. @@ -149,7 +150,8 @@ public interface AttributeMap extends MapAdaptable { * @return the collection attribute value * @throws IllegalArgumentException if the attribute is present but not a collection of the required type */ - public Collection getCollection(String attributeName, Class requiredType) throws IllegalArgumentException; + public > T getCollection(String attributeName, Class requiredType) + throws IllegalArgumentException; /** * Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a @@ -158,7 +160,7 @@ public interface AttributeMap extends MapAdaptable { * @return the collection attribute value * @throws IllegalArgumentException if the attribute is not present or is present but not a collection */ - public Collection getRequiredCollection(String attributeName) throws IllegalArgumentException; + public Collection getRequiredCollection(String attributeName) throws IllegalArgumentException; /** * Returns a collection attribute value in the map, throwing an exception if the attribute is not present or not a @@ -169,7 +171,8 @@ public interface AttributeMap extends MapAdaptable { * @throws IllegalArgumentException if the attribute is not present or is present but not a collection of the * required type */ - public Collection getRequiredCollection(String attributeName, Class requiredType) throws IllegalArgumentException; + public > T getRequiredCollection(String attributeName, Class requiredType) + throws IllegalArgumentException; /** * Returns an array attribute value in the map and makes sure it is of the required type. @@ -178,7 +181,8 @@ public interface AttributeMap extends MapAdaptable { * @return the array attribute value * @throws IllegalArgumentException if the attribute is present but not an array of the required type */ - public Object[] getArray(String attributeName, Class requiredType) throws IllegalArgumentException; + public T[] getArray(String attributeName, Class requiredType) + throws IllegalArgumentException; /** * Returns an array attribute value in the map, throwing an exception if the attribute is not present or not an @@ -189,7 +193,8 @@ public interface AttributeMap extends MapAdaptable { * @throws IllegalArgumentException if the attribute is not present or is present but not a array of the required * type */ - public Object[] getRequiredArray(String attributeName, Class requiredType) throws IllegalArgumentException; + public T[] getRequiredArray(String attributeName, Class requiredType) + throws IllegalArgumentException; /** * Returns a number attribute value in the map that is of the specified type, returning null if no @@ -199,7 +204,7 @@ public interface AttributeMap extends MapAdaptable { * @return the number attribute value * @throws IllegalArgumentException if the attribute is present but not a number of the required type */ - public Number getNumber(String attributeName, Class requiredType) throws IllegalArgumentException; + public T getNumber(String attributeName, Class requiredType) throws IllegalArgumentException; /** * Returns a number attribute value in the map of the specified type, returning the default value if no value was @@ -209,7 +214,7 @@ public interface AttributeMap extends MapAdaptable { * @return the number attribute value * @throws IllegalArgumentException if the attribute is present but not a number of the required type */ - public Number getNumber(String attributeName, Class requiredType, Number defaultValue) + public T getNumber(String attributeName, Class requiredType, T defaultValue) throws IllegalArgumentException; /** @@ -219,7 +224,8 @@ public interface AttributeMap extends MapAdaptable { * @return the number attribute value * @throws IllegalArgumentException if the attribute is not present or present but not a number of the required type */ - public Number getRequiredNumber(String attributeName, Class requiredType) throws IllegalArgumentException; + public T getRequiredNumber(String attributeName, Class requiredType) + throws IllegalArgumentException; /** * Returns an integer attribute value in the map, returning null if no value was found. @@ -304,6 +310,6 @@ public interface AttributeMap extends MapAdaptable { * @param attributes the map to combine with this map * @return a new, combined map */ - public AttributeMap union(AttributeMap attributes); + public AttributeMap union(AttributeMap attributes); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/AttributeMapBindingEvent.java b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/AttributeMapBindingEvent.java index 4dc09fcc..2e1266cd 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/AttributeMapBindingEvent.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/AttributeMapBindingEvent.java @@ -36,7 +36,7 @@ public class AttributeMapBindingEvent extends EventObject { * @param attributeName the name that this attribute was bound with * @param attributeValue the attribute */ - public AttributeMapBindingEvent(AttributeMap source, String attributeName, Object attributeValue) { + public AttributeMapBindingEvent(AttributeMap source, String attributeName, Object attributeValue) { super(source); this.source = source; this.attributeName = attributeName; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/CollectionUtils.java b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/CollectionUtils.java index 2c8250ef..c9159900 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/CollectionUtils.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/CollectionUtils.java @@ -32,12 +32,14 @@ public class CollectionUtils { /** * The shared, singleton empty iterator instance. */ + @SuppressWarnings("rawtypes") public static final Iterator EMPTY_ITERATOR = new EmptyIterator(); /** * The shared, singleton empty attribute map instance. */ - public static final AttributeMap EMPTY_ATTRIBUTE_MAP = new LocalAttributeMap(Collections.EMPTY_MAP); + public static final AttributeMap EMPTY_ATTRIBUTE_MAP = new LocalAttributeMap( + Collections. emptyMap()); /** * Private constructor to avoid instantiation. @@ -45,13 +47,18 @@ public class CollectionUtils { private CollectionUtils() { } + @SuppressWarnings("unchecked") + public static Iterator emptyIterator() { + return EMPTY_ITERATOR; + } + /** * Factory method that adapts an enumeration to an iterator. * @param enumeration the enumeration * @return the iterator */ - public static Iterator toIterator(Enumeration enumeration) { - return new EnumerationIterator(enumeration); + public static Iterator toIterator(Enumeration enumeration) { + return new EnumerationIterator(enumeration); } /** @@ -60,8 +67,8 @@ public class CollectionUtils { * @param attributeValue the attribute value * @return the unmodifiable map with a single element */ - public static AttributeMap singleEntryMap(String attributeName, Object attributeValue) { - return new LocalAttributeMap(attributeName, attributeValue); + public static AttributeMap singleEntryMap(String attributeName, V attributeValue) { + return new LocalAttributeMap(attributeName, attributeValue); } /** @@ -71,7 +78,7 @@ public class CollectionUtils { * @param objects the objects to add * @return whether or not the target collection changed */ - public static boolean addAllNoDuplicates(List target, Object[] objects) { + public static boolean addAllNoDuplicates(List target, T[] objects) { if (objects == null || objects.length == 0) { return false; } else { @@ -89,7 +96,7 @@ public class CollectionUtils { /** * Iterator iterating over no elements (hasNext() always returns false). */ - private static class EmptyIterator implements Iterator, Serializable { + private static class EmptyIterator implements Iterator, Serializable { private EmptyIterator() { } @@ -98,7 +105,7 @@ public class CollectionUtils { return false; } - public Object next() { + public E next() { throw new UnsupportedOperationException("There are no elements"); } @@ -110,11 +117,11 @@ public class CollectionUtils { /** * Iterator wrapping an Enumeration. */ - private static class EnumerationIterator implements Iterator { + private static class EnumerationIterator implements Iterator { - private Enumeration enumeration; + private Enumeration enumeration; - public EnumerationIterator(Enumeration enumeration) { + public EnumerationIterator(Enumeration enumeration) { this.enumeration = enumeration; } @@ -122,7 +129,7 @@ public class CollectionUtils { return enumeration.hasMoreElements(); } - public Object next() { + public E next() { return enumeration.nextElement(); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalAttributeMap.java b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalAttributeMap.java index 1259d681..fdabcc8d 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalAttributeMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalAttributeMap.java @@ -33,17 +33,17 @@ import org.springframework.util.Assert; * * @author Keith Donald */ -public class LocalAttributeMap implements MutableAttributeMap, Serializable { +public class LocalAttributeMap implements MutableAttributeMap, Serializable { /** * The backing map storing the attributes. */ - private Map attributes; + private Map attributes; /** * A helper for accessing attributes. Marked transient and restored on deserialization. */ - private transient MapAccessor attributeAccessor; + private transient MapAccessor attributeAccessor; /** * Creates a new attribute map, initially empty. @@ -64,7 +64,7 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { /** * Creates a new attribute map with a single entry. */ - public LocalAttributeMap(String attributeName, Object attributeValue) { + public LocalAttributeMap(String attributeName, V attributeValue) { initAttributes(createTargetMap(1, 1)); put(attributeName, attributeValue); } @@ -72,14 +72,14 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { /** * Creates a new attribute map wrapping the specified map. */ - public LocalAttributeMap(Map map) { + public LocalAttributeMap(Map map) { Assert.notNull(map, "The target map is required"); initAttributes(map); } // implementing attribute map - public Map asMap() { + public Map asMap() { return attributeAccessor.asMap(); } @@ -87,7 +87,7 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { return attributes.size(); } - public Object get(String attributeName) { + public V get(String attributeName) { return attributes.get(attributeName); } @@ -99,27 +99,28 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { return attributes.containsKey(attributeName); } - public boolean contains(String attributeName, Class requiredType) throws IllegalArgumentException { + public boolean contains(String attributeName, Class requiredType) throws IllegalArgumentException { return attributeAccessor.containsKey(attributeName, requiredType); } - public Object get(String attributeName, Object defaultValue) { + public V get(String attributeName, V defaultValue) { return attributeAccessor.get(attributeName, defaultValue); } - public Object get(String attributeName, Class requiredType) throws IllegalArgumentException { + public T get(String attributeName, Class requiredType) throws IllegalArgumentException { return attributeAccessor.get(attributeName, requiredType); } - public Object get(String attributeName, Class requiredType, Object defaultValue) throws IllegalStateException { + public T get(String attributeName, Class requiredType, T defaultValue) + throws IllegalStateException { return attributeAccessor.get(attributeName, requiredType, defaultValue); } - public Object getRequired(String attributeName) throws IllegalArgumentException { + public V getRequired(String attributeName) throws IllegalArgumentException { return attributeAccessor.getRequired(attributeName); } - public Object getRequired(String attributeName, Class requiredType) throws IllegalArgumentException { + public T getRequired(String attributeName, Class requiredType) throws IllegalArgumentException { return attributeAccessor.getRequired(attributeName, requiredType); } @@ -135,40 +136,45 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { return attributeAccessor.getRequiredString(attributeName); } - public Collection getCollection(String attributeName) throws IllegalArgumentException { + public Collection getCollection(String attributeName) throws IllegalArgumentException { return attributeAccessor.getCollection(attributeName); } - public Collection getCollection(String attributeName, Class requiredType) throws IllegalArgumentException { + public > T getCollection(String attributeName, Class requiredType) + throws IllegalArgumentException { return attributeAccessor.getCollection(attributeName, requiredType); } - public Collection getRequiredCollection(String attributeName) throws IllegalArgumentException { + public Collection getRequiredCollection(String attributeName) throws IllegalArgumentException { return attributeAccessor.getRequiredCollection(attributeName); } - public Collection getRequiredCollection(String attributeName, Class requiredType) throws IllegalArgumentException { + public > T getRequiredCollection(String attributeName, Class requiredType) + throws IllegalArgumentException { return attributeAccessor.getRequiredCollection(attributeName, requiredType); } - public Object[] getArray(String attributeName, Class requiredType) throws IllegalArgumentException { + public T[] getArray(String attributeName, Class requiredType) + throws IllegalArgumentException { return attributeAccessor.getArray(attributeName, requiredType); } - public Object[] getRequiredArray(String attributeName, Class requiredType) throws IllegalArgumentException { + public T[] getRequiredArray(String attributeName, Class requiredType) + throws IllegalArgumentException { return attributeAccessor.getRequiredArray(attributeName, requiredType); } - public Number getNumber(String attributeName, Class requiredType) throws IllegalArgumentException { + public T getNumber(String attributeName, Class requiredType) throws IllegalArgumentException { return attributeAccessor.getNumber(attributeName, requiredType); } - public Number getNumber(String attributeName, Class requiredType, Number defaultValue) + public T getNumber(String attributeName, Class requiredType, T defaultValue) throws IllegalArgumentException { return attributeAccessor.getNumber(attributeName, requiredType, defaultValue); } - public Number getRequiredNumber(String attributeName, Class requiredType) throws IllegalArgumentException { + public T getRequiredNumber(String attributeName, Class requiredType) + throws IllegalArgumentException { return attributeAccessor.getRequiredNumber(attributeName, requiredType); } @@ -208,24 +214,24 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { return attributeAccessor.getRequiredBoolean(attributeName); } - public AttributeMap union(AttributeMap attributes) { + public AttributeMap union(AttributeMap attributes) { if (attributes == null) { - return new LocalAttributeMap(getMapInternal()); + return new LocalAttributeMap(getMapInternal()); } else { - Map map = createTargetMap(); + Map map = createTargetMap(); map.putAll(getMapInternal()); map.putAll(attributes.asMap()); - return new LocalAttributeMap(map); + return new LocalAttributeMap(map); } } // implementing MutableAttributeMap - public Object put(String attributeName, Object attributeValue) { + public V put(String attributeName, V attributeValue) { return getMapInternal().put(attributeName, attributeValue); } - public MutableAttributeMap putAll(AttributeMap attributes) { + public MutableAttributeMap putAll(AttributeMap attributes) { if (attributes == null) { return this; } @@ -233,12 +239,12 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { return this; } - public MutableAttributeMap removeAll(MutableAttributeMap attributes) { + public MutableAttributeMap removeAll(MutableAttributeMap attributes) { if (attributes == null) { return this; } - Iterator it = attributes.asMap().keySet().iterator(); - Map internal = getMapInternal(); + Iterator it = attributes.asMap().keySet().iterator(); + Map internal = getMapInternal(); while (it.hasNext()) { internal.remove(it.next()); } @@ -250,7 +256,7 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { } public Object extract(String attributeName) { - Map map = getMapInternal(); + Map map = getMapInternal(); if (map.containsKey(attributeName)) { Object value = map.get(attributeName); map.remove(attributeName); @@ -260,12 +266,13 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { } } - public MutableAttributeMap clear() throws UnsupportedOperationException { + public MutableAttributeMap clear() throws UnsupportedOperationException { getMapInternal().clear(); return this; } - public MutableAttributeMap replaceWith(AttributeMap attributes) throws UnsupportedOperationException { + public MutableAttributeMap replaceWith(AttributeMap attributes) + throws UnsupportedOperationException { clear(); putAll(attributes); return this; @@ -277,15 +284,15 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { * Initializes this attribute map. * @param attributes the attributes */ - protected void initAttributes(Map attributes) { + protected void initAttributes(Map attributes) { this.attributes = attributes; - attributeAccessor = new MapAccessor(this.attributes); + attributeAccessor = new MapAccessor(this.attributes); } /** * Returns the wrapped, modifiable map implementation. */ - protected Map getMapInternal() { + protected Map getMapInternal() { return attributes; } @@ -295,8 +302,8 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { * Factory method that returns the target map storing the data in this attribute map. * @return the target map */ - protected Map createTargetMap() { - return new HashMap(); + protected Map createTargetMap() { + return new HashMap(); } /** @@ -305,15 +312,16 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { * @param loadFactor the load factor * @return the target map */ - protected Map createTargetMap(int size, int loadFactor) { - return new HashMap(size, loadFactor); + protected Map createTargetMap(int size, int loadFactor) { + return new HashMap(size, loadFactor); } + @SuppressWarnings("unchecked") public boolean equals(Object o) { if (!(o instanceof LocalAttributeMap)) { return false; } - LocalAttributeMap other = (LocalAttributeMap) o; + LocalAttributeMap other = (LocalAttributeMap) o; return getMapInternal().equals(other.getMapInternal()); } @@ -329,7 +337,7 @@ public class LocalAttributeMap implements MutableAttributeMap, Serializable { private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - attributeAccessor = new MapAccessor(attributes); + attributeAccessor = new MapAccessor(attributes); } public String toString() { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalParameterMap.java b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalParameterMap.java index 9580f824..a2be6280 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalParameterMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalParameterMap.java @@ -47,12 +47,12 @@ public class LocalParameterMap implements ParameterMap, Serializable { /** * The backing map storing the parameters. */ - private Map parameters; + private Map parameters; /** * A helper for accessing parameters. Marked transient and restored on deserialization. */ - private transient MapAccessor parameterAccessor; + private transient MapAccessor parameterAccessor; /** * A helper for converting string parameter values. Marked transient and restored on deserialization. @@ -66,7 +66,7 @@ public class LocalParameterMap implements ParameterMap, Serializable { * have string keys, string values, and remain unmodifiable. * @param parameters the contents of this parameter map */ - public LocalParameterMap(Map parameters) { + public LocalParameterMap(Map parameters) { this(parameters, DEFAULT_CONVERSION_SERVICE); } @@ -78,7 +78,7 @@ public class LocalParameterMap implements ParameterMap, Serializable { * @param parameters the contents of this parameter map * @param conversionService a helper for performing type conversion of map entry values */ - public LocalParameterMap(Map parameters, ConversionService conversionService) { + public LocalParameterMap(Map parameters, ConversionService conversionService) { initParameters(parameters); this.conversionService = conversionService; } @@ -95,7 +95,7 @@ public class LocalParameterMap implements ParameterMap, Serializable { return parameters.hashCode(); } - public Map asMap() { + public Map asMap() { return Collections.unmodifiableMap(parameterAccessor.asMap()); } @@ -151,16 +151,16 @@ public class LocalParameterMap implements ParameterMap, Serializable { } } - public Object[] getArray(String parameterName, Class targetElementType) throws ConversionExecutionException { + public T[] getArray(String parameterName, Class targetElementType) throws ConversionExecutionException { String[] parameters = getArray(parameterName); return parameters != null ? convert(parameters, targetElementType) : null; } - public Object get(String parameterName, Class targetType) throws ConversionExecutionException { + public T get(String parameterName, Class targetType) throws ConversionExecutionException { return get(parameterName, targetType, null); } - public Object get(String parameterName, Class targetType, Object defaultValue) throws ConversionExecutionException { + public T get(String parameterName, Class targetType, T defaultValue) throws ConversionExecutionException { if (defaultValue != null) { assertAssignableTo(targetType, defaultValue.getClass()); } @@ -178,97 +178,98 @@ public class LocalParameterMap implements ParameterMap, Serializable { return getArray(parameterName); } - public Object[] getRequiredArray(String parameterName, Class targetElementType) throws IllegalArgumentException, + public T[] getRequiredArray(String parameterName, Class targetElementType) throws IllegalArgumentException, ConversionExecutionException { String[] parameters = getRequiredArray(parameterName); return convert(parameters, targetElementType); } - public Object getRequired(String parameterName, Class targetType) throws IllegalArgumentException, + public T getRequired(String parameterName, Class targetType) throws IllegalArgumentException, ConversionExecutionException { return convert(getRequired(parameterName), targetType); } - public Number getNumber(String parameterName, Class targetType) throws ConversionExecutionException { - assertAssignableTo(Number.class, targetType); - return (Number) get(parameterName, targetType); - } - - public Number getNumber(String parameterName, Class targetType, Number defaultValue) + public T getNumber(String parameterName, Class targetType) throws ConversionExecutionException { assertAssignableTo(Number.class, targetType); - return (Number) get(parameterName, targetType, defaultValue); + return get(parameterName, targetType); } - public Number getRequiredNumber(String parameterName, Class targetType) throws IllegalArgumentException, - ConversionExecutionException { + public T getNumber(String parameterName, Class targetType, T defaultValue) + throws ConversionExecutionException { assertAssignableTo(Number.class, targetType); - return (Number) getRequired(parameterName, targetType); + return get(parameterName, targetType, defaultValue); + } + + public T getRequiredNumber(String parameterName, Class targetType) + throws IllegalArgumentException, ConversionExecutionException { + assertAssignableTo(Number.class, targetType); + return getRequired(parameterName, targetType); } public Integer getInteger(String parameterName) throws ConversionExecutionException { - return (Integer) get(parameterName, Integer.class); + return get(parameterName, Integer.class); } public Integer getInteger(String parameterName, Integer defaultValue) throws ConversionExecutionException { - return (Integer) get(parameterName, Integer.class, defaultValue); + return get(parameterName, Integer.class, defaultValue); } public Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, ConversionExecutionException { - return (Integer) getRequired(parameterName, Integer.class); + return getRequired(parameterName, Integer.class); } public Long getLong(String parameterName) throws ConversionExecutionException { - return (Long) get(parameterName, Long.class); + return get(parameterName, Long.class); } public Long getLong(String parameterName, Long defaultValue) throws ConversionExecutionException { - return (Long) get(parameterName, Long.class, defaultValue); + return get(parameterName, Long.class, defaultValue); } public Long getRequiredLong(String parameterName) throws IllegalArgumentException, ConversionExecutionException { - return (Long) getRequired(parameterName, Long.class); + return getRequired(parameterName, Long.class); } public Boolean getBoolean(String parameterName) throws ConversionExecutionException { - return (Boolean) get(parameterName, Boolean.class); + return get(parameterName, Boolean.class); } public Boolean getBoolean(String parameterName, Boolean defaultValue) throws ConversionExecutionException { - return (Boolean) get(parameterName, Boolean.class, defaultValue); + return get(parameterName, Boolean.class, defaultValue); } public Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, ConversionExecutionException { - return (Boolean) getRequired(parameterName, Boolean.class); + return getRequired(parameterName, Boolean.class); } public MultipartFile getMultipartFile(String parameterName) { - return (MultipartFile) parameterAccessor.get(parameterName, MultipartFile.class); + return parameterAccessor.get(parameterName, MultipartFile.class); } public MultipartFile getRequiredMultipartFile(String parameterName) throws IllegalArgumentException { - return (MultipartFile) parameterAccessor.getRequired(parameterName, MultipartFile.class); + return parameterAccessor.getRequired(parameterName, MultipartFile.class); } - public AttributeMap asAttributeMap() { - return new LocalAttributeMap(getMapInternal()); + public AttributeMap asAttributeMap() { + return new LocalAttributeMap(getMapInternal()); } /** * Initializes this parameter map. * @param parameters the parameters */ - protected void initParameters(Map parameters) { + protected void initParameters(Map parameters) { this.parameters = parameters; - parameterAccessor = new MapAccessor(this.parameters); + parameterAccessor = new MapAccessor(this.parameters); } /** * Returns the wrapped, modifiable map implementation. */ - protected Map getMapInternal() { + protected Map getMapInternal() { return parameters; } @@ -277,26 +278,29 @@ public class LocalParameterMap implements ParameterMap, Serializable { /** * Convert given String parameter to specified target type. */ - private Object convert(String parameter, Class targetType) throws ConversionExecutionException { - return conversionService.getConversionExecutor(String.class, targetType).execute(parameter); + @SuppressWarnings("unchecked") + private T convert(String parameter, Class targetType) throws ConversionExecutionException { + return (T) conversionService.getConversionExecutor(String.class, targetType).execute(parameter); } /** * Convert given array of String parameters to specified target type and return the resulting array. */ - private Object[] convert(String[] parameters, Class targetElementType) throws ConversionExecutionException { - List list = new ArrayList(parameters.length); + @SuppressWarnings("unchecked") + private T[] convert(String[] parameters, Class targetElementType) + throws ConversionExecutionException { + List list = new ArrayList(parameters.length); ConversionExecutor converter = conversionService.getConversionExecutor(String.class, targetElementType); - for (int i = 0; i < parameters.length; i++) { - list.add(converter.execute(parameters[i])); + for (String parameter : parameters) { + list.add((T) converter.execute(parameter)); } - return list.toArray((Object[]) Array.newInstance(targetElementType, parameters.length)); + return list.toArray((T[]) Array.newInstance(targetElementType, parameters.length)); } /** * Make sure clazz is assignable from requiredType. */ - private void assertAssignableTo(Class clazz, Class requiredType) { + private void assertAssignableTo(Class clazz, Class requiredType) { Assert.isTrue(clazz.isAssignableFrom(requiredType), "The provided required type must be assignable to [" + clazz + "]"); } @@ -309,7 +313,7 @@ public class LocalParameterMap implements ParameterMap, Serializable { private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - parameterAccessor = new MapAccessor(parameters); + parameterAccessor = new MapAccessor(parameters); conversionService = DEFAULT_CONVERSION_SERVICE; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalSharedAttributeMap.java b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalSharedAttributeMap.java index 3a5de241..47855518 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalSharedAttributeMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/LocalSharedAttributeMap.java @@ -25,13 +25,13 @@ import org.springframework.binding.collection.SharedMap; * * @author Keith Donald */ -public class LocalSharedAttributeMap extends LocalAttributeMap implements SharedAttributeMap { +public class LocalSharedAttributeMap extends LocalAttributeMap implements SharedAttributeMap { /** * Creates a new shared attribute map. * @param sharedMap the shared map */ - public LocalSharedAttributeMap(SharedMap sharedMap) { + public LocalSharedAttributeMap(SharedMap sharedMap) { super(sharedMap); } @@ -42,7 +42,7 @@ public class LocalSharedAttributeMap extends LocalAttributeMap implements Shared /** * Returns the wrapped shared map. */ - protected SharedMap getSharedMap() { - return (SharedMap) getMapInternal(); + protected SharedMap getSharedMap() { + return (SharedMap) getMapInternal(); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/MutableAttributeMap.java b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/MutableAttributeMap.java index f0bcf52e..8458c048 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/MutableAttributeMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/MutableAttributeMap.java @@ -23,7 +23,7 @@ package org.springframework.webflow.core.collection; * * @author Keith Donald */ -public interface MutableAttributeMap extends AttributeMap { +public interface MutableAttributeMap extends AttributeMap { /** * Put the attribute into this map. @@ -36,27 +36,27 @@ public interface MutableAttributeMap extends AttributeMap { * @param attributeValue the attribute value * @return the previous value of the attribute, or null of there was no previous value */ - public Object put(String attributeName, Object attributeValue); + public V put(String attributeName, V attributeValue); /** * Put all the attributes into this map. * @param attributes the attributes to put into this map * @return this, to support call chaining */ - public MutableAttributeMap putAll(AttributeMap attributes); + public MutableAttributeMap putAll(AttributeMap attributes); /** * Remove all attributes in the map provided from this map. * @param attributes the attributes to remove from this map * @return this, to support call chaining */ - public MutableAttributeMap removeAll(MutableAttributeMap attributes); + public MutableAttributeMap removeAll(MutableAttributeMap attributes); /** * Remove an attribute from this map. * @param attributeName the name of the attribute to remove - * @return previous value associated with specified attribute name, or null if there was no mapping for - * the name + * @return previous value associated with specified attribute name, or null if there was no mapping for the + * name */ public Object remove(String attributeName); @@ -71,13 +71,14 @@ public interface MutableAttributeMap extends AttributeMap { * Remove all attributes in this map. * @return this, to support call chaining */ - public MutableAttributeMap clear(); + public MutableAttributeMap clear(); /** * Replace the contents of this attribute map with the contents of the provided collection. * @param attributes the attribute collection * @return this, to support call chaining */ - public MutableAttributeMap replaceWith(AttributeMap attributes) throws UnsupportedOperationException; + public MutableAttributeMap replaceWith(AttributeMap attributes) + throws UnsupportedOperationException; } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/ParameterMap.java b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/ParameterMap.java index 675db489..5d1b07bd 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/ParameterMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/ParameterMap.java @@ -28,7 +28,7 @@ import org.springframework.web.multipart.MultipartFile; * * @author Keith Donald */ -public interface ParameterMap extends MapAdaptable { +public interface ParameterMap extends MapAdaptable { /** * Is this parameter map empty, with a size of 0? @@ -65,22 +65,22 @@ public interface ParameterMap extends MapAdaptable { public String get(String parameterName, String defaultValue); /** - * Get a multi-valued parameter value, returning null if no value is found. If the parameter is - * single valued an array with a single element is returned. + * Get a multi-valued parameter value, returning null if no value is found. If the parameter is single + * valued an array with a single element is returned. * @param parameterName the parameter name * @return the parameter value array */ public String[] getArray(String parameterName); /** - * Get a multi-valued parameter value, converting each value to the target type or returning null if - * no value is found. + * Get a multi-valued parameter value, converting each value to the target type or returning null if no + * value is found. * @param parameterName the parameter name * @param targetElementType the target type of the array's elements * @return the converterd parameter value array * @throws ConversionExecutionException when the value could not be converted */ - public Object[] getArray(String parameterName, Class targetElementType) throws ConversionExecutionException; + public T[] getArray(String parameterName, Class targetElementType) throws ConversionExecutionException; /** * Get a parameter value, converting it from String to the target type. @@ -89,18 +89,18 @@ public interface ParameterMap extends MapAdaptable { * @return the converted parameter value, or null if not found * @throws ConversionExecutionException when the value could not be converted */ - public Object get(String parameterName, Class targetType) throws ConversionExecutionException; + public T get(String parameterName, Class targetType) throws ConversionExecutionException; /** - * Get a parameter value, converting it from String to the target type or returning the defaultValue - * if not found. + * Get a parameter value, converting it from String to the target type or returning the defaultValue if + * not found. * @param parameterName name of the parameter to get * @param targetType the target type of the parameter value * @param defaultValue the default value * @return the converted parameter value, or the default if not found * @throws ConversionExecutionException when a value could not be converted */ - public Object get(String parameterName, Class targetType, Object defaultValue) throws ConversionExecutionException; + public T get(String parameterName, Class targetType, T defaultValue) throws ConversionExecutionException; /** * Get the value of a required parameter. @@ -125,7 +125,7 @@ public interface ParameterMap extends MapAdaptable { * @throws IllegalArgumentException when the parameter is not found * @throws ConversionExecutionException when a value could not be converted */ - public Object[] getRequiredArray(String parameterName, Class targetElementType) throws IllegalArgumentException, + public T[] getRequiredArray(String parameterName, Class targetElementType) throws IllegalArgumentException, ConversionExecutionException; /** @@ -136,7 +136,7 @@ public interface ParameterMap extends MapAdaptable { * @throws IllegalArgumentException when the parameter is not found * @throws ConversionExecutionException when the value could not be converted */ - public Object getRequired(String parameterName, Class targetType) throws IllegalArgumentException, + public T getRequired(String parameterName, Class targetType) throws IllegalArgumentException, ConversionExecutionException; /** @@ -147,7 +147,8 @@ public interface ParameterMap extends MapAdaptable { * @return the number parameter value * @throws ConversionExecutionException when the value could not be converted */ - public Number getNumber(String parameterName, Class targetType) throws ConversionExecutionException; + public T getNumber(String parameterName, Class targetType) + throws ConversionExecutionException; /** * Returns a number parameter value in the map of the specified type, returning the defaultValue if no value was @@ -157,7 +158,8 @@ public interface ParameterMap extends MapAdaptable { * @return the number parameter value * @throws ConversionExecutionException when the value could not be converted */ - public Number getNumber(String parameterName, Class targetType, Number defaultValue) throws ConversionExecutionException; + public T getNumber(String parameterName, Class targetType, T defaultValue) + throws ConversionExecutionException; /** * Returns a number parameter value in the map, throwing an exception if the parameter is not present or could not @@ -167,8 +169,8 @@ public interface ParameterMap extends MapAdaptable { * @throws IllegalArgumentException if the parameter is not present * @throws ConversionExecutionException when the value could not be converted */ - public Number getRequiredNumber(String parameterName, Class targetType) throws IllegalArgumentException, - ConversionExecutionException; + public T getRequiredNumber(String parameterName, Class targetType) + throws IllegalArgumentException, ConversionExecutionException; /** * Returns an integer parameter value in the map, returning null if no value was found. @@ -195,7 +197,8 @@ public interface ParameterMap extends MapAdaptable { * @throws IllegalArgumentException if the parameter is not present * @throws ConversionExecutionException when the value could not be converted */ - public Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, ConversionExecutionException; + public Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, + ConversionExecutionException; /** * Returns a long parameter value in the map, returning null if no value was found. @@ -249,7 +252,8 @@ public interface ParameterMap extends MapAdaptable { * @throws IllegalArgumentException if the parameter is not present * @throws ConversionExecutionException when the value could not be converted */ - public Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, ConversionExecutionException; + public Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, + ConversionExecutionException; /** * Get a multi-part file parameter value, returning null if no value is found. @@ -270,6 +274,6 @@ public interface ParameterMap extends MapAdaptable { * Adapts this parameter map to an {@link AttributeMap}. * @return the underlying map as a unmodifiable attribute map */ - public AttributeMap asAttributeMap(); + public AttributeMap asAttributeMap(); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/SharedAttributeMap.java b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/SharedAttributeMap.java index acbc2a45..21db0ffa 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/core/collection/SharedAttributeMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/core/collection/SharedAttributeMap.java @@ -20,7 +20,7 @@ package org.springframework.webflow.core.collection; * * @author Keith Donald */ -public interface SharedAttributeMap extends MutableAttributeMap { +public interface SharedAttributeMap extends MutableAttributeMap { /** * Returns the shared map's mutex, which may be synchronized on to block access to the map by other threads. diff --git a/spring-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionLocator.java b/spring-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionLocator.java index 2c6bd89c..1e18446d 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionLocator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionLocator.java @@ -18,8 +18,8 @@ package org.springframework.webflow.definition.registry; import org.springframework.webflow.definition.FlowDefinition; /** - * A runtime service locator interface for retrieving flow definitions by id. Flow locators are needed - * by flow executors at runtime to retrieve fully-configured flow definitions to support launching new flow executions. + * A runtime service locator interface for retrieving flow definitions by id. Flow locators are needed by + * flow executors at runtime to retrieve fully-configured flow definitions to support launching new flow executions. * * @author Keith Donald * @author Erwin Vervaet diff --git a/spring-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImpl.java index 4405cb98..9961309f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImpl.java @@ -38,7 +38,7 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry { /** * The map of loaded Flow definitions maintained in this registry. */ - private Map flowDefinitions; + private Map flowDefinitions; /** * An optional parent flow definition registry. @@ -46,7 +46,7 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry { private FlowDefinitionRegistry parent; public FlowDefinitionRegistryImpl() { - flowDefinitions = new TreeMap(); + flowDefinitions = new TreeMap(); } // implementing FlowDefinitionLocator @@ -83,7 +83,7 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry { } public String[] getFlowDefinitionIds() { - return (String[]) flowDefinitions.keySet().toArray(new String[flowDefinitions.size()]); + return flowDefinitions.keySet().toArray(new String[flowDefinitions.size()]); } public FlowDefinitionRegistry getParent() { @@ -108,9 +108,9 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry { } public void destroy() { - Iterator it = flowDefinitions.values().iterator(); + Iterator it = flowDefinitions.values().iterator(); while (it.hasNext()) { - FlowDefinitionHolder holder = (FlowDefinitionHolder) it.next(); + FlowDefinitionHolder holder = it.next(); holder.destroy(); } } @@ -121,7 +121,7 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry { * Returns the identified flow definition holder. Throws an exception if it cannot be found. */ private FlowDefinitionHolder getFlowDefinitionHolder(String id) throws NoSuchFlowDefinitionException { - FlowDefinitionHolder holder = (FlowDefinitionHolder) flowDefinitions.get(id); + FlowDefinitionHolder holder = flowDefinitions.get(id); if (holder == null) { throw new NoSuchFlowDefinitionException(id); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/ActionList.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/ActionList.java index 326c689e..7acf772d 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/ActionList.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/ActionList.java @@ -38,12 +38,12 @@ import org.springframework.webflow.execution.RequestContext; * * @author Keith Donald */ -public class ActionList { +public class ActionList implements Iterable { /** * The lists of actions. */ - private List actions = new LinkedList(); + private List actions = new LinkedList(); /** * Add an action to this list. @@ -98,7 +98,7 @@ public class ActionList { * @return the action the action */ public Action get(int index) throws IndexOutOfBoundsException { - return (Action) actions.get(index); + return actions.get(index); } /** @@ -119,7 +119,7 @@ public class ActionList { /** * Returns an iterator over this action list. */ - public Iterator iterator() { + public Iterator iterator() { return actions.iterator(); } @@ -128,7 +128,7 @@ public class ActionList { * @return the action list, as a typed array */ public Action[] toArray() { - return (Action[]) actions.toArray(new Action[actions.size()]); + return actions.toArray(new Action[actions.size()]); } /** @@ -150,9 +150,9 @@ public class ActionList { * @param context the action execution request context */ public void execute(RequestContext context) { - Iterator it = actions.iterator(); + Iterator it = actions.iterator(); while (it.hasNext()) { - ActionExecutor.execute((Action) it.next(), context); + ActionExecutor.execute(it.next(), context); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/ActionState.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/ActionState.java index 5ce4e137..daadbf4e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/ActionState.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/ActionState.java @@ -82,12 +82,12 @@ public class ActionState extends TransitionableState { } /** - * Specialization of State's doEnter template method that executes behavior specific to this state - * type in polymorphic fashion. + * Specialization of State's doEnter template method that executes behavior specific to this state type + * in polymorphic fashion. *

    * This implementation iterates over each configured Action instance and executes it. Execution - * continues until an Action returns a result event that matches a transition in this request - * context, or the set of all actions is exhausted. + * continues until an Action returns a result event that matches a transition in this request context, + * or the set of all actions is exhausted. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @throws FlowExecutionException if an exception occurs in this state @@ -95,9 +95,9 @@ public class ActionState extends TransitionableState { protected void doEnter(RequestControlContext context) throws FlowExecutionException { int executionCount = 0; String[] eventIds = new String[actionList.size()]; - Iterator it = actionList.iterator(); + Iterator it = actionList.iterator(); while (it.hasNext()) { - Action action = (Action) it.next(); + Action action = it.next(); Event event = ActionExecutor.execute(action, context); if (event != null) { eventIds[executionCount] = event.getId(); @@ -117,12 +117,10 @@ public class ActionState extends TransitionableState { } } else { if (logger.isDebugEnabled()) { - logger - .debug("Action execution [" - + (executionCount + 1) - + "] returned a [null] event" - + (it.hasNext() ? ": proceeding to the next action in the list" - : ": action list exhausted")); + logger.debug("Action execution [" + + (executionCount + 1) + + "] returned a [null] event" + + (it.hasNext() ? ": proceeding to the next action in the list" : ": action list exhausted")); } eventIds[executionCount] = null; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/DecisionState.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/DecisionState.java index 4b489551..43380dae 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/DecisionState.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/DecisionState.java @@ -39,8 +39,8 @@ public class DecisionState extends TransitionableState { } /** - * Specialization of State's doEnter template method that executes behavior specific to this state - * type in polymorphic fashion. + * Specialization of State's doEnter template method that executes behavior specific to this state type + * in polymorphic fashion. *

    * Simply looks up the first transition that matches the state of the context and executes it. * @param context the control context for the currently executing flow, used by this state to manipulate the flow diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/EndState.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/EndState.java index dfbc7194..a62a7417 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/EndState.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/EndState.java @@ -103,7 +103,7 @@ public class EndState extends State { context.endActiveFlowSession(getId(), createSessionOutput(context)); } else { // there is a parent flow that will resume (this flow is a subflow) - LocalAttributeMap sessionOutput = createSessionOutput(context); + LocalAttributeMap sessionOutput = createSessionOutput(context); context.endActiveFlowSession(getId(), sessionOutput); } } @@ -112,8 +112,8 @@ public class EndState extends State { * Returns the subflow output map. This will invoke the output mapper (if any) to map data available in the flow * execution request context into a newly created empty map. */ - protected LocalAttributeMap createSessionOutput(RequestContext context) { - LocalAttributeMap output = new LocalAttributeMap(); + protected LocalAttributeMap createSessionOutput(RequestContext context) { + LocalAttributeMap output = new LocalAttributeMap(); if (outputMapper != null) { MappingResults results = outputMapper.map(context, output); if (results != null && results.hasErrorResults()) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/Flow.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/Flow.java index 8158d0ff..2b974e9b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/Flow.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/Flow.java @@ -124,7 +124,7 @@ public class Flow extends AnnotatedObject implements FlowDefinition { /** * The set of state definitions for this flow. */ - private Set states = new LinkedHashSet(9); + private Set states = new LinkedHashSet(9); /** * The default start state for this flow. @@ -134,7 +134,7 @@ public class Flow extends AnnotatedObject implements FlowDefinition { /** * The set of flow variables created by this flow. */ - private Map variables = new LinkedHashMap(); + private Map variables = new LinkedHashMap(); /** * The mapper to map flow input attributes. @@ -191,7 +191,7 @@ public class Flow extends AnnotatedObject implements FlowDefinition { * @param attributes the attributes * @return the flow */ - public static Flow create(String id, AttributeMap attributes) { + public static Flow create(String id, AttributeMap attributes) { Flow flow = new Flow(id); flow.getAttributes().putAll(attributes); return flow; @@ -216,14 +216,13 @@ public class Flow extends AnnotatedObject implements FlowDefinition { } public String[] getPossibleOutcomes() { - List possibleOutcomes = new ArrayList(); - for (Iterator it = states.iterator(); it.hasNext();) { - State state = (State) it.next(); + List possibleOutcomes = new ArrayList(); + for (State state : states) { if (state instanceof EndState) { possibleOutcomes.add(state.getId()); } } - return (String[]) possibleOutcomes.toArray(new String[possibleOutcomes.size()]); + return possibleOutcomes.toArray(new String[possibleOutcomes.size()]); } public ClassLoader getClassLoader() { @@ -280,9 +279,9 @@ public class Flow extends AnnotatedObject implements FlowDefinition { * @return true if yes, false otherwise */ public boolean containsState(String stateId) { - Iterator it = states.iterator(); + Iterator it = states.iterator(); while (it.hasNext()) { - State state = (State) it.next(); + State state = it.next(); if (state.getId().equals(stateId)) { return true; } @@ -338,9 +337,9 @@ public class Flow extends AnnotatedObject implements FlowDefinition { if (!StringUtils.hasText(stateId)) { throw new IllegalArgumentException("The specified stateId is invalid: state identifiers must be non-blank"); } - Iterator it = states.iterator(); + Iterator it = states.iterator(); while (it.hasNext()) { - State state = (State) it.next(); + State state = it.next(); if (state.getId().equals(stateId)) { return state; } @@ -357,9 +356,9 @@ public class Flow extends AnnotatedObject implements FlowDefinition { public String[] getStateIds() { String[] stateIds = new String[getStateCount()]; int i = 0; - Iterator it = states.iterator(); + Iterator it = states.iterator(); while (it.hasNext()) { - stateIds[i++] = ((State) it.next()).getId(); + stateIds[i++] = it.next().getId(); } return stateIds; } @@ -380,8 +379,8 @@ public class Flow extends AnnotatedObject implements FlowDefinition { if (variables == null) { return; } - for (int i = 0; i < variables.length; i++) { - addVariable(variables[i]); + for (FlowVariable variable : variables) { + addVariable(variable); } } @@ -390,14 +389,14 @@ public class Flow extends AnnotatedObject implements FlowDefinition { * @param name the name of the variable */ public FlowVariable getVariable(String name) { - return (FlowVariable) variables.get(name); + return variables.get(name); } /** * Returns the flow variables. */ public FlowVariable[] getVariables() { - return (FlowVariable[]) variables.values().toArray(new FlowVariable[variables.size()]); + return variables.values().toArray(new FlowVariable[variables.size()]); } /** @@ -476,8 +475,7 @@ public class Flow extends AnnotatedObject implements FlowDefinition { * @return the transition that matches, or null if no match is found. */ public TransitionDefinition getGlobalTransition(String eventId) { - for (Iterator it = globalTransitionSet.iterator(); it.hasNext();) { - Transition transition = (Transition) it.next(); + for (Transition transition : globalTransitionSet) { if (transition.getId().equals(eventId)) { return transition; } @@ -522,7 +520,7 @@ public class Flow extends AnnotatedObject implements FlowDefinition { * @param input eligible input into the session * @throws FlowExecutionException when an exception occurs starting the flow */ - public void start(RequestControlContext context, MutableAttributeMap input) throws FlowExecutionException { + public void start(RequestControlContext context, MutableAttributeMap input) throws FlowExecutionException { assertStartStateSet(); createVariables(context); if (inputMapper != null) { @@ -581,7 +579,7 @@ public class Flow extends AnnotatedObject implements FlowDefinition { * @param output initial output produced by the session that is eligible for modification by this method * @throws FlowExecutionException when an exception occurs ending this flow */ - public void end(RequestControlContext context, String outcome, MutableAttributeMap output) + public void end(RequestControlContext context, String outcome, MutableAttributeMap output) throws FlowExecutionException { endActionList.execute(context); if (outputMapper != null) { @@ -618,9 +616,9 @@ public class Flow extends AnnotatedObject implements FlowDefinition { } private void createVariables(RequestContext context) { - Iterator it = variables.values().iterator(); + Iterator it = variables.values().iterator(); while (it.hasNext()) { - FlowVariable variable = (FlowVariable) it.next(); + FlowVariable variable = it.next(); if (logger.isDebugEnabled()) { logger.debug("Creating " + variable); } @@ -629,9 +627,9 @@ public class Flow extends AnnotatedObject implements FlowDefinition { } public void restoreVariables(RequestContext context) { - Iterator it = variables.values().iterator(); + Iterator it = variables.values().iterator(); while (it.hasNext()) { - FlowVariable variable = (FlowVariable) it.next(); + FlowVariable variable = it.next(); if (logger.isDebugEnabled()) { logger.debug("Restoring " + variable); } @@ -659,10 +657,10 @@ public class Flow extends AnnotatedObject implements FlowDefinition { public String toString() { return new ToStringCreator(this).append("id", id).append("states", states).append("startState", startState) - .append("variables", variables).append("inputMapper", inputMapper).append("startActionList", - startActionList).append("exceptionHandlerSet", exceptionHandlerSet).append( - "globalTransitionSet", globalTransitionSet).append("endActionList", endActionList).append( - "outputMapper", outputMapper).toString(); + .append("variables", variables).append("inputMapper", inputMapper) + .append("startActionList", startActionList).append("exceptionHandlerSet", exceptionHandlerSet) + .append("globalTransitionSet", globalTransitionSet).append("endActionList", endActionList) + .append("outputMapper", outputMapper).toString(); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/FlowExecutionExceptionHandlerSet.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/FlowExecutionExceptionHandlerSet.java index 8e3f5550..64711179 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/FlowExecutionExceptionHandlerSet.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/FlowExecutionExceptionHandlerSet.java @@ -38,7 +38,7 @@ public class FlowExecutionExceptionHandlerSet { /** * The set of exception handlers. */ - private List exceptionHandlers = new LinkedList(); + private List exceptionHandlers = new LinkedList(); /** * Add a state exception handler to this set. @@ -92,8 +92,7 @@ public class FlowExecutionExceptionHandlerSet { * @return the exception handler list, as a typed array */ public FlowExecutionExceptionHandler[] toArray() { - return (FlowExecutionExceptionHandler[]) exceptionHandlers - .toArray(new FlowExecutionExceptionHandler[exceptionHandlers.size()]); + return exceptionHandlers.toArray(new FlowExecutionExceptionHandler[exceptionHandlers.size()]); } /** @@ -106,9 +105,9 @@ public class FlowExecutionExceptionHandlerSet { * @return true if the exception was handled */ public boolean handleException(FlowExecutionException exception, RequestControlContext context) { - Iterator it = exceptionHandlers.iterator(); + Iterator it = exceptionHandlers.iterator(); while (it.hasNext()) { - FlowExecutionExceptionHandler handler = (FlowExecutionExceptionHandler) it.next(); + FlowExecutionExceptionHandler handler = it.next(); if (handler.canHandle(exception)) { handler.handle(exception, context); return true; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/RequestControlContext.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/RequestControlContext.java index dfeadc4a..e104d723 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/RequestControlContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/RequestControlContext.java @@ -131,7 +131,7 @@ public interface RequestControlContext extends RequestContext { * start operation * @see Flow#start(RequestControlContext, MutableAttributeMap) */ - public void start(Flow flow, MutableAttributeMap input) throws FlowExecutionException; + public void start(Flow flow, MutableAttributeMap input) throws FlowExecutionException; /** * End the active flow session of the current flow execution. This method should be called by clients that terminate @@ -142,7 +142,7 @@ public interface RequestControlContext extends RequestContext { * @throws IllegalStateException when the flow execution is not active * @see Flow#end(RequestControlContext, String, MutableAttributeMap) */ - public void endActiveFlowSession(String outcome, MutableAttributeMap output) throws IllegalStateException; + public void endActiveFlowSession(String outcome, MutableAttributeMap output) throws IllegalStateException; /** * Returns true if the 'redirect on pause' flow execution attribute is set to true, false otherwise. diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/State.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/State.java index 0de10b1a..4ea52ddd 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/State.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/State.java @@ -75,8 +75,8 @@ public abstract class State extends AnnotatedObject implements StateDefinition { private FlowExecutionExceptionHandlerSet exceptionHandlerSet = new FlowExecutionExceptionHandlerSet(); /** - * Creates a state for the provided flow identified by the provided id. The id must - * be locally unique to the owning flow. The state will be automatically added to the flow. + * Creates a state for the provided flow identified by the provided id. The id must be + * locally unique to the owning flow. The state will be automatically added to the flow. * @param flow the owning flow * @param id the state identifier (must be unique to the flow) * @throws IllegalArgumentException if this state cannot be added to the flow, for instance when the provided id is @@ -223,8 +223,8 @@ public abstract class State extends AnnotatedObject implements StateDefinition { } public String toString() { - ToStringCreator creator = new ToStringCreator(this).append("id", getId()).append("flow", flow.getId()).append( - "entryActionList", entryActionList).append("exceptionHandlerSet", exceptionHandlerSet); + ToStringCreator creator = new ToStringCreator(this).append("id", getId()).append("flow", flow.getId()) + .append("entryActionList", entryActionList).append("exceptionHandlerSet", exceptionHandlerSet); appendToString(creator); return creator.toString(); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/SubflowAttributeMapper.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/SubflowAttributeMapper.java index 681d7952..14b4e8e7 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/SubflowAttributeMapper.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/SubflowAttributeMapper.java @@ -30,12 +30,12 @@ public interface SubflowAttributeMapper { * @param context the current request execution context * @return a map of attributes to pass as input */ - public MutableAttributeMap createSubflowInput(RequestContext context); + public MutableAttributeMap createSubflowInput(RequestContext context); /** * Map output attributes of an ended subflow flow to the resuming parent flow. * @param output the output attributes returned by the ended subflow * @param context the current request execution context, which gives access to the parent flow scope */ - public void mapSubflowOutput(AttributeMap output, RequestContext context); + public void mapSubflowOutput(AttributeMap output, RequestContext context); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/SubflowState.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/SubflowState.java index b34ba29c..72640118 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/SubflowState.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/SubflowState.java @@ -88,11 +88,11 @@ public class SubflowState extends TransitionableState { * @throws FlowExecutionException if an exception occurs in this state */ protected void doEnter(RequestControlContext context) throws FlowExecutionException { - MutableAttributeMap flowInput; + MutableAttributeMap flowInput; if (subflowAttributeMapper != null) { flowInput = subflowAttributeMapper.createSubflowInput(context); } else { - flowInput = new LocalAttributeMap(); + flowInput = new LocalAttributeMap(); } Flow subflow = (Flow) this.subflow.getValue(context); if (logger.isDebugEnabled()) { @@ -107,7 +107,7 @@ public class SubflowState extends TransitionableState { */ public boolean handleEvent(RequestControlContext context) { if (subflowAttributeMapper != null) { - AttributeMap subflowOutput = context.getCurrentEvent().getAttributes(); + AttributeMap subflowOutput = context.getCurrentEvent().getAttributes(); if (logger.isDebugEnabled()) { logger.debug("Mapping subflow output " + subflowOutput); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/Transition.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/Transition.java index 26aae80c..de1aea47 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/Transition.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/Transition.java @@ -33,8 +33,9 @@ import org.springframework.webflow.execution.RequestContext; * {@link Event} from within a transitionable source state. *

    * When an event occurs within this transition's source TransitionableState the determination of the - * eligibility of this transition is made by a TransitionCriteria object called the matching criteria. - * If the matching criteria returns true this transition is marked eligible for execution for that event. + * eligibility of this transition is made by a TransitionCriteria object called the matching + * criteria. If the matching criteria returns true this transition is marked eligible for execution for + * that event. *

    * Determination as to whether an eligible transition should be allowed to execute is made by a * TransitionCriteria object called the execution criteria. If the execution criteria test fails diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionSet.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionSet.java index b81a8412..18cb99fb 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionSet.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionSet.java @@ -31,12 +31,12 @@ import org.springframework.webflow.execution.RequestContext; * * @author Keith Donald */ -public class TransitionSet { +public class TransitionSet implements Iterable { /** * The set of transitions. */ - private List transitions = new LinkedList(); + private List transitions = new LinkedList(); /** * Add a transition to this set. @@ -89,7 +89,7 @@ public class TransitionSet { * Returns an iterator over this transition set. * @return an iterator */ - public Iterator iterator() { + public Iterator iterator() { return transitions.iterator(); } @@ -98,7 +98,7 @@ public class TransitionSet { * @return the transition set as a typed array */ public Transition[] toArray() { - return (Transition[]) transitions.toArray(new Transition[transitions.size()]); + return transitions.toArray(new Transition[transitions.size()]); } /** @@ -108,9 +108,9 @@ public class TransitionSet { public TransitionCriteria[] getTransitionCriterias() { TransitionCriteria[] criterias = new TransitionCriteria[transitions.size()]; int i = 0; - Iterator it = transitions.iterator(); + Iterator it = transitions.iterator(); while (it.hasNext()) { - criterias[i++] = ((Transition) it.next()).getMatchingCriteria(); + criterias[i++] = it.next().getMatchingCriteria(); } return criterias; } @@ -121,9 +121,9 @@ public class TransitionSet { * @return the transition, or null if no transition matches */ public Transition getTransition(RequestContext context) { - Iterator it = transitions.iterator(); + Iterator it = transitions.iterator(); while (it.hasNext()) { - Transition transition = (Transition) it.next(); + Transition transition = it.next(); if (transition.matches(context)) { return transition; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionableState.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionableState.java index 44bdbcdf..68afa4eb 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionableState.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/TransitionableState.java @@ -15,8 +15,6 @@ */ package org.springframework.webflow.engine; -import java.util.Iterator; - import org.springframework.core.style.StylerUtils; import org.springframework.core.style.ToStringCreator; import org.springframework.webflow.definition.TransitionDefinition; @@ -64,8 +62,7 @@ public abstract class TransitionableState extends State implements Transitionabl } public TransitionDefinition getTransition(String eventId) { - for (Iterator it = transitions.iterator(); it.hasNext();) { - Transition transition = (Transition) it.next(); + for (Transition transition : transitions) { if (transition.getId().equals(eventId)) { return transition; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java index d5b7b812..9937d91e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java @@ -54,7 +54,7 @@ public class ViewState extends TransitionableState { /** * The set of view variables created by this view state. */ - private Map variables = new LinkedHashMap(); + private Map variables = new LinkedHashMap(); /** * Whether or not a redirect should occur before the view is rendered. @@ -98,8 +98,8 @@ public class ViewState extends TransitionableState { * @param variables the variables */ public void addVariables(ViewVariable[] variables) { - for (int i = 0; i < variables.length; i++) { - addVariable(variables[i]); + for (ViewVariable variable : variables) { + addVariable(variable); } } @@ -108,14 +108,14 @@ public class ViewState extends TransitionableState { * @param name the name of the variable */ public ViewVariable getVariable(String name) { - return (ViewVariable) variables.get(name); + return variables.get(name); } /** * Returns the configured view variables. */ public ViewVariable[] getVariables() { - return (ViewVariable[]) variables.values().toArray(new ViewVariable[variables.size()]); + return variables.values().toArray(new ViewVariable[variables.size()]); } /** @@ -254,9 +254,9 @@ public class ViewState extends TransitionableState { // internal helpers private void createVariables(RequestContext context) { - Iterator it = variables.values().iterator(); + Iterator it = variables.values().iterator(); while (it.hasNext()) { - ViewVariable variable = (ViewVariable) it.next(); + ViewVariable variable = it.next(); if (logger.isDebugEnabled()) { logger.debug("Creating " + variable); } @@ -308,9 +308,9 @@ public class ViewState extends TransitionableState { } private void restoreVariables(RequestContext context) { - Iterator it = variables.values().iterator(); + Iterator it = variables.values().iterator(); while (it.hasNext()) { - ViewVariable variable = (ViewVariable) it.next(); + ViewVariable variable = it.next(); if (logger.isDebugEnabled()) { logger.debug("Restoring " + variable); @@ -336,9 +336,9 @@ public class ViewState extends TransitionableState { } private void destroyVariables(RequestContext context) { - Iterator it = variables.values().iterator(); + Iterator it = variables.values().iterator(); while (it.hasNext()) { - ViewVariable variable = (ViewVariable) it.next(); + ViewVariable variable = it.next(); if (logger.isDebugEnabled()) { logger.debug("Destroying " + variable); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/BinderConfiguration.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/BinderConfiguration.java index 9b6a758a..cbe08923 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/BinderConfiguration.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/BinderConfiguration.java @@ -17,7 +17,7 @@ import org.springframework.util.Assert; */ public class BinderConfiguration { - private Set bindings = new LinkedHashSet(); + private Set bindings = new LinkedHashSet(); /** * Adds a new binding to this binding configuration. @@ -30,7 +30,7 @@ public class BinderConfiguration { /** * Returns the set of bindings associated with this binding configuration. */ - public Set getBindings() { + public Set getBindings() { return bindings; } @@ -40,9 +40,9 @@ public class BinderConfiguration { * @return the binding */ public Binding getBinding(String name) { - Iterator it = bindings.iterator(); + Iterator it = bindings.iterator(); while (it.hasNext()) { - Binding binding = (Binding) it.next(); + Binding binding = it.next(); if (name.equals(binding.getProperty())) { return binding; } @@ -129,8 +129,8 @@ public class BinderConfiguration { } public String toString() { - return new ToStringCreator(this).append("property", property).append("converter", converter).append( - "required", required).toString(); + return new ToStringCreator(this).append("property", property).append("converter", converter) + .append("required", required).toString(); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowArtifactFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowArtifactFactory.java index 988e263d..63397eb6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowArtifactFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowArtifactFactory.java @@ -58,7 +58,7 @@ public class FlowArtifactFactory { * null * @return the initial flow instance, ready for assembly by a FlowBuilder */ - public Flow createFlow(String id, AttributeMap attributes) { + public Flow createFlow(String id, AttributeMap attributes) { return Flow.create(id, attributes); } @@ -82,7 +82,7 @@ public class FlowArtifactFactory { */ public State createViewState(String id, Flow flow, ViewVariable[] variables, Action[] entryActions, ViewFactory viewFactory, Boolean redirect, boolean popup, Action[] renderActions, Transition[] transitions, - FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { + FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { ViewState viewState = new ViewState(flow, id, viewFactory); viewState.addVariables(variables); viewState.setRedirect(redirect); @@ -109,7 +109,7 @@ public class FlowArtifactFactory { */ public State createActionState(String id, Flow flow, Action[] entryActions, Action[] actions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, - AttributeMap attributes) { + AttributeMap attributes) { ActionState actionState = new ActionState(flow, id); actionState.getActionList().addAll(actions); configureCommonProperties(actionState, entryActions, transitions, exceptionHandlers, exitActions, attributes); @@ -131,7 +131,7 @@ public class FlowArtifactFactory { * @return the fully initialized decision state instance */ public State createDecisionState(String id, Flow flow, Action[] entryActions, Transition[] transitions, - FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { + FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { DecisionState decisionState = new DecisionState(flow, id); configureCommonProperties(decisionState, entryActions, transitions, exceptionHandlers, exitActions, attributes); return decisionState; @@ -155,7 +155,7 @@ public class FlowArtifactFactory { */ public State createSubflowState(String id, Flow flow, Action[] entryActions, Expression subflow, SubflowAttributeMapper attributeMapper, Transition[] transitions, - FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { + FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { SubflowState subflowState = new SubflowState(flow, id, subflow); if (attributeMapper != null) { subflowState.setAttributeMapper(attributeMapper); @@ -179,7 +179,7 @@ public class FlowArtifactFactory { * @return the fully initialized subflow state instance */ public State createEndState(String id, Flow flow, Action[] entryActions, Action finalResponseAction, - Mapper outputMapper, FlowExecutionExceptionHandler[] exceptionHandlers, AttributeMap attributes) { + Mapper outputMapper, FlowExecutionExceptionHandler[] exceptionHandlers, AttributeMap attributes) { EndState endState = new EndState(flow, id); if (finalResponseAction != null) { endState.setFinalResponseAction(finalResponseAction); @@ -203,7 +203,7 @@ public class FlowArtifactFactory { * @return the fully initialized transition instance */ public Transition createTransition(TargetStateResolver targetStateResolver, TransitionCriteria matchingCriteria, - TransitionCriteria executionCriteria, AttributeMap attributes) { + TransitionCriteria executionCriteria, AttributeMap attributes) { Transition transition = new Transition(targetStateResolver); if (matchingCriteria != null) { transition.setMatchingCriteria(matchingCriteria); @@ -221,7 +221,7 @@ public class FlowArtifactFactory { * Configure common properties for a transitionable state. */ private void configureCommonProperties(TransitionableState state, Action[] entryActions, Transition[] transitions, - FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { + FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { configureCommonProperties(state, entryActions, exceptionHandlers, attributes); state.getTransitionSet().addAll(transitions); state.getExitActionList().addAll(exitActions); @@ -231,7 +231,7 @@ public class FlowArtifactFactory { * Configure common properties for a state. */ private void configureCommonProperties(State state, Action[] entryActions, - FlowExecutionExceptionHandler[] exceptionHandlers, AttributeMap attributes) { + FlowExecutionExceptionHandler[] exceptionHandlers, AttributeMap attributes) { state.getEntryActionList().addAll(entryActions); state.getExceptionHandlerSet().addAll(exceptionHandlers); state.getAttributes().putAll(attributes); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowBuilderContext.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowBuilderContext.java index ec9131b9..1875efca 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowBuilderContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/FlowBuilderContext.java @@ -38,7 +38,7 @@ public interface FlowBuilderContext { * Returns externally configured attributes to assign to the flow definition being built. * @return the flow attributes */ - public AttributeMap getFlowAttributes(); + public AttributeMap getFlowAttributes(); /** * Returns the locator for locating dependent flows (subflows). diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java index db544f21..22cf24fb 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilder.java @@ -18,7 +18,6 @@ package org.springframework.webflow.engine.builder.model; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -155,7 +154,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { protected Flow createFlow() { String flowId = getContext().getFlowId(); - AttributeMap flowAttributes = parseFlowMetaAttributes(flowModel); + AttributeMap flowAttributes = parseFlowMetaAttributes(flowModel); flowAttributes = getContext().getFlowAttributes().union(flowAttributes); Flow flow = getLocalContext().getFlowArtifactFactory().createFlow(flowId, flowAttributes); flow.setApplicationContext(getLocalContext().getApplicationContext()); @@ -168,8 +167,8 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { */ public void buildVariables() throws FlowBuilderException { if (flowModel.getVars() != null) { - for (Iterator it = flowModel.getVars().iterator(); it.hasNext();) { - getFlow().addVariable(parseFlowVariable((VarModel) it.next())); + for (VarModel varModel : flowModel.getVars()) { + getFlow().addVariable(parseFlowVariable(varModel)); } } } @@ -198,8 +197,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { if (flowModel.getStates() == null) { throw new FlowBuilderException("At least one state is required to build a Flow"); } - for (Iterator it = flowModel.getStates().iterator(); it.hasNext();) { - AbstractStateModel state = (AbstractStateModel) it.next(); + for (AbstractStateModel state : flowModel.getStates()) { if (state instanceof ActionStateModel) { parseAndAddActionState((ActionStateModel) state, getFlow()); } else if (state instanceof ViewStateModel) { @@ -303,12 +301,11 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { setLocalContext(new LocalFlowBuilderContext(getContext(), flowContext)); } - private Resource[] parseContextResources(List beanImports) { + private Resource[] parseContextResources(List beanImports) { if (beanImports != null && !beanImports.isEmpty()) { Resource flowResource = flowModelHolder.getFlowModelResource(); - List resources = new ArrayList(beanImports.size()); - for (Iterator it = getFlowModel().getBeanImports().iterator(); it.hasNext();) { - BeanImportModel beanImport = (BeanImportModel) it.next(); + List resources = new ArrayList(beanImports.size()); + for (BeanImportModel beanImport : getFlowModel().getBeanImports()) { try { resources.add(flowResource.createRelative(beanImport.getResource())); } catch (IOException e) { @@ -316,7 +313,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { + beanImport.getResource() + "'", e); } } - return (Resource[]) resources.toArray(new Resource[resources.size()]); + return resources.toArray(new Resource[resources.size()]); } else { return new Resource[0]; } @@ -378,25 +375,25 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } } - private AttributeMap parseFlowMetaAttributes(FlowModel flow) { - MutableAttributeMap flowAttributes = parseMetaAttributes(flow.getAttributes()); + private AttributeMap parseFlowMetaAttributes(FlowModel flow) { + MutableAttributeMap flowAttributes = parseMetaAttributes(flow.getAttributes()); parseAndPutPersistenceContext(flow.getPersistenceContext(), flowAttributes); parseAndPutSecured(flow.getSecured(), flowAttributes); return flowAttributes; } private FlowVariable parseFlowVariable(VarModel var) { - Class clazz = toClass(var.getClassName()); + Class clazz = toClass(var.getClassName()); VariableValueFactory valueFactory = new BeanFactoryVariableValueFactory(clazz, getFlow() .getApplicationContext().getAutowireCapableBeanFactory()); return new FlowVariable(var.getName(), valueFactory); } - private Mapper parseFlowInputMapper(List inputs) { + private Mapper parseFlowInputMapper(List inputs) { if (inputs != null && !inputs.isEmpty()) { DefaultMapper inputMapper = new DefaultMapper(); - for (Iterator it = inputs.iterator(); it.hasNext();) { - inputMapper.addMapping(parseFlowInputMapping((InputModel) it.next())); + for (InputModel inputModel : inputs) { + inputMapper.addMapping(parseFlowInputMapping(inputModel)); } return inputMapper; } else { @@ -421,11 +418,11 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { return mapping; } - private Mapper parseSubflowInputMapper(List inputs) { + private Mapper parseSubflowInputMapper(List inputs) { if (inputs != null && !inputs.isEmpty()) { DefaultMapper inputMapper = new DefaultMapper(); - for (Iterator it = inputs.iterator(); it.hasNext();) { - inputMapper.addMapping(parseSubflowInputMapping((InputModel) it.next())); + for (InputModel inputModel : inputs) { + inputMapper.addMapping(parseSubflowInputMapping(inputModel)); } return inputMapper; } else { @@ -450,11 +447,11 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { return mapping; } - private Mapper parseFlowOutputMapper(List outputs) { + private Mapper parseFlowOutputMapper(List outputs) { if (outputs != null && !outputs.isEmpty()) { DefaultMapper outputMapper = new DefaultMapper(); - for (Iterator it = outputs.iterator(); it.hasNext();) { - outputMapper.addMapping(parseFlowOutputMapping((OutputModel) it.next())); + for (OutputModel outputModel : outputs) { + outputMapper.addMapping(parseFlowOutputMapping(outputModel)); } return outputMapper; } else { @@ -479,11 +476,11 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { return mapping; } - private Mapper parseSubflowOutputMapper(List outputs) { + private Mapper parseSubflowOutputMapper(List outputs) { if (outputs != null && !outputs.isEmpty()) { DefaultMapper outputMapper = new DefaultMapper(); - for (Iterator it = outputs.iterator(); it.hasNext();) { - outputMapper.addMapping(parseSubflowOutputMapping((OutputModel) it.next())); + for (OutputModel outputModel : outputs) { + outputMapper.addMapping(parseSubflowOutputMapping(outputModel)); } return outputMapper; } else { @@ -510,7 +507,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { private void parseAndSetMappingConversionExecutor(AbstractMappingModel mappingModel, DefaultMapping mapping) { if (StringUtils.hasText(mappingModel.getType())) { - Class type = toClass(mappingModel.getType()); + Class type = toClass(mappingModel.getType()); ConversionExecutor typeConverter = new RuntimeBindingConversionExecutor(type, getLocalContext() .getConversionService()); mapping.setTypeConverter(typeConverter); @@ -535,7 +532,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { if (StringUtils.hasText(state.getPopup())) { popup = ((Boolean) fromStringTo(Boolean.class).execute(state.getPopup())).booleanValue(); } - MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); + MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); if (state.getModel() != null) { attributes.put( "model", @@ -551,7 +548,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } private void parseAndAddActionState(ActionStateModel state, Flow flow) { - MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); + MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createActionState(state.getId(), flow, parseActions(state.getOnEntryActions()), parseActions(state.getActions()), @@ -561,7 +558,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } private void parseAndAddDecisionState(DecisionStateModel state, Flow flow) { - MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); + MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createDecisionState(state.getId(), flow, parseActions(state.getOnEntryActions()), parseIfs(state.getIfs()), @@ -570,7 +567,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } private void parseAndAddSubflowState(SubflowStateModel state, Flow flow) { - MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); + MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createSubflowState(state.getId(), flow, parseActions(state.getOnEntryActions()), parseSubflowExpression(state.getSubflow()), @@ -580,7 +577,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } private void parseAndAddEndState(EndStateModel state, Flow flow) { - MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); + MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); if (StringUtils.hasText(state.getCommit())) { attributes.put("commit", fromStringTo(Boolean.class).execute(state.getCommit())); } @@ -635,9 +632,8 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { private BinderConfiguration createBinderConfiguration(BinderModel binderModel) { if (binderModel != null && binderModel.getBindings() != null) { BinderConfiguration binderConfiguration = new BinderConfiguration(); - List bindings = binderModel.getBindings(); - for (Iterator it = bindings.iterator(); it.hasNext();) { - BindingModel bindingModel = (BindingModel) it.next(); + List bindings = binderModel.getBindings(); + for (BindingModel bindingModel : bindings) { boolean required; if (StringUtils.hasText(bindingModel.getRequired())) { required = ((Boolean) fromStringTo(Boolean.class).execute(bindingModel.getRequired())) @@ -654,32 +650,32 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } } - private ViewVariable[] parseViewVariables(List vars) { + private ViewVariable[] parseViewVariables(List vars) { if (vars != null && !vars.isEmpty()) { - List variables = new ArrayList(vars.size()); - for (Iterator it = vars.iterator(); it.hasNext();) { - variables.add(parseViewVariable((VarModel) it.next())); + List variables = new ArrayList(vars.size()); + for (VarModel varModel : vars) { + variables.add(parseViewVariable(varModel)); } - return (ViewVariable[]) variables.toArray(new ViewVariable[variables.size()]); + return variables.toArray(new ViewVariable[variables.size()]); } else { return new ViewVariable[0]; } } private ViewVariable parseViewVariable(VarModel var) { - Class clazz = toClass(var.getClassName()); + Class clazz = toClass(var.getClassName()); VariableValueFactory valueFactory = new BeanFactoryVariableValueFactory(clazz, getFlow() .getApplicationContext().getAutowireCapableBeanFactory()); return new ViewVariable(var.getName(), valueFactory); } - private Transition[] parseIfs(List ifModels) { + private Transition[] parseIfs(List ifModels) { if (ifModels != null && !ifModels.isEmpty()) { - List transitions = new ArrayList(ifModels.size()); - for (Iterator it = ifModels.iterator(); it.hasNext();) { - transitions.addAll(Arrays.asList(parseIf((IfModel) it.next()))); + List transitions = new ArrayList(ifModels.size()); + for (IfModel ifModel : ifModels) { + transitions.addAll(Arrays.asList(parseIf(ifModel))); } - return (Transition[]) transitions.toArray(new Transition[transitions.size()]); + return transitions.toArray(new Transition[transitions.size()]); } else { return new Transition[0]; } @@ -720,8 +716,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { private SubflowAttributeMapper parseSubflowAttributeMapper(SubflowStateModel state) { if (StringUtils.hasText(state.getSubflowAttributeMapper())) { String beanId = state.getSubflowAttributeMapper(); - return (SubflowAttributeMapper) getLocalContext().getApplicationContext().getBean(beanId, - SubflowAttributeMapper.class); + return getLocalContext().getApplicationContext().getBean(beanId, SubflowAttributeMapper.class); } else { Mapper inputMapper = parseSubflowInputMapper(state.getInputs()); Mapper outputMapper = parseSubflowOutputMapper(state.getOutputs()); @@ -729,7 +724,8 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } } - private FlowExecutionExceptionHandler[] parseExceptionHandlers(List modelExceptionHandlers, List modelTransitions) { + private FlowExecutionExceptionHandler[] parseExceptionHandlers(List modelExceptionHandlers, + List modelTransitions) { FlowExecutionExceptionHandler[] transitionExecutingHandlers = parseTransitionExecutingExceptionHandlers(modelTransitions); FlowExecutionExceptionHandler[] customHandlers = parseCustomExceptionHandlers(modelExceptionHandlers); FlowExecutionExceptionHandler[] exceptionHandlers = new FlowExecutionExceptionHandler[transitionExecutingHandlers.length @@ -740,11 +736,12 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { return exceptionHandlers; } - private FlowExecutionExceptionHandler[] parseTransitionExecutingExceptionHandlers(List transitionModels) { + private FlowExecutionExceptionHandler[] parseTransitionExecutingExceptionHandlers( + List transitionModels) { if (transitionModels != null && !transitionModels.isEmpty()) { - List exceptionHandlers = new ArrayList(transitionModels.size()); - for (Iterator it = transitionModels.iterator(); it.hasNext();) { - TransitionModel model = (TransitionModel) it.next(); + List exceptionHandlers = new ArrayList( + transitionModels.size()); + for (TransitionModel model : transitionModels) { if (StringUtils.hasText(model.getOnException())) { if (model.getSecured() != null) { throw new FlowBuilderException("Exception based transitions cannot be secured"); @@ -752,8 +749,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { exceptionHandlers.add(parseTransitionExecutingExceptionHandler(model)); } } - return (FlowExecutionExceptionHandler[]) exceptionHandlers - .toArray(new FlowExecutionExceptionHandler[exceptionHandlers.size()]); + return exceptionHandlers.toArray(new FlowExecutionExceptionHandler[exceptionHandlers.size()]); } else { return new FlowExecutionExceptionHandler[0]; } @@ -761,7 +757,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { private FlowExecutionExceptionHandler parseTransitionExecutingExceptionHandler(TransitionModel transition) { TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); - Class exceptionClass = toClass(transition.getOnException()); + Class exceptionClass = toClass(transition.getOnException(), Throwable.class); TargetStateResolver targetStateResolver = (TargetStateResolver) fromStringTo(TargetStateResolver.class) .execute(transition.getTo()); handler.add(exceptionClass, targetStateResolver); @@ -769,36 +765,36 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { return handler; } - private FlowExecutionExceptionHandler[] parseCustomExceptionHandlers(List exceptionHandlerModels) { + private FlowExecutionExceptionHandler[] parseCustomExceptionHandlers( + List exceptionHandlerModels) { if (exceptionHandlerModels != null && !exceptionHandlerModels.isEmpty()) { - List exceptionHandlers = new ArrayList(exceptionHandlerModels.size()); - for (Iterator it = exceptionHandlerModels.iterator(); it.hasNext();) { - exceptionHandlers.add(parseCustomExceptionHandler((ExceptionHandlerModel) it.next())); + List exceptionHandlers = new ArrayList( + exceptionHandlerModels.size()); + for (ExceptionHandlerModel exceptionHandlerModel : exceptionHandlerModels) { + exceptionHandlers.add(parseCustomExceptionHandler(exceptionHandlerModel)); } - return (FlowExecutionExceptionHandler[]) exceptionHandlers - .toArray(new FlowExecutionExceptionHandler[exceptionHandlers.size()]); + return exceptionHandlers.toArray(new FlowExecutionExceptionHandler[exceptionHandlers.size()]); } else { return new FlowExecutionExceptionHandler[0]; } } private FlowExecutionExceptionHandler parseCustomExceptionHandler(ExceptionHandlerModel exceptionHandler) { - return (FlowExecutionExceptionHandler) getLocalContext().getApplicationContext().getBean( - exceptionHandler.getBean(), FlowExecutionExceptionHandler.class); + return getLocalContext().getApplicationContext().getBean(exceptionHandler.getBean(), + FlowExecutionExceptionHandler.class); } - private Transition[] parseTransitions(List transitionModels) { + private Transition[] parseTransitions(List transitionModels) { if (transitionModels != null && !transitionModels.isEmpty()) { - List transitions = new ArrayList(transitionModels.size()); + List transitions = new ArrayList(transitionModels.size()); if (transitionModels != null) { - for (Iterator it = transitionModels.iterator(); it.hasNext();) { - TransitionModel transition = (TransitionModel) it.next(); + for (TransitionModel transition : transitionModels) { if (!StringUtils.hasText(transition.getOnException())) { transitions.add(parseTransition(transition)); } } } - return (Transition[]) transitions.toArray(new Transition[transitions.size()]); + return transitions.toArray(new Transition[transitions.size()]); } else { return new Transition[0]; } @@ -811,7 +807,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { transition.getTo()); TransitionCriteria executionCriteria = TransitionCriteriaChain.criteriaChainFor(parseActions(transition .getActions())); - MutableAttributeMap attributes = parseMetaAttributes(transition.getAttributes()); + MutableAttributeMap attributes = parseMetaAttributes(transition.getAttributes()); if (StringUtils.hasText(transition.getBind())) { attributes.put("bind", fromStringTo(Boolean.class).execute(transition.getBind())); } @@ -826,11 +822,10 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { executionCriteria, attributes); } - private Action[] parseActions(List actionModels) { + private Action[] parseActions(List actionModels) { if (actionModels != null && !actionModels.isEmpty()) { - List actions = new ArrayList(actionModels.size()); - for (Iterator it = actionModels.iterator(); it.hasNext();) { - AbstractActionModel actionModel = (AbstractActionModel) it.next(); + List actions = new ArrayList(actionModels.size()); + for (AbstractActionModel actionModel : actionModels) { Action action; if (actionModel instanceof EvaluateModel) { action = parseEvaluateAction((EvaluateModel) actionModel); @@ -847,7 +842,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { actions.add(annotatedAction); } } - return (Action[]) actions.toArray(new Action[actions.size()]); + return actions.toArray(new Action[actions.size()]); } else { return new Action[0]; } @@ -893,19 +888,19 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { return new SetAction(nameExpression, valueExpression); } - private MutableAttributeMap parseMetaAttributes(List attributeModels) { + private MutableAttributeMap parseMetaAttributes(List attributeModels) { if (attributeModels != null && !attributeModels.isEmpty()) { - LocalAttributeMap attributes = new LocalAttributeMap(); - for (Iterator it = attributeModels.iterator(); it.hasNext();) { - parseAndPutMetaAttribute((AttributeModel) it.next(), attributes); + LocalAttributeMap attributes = new LocalAttributeMap(); + for (AttributeModel attributeModel : attributeModels) { + parseAndPutMetaAttribute(attributeModel, attributes); } return attributes; } else { - return new LocalAttributeMap(); + return new LocalAttributeMap(); } } - private void parseAndPutMetaAttribute(AttributeModel attribute, MutableAttributeMap attributes) { + private void parseAndPutMetaAttribute(AttributeModel attribute, MutableAttributeMap attributes) { String name = attribute.getName(); String value = attribute.getValue(); attributes.put(name, parseAttributeValueIfNecessary(attribute, value)); @@ -913,7 +908,7 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { private Object parseAttributeValueIfNecessary(AttributeModel attribute, String stringValue) { if (StringUtils.hasText(attribute.getType())) { - Class targetClass = toClass(attribute.getType()); + Class targetClass = toClass(attribute.getType()); return fromStringTo(targetClass).execute(stringValue); } else { return stringValue; @@ -921,13 +916,13 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } private void parseAndPutPersistenceContext(PersistenceContextModel persistenceContext, - MutableAttributeMap attributes) { + MutableAttributeMap attributes) { if (persistenceContext != null) { attributes.put("persistenceContext", Boolean.TRUE); } } - private void parseAndPutSecured(SecuredModel secured, MutableAttributeMap attributes) { + private void parseAndPutSecured(SecuredModel secured, MutableAttributeMap attributes) { if (secured != null) { SecurityRule rule = new SecurityRule(); rule.setAttributes(SecurityRule.commaDelimitedListToSecurityAttributes(secured.getAttributes())); @@ -944,12 +939,12 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } } - private ConversionExecutor fromStringTo(Class targetType) throws ConversionExecutionException { + private ConversionExecutor fromStringTo(Class targetType) throws ConversionExecutionException { return getLocalContext().getConversionService().getConversionExecutor(String.class, targetType); } - private Class toClass(String name) { - Class clazz = getLocalContext().getConversionService().getClassForAlias(name); + private Class toClass(String name) { + Class clazz = getLocalContext().getConversionService().getClassForAlias(name); if (clazz != null) { return clazz; } else { @@ -962,6 +957,13 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder { } } + @SuppressWarnings("unchecked") + private Class toClass(String name, Class superType) { + Class clazz = toClass(name); + Assert.isAssignable(superType, clazz); + return (Class) clazz; + } + public String toString() { return new ToStringCreator(this).append("flowModelResource", flowModelHolder.getFlowModelResource()).toString(); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/LocalFlowBuilderContext.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/LocalFlowBuilderContext.java index bd55c800..37056d3d 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/LocalFlowBuilderContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/LocalFlowBuilderContext.java @@ -50,7 +50,7 @@ class LocalFlowBuilderContext implements FlowBuilderContext { return parent.getFlowId(); } - public AttributeMap getFlowAttributes() { + public AttributeMap getFlowAttributes() { return parent.getFlowAttributes(); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/SubflowExpression.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/SubflowExpression.java index a0d1d2ac..932e6c40 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/SubflowExpression.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/model/SubflowExpression.java @@ -39,7 +39,7 @@ class SubflowExpression implements Expression { throw new UnsupportedOperationException("Cannot set a subflow expression"); } - public Class getValueType(Object context) { + public Class getValueType(Object context) { return null; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/AbstractFlowBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/AbstractFlowBuilder.java index 574b16d4..90fc43b7 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/AbstractFlowBuilder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/AbstractFlowBuilder.java @@ -61,7 +61,7 @@ public abstract class AbstractFlowBuilder implements FlowBuilder { */ protected Flow createFlow() { String id = getContext().getFlowId(); - AttributeMap attributes = getContext().getFlowAttributes(); + AttributeMap attributes = getContext().getFlowAttributes(); return getContext().getFlowArtifactFactory().createFlow(id, attributes); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderContextImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderContextImpl.java index 60fd08b0..aa3e2a8e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderContextImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/FlowBuilderContextImpl.java @@ -40,7 +40,7 @@ public class FlowBuilderContextImpl implements FlowBuilderContext { private String flowId; - private AttributeMap flowAttributes; + private AttributeMap flowAttributes; private FlowDefinitionLocator flowDefinitionLocator; @@ -55,7 +55,7 @@ public class FlowBuilderContextImpl implements FlowBuilderContext { * @param flowDefinitionLocator a locator to find dependent subflows * @param flowBuilderServices a parameter object providing access to additional services needed by the flow builder */ - public FlowBuilderContextImpl(String flowId, AttributeMap flowAttributes, + public FlowBuilderContextImpl(String flowId, AttributeMap flowAttributes, FlowDefinitionLocator flowDefinitionLocator, FlowBuilderServices flowBuilderServices) { Assert.hasText(flowId, "The flow id is required"); Assert.notNull(flowDefinitionLocator, "The flow definition locator is required"); @@ -77,7 +77,7 @@ public class FlowBuilderContextImpl implements FlowBuilderContext { return flowId; } - public AttributeMap getFlowAttributes() { + public AttributeMap getFlowAttributes() { return flowAttributes; } @@ -124,7 +124,7 @@ public class FlowBuilderContextImpl implements FlowBuilderContext { return service; } - private void initFlowAttributes(AttributeMap flowAttributes) { + private void initFlowAttributes(AttributeMap flowAttributes) { if (flowAttributes != null) { this.flowAttributes = flowAttributes; } else { @@ -136,32 +136,30 @@ public class FlowBuilderContextImpl implements FlowBuilderContext { * A little proxy that refreshes the externally configured conversion service reference on each invocation. */ private class ParentConversionServiceProxy implements ConversionService { - public Object executeConversion(Object source, Class targetClass) throws ConversionException { + public Object executeConversion(Object source, Class targetClass) throws ConversionException { return getFlowBuilderServices().getConversionService().executeConversion(source, targetClass); } - public Object executeConversion(String converterId, Object source, Class targetClass) { + public Object executeConversion(String converterId, Object source, Class targetClass) { return getFlowBuilderServices().getConversionService().executeConversion(converterId, source, targetClass); } - public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) throws ConversionExecutionException { return getFlowBuilderServices().getConversionService().getConversionExecutor(sourceClass, targetClass); } - public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) throws ConversionExecutorNotFoundException { return getFlowBuilderServices().getConversionService().getConversionExecutor(id, sourceClass, targetClass); } - public Class getClassForAlias(String name) { + public Class getClassForAlias(String name) { return getFlowBuilderServices().getConversionService().getClassForAlias(name); } public org.springframework.core.convert.ConversionService getDelegateConversionService() { return getFlowBuilderServices().getConversionService().getDelegateConversionService(); } - } - } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/TextToTargetStateResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/TextToTargetStateResolver.java index ac17331d..ac578e24 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/TextToTargetStateResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/TextToTargetStateResolver.java @@ -31,7 +31,7 @@ import org.springframework.webflow.execution.RequestContext; *

    * This converter supports the following encoded forms: *

      - *
    • "stateId" - will result in a TargetStateResolver that always resolves the same state.
    • + *
    • "stateId" - will result in a TargetStateResolver that always resolves the same state.
    • *
    • "${stateIdExpression} - will result in a TargetStateResolver that resolves the target state by evaluating an * expression against the request context. The resolved value can be a target state identifier or a custom * TargetStateResolver to delegate to.
    • @@ -55,22 +55,22 @@ class TextToTargetStateResolver implements Converter { this.flowBuilderContext = flowBuilderContext; } - public Class getSourceClass() { + public Class getSourceClass() { return String.class; } - public Class getTargetClass() { + public Class getTargetClass() { return TargetStateResolver.class; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { String targetStateId = (String) source; if (!StringUtils.hasText(targetStateId)) { return null; } ExpressionParser parser = flowBuilderContext.getExpressionParser(); - Expression expression = parser.parseExpression(targetStateId, new FluentParserContext().template().evaluate( - RequestContext.class).expectResult(String.class)); + Expression expression = parser.parseExpression(targetStateId, + new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)); return new DefaultTargetStateResolver(expression); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/TextToTransitionCriteria.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/TextToTransitionCriteria.java index 5122aa0e..2eba6555 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/TextToTransitionCriteria.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/builder/support/TextToTransitionCriteria.java @@ -33,10 +33,10 @@ import org.springframework.webflow.execution.RequestContext; *

      * This converter supports the following encoded forms: *

        - *
      • "*" - will result in a TransitionCriteria object that matches on everything.
      • - *
      • "eventId" - will result in a TransitionCriteria object that matches given event id.
      • - *
      • "${...}" - will result in a TransitionCriteria object that evaluates given condition, expressed as an - * expression.
      • + *
      • "*" - will result in a TransitionCriteria object that matches on everything.
      • + *
      • "eventId" - will result in a TransitionCriteria object that matches given event id.
      • + *
      • "${...}" - will result in a TransitionCriteria object that evaluates given condition, expressed as an expression. + *
      • *
      * * @see org.springframework.webflow.engine.TransitionCriteria @@ -59,15 +59,15 @@ class TextToTransitionCriteria implements Converter { this.flowBuilderContext = flowBuilderContext; } - public Class getSourceClass() { + public Class getSourceClass() { return String.class; } - public Class getTargetClass() { + public Class getTargetClass() { return TransitionCriteria.class; } - public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { + public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception { String encodedCriteria = (String) source; ExpressionParser parser = flowBuilderContext.getExpressionParser(); if (!StringUtils.hasText(encodedCriteria) @@ -88,8 +88,8 @@ class TextToTransitionCriteria implements Converter { */ protected TransitionCriteria createBooleanExpressionTransitionCriteria(String encodedCriteria, ExpressionParser parser) throws ConversionExecutionException { - Expression expression = parser.parseExpression(encodedCriteria, new FluentParserContext().template().evaluate( - RequestContext.class)); + Expression expression = parser.parseExpression(encodedCriteria, + new FluentParserContext().template().evaluate(RequestContext.class)); return new DefaultTransitionCriteria(expression); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImpl.java index 161a1def..b0bc9869 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImpl.java @@ -92,7 +92,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { * The stack of active, currently executing flow sessions. As subflows are spawned, they are pushed onto the stack. * As they end, they are popped off the stack. */ - private LinkedList flowSessions; + private LinkedList flowSessions; /** * A thread-safe listener list, holding listeners monitoring the lifecycle of this flow execution. @@ -116,14 +116,14 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { *

      * Transient to support restoration by the {@link FlowExecutionImplFactory}. */ - private transient MutableAttributeMap conversationScope; + private transient MutableAttributeMap conversationScope; /** * A data structure for runtime system execution attributes. *

      * Transient to support restoration by the {@link FlowExecutionImplFactory}. */ - private transient AttributeMap attributes; + private transient AttributeMap attributes; /** * The outcome reached by this flow execution when it ends. @@ -147,9 +147,9 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { status = FlowExecutionStatus.NOT_STARTED; listeners = new FlowExecutionListeners(); attributes = CollectionUtils.EMPTY_ATTRIBUTE_MAP; - flowSessions = new LinkedList(); - conversationScope = new LocalAttributeMap(); - conversationScope.put(FLASH_SCOPE_ATTRIBUTE, new LocalAttributeMap()); + flowSessions = new LinkedList(); + conversationScope = new LocalAttributeMap(); + conversationScope.put(FLASH_SCOPE_ATTRIBUTE, new LocalAttributeMap()); } public String getCaption() { @@ -194,21 +194,22 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { return getActiveSessionInternal(); } - public MutableAttributeMap getFlashScope() { - return (MutableAttributeMap) conversationScope.get(FLASH_SCOPE_ATTRIBUTE); + @SuppressWarnings("unchecked") + public MutableAttributeMap getFlashScope() { + return (MutableAttributeMap) conversationScope.get(FLASH_SCOPE_ATTRIBUTE); } - public MutableAttributeMap getConversationScope() { + public MutableAttributeMap getConversationScope() { return conversationScope; } - public AttributeMap getAttributes() { + public AttributeMap getAttributes() { return attributes; } // methods implementing FlowExecution - public void start(MutableAttributeMap input, ExternalContext externalContext) throws FlowExecutionException, + public void start(MutableAttributeMap input, ExternalContext externalContext) throws FlowExecutionException, IllegalStateException { Assert.state(!hasStarted(), "This flow has already been started; you cannot call 'start()' more than once"); if (logger.isDebugEnabled()) { @@ -299,9 +300,10 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { // custom serialization (implementation of Externalizable for optimized storage) + @SuppressWarnings("unchecked") public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { status = (FlowExecutionStatus) in.readObject(); - flowSessions = (LinkedList) in.readObject(); + flowSessions = (LinkedList) in.readObject(); } public void writeExternal(ObjectOutput out) throws IOException { @@ -348,14 +350,14 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { // package private request control context callbacks - void start(Flow flow, MutableAttributeMap input, RequestControlContext context) { + void start(Flow flow, MutableAttributeMap input, RequestControlContext context) { listeners.fireSessionCreating(context, flow); FlowSessionImpl session = activateSession(flow); if (session.isRoot()) { status = FlowExecutionStatus.ACTIVE; } if (input == null) { - input = new LocalAttributeMap(); + input = new LocalAttributeMap(); } if (hasEmbeddedModeAttribute(input)) { session.setEmbeddedMode(); @@ -393,7 +395,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { return transition.execute((State) getActiveSession().getState(), context); } - void endActiveFlowSession(String outcome, MutableAttributeMap output, RequestControlContext context) { + void endActiveFlowSession(String outcome, MutableAttributeMap output, RequestControlContext context) { FlowSessionImpl session = getActiveSessionInternal(); listeners.fireSessionEnding(context, session, outcome, output); session.getFlow().end(context, outcome, output); @@ -456,7 +458,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { this.listeners = new FlowExecutionListeners(listeners); } - void setAttributes(AttributeMap attributes) { + void setAttributes(AttributeMap attributes) { this.attributes = attributes; } @@ -473,7 +475,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { /** * Returns the list of flow session maintained by this flow execution. */ - LinkedList getFlowSessions() { + LinkedList getFlowSessions() { return flowSessions; } @@ -495,13 +497,13 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { * Returns the flow session for the root flow of this flow execution. */ FlowSessionImpl getRootSession() { - return (FlowSessionImpl) flowSessions.getFirst(); + return flowSessions.getFirst(); } /** * Returns an iterator looping over the subflow sessions in this flow execution. */ - Iterator getSubflowSessionIterator() { + Iterator getSubflowSessionIterator() { return flowSessions.listIterator(1); } @@ -515,7 +517,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { /** * Restore conversation scope for this flow execution. */ - void setConversationScope(MutableAttributeMap conversationScope) { + void setConversationScope(MutableAttributeMap conversationScope) { this.conversationScope = conversationScope; } @@ -554,7 +556,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { if (flowSessions.isEmpty()) { return null; } - return (FlowSessionImpl) flowSessions.getLast(); + return flowSessions.getLast(); } private void saveFlashMessages(RequestContext context) { @@ -645,7 +647,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable { return getActiveSessionInternal().getFlow().handleException(exception, context); } - private boolean hasEmbeddedModeAttribute(AttributeMap input) { + private boolean hasEmbeddedModeAttribute(AttributeMap input) { if (input != null) { String mode = (String) input.get("mode"); if (mode != null && mode.trim().toLowerCase().equals("embedded")) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactory.java index 478388d7..5bb67d03 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactory.java @@ -42,7 +42,7 @@ public class FlowExecutionImplFactory implements FlowExecutionFactory { private static final Log logger = LogFactory.getLog(FlowExecutionImplFactory.class); - private AttributeMap executionAttributes = CollectionUtils.EMPTY_ATTRIBUTE_MAP; + private AttributeMap executionAttributes = CollectionUtils.EMPTY_ATTRIBUTE_MAP; private FlowExecutionListenerLoader executionListenerLoader = StaticFlowExecutionListenerLoader.EMPTY_INSTANCE; @@ -53,7 +53,7 @@ public class FlowExecutionImplFactory implements FlowExecutionFactory { * execution behavior. * @param executionAttributes flow execution system attributes */ - public void setExecutionAttributes(AttributeMap executionAttributes) { + public void setExecutionAttributes(AttributeMap executionAttributes) { this.executionAttributes = executionAttributes; } @@ -85,7 +85,7 @@ public class FlowExecutionImplFactory implements FlowExecutionFactory { } public FlowExecution restoreFlowExecution(FlowExecution flowExecution, FlowDefinition flowDefinition, - FlowExecutionKey flowExecutionKey, MutableAttributeMap conversationScope, + FlowExecutionKey flowExecutionKey, MutableAttributeMap conversationScope, FlowDefinitionLocator subflowDefinitionLocator) { Assert.isInstanceOf(FlowExecutionImpl.class, flowExecution, "FlowExecution is of the wrong type: "); Assert.isInstanceOf(Flow.class, flowDefinition, "FlowDefinition is of the wrong type: "); @@ -97,8 +97,8 @@ public class FlowExecutionImplFactory implements FlowExecutionFactory { rootSession.setFlow(flow); rootSession.setState(flow.getStateInstance(rootSession.getStateId())); if (execution.hasSubflowSessions()) { - for (Iterator it = execution.getSubflowSessionIterator(); it.hasNext();) { - FlowSessionImpl subflowSession = (FlowSessionImpl) it.next(); + for (Iterator it = execution.getSubflowSessionIterator(); it.hasNext();) { + FlowSessionImpl subflowSession = it.next(); Flow subflowDef = (Flow) subflowDefinitionLocator.getFlowDefinition(subflowSession.getFlowId()); subflowSession.setFlow(subflowDef); subflowSession.setState(subflowDef.getStateInstance(subflowSession.getStateId())); @@ -107,7 +107,7 @@ public class FlowExecutionImplFactory implements FlowExecutionFactory { } execution.setKey(flowExecutionKey); if (conversationScope == null) { - conversationScope = new LocalAttributeMap(); + conversationScope = new LocalAttributeMap(); } execution.setConversationScope(conversationScope); execution.setAttributes(executionAttributes); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionListeners.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionListeners.java index 1e23443d..fcf52940 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionListeners.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowExecutionListeners.java @@ -85,8 +85,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a request was submitted to the flow execution. */ public void fireRequestSubmitted(RequestContext context) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].requestSubmitted(context); + for (FlowExecutionListener listener : listeners) { + listener.requestSubmitted(context); } } @@ -94,8 +94,8 @@ class FlowExecutionListeners { * Notify all interested listeners that the flow execution finished processing a request. */ public void fireRequestProcessed(RequestContext context) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].requestProcessed(context); + for (FlowExecutionListener listener : listeners) { + listener.requestProcessed(context); } } @@ -103,8 +103,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a flow execution session is starting (about to be created). */ public void fireSessionCreating(RequestContext context, FlowDefinition flow) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].sessionCreating(context, flow); + for (FlowExecutionListener listener : listeners) { + listener.sessionCreating(context, flow); } } @@ -112,9 +112,9 @@ class FlowExecutionListeners { * Notify all interested listeners that a flow execution session has been activated (created, on the stack and about * to start). */ - public void fireSessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].sessionStarting(context, session, input); + public void fireSessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { + for (FlowExecutionListener listener : listeners) { + listener.sessionStarting(context, session, input); } } @@ -122,8 +122,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a flow execution session has started (has entered its start state). */ public void fireSessionStarted(RequestContext context, FlowSession session) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].sessionStarted(context, session); + for (FlowExecutionListener listener : listeners) { + listener.sessionStarted(context, session); } } @@ -131,8 +131,8 @@ class FlowExecutionListeners { * Notify all interested listeners that an event was signaled in the flow execution. */ public void fireEventSignaled(RequestContext context, Event event) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].eventSignaled(context, event); + for (FlowExecutionListener listener : listeners) { + listener.eventSignaled(context, event); } } @@ -140,8 +140,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a state is being entered in the flow execution. */ public void fireStateEntering(RequestContext context, StateDefinition nextState) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].stateEntering(context, nextState); + for (FlowExecutionListener listener : listeners) { + listener.stateEntering(context, nextState); } } @@ -149,8 +149,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a state was entered in the flow execution. */ public void fireStateEntered(RequestContext context, StateDefinition previousState) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].stateEntered(context, previousState, context.getCurrentState()); + for (FlowExecutionListener listener : listeners) { + listener.stateEntered(context, previousState, context.getCurrentState()); } } @@ -158,8 +158,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a flow execution view is rendering. */ public void fireViewRendering(RequestContext context, View view) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].viewRendering(context, view, context.getCurrentState()); + for (FlowExecutionListener listener : listeners) { + listener.viewRendering(context, view, context.getCurrentState()); } } @@ -167,8 +167,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a flow execution has rendered. */ public void fireViewRendered(RequestContext context, View view) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].viewRendered(context, view, context.getCurrentState()); + for (FlowExecutionListener listener : listeners) { + listener.viewRendered(context, view, context.getCurrentState()); } } @@ -176,8 +176,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a transition is being entered in the flow execution. */ public void fireTransitionExecuting(RequestContext context, TransitionDefinition transition) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].transitionExecuting(context, transition); + for (FlowExecutionListener listener : listeners) { + listener.transitionExecuting(context, transition); } } @@ -185,8 +185,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a flow session was paused in the flow execution. */ public void firePaused(RequestContext context) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].paused(context); + for (FlowExecutionListener listener : listeners) { + listener.paused(context); } } @@ -194,8 +194,8 @@ class FlowExecutionListeners { * Notify all interested listeners that the flow execution was resumed. */ public void fireResuming(RequestContext context) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].resuming(context); + for (FlowExecutionListener listener : listeners) { + listener.resuming(context); } } @@ -203,18 +203,18 @@ class FlowExecutionListeners { * Notify all interested listeners that the active flow execution session is ending. */ public void fireSessionEnding(RequestContext context, FlowSession session, String outcomeId, - MutableAttributeMap output) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].sessionEnding(context, session, outcomeId, output); + MutableAttributeMap output) { + for (FlowExecutionListener listener : listeners) { + listener.sessionEnding(context, session, outcomeId, output); } } /** * Notify all interested listeners that a flow execution session has ended. */ - public void fireSessionEnded(RequestContext context, FlowSession session, String outcomeId, AttributeMap output) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].sessionEnded(context, session, outcomeId, output); + public void fireSessionEnded(RequestContext context, FlowSession session, String outcomeId, AttributeMap output) { + for (FlowExecutionListener listener : listeners) { + listener.sessionEnded(context, session, outcomeId, output); } } @@ -222,8 +222,8 @@ class FlowExecutionListeners { * Notify all interested listeners that a flow execution threw an exception. */ public void fireExceptionThrown(RequestContext context, FlowExecutionException exception) { - for (int i = 0; i < listeners.length; i++) { - listeners[i].exceptionThrown(context, exception); + for (FlowExecutionListener listener : listeners) { + listener.exceptionThrown(context, exception); } } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowSessionImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowSessionImpl.java index 85e70122..42f1de6b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowSessionImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowSessionImpl.java @@ -61,7 +61,7 @@ class FlowSessionImpl implements FlowSession, Externalizable { /** * The session data model ("flow scope"). */ - private MutableAttributeMap scope = new LocalAttributeMap(); + private MutableAttributeMap scope = new LocalAttributeMap(); /** * The parent session of this session (may be null if this is a root session.) @@ -105,11 +105,12 @@ class FlowSessionImpl implements FlowSession, Externalizable { return state; } - public MutableAttributeMap getScope() { + public MutableAttributeMap getScope() { return scope; } - public MutableAttributeMap getViewScope() throws IllegalStateException { + @SuppressWarnings("unchecked") + public MutableAttributeMap getViewScope() throws IllegalStateException { if (state == null) { throw new IllegalStateException("The current state of this flow '" + flow.getId() + "' is [null] - cannot access view scope"); @@ -118,7 +119,7 @@ class FlowSessionImpl implements FlowSession, Externalizable { throw new IllegalStateException("The current state '" + state.getId() + "' of this flow '" + flow.getId() + "' is not a view state - view scope not accessible"); } - return (MutableAttributeMap) scope.get(VIEW_SCOPE_ATTRIBUTE); + return (MutableAttributeMap) scope.get(VIEW_SCOPE_ATTRIBUTE); } public boolean isEmbeddedMode() { @@ -147,10 +148,11 @@ class FlowSessionImpl implements FlowSession, Externalizable { // custom serialization + @SuppressWarnings("unchecked") public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { flowId = (String) in.readObject(); stateId = (String) in.readObject(); - scope = (MutableAttributeMap) in.readObject(); + scope = (MutableAttributeMap) in.readObject(); parent = (FlowSessionImpl) in.readObject(); } @@ -244,7 +246,7 @@ class FlowSessionImpl implements FlowSession, Externalizable { * Initialize the view scope data structure. */ private void initViewScope() { - scope.put(VIEW_SCOPE_ATTRIBUTE, new LocalAttributeMap()); + scope.put(VIEW_SCOPE_ATTRIBUTE, new LocalAttributeMap()); } /** diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/RequestControlContextImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/RequestControlContextImpl.java index 5b4a515d..5da31b96 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/RequestControlContextImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/RequestControlContextImpl.java @@ -64,12 +64,12 @@ class RequestControlContextImpl implements RequestControlContext { /** * The request scope data map. Never null, initially empty. */ - private LocalAttributeMap requestScope = new LocalAttributeMap(); + private LocalAttributeMap requestScope = new LocalAttributeMap(); /** * Holder for contextual properties describing the currently executing request; never null, initially empty. */ - private LocalAttributeMap attributes = new LocalAttributeMap(); + private LocalAttributeMap attributes = new LocalAttributeMap(); /** * The current event being processed by this flow; initially null. @@ -114,11 +114,11 @@ class RequestControlContextImpl implements RequestControlContext { return flowExecution.getMatchingTransition(eventId); } - public MutableAttributeMap getRequestScope() { + public MutableAttributeMap getRequestScope() { return requestScope; } - public MutableAttributeMap getFlashScope() { + public MutableAttributeMap getFlashScope() { return flowExecution.getFlashScope(); } @@ -126,15 +126,15 @@ class RequestControlContextImpl implements RequestControlContext { return flowExecution.isActive() && getCurrentState() != null && getCurrentState().isViewState(); } - public MutableAttributeMap getViewScope() throws IllegalStateException { + public MutableAttributeMap getViewScope() throws IllegalStateException { return flowExecution.getActiveSession().getViewScope(); } - public MutableAttributeMap getFlowScope() { + public MutableAttributeMap getFlowScope() { return flowExecution.getActiveSession().getScope(); } - public MutableAttributeMap getConversationScope() { + public MutableAttributeMap getConversationScope() { return flowExecution.getConversationScope(); } @@ -166,7 +166,7 @@ class RequestControlContextImpl implements RequestControlContext { return currentView; } - public MutableAttributeMap getAttributes() { + public MutableAttributeMap getAttributes() { return attributes; } @@ -230,11 +230,11 @@ class RequestControlContextImpl implements RequestControlContext { flowExecution.removeAllFlowExecutionSnapshots(); } - public void start(Flow flow, MutableAttributeMap input) throws FlowExecutionException { + public void start(Flow flow, MutableAttributeMap input) throws FlowExecutionException { flowExecution.start(flow, input, this); } - public void endActiveFlowSession(String outcome, MutableAttributeMap output) throws IllegalStateException { + public void endActiveFlowSession(String outcome, MutableAttributeMap output) throws IllegalStateException { flowExecution.endActiveFlowSession(outcome, output, this); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractActionModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractActionModel.java index 63b48b3e..44c66bfe 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractActionModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractActionModel.java @@ -24,7 +24,7 @@ import java.util.LinkedList; */ public abstract class AbstractActionModel extends AbstractModel { - private LinkedList attributes; + private LinkedList attributes; /** * Actions are not mergeable @@ -49,14 +49,14 @@ public abstract class AbstractActionModel extends AbstractModel { /** * @return the attributes */ - public LinkedList getAttributes() { + public LinkedList getAttributes() { return attributes; } /** * @param attributes the attributes to set */ - public void setAttributes(LinkedList attributes) { + public void setAttributes(LinkedList attributes) { this.attributes = attributes; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractModel.java index 4958e34a..6d5e2763 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractModel.java @@ -80,7 +80,7 @@ public abstract class AbstractModel implements Model { * @param parent the parent list to merge * @return the merged list */ - protected LinkedList merge(LinkedList child, LinkedList parent) { + protected LinkedList merge(LinkedList child, LinkedList parent) { return merge(child, parent, true); } @@ -92,7 +92,8 @@ public abstract class AbstractModel implements Model { * @param addAtEnd if true new items will be added at the end of the list, otherwise the beginning * @return the merged list */ - protected LinkedList merge(LinkedList child, LinkedList parent, boolean addAtEnd) { + @SuppressWarnings("unchecked") + protected LinkedList merge(LinkedList child, LinkedList parent, boolean addAtEnd) { if (child == null) { if (parent == null) { return null; @@ -103,14 +104,14 @@ public abstract class AbstractModel implements Model { return child; } else { if (!addAtEnd) { - parent = new LinkedList(parent); + parent = new LinkedList(parent); Collections.reverse(parent); } - for (Iterator parentIt = parent.iterator(); parentIt.hasNext();) { - Model parentElement = (Model) parentIt.next(); + for (Iterator parentIt = parent.iterator(); parentIt.hasNext();) { + Model parentElement = parentIt.next(); boolean matchFound = false; - for (Iterator childIt = child.iterator(); !matchFound && childIt.hasNext();) { - Model childElement = (Model) childIt.next(); + for (Iterator childIt = child.iterator(); !matchFound && childIt.hasNext();) { + Model childElement = childIt.next(); if (childElement.isMergeableWith(parentElement)) { matchFound = true; childElement.merge(parentElement); @@ -118,9 +119,9 @@ public abstract class AbstractModel implements Model { } if (!matchFound) { if (addAtEnd) { - child.addLast(parentElement.createCopy()); + child.addLast((T) parentElement.createCopy()); } else { - child.addFirst(parentElement.createCopy()); + child.addFirst((T) parentElement.createCopy()); } } } @@ -135,14 +136,14 @@ public abstract class AbstractModel implements Model { return model.createCopy(); } - protected LinkedList copyList(LinkedList list) { + @SuppressWarnings("unchecked") + protected LinkedList copyList(LinkedList list) { if (list == null) { return null; } - LinkedList copy = new LinkedList(); - for (Iterator it = list.iterator(); it.hasNext();) { - Model model = (Model) it.next(); - copy.add(model.createCopy()); + LinkedList copy = new LinkedList(); + for (T model : list) { + copy.add((T) model.createCopy()); } return copy; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractStateModel.java index a1496672..f7c71e52 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractStateModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractStateModel.java @@ -30,13 +30,13 @@ public abstract class AbstractStateModel extends AbstractModel { private String parent; - private LinkedList attributes; + private LinkedList attributes; private SecuredModel secured; - private LinkedList onEntryActions; + private LinkedList onEntryActions; - private LinkedList exceptionHandlers; + private LinkedList exceptionHandlers; public AbstractStateModel(String id) { setId(id); @@ -89,14 +89,14 @@ public abstract class AbstractStateModel extends AbstractModel { /** * @return the attributes */ - public LinkedList getAttributes() { + public LinkedList getAttributes() { return attributes; } /** * @param attributes the attributes to set */ - public void setAttributes(LinkedList attributes) { + public void setAttributes(LinkedList attributes) { this.attributes = attributes; } @@ -117,28 +117,28 @@ public abstract class AbstractStateModel extends AbstractModel { /** * @return the on entry actions */ - public LinkedList getOnEntryActions() { + public LinkedList getOnEntryActions() { return onEntryActions; } /** * @param onEntryActions the on entry actions to set */ - public void setOnEntryActions(LinkedList onEntryActions) { + public void setOnEntryActions(LinkedList onEntryActions) { this.onEntryActions = onEntryActions; } /** * @return the exception handlers */ - public LinkedList getExceptionHandlers() { + public LinkedList getExceptionHandlers() { return exceptionHandlers; } /** * @param exceptionHandlers the exception handlers to set */ - public void setExceptionHandlers(LinkedList exceptionHandlers) { + public void setExceptionHandlers(LinkedList exceptionHandlers) { this.exceptionHandlers = exceptionHandlers; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractTransitionableStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractTransitionableStateModel.java index faa44f5d..96821ac3 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractTransitionableStateModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/AbstractTransitionableStateModel.java @@ -24,9 +24,9 @@ import java.util.LinkedList; */ public abstract class AbstractTransitionableStateModel extends AbstractStateModel { - private LinkedList transitions; + private LinkedList transitions; - private LinkedList onExitActions; + private LinkedList onExitActions; public AbstractTransitionableStateModel(String id) { super(id); @@ -41,28 +41,28 @@ public abstract class AbstractTransitionableStateModel extends AbstractStateMode /** * @return the transitions */ - public LinkedList getTransitions() { + public LinkedList getTransitions() { return transitions; } /** * @param transitions the transitions to set */ - public void setTransitions(LinkedList transitions) { + public void setTransitions(LinkedList transitions) { this.transitions = transitions; } /** * @return the on exit actions */ - public LinkedList getOnExitActions() { + public LinkedList getOnExitActions() { return onExitActions; } /** * @param onExitActions the on exit actions to set */ - public void setOnExitActions(LinkedList onExitActions) { + public void setOnExitActions(LinkedList onExitActions) { this.onExitActions = onExitActions; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ActionStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ActionStateModel.java index e2b6d28d..6b85d00b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ActionStateModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ActionStateModel.java @@ -25,7 +25,7 @@ import org.springframework.util.ObjectUtils; */ public class ActionStateModel extends AbstractTransitionableStateModel { - private LinkedList actions; + private LinkedList actions; /** * Create an action state model @@ -65,14 +65,14 @@ public class ActionStateModel extends AbstractTransitionableStateModel { /** * @return the actions */ - public LinkedList getActions() { + public LinkedList getActions() { return actions; } /** * @param actions the actions to set */ - public void setActions(LinkedList actions) { + public void setActions(LinkedList actions) { this.actions = actions; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BeanImportModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BeanImportModel.java index 1dc1b6fb..6c961a51 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BeanImportModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BeanImportModel.java @@ -45,11 +45,11 @@ public class BeanImportModel extends AbstractModel { } - public Model createCopy() { - return new BeanImportModel(resource); - } + public Model createCopy() { + return new BeanImportModel(resource); + } - /** + /** * @return the resource */ public String getResource() { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BinderModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BinderModel.java index 77a4d3b9..69d09c2c 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BinderModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BinderModel.java @@ -23,13 +23,13 @@ import java.util.LinkedList; */ public class BinderModel extends AbstractModel { - private LinkedList bindings; + private LinkedList bindings; - public LinkedList getBindings() { + public LinkedList getBindings() { return bindings; } - public void setBindings(LinkedList bindings) { + public void setBindings(LinkedList bindings) { this.bindings = bindings; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BindingModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BindingModel.java index efac4205..ccc6e06f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BindingModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/BindingModel.java @@ -56,11 +56,11 @@ public class BindingModel extends AbstractModel { setRequired(merge(getRequired(), binding.getRequired())); } - public Model createCopy() { - return new BindingModel(property, converter, required); - } + public Model createCopy() { + return new BindingModel(property, converter, required); + } - public String getProperty() { + public String getProperty() { return property; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/DecisionStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/DecisionStateModel.java index dec99572..44e4775b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/DecisionStateModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/DecisionStateModel.java @@ -25,9 +25,9 @@ import org.springframework.util.ObjectUtils; */ public class DecisionStateModel extends AbstractStateModel { - private LinkedList ifs; + private LinkedList ifs; - private LinkedList onExitActions; + private LinkedList onExitActions; /** * Create a decision state model @@ -67,28 +67,28 @@ public class DecisionStateModel extends AbstractStateModel { /** * @return the ifs */ - public LinkedList getIfs() { + public LinkedList getIfs() { return ifs; } /** * @param ifs the ifs to set */ - public void setIfs(LinkedList ifs) { + public void setIfs(LinkedList ifs) { this.ifs = ifs; } /** * @return the on exit actions */ - public LinkedList getOnExitActions() { + public LinkedList getOnExitActions() { return onExitActions; } /** * @param onExitActions the on exit actions to set */ - public void setOnExitActions(LinkedList onExitActions) { + public void setOnExitActions(LinkedList onExitActions) { this.onExitActions = onExitActions; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/EndStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/EndStateModel.java index 5f5be866..639451ac 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/EndStateModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/EndStateModel.java @@ -30,7 +30,7 @@ public class EndStateModel extends AbstractStateModel { private String commit; - private LinkedList outputs; + private LinkedList outputs; /** * Create an end state model @@ -108,14 +108,14 @@ public class EndStateModel extends AbstractStateModel { /** * @return the outputs */ - public LinkedList getOutputs() { + public LinkedList getOutputs() { return outputs; } /** * @param outputs the outputs to set */ - public void setOutputs(LinkedList outputs) { + public void setOutputs(LinkedList outputs) { this.outputs = outputs; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ExceptionHandlerModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ExceptionHandlerModel.java index 897470d1..a966f4f6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ExceptionHandlerModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ExceptionHandlerModel.java @@ -43,11 +43,11 @@ public class ExceptionHandlerModel extends AbstractModel { public void merge(Model model) { } - public Model createCopy() { - return new ExceptionHandlerModel(bean); - } + public Model createCopy() { + return new ExceptionHandlerModel(bean); + } - public String getBean() { + public String getBean() { return bean; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/FlowModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/FlowModel.java index 2a98c122..b56dad06 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/FlowModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/FlowModel.java @@ -15,7 +15,6 @@ */ package org.springframework.webflow.engine.model; -import java.util.Iterator; import java.util.LinkedList; import org.springframework.util.StringUtils; @@ -52,29 +51,29 @@ public class FlowModel extends AbstractModel { private String startStateId; - private LinkedList attributes; + private LinkedList attributes; private SecuredModel secured; private PersistenceContextModel persistenceContext; - private LinkedList vars; + private LinkedList vars; - private LinkedList inputs; + private LinkedList inputs; - private LinkedList outputs; + private LinkedList outputs; - private LinkedList onStartActions; + private LinkedList onStartActions; - private LinkedList states; + private LinkedList states; - private LinkedList globalTransitions; + private LinkedList globalTransitions; - private LinkedList onEndActions; + private LinkedList onEndActions; - private LinkedList exceptionHandlers; + private LinkedList exceptionHandlers; - private LinkedList beanImports; + private LinkedList beanImports; /** * Create a flow model @@ -185,14 +184,14 @@ public class FlowModel extends AbstractModel { /** * @return the attributes */ - public LinkedList getAttributes() { + public LinkedList getAttributes() { return attributes; } /** * @param attributes the attributes to set */ - public void setAttributes(LinkedList attributes) { + public void setAttributes(LinkedList attributes) { this.attributes = attributes; } @@ -227,63 +226,63 @@ public class FlowModel extends AbstractModel { /** * @return the vars */ - public LinkedList getVars() { + public LinkedList getVars() { return vars; } /** * @param vars the vars to set */ - public void setVars(LinkedList vars) { + public void setVars(LinkedList vars) { this.vars = vars; } /** * @return the input mappings */ - public LinkedList getInputs() { + public LinkedList getInputs() { return inputs; } /** * @param inputs the input mappings to set */ - public void setInputs(LinkedList inputs) { + public void setInputs(LinkedList inputs) { this.inputs = inputs; } /** * @return the output mappings */ - public LinkedList getOutputs() { + public LinkedList getOutputs() { return outputs; } /** * @param outputs the output mappings to set */ - public void setOutputs(LinkedList outputs) { + public void setOutputs(LinkedList outputs) { this.outputs = outputs; } /** * @return the on start actions */ - public LinkedList getOnStartActions() { + public LinkedList getOnStartActions() { return onStartActions; } /** * @param onStartActions the on start actions to set */ - public void setOnStartActions(LinkedList onStartActions) { + public void setOnStartActions(LinkedList onStartActions) { this.onStartActions = onStartActions; } /** * @return the states */ - public LinkedList getStates() { + public LinkedList getStates() { return states; } @@ -294,8 +293,7 @@ public class FlowModel extends AbstractModel { */ public AbstractStateModel getStateById(String id) { if (states != null) { - for (Iterator it = states.iterator(); it.hasNext();) { - AbstractStateModel state = (AbstractStateModel) it.next(); + for (AbstractStateModel state : states) { if (id.equals(state.getId())) { return state; } @@ -307,63 +305,63 @@ public class FlowModel extends AbstractModel { /** * @param states the states to set */ - public void setStates(LinkedList states) { + public void setStates(LinkedList states) { this.states = states; } /** * @return the global transitions */ - public LinkedList getGlobalTransitions() { + public LinkedList getGlobalTransitions() { return globalTransitions; } /** * @param globalTransitions the global transitions to set */ - public void setGlobalTransitions(LinkedList globalTransitions) { + public void setGlobalTransitions(LinkedList globalTransitions) { this.globalTransitions = globalTransitions; } /** * @return the on end actions */ - public LinkedList getOnEndActions() { + public LinkedList getOnEndActions() { return onEndActions; } /** * @param onEndActions the on end actions to set */ - public void setOnEndActions(LinkedList onEndActions) { + public void setOnEndActions(LinkedList onEndActions) { this.onEndActions = onEndActions; } /** * @return the exception handlers */ - public LinkedList getExceptionHandlers() { + public LinkedList getExceptionHandlers() { return exceptionHandlers; } /** * @param exceptionHandlers the exception handlers to set */ - public void setExceptionHandlers(LinkedList exceptionHandlers) { + public void setExceptionHandlers(LinkedList exceptionHandlers) { this.exceptionHandlers = exceptionHandlers; } /** * @return the bean imports */ - public LinkedList getBeanImports() { + public LinkedList getBeanImports() { return beanImports; } /** * @param beanImports the bean imports to set */ - public void setBeanImports(LinkedList beanImports) { + public void setBeanImports(LinkedList beanImports) { this.beanImports = beanImports; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/Model.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/Model.java index ec93af70..ccb0232c 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/Model.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/Model.java @@ -17,32 +17,32 @@ package org.springframework.webflow.engine.model; /** * Interface defining models. All models must be able to handle merging of their content with an eligible model. - * + * * @author Scott Andrews */ public interface Model { - /** - * Determine if the model is able to be merged into the current model - * - * @param model the model to compare - * - * @return true if able to merge - */ - public boolean isMergeableWith(Model model); + /** + * Determine if the model is able to be merged into the current model + * + * @param model the model to compare + * + * @return true if able to merge + */ + public boolean isMergeableWith(Model model); - /** - * Merge the model into the current model - * - * @param model the model to merge with - */ - public void merge(Model model); + /** + * Merge the model into the current model + * + * @param model the model to merge with + */ + public void merge(Model model); - /** - * Create a deep copy of this model. Needed when merging models and collections. - * - * @return a deep copy of this model - */ - public Model createCopy(); + /** + * Create a deep copy of this model. Needed when merging models and collections. + * + * @return a deep copy of this model + */ + public Model createCopy(); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/PersistenceContextModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/PersistenceContextModel.java index 54ceb7b7..53579b7b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/PersistenceContextModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/PersistenceContextModel.java @@ -42,9 +42,8 @@ public class PersistenceContextModel extends AbstractModel { } - public Model createCopy() { - return new PersistenceContextModel(); - } - + public Model createCopy() { + return new PersistenceContextModel(); + } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/SetModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/SetModel.java index 1a45800d..00a65986 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/SetModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/SetModel.java @@ -42,12 +42,12 @@ public class SetModel extends AbstractActionModel { setValue(value); } - public Model createCopy() { - final SetModel copy = new SetModel(name, value); - super.fillCopy(copy); - copy.setType(type); - return copy; - } + public Model createCopy() { + final SetModel copy = new SetModel(name, value); + super.fillCopy(copy); + copy.setType(type); + return copy; + } /** * @return the name diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/SubflowStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/SubflowStateModel.java index 536b3b67..785e6aea 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/SubflowStateModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/SubflowStateModel.java @@ -30,9 +30,9 @@ public class SubflowStateModel extends AbstractTransitionableStateModel { private String subflowAttributeMapper; - private LinkedList inputs; + private LinkedList inputs; - private LinkedList outputs; + private LinkedList outputs; /** * Create a subflow state model @@ -115,28 +115,28 @@ public class SubflowStateModel extends AbstractTransitionableStateModel { /** * @return the input mappings */ - public LinkedList getInputs() { + public LinkedList getInputs() { return inputs; } /** * @param inputs the input mappings to set */ - public void setInputs(LinkedList inputs) { + public void setInputs(LinkedList inputs) { this.inputs = inputs; } /** * @return the output mappings */ - public LinkedList getOutputs() { + public LinkedList getOutputs() { return outputs; } /** * @param outputs the output mappings to set */ - public void setOutputs(LinkedList outputs) { + public void setOutputs(LinkedList outputs) { this.outputs = outputs; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/TransitionModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/TransitionModel.java index f9dc8f38..ef28c0c6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/TransitionModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/TransitionModel.java @@ -43,11 +43,11 @@ public class TransitionModel extends AbstractModel { private String history; - private LinkedList attributes; + private LinkedList attributes; private SecuredModel secured; - private LinkedList actions; + private LinkedList actions; /** * Create a transition model @@ -201,14 +201,14 @@ public class TransitionModel extends AbstractModel { /** * @return the attributes */ - public LinkedList getAttributes() { + public LinkedList getAttributes() { return attributes; } /** * @param attributes the attributes to set */ - public void setAttributes(LinkedList attributes) { + public void setAttributes(LinkedList attributes) { this.attributes = attributes; } @@ -229,14 +229,14 @@ public class TransitionModel extends AbstractModel { /** * @return the actions */ - public LinkedList getActions() { + public LinkedList getActions() { return actions; } /** * @param actions the actions to set */ - public void setActions(LinkedList actions) { + public void setActions(LinkedList actions) { this.actions = actions; } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/VarModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/VarModel.java index 509529e9..1c6cce7f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/VarModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/VarModel.java @@ -55,11 +55,11 @@ public class VarModel extends AbstractModel { setClassName(merge(getClassName(), var.getClassName())); } - public Model createCopy() { - return new VarModel(name, className); - } + public Model createCopy() { + return new VarModel(name, className); + } - /** + /** * @return the name */ public String getName() { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java index 18649107..42a929c3 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/ViewStateModel.java @@ -35,11 +35,11 @@ public class ViewStateModel extends AbstractTransitionableStateModel { private String model; - private LinkedList vars; + private LinkedList vars; private BinderModel binder; - private LinkedList onRenderActions; + private LinkedList onRenderActions; /** * Create a view state model @@ -163,14 +163,14 @@ public class ViewStateModel extends AbstractTransitionableStateModel { /** * @return the vars */ - public LinkedList getVars() { + public LinkedList getVars() { return vars; } /** * @param vars the vars to set */ - public void setVars(LinkedList vars) { + public void setVars(LinkedList vars) { this.vars = vars; } @@ -185,14 +185,14 @@ public class ViewStateModel extends AbstractTransitionableStateModel { /** * @return the on render actions */ - public LinkedList getOnRenderActions() { + public LinkedList getOnRenderActions() { return onRenderActions; } /** * @param onRenderActions the on render actions to set */ - public void setOnRenderActions(LinkedList onRenderActions) { + public void setOnRenderActions(LinkedList onRenderActions) { this.onRenderActions = onRenderActions; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/WebFlowEntityResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/WebFlowEntityResolver.java index 136f6fad..4f49c732 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/WebFlowEntityResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/WebFlowEntityResolver.java @@ -47,9 +47,9 @@ class WebFlowEntityResolver implements EntityResolver { if (systemId != null && systemId.indexOf("spring-webflow.xsd") > -1) { return createInputSource(publicId, systemId, WEBFLOW_VERSIONS[0] + ".xsd"); } - for (int i = 0; i < WEBFLOW_VERSIONS.length; i++) { - if (systemId != null && systemId.indexOf(WEBFLOW_VERSIONS[i]) > systemId.lastIndexOf("/")) { - String fileName = systemId.substring(systemId.indexOf(WEBFLOW_VERSIONS[i])); + for (String element : WEBFLOW_VERSIONS) { + if (systemId != null && systemId.indexOf(element) > systemId.lastIndexOf("/")) { + String fileName = systemId.substring(systemId.indexOf(element)); return createInputSource(publicId, systemId, fileName); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java index a9842463..ac2c892c 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilder.java @@ -17,7 +17,6 @@ package org.springframework.webflow.engine.model.builder.xml; import java.io.IOException; import java.util.Arrays; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -213,123 +212,124 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { return flow; } - private LinkedList parseAttributes(Element element) { - List attributeElements = DomUtils.getChildElementsByTagName(element, "attribute"); + private LinkedList parseAttributes(Element element) { + List attributeElements = DomUtils.getChildElementsByTagName(element, "attribute"); if (attributeElements.isEmpty()) { return null; } - LinkedList attributes = new LinkedList(); - for (Iterator it = attributeElements.iterator(); it.hasNext();) { - attributes.add(parseAttribute((Element) it.next())); + LinkedList attributes = new LinkedList(); + for (Element element2 : attributeElements) { + attributes.add(parseAttribute(element2)); } return attributes; } - private LinkedList parseVars(Element element) { - List varElements = DomUtils.getChildElementsByTagName(element, "var"); + private LinkedList parseVars(Element element) { + List varElements = DomUtils.getChildElementsByTagName(element, "var"); if (varElements.isEmpty()) { return null; } - LinkedList vars = new LinkedList(); - for (Iterator it = varElements.iterator(); it.hasNext();) { - vars.add(parseVar((Element) it.next())); + LinkedList vars = new LinkedList(); + for (Element element2 : varElements) { + vars.add(parseVar(element2)); } return vars; } - private LinkedList parseInputs(Element element) { - List inputElements = DomUtils.getChildElementsByTagName(element, "input"); + private LinkedList parseInputs(Element element) { + List inputElements = DomUtils.getChildElementsByTagName(element, "input"); if (inputElements.isEmpty()) { return null; } - LinkedList inputs = new LinkedList(); - for (Iterator it = inputElements.iterator(); it.hasNext();) { - inputs.add(parseInput((Element) it.next())); + LinkedList inputs = new LinkedList(); + for (Element element2 : inputElements) { + inputs.add(parseInput(element2)); } return inputs; } - private LinkedList parseOutputs(Element element) { - List outputElements = DomUtils.getChildElementsByTagName(element, "output"); + private LinkedList parseOutputs(Element element) { + List outputElements = DomUtils.getChildElementsByTagName(element, "output"); if (outputElements.isEmpty()) { return null; } - LinkedList outputs = new LinkedList(); - for (Iterator it = outputElements.iterator(); it.hasNext();) { - outputs.add(parseOutput((Element) it.next())); + LinkedList outputs = new LinkedList(); + for (Element element2 : outputElements) { + outputs.add(parseOutput(element2)); } return outputs; } - private LinkedList parseActions(Element element) { - List actionElements = DomUtils.getChildElementsByTagName(element, new String[] { "evaluate", "render", "set" }); + private LinkedList parseActions(Element element) { + List actionElements = DomUtils.getChildElementsByTagName(element, new String[] { "evaluate", "render", + "set" }); if (actionElements.isEmpty()) { return null; } - LinkedList actions = new LinkedList(); - for (Iterator it = actionElements.iterator(); it.hasNext();) { - actions.add(parseAction((Element) it.next())); + LinkedList actions = new LinkedList(); + for (Element element2 : actionElements) { + actions.add(parseAction(element2)); } return actions; } - private LinkedList parseStates(Element element) { - List stateElements = DomUtils.getChildElementsByTagName(element, new String[] { "view-state", "action-state", - "decision-state", "subflow-state", "end-state" }); + private LinkedList parseStates(Element element) { + List stateElements = DomUtils.getChildElementsByTagName(element, new String[] { "view-state", + "action-state", "decision-state", "subflow-state", "end-state" }); if (stateElements.isEmpty()) { return null; } - LinkedList states = new LinkedList(); - for (Iterator it = stateElements.iterator(); it.hasNext();) { - states.add(parseState((Element) it.next())); + LinkedList states = new LinkedList(); + for (Element element2 : stateElements) { + states.add(parseState(element2)); } return states; } - private LinkedList parseTransitions(Element element) { - List transitionElements = DomUtils.getChildElementsByTagName(element, "transition"); + private LinkedList parseTransitions(Element element) { + List transitionElements = DomUtils.getChildElementsByTagName(element, "transition"); if (transitionElements.isEmpty()) { return null; } - LinkedList transitions = new LinkedList(); - for (Iterator it = transitionElements.iterator(); it.hasNext();) { - transitions.add(parseTransition((Element) it.next())); + LinkedList transitions = new LinkedList(); + for (Element element2 : transitionElements) { + transitions.add(parseTransition(element2)); } return transitions; } - private LinkedList parseExceptionHandlers(Element element) { - List exceptionHandlerElements = DomUtils.getChildElementsByTagName(element, "exception-handler"); + private LinkedList parseExceptionHandlers(Element element) { + List exceptionHandlerElements = DomUtils.getChildElementsByTagName(element, "exception-handler"); if (exceptionHandlerElements.isEmpty()) { return null; } - LinkedList exceptionHandlers = new LinkedList(); - for (Iterator it = exceptionHandlerElements.iterator(); it.hasNext();) { - exceptionHandlers.add(parseExceptionHandler((Element) it.next())); + LinkedList exceptionHandlers = new LinkedList(); + for (Element element2 : exceptionHandlerElements) { + exceptionHandlers.add(parseExceptionHandler(element2)); } return exceptionHandlers; } - private LinkedList parseBeanImports(Element element) { - List importElements = DomUtils.getChildElementsByTagName(element, "bean-import"); + private LinkedList parseBeanImports(Element element) { + List importElements = DomUtils.getChildElementsByTagName(element, "bean-import"); if (importElements.isEmpty()) { return null; } - LinkedList beanImports = new LinkedList(); - for (Iterator it = importElements.iterator(); it.hasNext();) { - beanImports.add(parseBeanImport((Element) it.next())); + LinkedList beanImports = new LinkedList(); + for (Element element2 : importElements) { + beanImports.add(parseBeanImport(element2)); } return beanImports; } - private LinkedList parseIfs(Element element) { - List ifElements = DomUtils.getChildElementsByTagName(element, "if"); + private LinkedList parseIfs(Element element) { + List ifElements = DomUtils.getChildElementsByTagName(element, "if"); if (ifElements.isEmpty()) { return null; } - LinkedList ifs = new LinkedList(); - for (Iterator it = ifElements.iterator(); it.hasNext();) { - ifs.add(parseIf((Element) it.next())); + LinkedList ifs = new LinkedList(); + for (Element element2 : ifElements) { + ifs.add(parseIf(element2)); } return ifs; } @@ -362,7 +362,7 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { } } - private LinkedList parseGlobalTransitions(Element element) { + private LinkedList parseGlobalTransitions(Element element) { element = DomUtils.getChildElementByTagName(element, "global-transitions"); if (element == null) { return null; @@ -456,7 +456,7 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { return ifModel; } - private LinkedList parseOnStartActions(Element element) { + private LinkedList parseOnStartActions(Element element) { Element onStartElement = DomUtils.getChildElementByTagName(element, "on-start"); if (onStartElement != null) { return parseActions(onStartElement); @@ -465,7 +465,7 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { } } - private LinkedList parseOnEntryActions(Element element) { + private LinkedList parseOnEntryActions(Element element) { Element onEntryElement = DomUtils.getChildElementByTagName(element, "on-entry"); if (onEntryElement != null) { return parseActions(onEntryElement); @@ -474,7 +474,7 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { } } - private LinkedList parseOnRenderActions(Element element) { + private LinkedList parseOnRenderActions(Element element) { Element onRenderElement = DomUtils.getChildElementByTagName(element, "on-render"); if (onRenderElement != null) { return parseActions(onRenderElement); @@ -494,14 +494,14 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { } } - private LinkedList parseBindings(Element element) { - List bindingElements = DomUtils.getChildElementsByTagName(element, "binding"); + private LinkedList parseBindings(Element element) { + List bindingElements = DomUtils.getChildElementsByTagName(element, "binding"); if (bindingElements.isEmpty()) { return null; } - LinkedList bindings = new LinkedList(); - for (Iterator it = bindingElements.iterator(); it.hasNext();) { - bindings.add(parseBinding((Element) it.next())); + LinkedList bindings = new LinkedList(); + for (Element element2 : bindingElements) { + bindings.add(parseBinding(element2)); } return bindings; } @@ -511,7 +511,7 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { element.getAttribute("required")); } - private LinkedList parseOnExitActions(Element element) { + private LinkedList parseOnExitActions(Element element) { Element onExitElement = DomUtils.getChildElementByTagName(element, "on-exit"); if (onExitElement != null) { return parseActions(onExitElement); @@ -520,7 +520,7 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { } } - private LinkedList parseOnEndActions(Element element) { + private LinkedList parseOnEndActions(Element element) { Element onEndElement = DomUtils.getChildElementByTagName(element, "on-end"); if (onEndElement != null) { return parseActions(onEndElement); @@ -624,9 +624,8 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { private void mergeFlows() { if (flowModel.getParent() != null) { - List parents = Arrays.asList(StringUtils.trimArrayElements(flowModel.getParent().split(","))); - for (Iterator it = parents.iterator(); it.hasNext();) { - String parentFlowId = (String) it.next(); + List parents = Arrays.asList(StringUtils.trimArrayElements(flowModel.getParent().split(","))); + for (String parentFlowId : parents) { if (StringUtils.hasText(parentFlowId)) { try { flowModel.merge(modelLocator.getFlowModel(parentFlowId)); @@ -643,8 +642,7 @@ public class XmlFlowModelBuilder implements FlowModelBuilder { if (flowModel.getStates() == null) { return; } - for (Iterator it = flowModel.getStates().iterator(); it.hasNext();) { - AbstractStateModel childState = (AbstractStateModel) it.next(); + for (AbstractStateModel childState : flowModel.getStates()) { String parent = childState.getParent(); if (childState.getParent() != null) { String flowId; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/registry/FlowModelLocator.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/registry/FlowModelLocator.java index 56d93f60..534534ce 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/registry/FlowModelLocator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/registry/FlowModelLocator.java @@ -18,8 +18,8 @@ package org.springframework.webflow.engine.model.registry; import org.springframework.webflow.engine.model.FlowModel; /** - * A runtime service locator interface for retrieving flow definitions by id. Flow locators are needed - * by flow executors at runtime to retrieve flow models to support loading flow definitions. + * A runtime service locator interface for retrieving flow definitions by id. Flow locators are needed by + * flow executors at runtime to retrieve flow models to support loading flow definitions. * * @author Keith Donald * @author Erwin Vervaet diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/registry/FlowModelRegistryImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/registry/FlowModelRegistryImpl.java index 0be69007..46ca435b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/registry/FlowModelRegistryImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/registry/FlowModelRegistryImpl.java @@ -33,7 +33,7 @@ public class FlowModelRegistryImpl implements FlowModelRegistry { /** * The map of loaded Flow models maintained in this registry. */ - private Map flowModels; + private Map flowModels; /** * An optional parent flow model registry. @@ -41,7 +41,7 @@ public class FlowModelRegistryImpl implements FlowModelRegistry { private FlowModelRegistry parent; public FlowModelRegistryImpl() { - flowModels = new TreeMap(); + flowModels = new TreeMap(); } // implementing FlowModelLocator @@ -75,7 +75,7 @@ public class FlowModelRegistryImpl implements FlowModelRegistry { * Returns the identified flow model holder. Throws an exception if it cannot be found. */ private FlowModelHolder getFlowModelHolder(String id) throws NoSuchFlowModelException { - FlowModelHolder holder = (FlowModelHolder) flowModels.get(id); + FlowModelHolder holder = flowModels.get(id); if (holder == null) { throw new NoSuchFlowModelException(id); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/ActionTransitionCriteria.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/ActionTransitionCriteria.java index 0b9ad3e5..708b5598 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/ActionTransitionCriteria.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/ActionTransitionCriteria.java @@ -22,8 +22,8 @@ import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.RequestContext; /** - * A transition criteria that will execute an action when tested and return true if the action's result - * is equal to the 'trueEventId', false otherwise. + * A transition criteria that will execute an action when tested and return true if the action's result is + * equal to the 'trueEventId', false otherwise. *

      * This effectively adapts an Action to a TransitionCriteria. * @@ -84,8 +84,8 @@ public class ActionTransitionCriteria implements TransitionCriteria { } private boolean isTrueEvent(String eventId) { - for (int i = 0; i < trueEventIds.length; i++) { - if (trueEventIds[i].equals(eventId)) { + for (String trueEventId : trueEventIds) { + if (trueEventId.equals(eventId)) { return true; } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/BeanFactoryVariableValueFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/BeanFactoryVariableValueFactory.java index bb48a0e7..8d6879be 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/BeanFactoryVariableValueFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/BeanFactoryVariableValueFactory.java @@ -31,7 +31,7 @@ public class BeanFactoryVariableValueFactory implements VariableValueFactory { /** * The class of variable value. Typically a Java bean. */ - private Class type; + private Class type; /** * The backing bean factory that will create and restore variable instances. @@ -43,7 +43,7 @@ public class BeanFactoryVariableValueFactory implements VariableValueFactory { * @param type the variable class * @param beanFactory the bean factory that will create and restore variable instances. */ - public BeanFactoryVariableValueFactory(Class type, AutowireCapableBeanFactory beanFactory) { + public BeanFactoryVariableValueFactory(Class type, AutowireCapableBeanFactory beanFactory) { this.type = type; this.beanFactory = beanFactory; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/GenericSubflowAttributeMapper.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/GenericSubflowAttributeMapper.java index 6c085659..0cb48e4f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/GenericSubflowAttributeMapper.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/GenericSubflowAttributeMapper.java @@ -49,9 +49,9 @@ public final class GenericSubflowAttributeMapper implements SubflowAttributeMapp this.outputMapper = outputMapper; } - public MutableAttributeMap createSubflowInput(RequestContext context) { + public MutableAttributeMap createSubflowInput(RequestContext context) { if (inputMapper != null) { - LocalAttributeMap input = new LocalAttributeMap(); + LocalAttributeMap input = new LocalAttributeMap(); MappingResults results = inputMapper.map(context, input); if (results != null && results.hasErrorResults()) { throw new FlowInputMappingException(context.getActiveFlow().getId(), context.getCurrentState().getId(), @@ -59,11 +59,11 @@ public final class GenericSubflowAttributeMapper implements SubflowAttributeMapp } return input; } else { - return new LocalAttributeMap(); + return new LocalAttributeMap(); } } - public void mapSubflowOutput(AttributeMap output, RequestContext context) { + public void mapSubflowOutput(AttributeMap output, RequestContext context) { if (outputMapper != null && output != null) { MappingResults results = outputMapper.map(output, context); if (results != null && results.hasErrorResults()) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionCriteriaChain.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionCriteriaChain.java index 8b317fca..bd022b2a 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionCriteriaChain.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionCriteriaChain.java @@ -37,7 +37,7 @@ public class TransitionCriteriaChain implements TransitionCriteria { /** * The ordered chain of TransitionCriteria objects. */ - private List criteriaChain = new LinkedList(); + private List criteriaChain = new LinkedList(); /** * Creates an initially empty transition criteria chain. @@ -65,9 +65,9 @@ public class TransitionCriteriaChain implements TransitionCriteria { } public boolean test(RequestContext context) { - Iterator it = criteriaChain.iterator(); + Iterator it = criteriaChain.iterator(); while (it.hasNext()) { - TransitionCriteria criteria = (TransitionCriteria) it.next(); + TransitionCriteria criteria = it.next(); if (!criteria.test(context)) { return false; } @@ -90,8 +90,8 @@ public class TransitionCriteriaChain implements TransitionCriteria { return WildcardTransitionCriteria.INSTANCE; } TransitionCriteriaChain chain = new TransitionCriteriaChain(); - for (int i = 0; i < actions.length; i++) { - chain.add(new ActionTransitionCriteria(actions[i])); + for (Action action : actions) { + chain.add(new ActionTransitionCriteria(action)); } return chain; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionExecutingFlowExecutionExceptionHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionExecutingFlowExecutionExceptionHandler.java index aba0dd26..c2a5705e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionExecutingFlowExecutionExceptionHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/TransitionExecutingFlowExecutionExceptionHandler.java @@ -58,7 +58,7 @@ public class TransitionExecutingFlowExecutionExceptionHandler implements FlowExe /** * The exceptionType to targetStateResolver map. */ - private Map exceptionTargetStateMappings = new HashMap(); + private Map, TargetStateResolver> exceptionTargetStateMappings = new HashMap, TargetStateResolver>(); /** * The list of actions to execute when this handler handles an exception. @@ -71,7 +71,8 @@ public class TransitionExecutingFlowExecutionExceptionHandler implements FlowExe * @param targetStateId the id of the state to transition to if the specified type of exception is handled * @return this handler, to allow for adding multiple mappings in a single statement */ - public TransitionExecutingFlowExecutionExceptionHandler add(Class exceptionClass, String targetStateId) { + public TransitionExecutingFlowExecutionExceptionHandler add(Class exceptionClass, + String targetStateId) { return add(exceptionClass, new DefaultTargetStateResolver(targetStateId)); } @@ -82,7 +83,7 @@ public class TransitionExecutingFlowExecutionExceptionHandler implements FlowExe * exception is handled * @return this handler, to allow for adding multiple mappings in a single statement */ - public TransitionExecutingFlowExecutionExceptionHandler add(Class exceptionClass, + public TransitionExecutingFlowExecutionExceptionHandler add(Class exceptionClass, TargetStateResolver targetStateResolver) { Assert.notNull(exceptionClass, "The exception class is required"); Assert.notNull(targetStateResolver, "The target state resolver is required"); @@ -140,7 +141,7 @@ public class TransitionExecutingFlowExecutionExceptionHandler implements FlowExe if (isRootCause(e)) { return findTargetStateResolver(e.getClass()); } else { - targetStateResolver = (TargetStateResolver) exceptionTargetStateMappings.get(e.getClass()); + targetStateResolver = exceptionTargetStateMappings.get(e.getClass()); if (targetStateResolver != null) { return targetStateResolver; } else { @@ -162,12 +163,13 @@ public class TransitionExecutingFlowExecutionExceptionHandler implements FlowExe * @param exceptionType the exception type to lookup * @return the target state id or null if not found */ - private TargetStateResolver findTargetStateResolver(Class exceptionType) { - while (exceptionType != null && exceptionType != Object.class) { - if (exceptionTargetStateMappings.containsKey(exceptionType)) { - return (TargetStateResolver) exceptionTargetStateMappings.get(exceptionType); + private TargetStateResolver findTargetStateResolver(Class exceptionType) { + Class type = exceptionType; + while (type != null && type != Object.class) { + if (exceptionTargetStateMappings.containsKey(type)) { + return exceptionTargetStateMappings.get(type); } else { - exceptionType = exceptionType.getSuperclass(); + type = type.getSuperclass(); } } return null; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/Action.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/Action.java index 71e0872f..24616bfa 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/Action.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/Action.java @@ -69,11 +69,10 @@ public interface Action { *
        *
      • Attributes set in {@link RequestContext#getRequestScope() request scope} exist for the life of the currently * executing request only. - *
      • Attributes set in {@link RequestContext#getFlashScope() flash scope} exist until the next external user - * event is signaled. That time includes the current request plus any redirect or additional refreshes to the next - * view. - *
      • Attributes set in {@link RequestContext#getFlowScope() flow scope} exist for the life of the flow session - * and will be cleaned up automatically when the flow session ends. + *
      • Attributes set in {@link RequestContext#getFlashScope() flash scope} exist until the next external user event + * is signaled. That time includes the current request plus any redirect or additional refreshes to the next view. + *
      • Attributes set in {@link RequestContext#getFlowScope() flow scope} exist for the life of the flow session and + * will be cleaned up automatically when the flow session ends. *
      • Attributes set in {@link RequestContext#getConversationScope() conversation scope} exist for the life of the * entire flow execution representing a single logical "conversation" with a user. *
      @@ -89,9 +88,9 @@ public interface Action { *

      * Note: as flow scoped attributes are eligible for serialization they should be Serializable. * - * @param context the action execution context, for accessing and setting data in a {@link ScopeType scope type}, - * as well as obtaining other flow contextual information (e.g. request context attributes and flow execution - * context information) + * @param context the action execution context, for accessing and setting data in a {@link ScopeType scope type}, as + * well as obtaining other flow contextual information (e.g. request context attributes and flow execution context + * information) * @return a logical result outcome, used as grounds for a transition in the calling flow (e.g. "success", "error", * "yes", "no", * ...) * @throws Exception a exception occurred during action execution, either checked or unchecked; note, any diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/ActionExecutionException.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/ActionExecutionException.java index d054522d..6e28898e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/ActionExecutionException.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/ActionExecutionException.java @@ -36,8 +36,8 @@ public class ActionExecutionException extends FlowExecutionException { * @param executionAttributes action execution properties that may have contributed to this failure * @param cause the underlying cause */ - public ActionExecutionException(String flowId, String stateId, Action action, AttributeMap executionAttributes, - Throwable cause) { + public ActionExecutionException(String flowId, String stateId, Action action, + AttributeMap executionAttributes, Throwable cause) { super(flowId, stateId, "Exception thrown executing " + action + " in state '" + stateId + "' of flow '" + flowId + "' -- action execution attributes were '" + executionAttributes + "'", cause); } @@ -51,8 +51,8 @@ public class ActionExecutionException extends FlowExecutionException { * @param message a descriptive message * @param cause the underlying cause */ - public ActionExecutionException(String flowId, String stateId, Action action, AttributeMap executionAttributes, - String message, Throwable cause) { + public ActionExecutionException(String flowId, String stateId, Action action, + AttributeMap executionAttributes, String message, Throwable cause) { super(flowId, stateId, message, cause); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/ActionExecutor.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/ActionExecutor.java index b6d4c6d6..65989288 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/ActionExecutor.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/ActionExecutor.java @@ -58,8 +58,8 @@ public class ActionExecutor { } catch (Exception e) { // wrap the exception as an ActionExecutionException throw new ActionExecutionException(context.getActiveFlow().getId(), - context.getCurrentState() != null ? context.getCurrentState().getId() : null, action, context - .getAttributes(), e); + context.getCurrentState() != null ? context.getCurrentState().getId() : null, action, + context.getAttributes(), e); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/AnnotatedAction.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/AnnotatedAction.java index fff4c115..a868e977 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/AnnotatedAction.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/AnnotatedAction.java @@ -23,8 +23,8 @@ import org.springframework.util.StringUtils; import org.springframework.webflow.core.AnnotatedObject; /** - * An action proxy/decorator that stores arbitrary properties about a target Action implementation for - * use within a specific Action execution context, for example an ActionState definition, a + * An action proxy/decorator that stores arbitrary properties about a target Action implementation for use + * within a specific Action execution context, for example an ActionState definition, a * TransitionCriteria definition, or in a test environment. *

      * An annotated action is an action that wraps another action (referred to as the target action), setting up the diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/Event.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/Event.java index 5719b34c..a1900f4a 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/Event.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/Event.java @@ -52,7 +52,7 @@ public class Event extends EventObject { /** * Additional event attributes that form this event's payload. */ - private final AttributeMap attributes; + private final AttributeMap attributes; /** * Create a new event with the specified id and no payload. @@ -69,7 +69,7 @@ public class Event extends EventObject { * @param id the event identifier (required) * @param attributes additional event attributes */ - public Event(Object source, String id, AttributeMap attributes) { + public Event(Object source, String id, AttributeMap attributes) { super(source); Assert.hasText(id, "The event id is required: please set this event's id to a non-blank string identifier"); this.id = id; @@ -97,7 +97,7 @@ public class Event extends EventObject { * Returns an unmodifiable map storing the attributes of this event. Never returns null. * @return the event attributes (payload) */ - public AttributeMap getAttributes() { + public AttributeMap getAttributes() { return attributes; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecution.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecution.java index b9b17e70..2bbd888f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecution.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecution.java @@ -36,7 +36,7 @@ public interface FlowExecution extends FlowExecutionContext { * @throws FlowExecutionException if an exception was thrown within a state of the flow execution during request * processing */ - public void start(MutableAttributeMap input, ExternalContext context) throws FlowExecutionException; + public void start(MutableAttributeMap input, ExternalContext context) throws FlowExecutionException; /** * Resume this flow execution. May be called when the flow execution is paused. diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionContext.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionContext.java index 0a02db66..5382a7a8 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionContext.java @@ -102,19 +102,19 @@ public interface FlowExecutionContext { * rendering. Flash attributes survive flow execution refresh operations. * @return flash scope */ - public MutableAttributeMap getFlashScope(); + public MutableAttributeMap getFlashScope(); /** * Returns a mutable map for data held in "conversation scope". Conversation scope is a data structure that exists * for the life of this flow execution and is accessible to all flow sessions. * @return conversation scope */ - public MutableAttributeMap getConversationScope(); + public MutableAttributeMap getConversationScope(); /** * Returns runtime execution attributes that may influence the behavior of flow artifacts, such as states and * actions. * @return execution attributes */ - public AttributeMap getAttributes(); + public AttributeMap getAttributes(); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionFactory.java index 5772b771..44b4c5e1 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionFactory.java @@ -56,6 +56,6 @@ public interface FlowExecutionFactory { * @return the restored flow execution */ public FlowExecution restoreFlowExecution(FlowExecution flowExecution, FlowDefinition flowDefinition, - FlowExecutionKey flowExecutionKey, MutableAttributeMap conversationScope, + FlowExecutionKey flowExecutionKey, MutableAttributeMap conversationScope, FlowDefinitionLocator subflowDefinitionLocator); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionListener.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionListener.java index 89eb22a5..72b5e843 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionListener.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionListener.java @@ -23,8 +23,8 @@ import org.springframework.webflow.definition.TransitionDefinition; import org.springframework.webflow.engine.FlowExecutionExceptionHandler; /** - * Interface to be implemented by objects that wish to listen and respond to the lifecycle of - * {@link FlowExecution flow executions}. + * Interface to be implemented by objects that wish to listen and respond to the lifecycle of {@link FlowExecution flow + * executions}. *

      * An 'observer' that is very aspect like, allowing you to insert 'cross cutting' behavior at well-defined points within * one or more well-defined flow execution lifecycles. @@ -81,7 +81,7 @@ public interface FlowExecutionListener { * @param input a mutable input map - attributes placed in this map are eligible for input mapping by the flow * definition at startup */ - public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input); + public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input); /** * Called after a new flow session has started. At this point the flow's start state has been entered and any other @@ -157,7 +157,7 @@ public interface FlowExecutionListener { * @param output the flow output produced by the ending session, this map may be modified by this listener to affect * the output returned */ - public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output); + public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output); /** * Called when a flow execution session ends. If the ended session was the root session of the flow execution, the @@ -167,7 +167,7 @@ public interface FlowExecutionListener { * @param outcome the outcome reached by the ended session, generally the id of the terminating end-state * @param output the flow output returned by the ending session */ - public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output); + public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output); /** * Called when an exception is thrown during a flow execution, before the exception is handled by any registered diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionListenerAdapter.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionListenerAdapter.java index cd2fb63f..7b15e6b6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionListenerAdapter.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionListenerAdapter.java @@ -40,7 +40,7 @@ public abstract class FlowExecutionListenerAdapter implements FlowExecutionListe public void sessionCreating(RequestContext context, FlowDefinition definition) { } - public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { + public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { } public void sessionStarted(RequestContext context, FlowSession session) { @@ -70,10 +70,10 @@ public abstract class FlowExecutionListenerAdapter implements FlowExecutionListe public void resuming(RequestContext context) { } - public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output) { + public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output) { } - public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output) { + public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output) { } public void exceptionThrown(RequestContext context, FlowExecutionException exception) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionOutcome.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionOutcome.java index 17b1347f..f82935ef 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionOutcome.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionOutcome.java @@ -28,14 +28,14 @@ public class FlowExecutionOutcome { private String id; - private AttributeMap output; + private AttributeMap output; /** * Creates a new flow execution outcome * @param id the outcome id * @param output the output returned by the execution */ - public FlowExecutionOutcome(String id, AttributeMap output) { + public FlowExecutionOutcome(String id, AttributeMap output) { super(); this.id = id; this.output = (output != null ? output : CollectionUtils.EMPTY_ATTRIBUTE_MAP); @@ -53,7 +53,7 @@ public class FlowExecutionOutcome { * Returns the output returned by the flow execution. * @return the output that was returned */ - public AttributeMap getOutput() { + public AttributeMap getOutput() { return output; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowSession.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowSession.java index 021a6c2a..b586f6d8 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowSession.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowSession.java @@ -52,7 +52,7 @@ public interface FlowSession { * Return this session's local attributes; the basis for "flow scope" (flow session scope). * @return the flow scope attributes */ - public MutableAttributeMap getScope(); + public MutableAttributeMap getScope(); /** * Returns a mutable map for data held in "view scope". Attributes in this map are cleared out when the current view @@ -60,7 +60,7 @@ public interface FlowSession { * @return view scope * @throws IllegalStateException if this flow session is not currently in a view state */ - public MutableAttributeMap getViewScope() throws IllegalStateException; + public MutableAttributeMap getViewScope() throws IllegalStateException; /** * Returns true if the flow session was started in embedded page mode. An embedded flow can make different diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/RequestContext.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/RequestContext.java index 2110ed38..482310e4 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/RequestContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/RequestContext.java @@ -96,14 +96,14 @@ public interface RequestContext { * exist for the duration of this request only. * @return the request scope */ - public MutableAttributeMap getRequestScope(); + public MutableAttributeMap getRequestScope(); /** * Returns a mutable map for accessing and/or setting attributes in flash scope. Flash scoped attributes exist * until the next event is signaled in the flow execution. * @return the flash scope */ - public MutableAttributeMap getFlashScope(); + public MutableAttributeMap getFlashScope(); /** * Returns a mutable map for accessing and/or setting attributes in view scope. View scoped attributes exist for @@ -113,7 +113,7 @@ public interface RequestContext { * @throws IllegalStateException if this flow is not in a view-state or the flow execution is not active * @see FlowExecutionContext#isActive() */ - public MutableAttributeMap getViewScope() throws IllegalStateException; + public MutableAttributeMap getViewScope() throws IllegalStateException; /** * Returns a mutable map for accessing and/or setting attributes in flow scope. Flow scoped attributes exist for @@ -123,7 +123,7 @@ public interface RequestContext { * @throws IllegalStateException if the flow execution is not active * @see FlowExecutionContext#isActive() */ - public MutableAttributeMap getFlowScope() throws IllegalStateException; + public MutableAttributeMap getFlowScope() throws IllegalStateException; /** * Returns a mutable accessor for accessing and/or setting attributes in conversation scope. Conversation scoped @@ -131,7 +131,7 @@ public interface RequestContext { * @return the conversation scope * @see FlowExecutionContext */ - public MutableAttributeMap getConversationScope(); + public MutableAttributeMap getConversationScope(); /** * Returns the immutable input parameters associated with this request into Spring Web Flow. The map returned is @@ -198,7 +198,7 @@ public interface RequestContext { * used to influence flow execution behavior. * @return the current attributes of this request, or empty if none are set */ - public MutableAttributeMap getAttributes(); + public MutableAttributeMap getAttributes(); /** * Returns the URL of this flow execution. Needed by response writers that write out the URL of this flow execution diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/RequestContextHolder.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/RequestContextHolder.java index a4d78a0a..c2085416 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/RequestContextHolder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/RequestContextHolder.java @@ -30,7 +30,8 @@ import org.springframework.core.NamedThreadLocal; */ public class RequestContextHolder { - private static final ThreadLocal requestContextHolder = new NamedThreadLocal("Flow RequestContext"); + private static final ThreadLocal requestContextHolder = new NamedThreadLocal( + "Flow RequestContext"); /** * Associate the given RequestContext with the current thread. @@ -46,7 +47,7 @@ public class RequestContextHolder { * @throws IllegalStateException if no RequestContext is bound to this thread */ public static RequestContext getRequestContext() { - return (RequestContext) requestContextHolder.get(); + return requestContextHolder.get(); } // not instantiable diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/ScopeType.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/ScopeType.java index 5866a1ab..fcd8b2dc 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/ScopeType.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/ScopeType.java @@ -35,7 +35,7 @@ public enum ScopeType { * flow execution. When the request ends any attributes in request scope go out of scope. */ REQUEST() { - public MutableAttributeMap getScope(RequestContext context) { + public MutableAttributeMap getScope(RequestContext context) { return context.getRequestScope(); } }, @@ -47,7 +47,7 @@ public enum ScopeType { * Flash scope is typically used to store messages that should be preserved until after the next view renders. */ FLASH() { - public MutableAttributeMap getScope(RequestContext context) { + public MutableAttributeMap getScope(RequestContext context) { return context.getFlashScope(); } }, @@ -59,7 +59,7 @@ public enum ScopeType { * View scope is typically used to store view model objects manipulated over a series of Ajax requests. */ VIEW() { - public MutableAttributeMap getScope(RequestContext context) { + public MutableAttributeMap getScope(RequestContext context) { return context.getViewScope(); } }, @@ -70,7 +70,7 @@ public enum ScopeType { * flow scope goes out of scope. */ FLOW() { - public MutableAttributeMap getScope(RequestContext context) { + public MutableAttributeMap getScope(RequestContext context) { return context.getFlowScope(); } }, @@ -81,12 +81,12 @@ public enum ScopeType { * conversation). When the governing execution ends, any data in conversation scope goes out of scope. */ CONVERSATION() { - public MutableAttributeMap getScope(RequestContext context) { + public MutableAttributeMap getScope(RequestContext context) { return context.getConversationScope(); } }; - public Class getType() { + public Class getType() { // force ScopeType as type return ScopeType.class; } @@ -96,6 +96,6 @@ public enum ScopeType { * @param context the context representing an executing request * @return the scope map of this type for that request, allowing attributes to be accessed and set */ - public abstract MutableAttributeMap getScope(RequestContext context); + public abstract MutableAttributeMap getScope(RequestContext context); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerHolder.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerHolder.java index 31fedbf8..366180aa 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerHolder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerHolder.java @@ -42,7 +42,7 @@ class ConditionalFlowExecutionListenerHolder { /** * The listener criteria set. */ - private Set criteriaSet = new LinkedHashSet(3); + private Set criteriaSet = new LinkedHashSet(3); /** * Create a new conditional flow execution listener holder. @@ -88,9 +88,9 @@ class ConditionalFlowExecutionListenerHolder { * @return true if yes, false otherwise */ public boolean listenerAppliesTo(FlowDefinition flowDefinition) { - Iterator it = criteriaSet.iterator(); + Iterator it = criteriaSet.iterator(); while (it.hasNext()) { - FlowExecutionListenerCriteria criteria = (FlowExecutionListenerCriteria) it.next(); + FlowExecutionListenerCriteria criteria = it.next(); if (criteria.appliesTo(flowDefinition)) { return true; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerLoader.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerLoader.java index c946dfd9..df87df60 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerLoader.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/ConditionalFlowExecutionListenerLoader.java @@ -44,7 +44,7 @@ public class ConditionalFlowExecutionListenerLoader implements FlowExecutionList * The list of flow execution listeners containing {@link ConditionalFlowExecutionListenerHolder} objects. The list * determines the conditions in which a single flow execution listener applies. */ - private List listeners = new LinkedList(); + private List listeners = new LinkedList(); /** * Add a listener that will listen to executions to flows matching the specified criteria. @@ -76,9 +76,8 @@ public class ConditionalFlowExecutionListenerLoader implements FlowExecutionList */ public FlowExecutionListener[] getListeners(FlowDefinition flowDefinition) { Assert.notNull(flowDefinition, "The Flow to load listeners for cannot be null"); - List listenersToAttach = new LinkedList(); - for (Iterator it = listeners.iterator(); it.hasNext();) { - ConditionalFlowExecutionListenerHolder listenerHolder = (ConditionalFlowExecutionListenerHolder) it.next(); + List listenersToAttach = new LinkedList(); + for (ConditionalFlowExecutionListenerHolder listenerHolder : listeners) { if (listenerHolder.listenerAppliesTo(flowDefinition)) { listenersToAttach.add(listenerHolder.getListener()); } @@ -88,7 +87,7 @@ public class ConditionalFlowExecutionListenerLoader implements FlowExecutionList + " listeners for this execution request for flow '" + flowDefinition.getId() + "', the listeners to attach are " + StylerUtils.style(listenersToAttach)); } - return (FlowExecutionListener[]) listenersToAttach.toArray(new FlowExecutionListener[listenersToAttach.size()]); + return listenersToAttach.toArray(new FlowExecutionListener[listenersToAttach.size()]); } // internal helpers @@ -99,9 +98,9 @@ public class ConditionalFlowExecutionListenerLoader implements FlowExecutionList * @return the holder, or null if not found */ private ConditionalFlowExecutionListenerHolder getHolder(FlowExecutionListener listener) { - Iterator it = listeners.iterator(); + Iterator it = listeners.iterator(); while (it.hasNext()) { - ConditionalFlowExecutionListenerHolder next = (ConditionalFlowExecutionListenerHolder) it.next(); + ConditionalFlowExecutionListenerHolder next = it.next(); if (next.getListener().equals(listener)) { return next; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/FlowExecutionListenerCriteriaFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/FlowExecutionListenerCriteriaFactory.java index 423e38ee..796d4a8b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/FlowExecutionListenerCriteriaFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/factory/FlowExecutionListenerCriteriaFactory.java @@ -102,8 +102,8 @@ public class FlowExecutionListenerCriteriaFactory { } public boolean appliesTo(FlowDefinition definition) { - for (int i = 0; i < flowIds.length; i++) { - if (flowIds[i].equals(definition.getId())) { + for (String flowId : flowIds) { + if (flowId.equals(definition.getId())) { return true; } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/FlowExecutionRepository.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/FlowExecutionRepository.java index 12b62534..7278eade 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/FlowExecutionRepository.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/FlowExecutionRepository.java @@ -77,8 +77,8 @@ public interface FlowExecutionRepository { public FlowExecution getFlowExecution(FlowExecutionKey key) throws FlowExecutionRepositoryException; /** - * Place the FlowExecution in this repository under the provided key. This should be called to save - * or update the persistent state of an active (but paused) flow execution. Before calling this method, you should + * Place the FlowExecution in this repository under the provided key. This should be called to save or + * update the persistent state of an active (but paused) flow execution. Before calling this method, you should * acquire the lock for the keyed flow execution. * @param flowExecution the flow execution * @throws FlowExecutionRepositoryException the flow execution could not be stored diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/impl/SimpleFlowExecutionSnapshotGroup.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/impl/SimpleFlowExecutionSnapshotGroup.java index 642c7f74..c28425c7 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/impl/SimpleFlowExecutionSnapshotGroup.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/impl/SimpleFlowExecutionSnapshotGroup.java @@ -20,7 +20,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; -import org.springframework.core.JdkVersion; import org.springframework.webflow.execution.repository.snapshot.FlowExecutionSnapshot; import org.springframework.webflow.execution.repository.snapshot.SnapshotNotFoundException; @@ -35,13 +34,13 @@ class SimpleFlowExecutionSnapshotGroup implements FlowExecutionSnapshotGroup, Se /** * The snapshot map; the key is a snapshot id, and the value is a {@link FlowExecutionSnapshot} object. */ - private Map snapshots = new HashMap(); + private Map snapshots = new HashMap(); /** * An ordered list of snapshot ids. Each snapshot id represents an pointer to a {@link FlowExecutionSnapshot} in the * map. The first element is the oldest snapshot and the last is the youngest. */ - private LinkedList snapshotIds = new LinkedList(); + private LinkedList snapshotIds = new LinkedList(); /** * The maximum number of snapshots allowed in this group. -1 indicates no max limit. @@ -69,7 +68,7 @@ class SimpleFlowExecutionSnapshotGroup implements FlowExecutionSnapshotGroup, Se } public FlowExecutionSnapshot getSnapshot(Serializable snapshotId) throws SnapshotNotFoundException { - FlowExecutionSnapshot snapshot = (FlowExecutionSnapshot) snapshots.get(snapshotId); + FlowExecutionSnapshot snapshot = snapshots.get(snapshotId); if (snapshot == null) { throw new SnapshotNotFoundException(snapshotId); } @@ -109,12 +108,7 @@ class SimpleFlowExecutionSnapshotGroup implements FlowExecutionSnapshotGroup, Se } public Serializable nextSnapshotId() { - Integer nextSnapshotId; - if (JdkVersion.isAtLeastJava15()) { - nextSnapshotId = Integer.valueOf(snapshotIdSequence); - } else { - nextSnapshotId = new Integer(snapshotIdSequence); - } + Integer nextSnapshotId = Integer.valueOf(snapshotIdSequence); snapshotIdSequence++; return nextSnapshotId; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/AbstractSnapshottingFlowExecutionRepository.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/AbstractSnapshottingFlowExecutionRepository.java index 7afc4fb3..2c7c2656 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/AbstractSnapshottingFlowExecutionRepository.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/AbstractSnapshottingFlowExecutionRepository.java @@ -82,9 +82,11 @@ public abstract class AbstractSnapshottingFlowExecutionRepository extends Abstra * @param conversation the governing conversation * @return the restored flow execution */ + @SuppressWarnings("unchecked") protected FlowExecution restoreFlowExecution(FlowExecutionSnapshot snapshot, FlowExecutionKey key, Conversation conversation) { - MutableAttributeMap conversationScope = (MutableAttributeMap) conversation.getAttribute("scope"); + MutableAttributeMap conversationScope = (MutableAttributeMap) conversation + .getAttribute("scope"); String flowId = (String) conversation.getAttribute("name"); return snapshotFactory.restoreExecution(snapshot, flowId, key, conversationScope, this); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/FlowExecutionSnapshotFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/FlowExecutionSnapshotFactory.java index 15e6a445..a68e4d42 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/FlowExecutionSnapshotFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/FlowExecutionSnapshotFactory.java @@ -48,6 +48,6 @@ public interface FlowExecutionSnapshotFactory { * @throws FlowExecutionRestorationFailureException if flow execution restoration fails */ public FlowExecution restoreExecution(FlowExecutionSnapshot snapshot, String flowId, FlowExecutionKey key, - MutableAttributeMap conversationScope, FlowExecutionKeyFactory keyFactory) + MutableAttributeMap conversationScope, FlowExecutionKeyFactory keyFactory) throws FlowExecutionRestorationFailureException; } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SerializedFlowExecutionSnapshot.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SerializedFlowExecutionSnapshot.java index 0b5114e6..86427614 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SerializedFlowExecutionSnapshot.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SerializedFlowExecutionSnapshot.java @@ -120,8 +120,8 @@ public class SerializedFlowExecutionSnapshot extends FlowExecutionSnapshot imple public int hashCode() { int hashCode = 0; - for (int i = 0; i < flowExecutionData.length; i++) { - hashCode += flowExecutionData[i]; + for (byte element : flowExecutionData) { + hashCode += element; } return hashCode; } @@ -231,7 +231,7 @@ public class SerializedFlowExecutionSnapshot extends FlowExecutionSnapshot imple private static class ConfigurableObjectInputStream extends ObjectInputStream { /* Temporary workaround for SPR-???? */ - private static final HashMap PRIMITIVE_CLASSES = new HashMap(8, 1.0F); + private static final HashMap> PRIMITIVE_CLASSES = new HashMap>(8, 1.0F); static { PRIMITIVE_CLASSES.put("boolean", boolean.class); PRIMITIVE_CLASSES.put("byte", byte.class); @@ -251,12 +251,12 @@ public class SerializedFlowExecutionSnapshot extends FlowExecutionSnapshot imple this.classLoader = classLoader; } - protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { + protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String name = desc.getName(); try { return ClassUtils.forName(desc.getName(), classLoader); } catch (ClassNotFoundException ex) { - Class rtn = (Class) PRIMITIVE_CLASSES.get(name); + Class rtn = PRIMITIVE_CLASSES.get(name); if (rtn == null) { throw ex; } @@ -264,14 +264,14 @@ public class SerializedFlowExecutionSnapshot extends FlowExecutionSnapshot imple } } - protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { + protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { ClassLoader nonPublicLoader = null; boolean hasNonPublicInterface = false; // define proxy in class loader of non-public interface(s), if any - Class[] classObjs = new Class[interfaces.length]; + Class[] classObjs = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { - Class cl = ClassUtils.forName(interfaces[i], classLoader); + Class cl = ClassUtils.forName(interfaces[i], classLoader); if ((cl.getModifiers() & Modifier.PUBLIC) == 0) { if (hasNonPublicInterface) { if (nonPublicLoader != cl.getClassLoader()) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SerializedFlowExecutionSnapshotFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SerializedFlowExecutionSnapshotFactory.java index 05f867ca..f7122477 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SerializedFlowExecutionSnapshotFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SerializedFlowExecutionSnapshotFactory.java @@ -71,7 +71,7 @@ public class SerializedFlowExecutionSnapshotFactory implements FlowExecutionSnap } public FlowExecution restoreExecution(FlowExecutionSnapshot snapshot, String flowId, FlowExecutionKey key, - MutableAttributeMap conversationScope, FlowExecutionKeyFactory keyFactory) + MutableAttributeMap conversationScope, FlowExecutionKeyFactory keyFactory) throws FlowExecutionRestorationFailureException { SerializedFlowExecutionSnapshot snapshotImpl = (SerializedFlowExecutionSnapshot) snapshot; FlowDefinition def = flowDefinitionLocator.getFlowDefinition(flowId); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SimpleFlowExecutionSnapshotFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SimpleFlowExecutionSnapshotFactory.java index 6583a7d5..68b2c7fe 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SimpleFlowExecutionSnapshotFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/snapshot/SimpleFlowExecutionSnapshotFactory.java @@ -26,8 +26,8 @@ import org.springframework.webflow.execution.FlowExecutionKeyFactory; import org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException; /** - * A factory that creates new flow execution snapshot instances that simply wraps an underlying - * {@link FlowExecution flow execution} instance. + * A factory that creates new flow execution snapshot instances that simply wraps an underlying {@link FlowExecution + * flow execution} instance. * * Note: this class is generally only suitable for use with a repository that has maxSnapshots set to 1, since no actual * copies of the execution data are made by this factory. This class exists to support the use case where taking copies @@ -59,7 +59,7 @@ public class SimpleFlowExecutionSnapshotFactory implements FlowExecutionSnapshot } public FlowExecution restoreExecution(FlowExecutionSnapshot snapshot, String flowId, FlowExecutionKey key, - MutableAttributeMap conversationScope, FlowExecutionKeyFactory keyFactory) + MutableAttributeMap conversationScope, FlowExecutionKeyFactory keyFactory) throws FlowExecutionRestorationFailureException { SimpleFlowExecutionSnapshot snapshotImpl = (SimpleFlowExecutionSnapshot) snapshot; FlowDefinition def = flowDefinitionLocator.getFlowDefinition(flowId); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/support/CompositeFlowExecutionKey.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/support/CompositeFlowExecutionKey.java index 7314e543..59c8dad7 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/support/CompositeFlowExecutionKey.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/support/CompositeFlowExecutionKey.java @@ -81,8 +81,8 @@ public class CompositeFlowExecutionKey extends FlowExecutionKey { } public String toString() { - return new StringBuffer().append(EXECUTION_ID_PREFIX).append(executionId).append(SNAPSHOT_ID_PREFIX).append( - snapshotId).toString(); + return new StringBuffer().append(EXECUTION_ID_PREFIX).append(executionId).append(SNAPSHOT_ID_PREFIX) + .append(snapshotId).toString(); } // static helpers diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/support/FlowExecutionStateRestorer.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/support/FlowExecutionStateRestorer.java index 2c8570ff..b33dde91 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/support/FlowExecutionStateRestorer.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/support/FlowExecutionStateRestorer.java @@ -40,5 +40,5 @@ public interface FlowExecutionStateRestorer { * @return the restored flow execution */ public FlowExecution restoreState(FlowExecution execution, FlowDefinition definition, FlowExecutionKey key, - MutableAttributeMap conversationScope, FlowDefinitionLocator subflowDefinitionLocator); + MutableAttributeMap conversationScope, FlowDefinitionLocator subflowDefinitionLocator); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutor.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutor.java index 68a1b1f5..97b42b91 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutor.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutor.java @@ -37,7 +37,7 @@ public interface FlowExecutor { * @param input input to pass to the new execution on startup (optional) * @param context access to the calling environment (required) */ - public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context) + public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context) throws FlowException; /** diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutorImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutorImpl.java index 45fef518..1c5810a0 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutorImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutorImpl.java @@ -128,7 +128,7 @@ public class FlowExecutorImpl implements FlowExecutor { return executionRepository; } - public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context) + public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context) throws FlowException { try { if (logger.isDebugEnabled()) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/WebFlowOgnlExpressionParser.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/WebFlowOgnlExpressionParser.java index 318f4014..1ae7029a 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/WebFlowOgnlExpressionParser.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/WebFlowOgnlExpressionParser.java @@ -39,6 +39,7 @@ import org.springframework.webflow.execution.RequestContext; * * @author Keith Donald */ +@SuppressWarnings("rawtypes") public class WebFlowOgnlExpressionParser extends OgnlExpressionParser { /** @@ -70,6 +71,7 @@ public class WebFlowOgnlExpressionParser extends OgnlExpressionParser { * Resolves Mutable Attribute Map properties, also capable of setting properties. */ private static class MutableAttributeMapPropertyAccessor extends MapAdaptablePropertyAccessor { + @SuppressWarnings("unchecked") public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { ((MutableAttributeMap) target).put((String) name, value); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ActionMethodELResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ActionMethodELResolver.java index 65456952..09a16d52 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ActionMethodELResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ActionMethodELResolver.java @@ -15,6 +15,7 @@ */ package org.springframework.webflow.expression.el; +import java.beans.FeatureDescriptor; import java.util.Iterator; import javax.el.ELContext; @@ -35,7 +36,7 @@ import org.springframework.webflow.execution.AnnotatedAction; */ public class ActionMethodELResolver extends ELResolver { - public Class getCommonPropertyType(ELContext elContext, Object base) { + public Class getCommonPropertyType(ELContext elContext, Object base) { if (base instanceof Action) { return String.class; } else { @@ -43,11 +44,11 @@ public class ActionMethodELResolver extends ELResolver { } } - public Iterator getFeatureDescriptors(ELContext elContext, Object base) { + public Iterator getFeatureDescriptors(ELContext elContext, Object base) { return null; } - public Class getType(ELContext elContext, Object base, Object property) { + public Class getType(ELContext elContext, Object base, Object property) { if (base instanceof Action) { elContext.setPropertyResolved(true); return Action.class; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/FlowResourceELResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/FlowResourceELResolver.java index fcbf801a..e491692a 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/FlowResourceELResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/FlowResourceELResolver.java @@ -1,5 +1,6 @@ package org.springframework.webflow.expression.el; +import java.beans.FeatureDescriptor; import java.util.Iterator; import java.util.Locale; @@ -31,7 +32,7 @@ public class FlowResourceELResolver extends ELResolver { this.requestContext = requestContext; } - public Class getCommonPropertyType(ELContext context, Object base) { + public Class getCommonPropertyType(ELContext context, Object base) { if (base == null) { return MessageSource.class; } else if (base instanceof MessageSource) { @@ -41,11 +42,11 @@ public class FlowResourceELResolver extends ELResolver { } } - public Iterator getFeatureDescriptors(ELContext context, Object base) { + public Iterator getFeatureDescriptors(ELContext context, Object base) { return null; } - public Class getType(ELContext context, Object base, Object property) { + public Class getType(ELContext context, Object base, Object property) { RequestContext requestContext = getRequestContext(); if (requestContext == null) { return null; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ImplicitFlowVariableELResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ImplicitFlowVariableELResolver.java index ee2a1e7a..b725cd49 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ImplicitFlowVariableELResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ImplicitFlowVariableELResolver.java @@ -15,6 +15,7 @@ */ package org.springframework.webflow.expression.el; +import java.beans.FeatureDescriptor; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -61,7 +62,7 @@ public class ImplicitFlowVariableELResolver extends ELResolver { this.requestContext = requestContext; } - public Class getCommonPropertyType(ELContext context, Object base) { + public Class getCommonPropertyType(ELContext context, Object base) { if (base == null) { return Object.class; } else { @@ -69,11 +70,11 @@ public class ImplicitFlowVariableELResolver extends ELResolver { } } - public Iterator getFeatureDescriptors(ELContext context, Object base) { + public Iterator getFeatureDescriptors(ELContext context, Object base) { return null; } - public Class getType(ELContext context, Object base, Object property) { + public Class getType(ELContext context, Object base, Object property) { RequestContext requestContext = getRequestContext(); if (base != null || requestContext == null) { return null; @@ -128,7 +129,7 @@ public class ImplicitFlowVariableELResolver extends ELResolver { } private static final class ImplicitVariables { - private static final Map vars = new HashMap(); + private static final Map vars = new HashMap(); private static final PropertyResolver requestContextResolver = new PropertyResolver() { protected Object doResolve(ELContext elContext, RequestContext requestContext, Object property) { @@ -168,7 +169,7 @@ public class ImplicitFlowVariableELResolver extends ELResolver { } public static Object value(ELContext elContext, RequestContext requestContext, Object property) { - PropertyResolver resolver = (PropertyResolver) vars.get(property); + PropertyResolver resolver = vars.get(property); return resolver.resolve(requestContext, property); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/RequestContextELResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/RequestContextELResolver.java index 9bacae46..c8caedef 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/RequestContextELResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/RequestContextELResolver.java @@ -15,6 +15,7 @@ */ package org.springframework.webflow.expression.el; +import java.beans.FeatureDescriptor; import java.util.Iterator; import javax.el.ELContext; @@ -25,8 +26,8 @@ import org.springframework.webflow.execution.RequestContext; import org.springframework.webflow.execution.RequestContextHolder; /** - * Custom EL resolver that resolves the current RequestContext under the variable {@link #REQUEST_CONTEXT_VARIABLE_NAME}. - * Allows for accessing any property of the RequestContext instance. For example: + * Custom EL resolver that resolves the current RequestContext under the variable {@link #REQUEST_CONTEXT_VARIABLE_NAME} + * . Allows for accessing any property of the RequestContext instance. For example: * "#{flowRequestContext.conversationScope.myProperty}". * * @author Jeremy Grelle @@ -47,18 +48,18 @@ public class RequestContextELResolver extends ELResolver { this.context = context; } - public Class getCommonPropertyType(ELContext elContext, Object base) { + public Class getCommonPropertyType(ELContext elContext, Object base) { if (base == null) { return RequestContext.class; } return null; } - public Iterator getFeatureDescriptors(ELContext elContext, Object base) { + public Iterator getFeatureDescriptors(ELContext elContext, Object base) { return null; } - public Class getType(ELContext elContext, Object base, Object property) { + public Class getType(ELContext elContext, Object base, Object property) { if (base == null && REQUEST_CONTEXT_VARIABLE_NAME.equals(property)) { elContext.setPropertyResolved(true); return RequestContext.class; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ScopeSearchingELResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ScopeSearchingELResolver.java index c07bf449..afdfac11 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ScopeSearchingELResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/ScopeSearchingELResolver.java @@ -15,6 +15,7 @@ */ package org.springframework.webflow.expression.el; +import java.beans.FeatureDescriptor; import java.util.Iterator; import javax.el.ELContext; @@ -43,7 +44,7 @@ public class ScopeSearchingELResolver extends ELResolver { this.requestContext = requestContext; } - public Class getCommonPropertyType(ELContext elContext, Object base) { + public Class getCommonPropertyType(ELContext elContext, Object base) { if (base == null) { return Object.class; } else { @@ -51,11 +52,11 @@ public class ScopeSearchingELResolver extends ELResolver { } } - public Iterator getFeatureDescriptors(ELContext elContext, Object base) { + public Iterator getFeatureDescriptors(ELContext elContext, Object base) { return null; } - public Class getType(ELContext elContext, Object base, Object property) { + public Class getType(ELContext elContext, Object base, Object property) { RequestContext requestContext = getRequestContext(); if (base != null || requestContext == null) { return null; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/WebFlowELExpressionParser.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/WebFlowELExpressionParser.java index 21ed0f61..9971a2d6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/el/WebFlowELExpressionParser.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/el/WebFlowELExpressionParser.java @@ -52,7 +52,7 @@ public class WebFlowELExpressionParser extends ELExpressionParser { private static class RequestContextELContextFactory implements ELContextFactory { public ELContext getELContext(Object target) { RequestContext context = (RequestContext) target; - List customResolvers = new ArrayList(); + List customResolvers = new ArrayList(); customResolvers.add(new RequestContextELResolver(context)); customResolvers.add(new FlowResourceELResolver(context)); customResolvers.add(new ImplicitFlowVariableELResolver(context)); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/ActionPropertyAccessor.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/ActionPropertyAccessor.java index ceda9029..86fca4be 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/ActionPropertyAccessor.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/ActionPropertyAccessor.java @@ -36,7 +36,7 @@ import org.springframework.webflow.execution.AnnotatedAction; */ public class ActionPropertyAccessor implements PropertyAccessor { - public Class[] getSpecificTargetClasses() { + public Class[] getSpecificTargetClasses() { return new Class[] { Action.class }; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/BeanFactoryPropertyAccessor.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/BeanFactoryPropertyAccessor.java index 19c48581..76830f42 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/BeanFactoryPropertyAccessor.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/BeanFactoryPropertyAccessor.java @@ -35,7 +35,7 @@ public class BeanFactoryPropertyAccessor implements PropertyAccessor { private static final BeanFactory EMPTY_BEAN_FACTORY = new StaticListableBeanFactory(); - public Class[] getSpecificTargetClasses() { + public Class[] getSpecificTargetClasses() { return null; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/FlowVariablePropertyAccessor.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/FlowVariablePropertyAccessor.java index bdc70c35..61612ad8 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/FlowVariablePropertyAccessor.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/FlowVariablePropertyAccessor.java @@ -47,7 +47,7 @@ import org.springframework.webflow.execution.RequestContextHolder; */ public class FlowVariablePropertyAccessor implements PropertyAccessor { - private static Map variables = new HashMap(); + private static Map variables = new HashMap(); static { variables.put("currentUser", new FlowVariableAccessor() { @@ -67,7 +67,7 @@ public class FlowVariablePropertyAccessor implements PropertyAccessor { }); } - public Class[] getSpecificTargetClasses() { + public Class[] getSpecificTargetClasses() { return null; } @@ -76,7 +76,7 @@ public class FlowVariablePropertyAccessor implements PropertyAccessor { } public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { - FlowVariableAccessor var = (FlowVariableAccessor) variables.get(name); + FlowVariableAccessor var = variables.get(name); return new TypedValue(var.getVariable()); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/MapAdaptablePropertyAccessor.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/MapAdaptablePropertyAccessor.java index e66bd72a..3646e054 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/MapAdaptablePropertyAccessor.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/MapAdaptablePropertyAccessor.java @@ -30,7 +30,7 @@ import org.springframework.webflow.core.collection.MutableAttributeMap; */ public class MapAdaptablePropertyAccessor implements PropertyAccessor { - public Class[] getSpecificTargetClasses() { + public Class[] getSpecificTargetClasses() { return new Class[] { MapAdaptable.class }; } @@ -39,7 +39,7 @@ public class MapAdaptablePropertyAccessor implements PropertyAccessor { } public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { - MapAdaptable map = (MapAdaptable) target; + MapAdaptable map = (MapAdaptable) target; return new TypedValue(map.asMap().get(name)); } @@ -47,6 +47,7 @@ public class MapAdaptablePropertyAccessor implements PropertyAccessor { return (target instanceof MutableAttributeMap); } + @SuppressWarnings({ "rawtypes", "unchecked" }) public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException { MutableAttributeMap map = (MutableAttributeMap) target; map.put(name, newValue); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/MessageSourcePropertyAccessor.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/MessageSourcePropertyAccessor.java index 6312a480..9b820199 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/MessageSourcePropertyAccessor.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/MessageSourcePropertyAccessor.java @@ -43,7 +43,7 @@ import org.springframework.webflow.execution.RequestContextHolder; */ public class MessageSourcePropertyAccessor implements PropertyAccessor { - public Class[] getSpecificTargetClasses() { + public Class[] getSpecificTargetClasses() { return new Class[] { MessageSource.class }; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/ScopeSearchingPropertyAccessor.java b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/ScopeSearchingPropertyAccessor.java index ec130f12..2ad1a1cb 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/ScopeSearchingPropertyAccessor.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/expression/spel/ScopeSearchingPropertyAccessor.java @@ -30,7 +30,7 @@ import org.springframework.webflow.execution.RequestContext; */ public class ScopeSearchingPropertyAccessor implements PropertyAccessor { - public Class[] getSpecificTargetClasses() { + public Class[] getSpecificTargetClasses() { return new Class[] { RequestContext.class }; } @@ -39,7 +39,7 @@ public class ScopeSearchingPropertyAccessor implements PropertyAccessor { } public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { - MutableAttributeMap scope = findScopeForAttribute((RequestContext) target, name); + MutableAttributeMap scope = findScopeForAttribute((RequestContext) target, name); return (scope != null) ? new TypedValue(scope.get(name)) : null; } @@ -48,13 +48,13 @@ public class ScopeSearchingPropertyAccessor implements PropertyAccessor { } public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException { - MutableAttributeMap scope = findScopeForAttribute((RequestContext) target, name); + MutableAttributeMap scope = findScopeForAttribute((RequestContext) target, name); if (scope != null) { scope.put(name, newValue); } } - private MutableAttributeMap findScopeForAttribute(RequestContext requestContext, String name) { + private MutableAttributeMap findScopeForAttribute(RequestContext requestContext, String name) { if (requestContext.getRequestScope().contains(name)) { return requestContext.getRequestScope(); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/DelegatingFlowViewResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/DelegatingFlowViewResolver.java index a951b945..5dc366a0 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/DelegatingFlowViewResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/DelegatingFlowViewResolver.java @@ -16,7 +16,6 @@ package org.springframework.webflow.mvc.builder; import java.util.Collections; -import java.util.Iterator; import java.util.List; import org.springframework.web.servlet.View; @@ -33,19 +32,18 @@ import org.springframework.webflow.mvc.view.FlowViewResolver; */ public class DelegatingFlowViewResolver implements FlowViewResolver { - private List viewResolvers; + private List viewResolvers; /** * Creates a new flow view resolver. * @param viewResolvers the Spring MVC view resolver chain to delegate to */ - public DelegatingFlowViewResolver(List viewResolvers) { - this.viewResolvers = viewResolvers != null ? viewResolvers : Collections.EMPTY_LIST; + public DelegatingFlowViewResolver(List viewResolvers) { + this.viewResolvers = viewResolvers != null ? viewResolvers : Collections. emptyList(); } public View resolveView(String viewId, RequestContext context) { - for (Iterator it = viewResolvers.iterator(); it.hasNext();) { - ViewResolver viewResolver = (ViewResolver) it.next(); + for (ViewResolver viewResolver : viewResolvers) { try { View view = viewResolver.resolveViewName(viewId, context.getExternalContext().getLocale()); if (view != null) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcViewFactoryCreator.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcViewFactoryCreator.java index c7c4f374..420196d3 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcViewFactoryCreator.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcViewFactoryCreator.java @@ -149,7 +149,7 @@ public class MvcViewFactoryCreator implements ViewFactoryCreator, ApplicationCon * to be used, the resolvers should be ordered in the manner they should be applied. * @param viewResolvers the view resolver list */ - public void setViewResolvers(List viewResolvers) { + public void setViewResolvers(List viewResolvers) { this.flowViewResolver = new DelegatingFlowViewResolver(viewResolvers); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/AbstractFlowHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/AbstractFlowHandler.java index 7d833b02..e33d48be 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/AbstractFlowHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/AbstractFlowHandler.java @@ -40,11 +40,11 @@ public class AbstractFlowHandler implements FlowHandler { return null; } - public MutableAttributeMap createExecutionInputMap(RenderRequest request) { + public MutableAttributeMap createExecutionInputMap(RenderRequest request) { return null; } - public MutableAttributeMap createResourceExecutionInputMap(ResourceRequest request) { + public MutableAttributeMap createResourceExecutionInputMap(ResourceRequest request) { return null; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandler.java index 44b8d677..083c35b1 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandler.java @@ -55,7 +55,7 @@ public interface FlowHandler { * @param request the current request * @return the input map */ - public MutableAttributeMap createExecutionInputMap(RenderRequest request); + public MutableAttributeMap createExecutionInputMap(RenderRequest request); /** * Creates the flow execution input map to pass to a new instance of the flow being started in a resource request. @@ -63,7 +63,7 @@ public interface FlowHandler { * @param request the current request * @return the input map */ - public MutableAttributeMap createResourceExecutionInputMap(ResourceRequest request); + public MutableAttributeMap createResourceExecutionInputMap(ResourceRequest request); /** * Handles a specific flow execution outcome. Used to change portlet modes after the flow ends. diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapter.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapter.java index 95d93835..2c950267 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapter.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapter.java @@ -128,7 +128,7 @@ public class FlowHandlerAdapter extends PortletContentGenerator implements Handl if (flowExecutionKey != null) { return resumeFlowRender(request, response, flowHandler, flowExecutionKey); } else { - MutableAttributeMap input = flowHandler.createExecutionInputMap(request); + MutableAttributeMap input = flowHandler.createExecutionInputMap(request); if (input == null) { input = defaultCreateFlowExecutionInputMap(request); } @@ -145,7 +145,7 @@ public class FlowHandlerAdapter extends PortletContentGenerator implements Handl if (flowExecutionKey != null) { return resumeFlowResource(request, response, flowHandler, flowExecutionKey); } else { - MutableAttributeMap input = flowHandler.createResourceExecutionInputMap(request); + MutableAttributeMap input = flowHandler.createResourceExecutionInputMap(request); if (input == null) { input = defaultCreateFlowExecutionInputMap(request); } @@ -188,17 +188,17 @@ public class FlowHandlerAdapter extends PortletContentGenerator implements Handl return new PortletExternalContext(getPortletContext(), request, response); } - protected MutableAttributeMap defaultCreateFlowExecutionInputMap(PortletRequest request) { - Map parameterMap = request.getParameterMap(); + protected MutableAttributeMap defaultCreateFlowExecutionInputMap(PortletRequest request) { + Map parameterMap = request.getParameterMap(); if (parameterMap.size() == 0) { return null; } - LocalAttributeMap inputMap = new LocalAttributeMap(); - Iterator it = parameterMap.entrySet().iterator(); + LocalAttributeMap inputMap = new LocalAttributeMap(); + Iterator> it = parameterMap.entrySet().iterator(); while (it.hasNext()) { - Map.Entry entry = (Map.Entry) it.next(); - String name = (String) entry.getKey(); - String[] values = (String[]) entry.getValue(); + Map.Entry entry = it.next(); + String name = entry.getKey(); + String[] values = entry.getValue(); if (values.length == 1) { inputMap.put(name, values[0]); } else { @@ -273,8 +273,8 @@ public class FlowHandlerAdapter extends PortletContentGenerator implements Handl } } - private ModelAndView startFlowRender(FlowHandler flowHandler, MutableAttributeMap input, RenderRequest request, - RenderResponse response) { + private ModelAndView startFlowRender(FlowHandler flowHandler, MutableAttributeMap input, + RenderRequest request, RenderResponse response) { PortletExternalContext context = createPortletExternalContext(request, response); try { FlowExecutionResult result = flowExecutor.launchExecution(flowHandler.getFlowId(), input, context); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/PortletMvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/PortletMvcView.java index 1b8486de..d22282b8 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/PortletMvcView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/portlet/PortletMvcView.java @@ -45,7 +45,7 @@ public class PortletMvcView extends AbstractMvcView { super(view, context); } - protected void doRender(Map model) throws Exception { + protected void doRender(Map model) throws Exception { RequestContext context = getRequestContext(); ExternalContext externalContext = context.getExternalContext(); View view = getView(); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/AbstractFlowHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/AbstractFlowHandler.java index ccd1145a..9f5aa784 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/AbstractFlowHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/AbstractFlowHandler.java @@ -35,7 +35,7 @@ public class AbstractFlowHandler implements FlowHandler { return null; } - public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { + public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { return null; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowController.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowController.java index a56d3559..c2837db9 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowController.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowController.java @@ -44,7 +44,7 @@ public class FlowController implements Controller, ApplicationContextAware, Init private FlowHandlerAdapter flowHandlerAdapter; - private Map flowHandlers = new HashMap(); + private Map flowHandlers = new HashMap(); private boolean customFlowHandlerAdapterSet; @@ -125,7 +125,7 @@ public class FlowController implements Controller, ApplicationContextAware, Init * Sets the custom flow handles for managing the access to flows in a custom manner. * @param flowHandlers the flow handler map */ - public void setFlowHandlers(Map flowHandlers) { + public void setFlowHandlers(Map flowHandlers) { this.flowHandlers = flowHandlers; } @@ -183,7 +183,7 @@ public class FlowController implements Controller, ApplicationContextAware, Init } private FlowHandler getFlowHandler(String flowId) { - FlowHandler handler = (FlowHandler) flowHandlers.get(flowId); + FlowHandler handler = flowHandlers.get(flowId); if (handler == null) { handler = new DefaultFlowHandler(flowId); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandler.java index 03efb997..13b4ca64 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandler.java @@ -49,7 +49,7 @@ public interface FlowHandler { * @param request the current request * @return the input map, or null if the contents of the input map should be determined by the caller */ - public MutableAttributeMap createExecutionInputMap(HttpServletRequest request); + public MutableAttributeMap createExecutionInputMap(HttpServletRequest request); /** * Handles a specific flow execution outcome. Used by a Controller to get the location of the resource to redirect diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java index 9d21f214..eb492d88 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapter.java @@ -18,6 +18,7 @@ package org.springframework.webflow.mvc.servlet; import java.io.IOException; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -188,7 +189,7 @@ public class FlowHandlerAdapter extends WebContentGenerator implements HandlerAd } else { try { String flowId = getFlowId(flowHandler, request); - MutableAttributeMap input = getInputMap(flowHandler, request); + MutableAttributeMap input = getInputMap(flowHandler, request); ServletExternalContext context = createServletExternalContext(request, response); FlowExecutionResult result = flowExecutor.launchExecution(flowId, input, context); handleFlowExecutionResult(result, context, request, response, flowHandler); @@ -233,17 +234,18 @@ public class FlowHandlerAdapter extends WebContentGenerator implements HandlerAd * current request parameters as flow execution input attributes. Subclasses may override. * @param request the current request */ - protected MutableAttributeMap defaultCreateFlowExecutionInputMap(HttpServletRequest request) { - Map parameterMap = request.getParameterMap(); + protected MutableAttributeMap defaultCreateFlowExecutionInputMap(HttpServletRequest request) { + @SuppressWarnings("unchecked") + Map parameterMap = request.getParameterMap(); if (parameterMap.size() == 0) { return null; } - LocalAttributeMap inputMap = new LocalAttributeMap(parameterMap.size(), 1); - Iterator it = parameterMap.entrySet().iterator(); + LocalAttributeMap inputMap = new LocalAttributeMap(parameterMap.size(), 1); + Iterator> it = parameterMap.entrySet().iterator(); while (it.hasNext()) { - Map.Entry entry = (Map.Entry) it.next(); - String name = (String) entry.getKey(); - String[] values = (String[]) entry.getValue(); + Entry entry = it.next(); + String name = entry.getKey(); + String[] values = entry.getValue(); if (values.length == 1) { inputMap.put(name, values[0]); } else { @@ -376,7 +378,7 @@ public class FlowHandlerAdapter extends WebContentGenerator implements HandlerAd private void sendFlowDefinitionRedirect(FlowExecutionResult result, ServletExternalContext context, HttpServletRequest request, HttpServletResponse response) throws IOException { String flowId = context.getFlowRedirectFlowId(); - MutableAttributeMap input = context.getFlowRedirectFlowInput(); + MutableAttributeMap input = context.getFlowRedirectFlowInput(); if (result.isPaused()) { input.put(REFERER_FLOW_EXECUTION_ATTRIBUTE, result.getPausedKey()); } @@ -468,8 +470,8 @@ public class FlowHandlerAdapter extends WebContentGenerator implements HandlerAd } } - private MutableAttributeMap getInputMap(FlowHandler handler, HttpServletRequest request) { - MutableAttributeMap input = handler.createExecutionInputMap(request); + private MutableAttributeMap getInputMap(FlowHandler handler, HttpServletRequest request) { + MutableAttributeMap input = handler.createExecutionInputMap(request); if (input != null) { return input; } else { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/ServletMvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/ServletMvcView.java index 4a669c7b..851023e8 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/ServletMvcView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/servlet/ServletMvcView.java @@ -40,7 +40,7 @@ public class ServletMvcView extends AbstractMvcView { super(view, context); } - protected void doRender(Map model) throws Exception { + protected void doRender(Map model) throws Exception { RequestContext context = getRequestContext(); ExternalContext externalContext = context.getExternalContext(); HttpServletRequest request = (HttpServletRequest) externalContext.getNativeRequest(); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java index ae80603a..d7a8c9b4 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java @@ -170,7 +170,7 @@ public abstract class AbstractMvcView implements View { } public void render() throws IOException { - Map model = new HashMap(); + Map model = new HashMap(); model.putAll(flowScopes()); exposeBindingModel(model); model.put("flowRequestContext", requestContext); @@ -278,7 +278,7 @@ public abstract class AbstractMvcView implements View { * @param model the view model data * @throws Exception an exception occurred rendering the view */ - protected abstract void doRender(Map model) throws Exception; + protected abstract void doRender(Map model) throws Exception; /** * Returns the id of the user event being processed. @@ -386,10 +386,10 @@ public abstract class AbstractMvcView implements View { * @param parameterNames the request parameters * @param model the model */ - protected void addModelBindings(DefaultMapper mapper, Set parameterNames, Object model) { - Iterator it = binderConfiguration.getBindings().iterator(); + protected void addModelBindings(DefaultMapper mapper, Set parameterNames, Object model) { + Iterator it = binderConfiguration.getBindings().iterator(); while (it.hasNext()) { - Binding binding = (Binding) it.next(); + Binding binding = it.next(); String parameterName = binding.getProperty(); if (parameterNames.contains(parameterName)) { addMapping(mapper, binding, model); @@ -445,9 +445,8 @@ public abstract class AbstractMvcView implements View { * @param parameterNames the request parameter names * @param model the model */ - protected void addDefaultMappings(DefaultMapper mapper, Set parameterNames, Object model) { - for (Iterator it = parameterNames.iterator(); it.hasNext();) { - String parameterName = (String) it.next(); + protected void addDefaultMappings(DefaultMapper mapper, Set parameterNames, Object model) { + for (String parameterName : parameterNames) { if (fieldMarkerPrefix != null && parameterName.startsWith(fieldMarkerPrefix)) { String field = parameterName.substring(fieldMarkerPrefix.length()); if (!parameterNames.contains(field)) { @@ -471,7 +470,7 @@ public abstract class AbstractMvcView implements View { ParserContext parserContext = new FluentParserContext().evaluate(model.getClass()); Expression target = expressionParser.parseExpression(field, parserContext); try { - Class propertyType = target.getValueType(model); + Class propertyType = target.getValueType(model); Expression source = new StaticExpression(getEmptyValue(propertyType)); DefaultMapping mapping = new DefaultMapping(source, target); if (logger.isDebugEnabled()) { @@ -526,7 +525,7 @@ public abstract class AbstractMvcView implements View { if (validateAttribute != null) { return validateAttribute.booleanValue(); } else { - AttributeMap flowExecutionAttributes = requestContext.getFlowExecutionContext().getAttributes(); + AttributeMap flowExecutionAttributes = requestContext.getFlowExecutionContext().getAttributes(); Boolean validateOnBindingErrors = flowExecutionAttributes.getBoolean("validateOnBindingErrors"); if (validateOnBindingErrors != null) { if (!validateOnBindingErrors.booleanValue() && mappingResults.hasErrorResults()) { @@ -539,7 +538,7 @@ public abstract class AbstractMvcView implements View { // internal helpers - private Map flowScopes() { + private Map flowScopes() { if (requestContext.getCurrentState().isViewState()) { return requestContext.getConversationScope().union(requestContext.getFlowScope()) .union(requestContext.getViewScope()).union(requestContext.getFlashScope()) @@ -550,7 +549,7 @@ public abstract class AbstractMvcView implements View { } } - private void exposeBindingModel(Map model) { + private void exposeBindingModel(Map model) { Object modelObject = getModelObject(); if (modelObject != null) { BindingModel bindingModel = new BindingModel(getModelExpression().getExpressionString(), modelObject, @@ -578,7 +577,7 @@ public abstract class AbstractMvcView implements View { return (Expression) requestContext.getCurrentState().getAttributes().get("model"); } - private Object getEmptyValue(Class fieldType) { + private Object getEmptyValue(Class fieldType) { if (fieldType != null && boolean.class.equals(fieldType) || Boolean.class.equals(fieldType)) { // Special handling of boolean property. return Boolean.FALSE; @@ -600,9 +599,8 @@ public abstract class AbstractMvcView implements View { } private void addErrorMessages(MappingResults results) { - List errors = results.getResults(MAPPING_ERROR); - for (Iterator it = errors.iterator(); it.hasNext();) { - MappingResult error = (MappingResult) it.next(); + List errors = results.getResults(MAPPING_ERROR); + for (MappingResult error : errors) { requestContext.getMessageContext().addMessage(createMessageResolver(error)); } } @@ -610,7 +608,7 @@ public abstract class AbstractMvcView implements View { private MessageResolver createMessageResolver(MappingResult error) { String model = getModelExpression().getExpressionString(); String field = error.getMapping().getTargetExpression().getExpressionString(); - Class fieldType = error.getMapping().getTargetExpression().getValueType(getModelObject()); + Class fieldType = error.getMapping().getTargetExpression().getValueType(getModelObject()); String[] messageCodes = messageCodesResolver.resolveMessageCodes(error.getCode(), model, field, fieldType); return new MessageBuilder().error().source(field).codes(messageCodes).resolvableArg(field) .defaultText(error.getCode() + " on " + field).build(); @@ -663,7 +661,7 @@ public abstract class AbstractMvcView implements View { return parameters.asMap().get(parameterName); } - public Class getValueType(Object context) { + public Class getValueType(Object context) { return String.class; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/BindingModel.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/BindingModel.java index dfea1d67..c1e5d233 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/BindingModel.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/BindingModel.java @@ -55,6 +55,7 @@ import org.springframework.webflow.engine.builder.BinderConfiguration; * * @author Keith Donald * @author Jeremy Grelle + * @author Phillip Webb */ public class BindingModel extends AbstractErrors implements BindingResult { @@ -106,15 +107,15 @@ public class BindingModel extends AbstractErrors implements BindingResult { // implementing Errors - public List getAllErrors() { - return toErrors(messageContext.getMessagesByCriteria(ERRORS_ANY_SOURCE)); + public List getAllErrors() { + return toErrors(messageContext.getMessagesByCriteria(ERRORS_ANY_SOURCE), ALL_ERRORS); } - public List getGlobalErrors() { - return toErrors(messageContext.getMessagesByCriteria(ERRORS_WITHOUT_FIELD_SOURCE)); + public List getGlobalErrors() { + return toErrors(messageContext.getMessagesByCriteria(ERRORS_WITHOUT_FIELD_SOURCE), ALL_ERRORS); } - public List getFieldErrors(String field) { + public List getFieldErrors(String field) { field = fixedField(field); MessageCriteria messageCriteria; if (field.endsWith("*")) { @@ -123,19 +124,19 @@ public class BindingModel extends AbstractErrors implements BindingResult { } else { messageCriteria = new FieldErrorMessage(field); } - return toErrors(messageContext.getMessagesByCriteria(messageCriteria)); + return toErrors(messageContext.getMessagesByCriteria(messageCriteria), FIELD_ERRORS); } - public Class getFieldType(String field) { + public Class getFieldType(String field) { return parseFieldExpression(fixedField(field), false).getValueType(boundObject); } public Object getFieldValue(String field) { field = fixedField(field); if (mappingResults != null) { - List results = mappingResults.getResults(new FieldErrorResult(field)); + List results = mappingResults.getResults(new FieldErrorResult(field)); if (!results.isEmpty()) { - MappingResult fieldError = (MappingResult) results.get(0); + MappingResult fieldError = results.get(0); return fieldError.getOriginalValue(); } } @@ -144,8 +145,8 @@ public class BindingModel extends AbstractErrors implements BindingResult { // not typically used by mvc views, but implemented to be on the safe side - public List getFieldErrors() { - return toErrors(messageContext.getMessagesByCriteria(ERRORS_FIELD_SOURCE)); + public List getFieldErrors() { + return toErrors(messageContext.getMessagesByCriteria(ERRORS_FIELD_SOURCE), FIELD_ERRORS); } public String getObjectName() { @@ -176,7 +177,7 @@ public class BindingModel extends AbstractErrors implements BindingResult { return parseFieldExpression(fixedField(field), false).getValue(boundObject); } - public PropertyEditor findEditor(String field, Class valueType) { + public PropertyEditor findEditor(String field, Class valueType) { if (field != null) { field = fixedField(field); } @@ -189,7 +190,7 @@ public class BindingModel extends AbstractErrors implements BindingResult { throw new UnsupportedOperationException("Should not be called during view rendering"); } - public Map getModel() { + public Map getModel() { throw new UnsupportedOperationException("Should not be called during view rendering"); } @@ -225,7 +226,7 @@ public class BindingModel extends AbstractErrors implements BindingResult { private Object getFormattedValue(String field) { Expression fieldExpression = parseFieldExpression(field, true); - Class valueType = fieldExpression.getValueType(boundObject); + Class valueType = fieldExpression.getValueType(boundObject); if (isCustomConverterConfigured(field) || avoidConversion(valueType)) { fieldExpression = parseFieldExpression(fieldExpression.getExpressionString(), false); } @@ -249,7 +250,7 @@ public class BindingModel extends AbstractErrors implements BindingResult { return (binderConfiguration.getConverterId(field) != null); } - private boolean avoidConversion(Class valueType) { + private boolean avoidConversion(Class valueType) { // special handling for array, collection, map types // necessary as getFieldValue is called by form tags for non-formattable properties, too // TODO - investigate how to improve this in Spring MVC @@ -260,7 +261,7 @@ public class BindingModel extends AbstractErrors implements BindingResult { return false; } - private PropertyEditor findSpringConvertingPropertyEditor(String field, Class valueType) { + private PropertyEditor findSpringConvertingPropertyEditor(String field, Class valueType) { if (conversionService != null) { String converterId = null; if (field != null) { @@ -283,17 +284,15 @@ public class BindingModel extends AbstractErrors implements BindingResult { } } - private List toErrors(Message[] messages) { + private List toErrors(Message[] messages, ObjectErrorFactory errorFactory) { if (messages == null || messages.length == 0) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } - ArrayList errors = new ArrayList(messages.length); - for (int i = 0; i < messages.length; i++) { - Message message = messages[i]; - if (message.getSource() == null) { - errors.add(new ObjectError(objectName, message.getText())); - } else { - errors.add(new FieldError(objectName, (String) message.getSource(), message.getText())); + ArrayList errors = new ArrayList(messages.length); + for (Message message : messages) { + T error = errorFactory.get(objectName, message); + if (error != null) { + errors.add(error); } } return Collections.unmodifiableList(errors); @@ -361,4 +360,29 @@ public class BindingModel extends AbstractErrors implements BindingResult { } } + private static interface ObjectErrorFactory { + T get(String objectName, Message message); + } + + private static final ObjectErrorFactory ALL_ERRORS = new ObjectErrorFactory() { + + public ObjectError get(String objectName, Message message) { + ObjectError error = FIELD_ERRORS.get(objectName, message); + if (error == null) { + error = new ObjectError(objectName, message.getText()); + } + return error; + } + }; + + private static final ObjectErrorFactory FIELD_ERRORS = new ObjectErrorFactory() { + + public FieldError get(String objectName, Message message) { + if (message.getSource() != null) { + return new FieldError(objectName, (String) message.getSource(), message.getText()); + } + return null; + } + }; + } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/FlowAjaxTilesView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/FlowAjaxTilesView.java index e38469c1..7a24b6f6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/FlowAjaxTilesView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/FlowAjaxTilesView.java @@ -39,7 +39,8 @@ import org.springframework.webflow.execution.View; */ public class FlowAjaxTilesView extends AjaxTilesView { - protected String[] getRenderFragments(Map model, HttpServletRequest request, HttpServletResponse response) { + protected String[] getRenderFragments(Map model, HttpServletRequest request, + HttpServletResponse response) { RequestContext context = RequestContextHolder.getRequestContext(); if (context == null) { return super.getRenderFragments(model, request, response); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/persistence/HibernateFlowExecutionListener.java b/spring-webflow/src/main/java/org/springframework/webflow/persistence/HibernateFlowExecutionListener.java index 5f16991d..64d54667 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/persistence/HibernateFlowExecutionListener.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/persistence/HibernateFlowExecutionListener.java @@ -104,7 +104,7 @@ public class HibernateFlowExecutionListener extends FlowExecutionListenerAdapter this.entityInterceptor = entityInterceptor; } - public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { + public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { boolean reusePersistenceContext = false; if (isParentPersistenceContext(session)) { if (isPersistenceContext(session.getDefinition())) { @@ -135,7 +135,7 @@ public class HibernateFlowExecutionListener extends FlowExecutionListenerAdapter } } - public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output) { + public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output) { if (isParentPersistenceContext(session)) { return; } @@ -156,7 +156,7 @@ public class HibernateFlowExecutionListener extends FlowExecutionListenerAdapter } } - public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output) { + public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output) { if (isParentPersistenceContext(session)) { if (!isPersistenceContext(session.getDefinition())) { bind(getHibernateSession(session.getParent())); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/persistence/JpaFlowExecutionListener.java b/spring-webflow/src/main/java/org/springframework/webflow/persistence/JpaFlowExecutionListener.java index 51e72a8b..090eff0e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/persistence/JpaFlowExecutionListener.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/persistence/JpaFlowExecutionListener.java @@ -94,7 +94,7 @@ public class JpaFlowExecutionListener extends FlowExecutionListenerAdapter { this.transactionTemplate = new TransactionTemplate(transactionManager); } - public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { + public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { boolean reusePersistenceContext = false; if (isParentPersistenceContext(session)) { if (isPersistenceContext(session.getDefinition())) { @@ -123,7 +123,7 @@ public class JpaFlowExecutionListener extends FlowExecutionListenerAdapter { } } - public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output) { + public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output) { if (isParentPersistenceContext(session)) { return; } @@ -142,7 +142,7 @@ public class JpaFlowExecutionListener extends FlowExecutionListenerAdapter { } } - public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output) { + public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output) { if (isParentPersistenceContext(session)) { if (!isPersistenceContext(session.getDefinition())) { bind(getEntityManager(session.getParent())); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/scope/AbstractWebFlowScope.java b/spring-webflow/src/main/java/org/springframework/webflow/scope/AbstractWebFlowScope.java index 3421192f..27649419 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/scope/AbstractWebFlowScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/scope/AbstractWebFlowScope.java @@ -35,8 +35,8 @@ public abstract class AbstractWebFlowScope implements Scope { */ protected final Log logger = LogFactory.getLog(getClass()); - public Object get(String name, ObjectFactory objectFactory) { - MutableAttributeMap scope = getScope(); + public Object get(String name, ObjectFactory objectFactory) { + MutableAttributeMap scope = getScope(); Object scopedObject = scope.get(name); if (scopedObject == null) { if (logger.isDebugEnabled()) { @@ -60,7 +60,7 @@ public abstract class AbstractWebFlowScope implements Scope { * Template method that returns the target scope map. * @throws IllegalStateException if the scope could not be accessed */ - protected abstract MutableAttributeMap getScope() throws IllegalStateException; + protected abstract MutableAttributeMap getScope() throws IllegalStateException; /** * Always returns null as most Spring Web Flow scopes do not have obvious conversation ids. Subclasses diff --git a/spring-webflow/src/main/java/org/springframework/webflow/scope/ConversationScope.java b/spring-webflow/src/main/java/org/springframework/webflow/scope/ConversationScope.java index 26567dea..239865cc 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/scope/ConversationScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/scope/ConversationScope.java @@ -23,7 +23,7 @@ import org.springframework.webflow.core.collection.MutableAttributeMap; * @author Ben Hale */ public class ConversationScope extends AbstractWebFlowScope { - protected MutableAttributeMap getScope() { + protected MutableAttributeMap getScope() { return getRequiredRequestContext().getConversationScope(); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/scope/FlashScope.java b/spring-webflow/src/main/java/org/springframework/webflow/scope/FlashScope.java index e533249f..847cc50b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/scope/FlashScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/scope/FlashScope.java @@ -23,7 +23,7 @@ import org.springframework.webflow.core.collection.MutableAttributeMap; * @author Ben Hale */ public class FlashScope extends AbstractWebFlowScope { - protected MutableAttributeMap getScope() { + protected MutableAttributeMap getScope() { return getRequiredRequestContext().getFlashScope(); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/scope/FlowScope.java b/spring-webflow/src/main/java/org/springframework/webflow/scope/FlowScope.java index 8a990cfa..b2a1ed8f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/scope/FlowScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/scope/FlowScope.java @@ -23,7 +23,7 @@ import org.springframework.webflow.core.collection.MutableAttributeMap; * @author Ben Hale */ public class FlowScope extends AbstractWebFlowScope { - protected MutableAttributeMap getScope() { + protected MutableAttributeMap getScope() { return getRequiredRequestContext().getFlowScope(); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/scope/RequestScope.java b/spring-webflow/src/main/java/org/springframework/webflow/scope/RequestScope.java index 4eab3c32..83dce6cc 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/scope/RequestScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/scope/RequestScope.java @@ -23,7 +23,7 @@ import org.springframework.webflow.core.collection.MutableAttributeMap; * @author Ben Hale */ public class RequestScope extends AbstractWebFlowScope { - protected MutableAttributeMap getScope() { + protected MutableAttributeMap getScope() { return getRequiredRequestContext().getRequestScope(); } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/scope/ViewScope.java b/spring-webflow/src/main/java/org/springframework/webflow/scope/ViewScope.java index 349f0e92..8a581421 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/scope/ViewScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/scope/ViewScope.java @@ -23,7 +23,7 @@ import org.springframework.webflow.core.collection.MutableAttributeMap; * @author Keith Donald */ public class ViewScope extends AbstractWebFlowScope { - protected MutableAttributeMap getScope() { + protected MutableAttributeMap getScope() { return getRequiredRequestContext().getViewScope(); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/security/SecurityFlowExecutionListener.java b/spring-webflow/src/main/java/org/springframework/webflow/security/SecurityFlowExecutionListener.java index 9bc220fa..f4c5c9f5 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/security/SecurityFlowExecutionListener.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/security/SecurityFlowExecutionListener.java @@ -21,6 +21,8 @@ import java.util.Iterator; import java.util.List; import org.springframework.security.access.AccessDecisionManager; +import org.springframework.security.access.AccessDecisionVoter; +import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.SecurityConfig; import org.springframework.security.access.vote.AbstractAccessDecisionManager; import org.springframework.security.access.vote.AffirmativeBased; @@ -90,12 +92,12 @@ public class SecurityFlowExecutionListener extends FlowExecutionListenerAdapter */ protected void decide(SecurityRule rule, Object object) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - Collection configAttributes = getConfigAttributes(rule); + Collection configAttributes = getConfigAttributes(rule); if (accessDecisionManager != null) { accessDecisionManager.decide(authentication, object, configAttributes); } else { AbstractAccessDecisionManager abstractAccessDecisionManager; - List voters = new ArrayList(); + List voters = new ArrayList(); voters.add(new RoleVoter()); if (rule.getComparisonType() == SecurityRule.COMPARISON_ANY) { abstractAccessDecisionManager = new AffirmativeBased(); @@ -114,11 +116,11 @@ public class SecurityFlowExecutionListener extends FlowExecutionListenerAdapter * @param rule the rule to convert * @return list of ConfigAttributes for Spring Security */ - protected Collection getConfigAttributes(SecurityRule rule) { - List configAttributes = new ArrayList(); - Iterator attributeIt = rule.getAttributes().iterator(); + protected Collection getConfigAttributes(SecurityRule rule) { + List configAttributes = new ArrayList(); + Iterator attributeIt = rule.getAttributes().iterator(); while (attributeIt.hasNext()) { - configAttributes.add(new SecurityConfig((String) attributeIt.next())); + configAttributes.add(new SecurityConfig(attributeIt.next())); } return configAttributes; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/security/SecurityRule.java b/spring-webflow/src/main/java/org/springframework/webflow/security/SecurityRule.java index 4717198d..0d930c5d 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/security/SecurityRule.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/security/SecurityRule.java @@ -42,7 +42,7 @@ public class SecurityRule { */ public static final short COMPARISON_ALL = 2; - private Collection attributes; + private Collection attributes; private short comparisonType = COMPARISON_ANY; @@ -51,9 +51,9 @@ public class SecurityRule { * @param attributes the attributes to convert * @return comma separated String */ - public static String securityAttributesToCommaDelimitedList(Collection attributes) { + public static String securityAttributesToCommaDelimitedList(Collection attributes) { StringBuffer attrs = new StringBuffer(); - Iterator attributeIt = attributes.iterator(); + Iterator attributeIt = attributes.iterator(); while (attributeIt.hasNext()) { if (attrs.length() != 0) { attrs.append(", "); @@ -68,11 +68,11 @@ public class SecurityRule { * @param attributes the attributes to convert * @return comma parsed Collection */ - public static Collection commaDelimitedListToSecurityAttributes(String attributes) { - Collection attrs = new HashSet(); - Iterator attributeIt = Arrays.asList(attributes.split(",")).iterator(); + public static Collection commaDelimitedListToSecurityAttributes(String attributes) { + Collection attrs = new HashSet(); + Iterator attributeIt = Arrays.asList(attributes.split(",")).iterator(); while (attributeIt.hasNext()) { - String attribute = ((String) attributeIt.next()).trim(); + String attribute = attributeIt.next().trim(); if (!"".equals(attribute)) { attrs.add(attribute); } @@ -84,7 +84,7 @@ public class SecurityRule { * Gets security attributes * @return security attributes */ - public Collection getAttributes() { + public Collection getAttributes() { return attributes; } @@ -92,7 +92,7 @@ public class SecurityRule { * Sets security attributes * @param attributes security attributes */ - public void setAttributes(Collection attributes) { + public void setAttributes(Collection attributes) { this.attributes = attributes; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockAction.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockAction.java index 5c2337e1..67eb1d11 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockAction.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockAction.java @@ -38,7 +38,7 @@ public class MockAction implements Action { private String resultEventId; - private AttributeMap resultAttributes; + private AttributeMap resultAttributes; /** * Constructs a new mock action that returns the default success execution result. @@ -67,7 +67,7 @@ public class MockAction implements Action { * Sets attributes to associate with a returned action execution outcome. * @param resultAttributes the action execution result attributes */ - public void setResultAttributes(AttributeMap resultAttributes) { + public void setResultAttributes(AttributeMap resultAttributes) { this.resultAttributes = resultAttributes; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java index 17d62847..9a6a9cb4 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java @@ -41,13 +41,15 @@ public class MockExternalContext implements ExternalContext { private ParameterMap requestParameterMap = new MockParameterMap(); - private MutableAttributeMap requestMap = new LocalAttributeMap(); + private MutableAttributeMap requestMap = new LocalAttributeMap(); - private SharedAttributeMap sessionMap = new LocalSharedAttributeMap(new SharedMapDecorator(new HashMap())); + private SharedAttributeMap sessionMap = new LocalSharedAttributeMap( + new SharedMapDecorator(new HashMap())); - private SharedAttributeMap globalSessionMap = sessionMap; + private SharedAttributeMap globalSessionMap = sessionMap; - private SharedAttributeMap applicationMap = new LocalSharedAttributeMap(new SharedMapDecorator(new HashMap())); + private SharedAttributeMap applicationMap = new LocalSharedAttributeMap( + new SharedMapDecorator(new HashMap())); private Object nativeContext = new Object(); @@ -71,7 +73,7 @@ public class MockExternalContext implements ExternalContext { private String flowDefinitionRedirectFlowId; - private MutableAttributeMap flowDefinitionRedirectFlowInput; + private MutableAttributeMap flowDefinitionRedirectFlowInput; private String externalRedirectUrl; @@ -104,19 +106,19 @@ public class MockExternalContext implements ExternalContext { return requestParameterMap; } - public MutableAttributeMap getRequestMap() { + public MutableAttributeMap getRequestMap() { return requestMap; } - public SharedAttributeMap getSessionMap() { + public SharedAttributeMap getSessionMap() { return sessionMap; } - public SharedAttributeMap getGlobalSessionMap() { + public SharedAttributeMap getGlobalSessionMap() { return globalSessionMap; } - public SharedAttributeMap getApplicationMap() { + public SharedAttributeMap getApplicationMap() { return applicationMap; } @@ -178,9 +180,12 @@ public class MockExternalContext implements ExternalContext { recordResponseComplete(); } - public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException { + public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException { flowDefinitionRedirectFlowId = flowId; - flowDefinitionRedirectFlowInput = input; + flowDefinitionRedirectFlowInput = new LocalAttributeMap(); + if (input != null) { + flowDefinitionRedirectFlowInput.putAll(input); + } recordResponseComplete(); } @@ -218,7 +223,7 @@ public class MockExternalContext implements ExternalContext { * Set the request attribute map. * @see ExternalContext#getRequestMap() */ - public void setRequestMap(MutableAttributeMap requestMap) { + public void setRequestMap(MutableAttributeMap requestMap) { this.requestMap = requestMap; } @@ -226,7 +231,7 @@ public class MockExternalContext implements ExternalContext { * Set the session attribute map. * @see ExternalContext#getSessionMap() */ - public void setSessionMap(SharedAttributeMap sessionMap) { + public void setSessionMap(SharedAttributeMap sessionMap) { this.sessionMap = sessionMap; } @@ -235,7 +240,7 @@ public class MockExternalContext implements ExternalContext { * are one and the same. * @see ExternalContext#getGlobalSessionMap() */ - public void setGlobalSessionMap(SharedAttributeMap globalSessionMap) { + public void setGlobalSessionMap(SharedAttributeMap globalSessionMap) { this.globalSessionMap = globalSessionMap; } @@ -243,7 +248,7 @@ public class MockExternalContext implements ExternalContext { * Set the application attribute map. * @see ExternalContext#getApplicationMap() */ - public void setApplicationMap(SharedAttributeMap applicationMap) { + public void setApplicationMap(SharedAttributeMap applicationMap) { this.applicationMap = applicationMap; } @@ -391,7 +396,7 @@ public class MockExternalContext implements ExternalContext { * Returns the input to pass the flow definition through the redirect. Only set when * {@link #getFlowDefinitionRedirectRequested()} returns true. */ - public MutableAttributeMap getFlowRedirectFlowInput() { + public MutableAttributeMap getFlowRedirectFlowInput() { return flowDefinitionRedirectFlowInput; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowBuilderContext.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowBuilderContext.java index f244990c..e4d39185 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowBuilderContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowBuilderContext.java @@ -48,7 +48,7 @@ public class MockFlowBuilderContext extends FlowBuilderContextImpl { /** * Creates a new mock flow service locator. */ - public MockFlowBuilderContext(String flowId, AttributeMap attributes) { + public MockFlowBuilderContext(String flowId, AttributeMap attributes) { super(flowId, attributes, new FlowDefinitionRegistryImpl(), TestFlowBuilderServicesFactory.getServices()); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowExecutionContext.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowExecutionContext.java index ed3bd793..86e7012b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowExecutionContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowExecutionContext.java @@ -42,11 +42,11 @@ public class MockFlowExecutionContext implements FlowExecutionContext { private FlowSession activeSession; - private MutableAttributeMap flashScope = new LocalAttributeMap(); + private MutableAttributeMap flashScope = new LocalAttributeMap(); - private MutableAttributeMap conversationScope = new LocalAttributeMap(); + private MutableAttributeMap conversationScope = new LocalAttributeMap(); - private MutableAttributeMap attributes = new LocalAttributeMap(); + private MutableAttributeMap attributes = new LocalAttributeMap(); private FlowExecutionOutcome outcome; @@ -107,15 +107,15 @@ public class MockFlowExecutionContext implements FlowExecutionContext { return activeSession; } - public MutableAttributeMap getFlashScope() { + public MutableAttributeMap getFlashScope() { return flashScope; } - public MutableAttributeMap getConversationScope() { + public MutableAttributeMap getConversationScope() { return conversationScope; } - public AttributeMap getAttributes() { + public AttributeMap getAttributes() { return attributes; } @@ -158,14 +158,14 @@ public class MockFlowExecutionContext implements FlowExecutionContext { /** * Sets the flow execution flash scope. */ - public void setFlashScope(MutableAttributeMap scope) { + public void setFlashScope(MutableAttributeMap scope) { this.flashScope = scope; } /** * Sets the flow execution conversation scope. */ - public void setConversationScope(MutableAttributeMap scope) { + public void setConversationScope(MutableAttributeMap scope) { this.conversationScope = scope; } @@ -190,7 +190,7 @@ public class MockFlowExecutionContext implements FlowExecutionContext { * Returns the mutable execution attribute map. * @return the execution attribute map */ - public MutableAttributeMap getAttributeMap() { + public MutableAttributeMap getAttributeMap() { return attributes; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowSession.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowSession.java index 1b76134e..babffc12 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowSession.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockFlowSession.java @@ -44,7 +44,7 @@ public class MockFlowSession implements FlowSession { private State state; - private MutableAttributeMap scope = new LocalAttributeMap(); + private MutableAttributeMap scope = new LocalAttributeMap(); private FlowSession parent; @@ -73,7 +73,7 @@ public class MockFlowSession implements FlowSession { * @param flow the flow definition for the session * @param input initial contents of 'flow scope' */ - public MockFlowSession(Flow flow, AttributeMap input) { + public MockFlowSession(Flow flow, AttributeMap input) { setDefinition(flow); scope.putAll(input); } @@ -88,11 +88,12 @@ public class MockFlowSession implements FlowSession { return state; } - public MutableAttributeMap getScope() { + public MutableAttributeMap getScope() { return scope; } - public MutableAttributeMap getViewScope() throws IllegalStateException { + @SuppressWarnings("unchecked") + public MutableAttributeMap getViewScope() throws IllegalStateException { if (state == null) { throw new IllegalStateException("The current state of this flow '" + definition.getId() + "' is [null] - cannot access view scope"); @@ -101,7 +102,7 @@ public class MockFlowSession implements FlowSession { throw new IllegalStateException("The current state '" + state.getId() + "' of this flow '" + definition.getId() + "' is not a view state - view scope not accessible"); } - return (MutableAttributeMap) scope.get(VIEW_MAP_ATTRIBUTE); + return (MutableAttributeMap) scope.get(VIEW_MAP_ATTRIBUTE); } public boolean isEmbeddedMode() { @@ -142,7 +143,7 @@ public class MockFlowSession implements FlowSession { * Set the scope data maintained by this flow session. This will be the flow scope data of the ongoing flow * execution. */ - public void setScope(MutableAttributeMap scope) { + public void setScope(MutableAttributeMap scope) { this.scope = scope; } @@ -180,7 +181,7 @@ public class MockFlowSession implements FlowSession { // internal helpers private void initViewScope() { - scope.put(VIEW_MAP_ATTRIBUTE, new LocalAttributeMap()); + scope.put(VIEW_MAP_ATTRIBUTE, new LocalAttributeMap()); } private void destroyViewScope() { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockParameterMap.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockParameterMap.java index 18bdbd1c..1ee3d482 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockParameterMap.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockParameterMap.java @@ -34,7 +34,7 @@ public class MockParameterMap extends LocalParameterMap { * Creates a new parameter map, initially empty. */ public MockParameterMap() { - super(new HashMap()); + super(new HashMap()); } /** diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestContext.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestContext.java index 962b5079..087f02ca 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestContext.java @@ -53,9 +53,9 @@ public class MockRequestContext implements RequestContext { private MessageContext messageContext; - private MutableAttributeMap requestScope = new LocalAttributeMap(); + private MutableAttributeMap requestScope = new LocalAttributeMap(); - private MutableAttributeMap attributes = new LocalAttributeMap(); + private MutableAttributeMap attributes = new LocalAttributeMap(); private Event currentEvent; @@ -135,23 +135,23 @@ public class MockRequestContext implements RequestContext { return getFlowExecutionContext().isActive() && getCurrentState() != null && getCurrentState().isViewState(); } - public MutableAttributeMap getRequestScope() { + public MutableAttributeMap getRequestScope() { return requestScope; } - public MutableAttributeMap getFlashScope() { + public MutableAttributeMap getFlashScope() { return getMockFlowExecutionContext().getFlashScope(); } - public MutableAttributeMap getViewScope() throws IllegalStateException { + public MutableAttributeMap getViewScope() throws IllegalStateException { return getMockFlowExecutionContext().getActiveSession().getViewScope(); } - public MutableAttributeMap getFlowScope() { + public MutableAttributeMap getFlowScope() { return getFlowExecutionContext().getActiveSession().getScope(); } - public MutableAttributeMap getConversationScope() { + public MutableAttributeMap getConversationScope() { return getMockFlowExecutionContext().getConversationScope(); } @@ -183,7 +183,7 @@ public class MockRequestContext implements RequestContext { return currentView; } - public MutableAttributeMap getAttributes() { + public MutableAttributeMap getAttributes() { return attributes; } @@ -313,7 +313,7 @@ public class MockRequestContext implements RequestContext { * attributes. * @return the attribute map */ - public MutableAttributeMap getAttributeMap() { + public MutableAttributeMap getAttributeMap() { return attributes; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestControlContext.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestControlContext.java index f65a0eb6..8b9b09d0 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestControlContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestControlContext.java @@ -99,7 +99,7 @@ public class MockRequestControlContext extends MockRequestContext implements Req } - public void start(Flow flow, MutableAttributeMap input) throws IllegalStateException { + public void start(Flow flow, MutableAttributeMap input) throws IllegalStateException { MockFlowSession session = new MockFlowSession(flow, input); if (getFlowExecutionContext().isActive()) { session.setParent(getFlowExecutionContext().getActiveSession()); @@ -108,7 +108,7 @@ public class MockRequestControlContext extends MockRequestContext implements Req flow.start(this, input); } - public void endActiveFlowSession(String outcome, MutableAttributeMap output) throws IllegalStateException { + public void endActiveFlowSession(String outcome, MutableAttributeMap output) throws IllegalStateException { MockFlowSession endingSession = getMockFlowExecutionContext().getMockActiveSession(); endingSession.getDefinitionInternal().end(this, outcome, output); getMockFlowExecutionContext().setActiveSession(endingSession.getParent()); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java index 0d72f59e..2391dc9b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractExternalizedFlowExecutionTests.java @@ -98,7 +98,7 @@ public abstract class AbstractExternalizedFlowExecutionTests extends AbstractFlo * Useful for assigning attributes that influence flow execution behavior. * @param executionAttributes the system attributes to assign */ - protected void setFlowExecutionAttributes(AttributeMap executionAttributes) { + protected void setFlowExecutionAttributes(AttributeMap executionAttributes) { getFlowExecutionImplFactory().setExecutionAttributes(executionAttributes); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java index 701cacfa..d7268373 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractFlowExecutionTests.java @@ -116,7 +116,7 @@ public abstract class AbstractFlowExecutionTests extends TestCase { * execution during the start operation * @throws FlowExecutionException if an exception was thrown while starting the flow execution */ - protected void startFlow(MutableAttributeMap input, ExternalContext context) throws FlowExecutionException { + protected void startFlow(MutableAttributeMap input, ExternalContext context) throws FlowExecutionException { flowExecution = getFlowExecutionFactory().createFlowExecution(getFlowDefinition()); flowExecution.start(input, context); if (flowExecution.hasEnded()) { @@ -174,7 +174,7 @@ public abstract class AbstractFlowExecutionTests extends TestCase { * Returns view scope. * @return view scope */ - protected MutableAttributeMap getViewScope() throws IllegalStateException { + protected MutableAttributeMap getViewScope() throws IllegalStateException { return getFlowExecution().getActiveSession().getViewScope(); } @@ -182,7 +182,7 @@ public abstract class AbstractFlowExecutionTests extends TestCase { * Returns flow scope. * @return flow scope */ - protected MutableAttributeMap getFlowScope() throws IllegalStateException { + protected MutableAttributeMap getFlowScope() throws IllegalStateException { return getFlowExecution().getActiveSession().getScope(); } @@ -190,7 +190,7 @@ public abstract class AbstractFlowExecutionTests extends TestCase { * Returns conversation scope. * @return conversation scope */ - protected MutableAttributeMap getConversationScope() throws IllegalStateException { + protected MutableAttributeMap getConversationScope() throws IllegalStateException { return getFlowExecution().getConversationScope(); } @@ -222,7 +222,8 @@ public abstract class AbstractFlowExecutionTests extends TestCase { * @return the attribute value * @throws IllegalStateException if the attribute was not present or was of the wrong type */ - protected Object getRequiredViewAttribute(String attributeName, Class requiredType) throws IllegalStateException { + protected Object getRequiredViewAttribute(String attributeName, Class requiredType) + throws IllegalStateException { return getFlowExecution().getActiveSession().getViewScope().getRequired(attributeName, requiredType); } @@ -253,7 +254,8 @@ public abstract class AbstractFlowExecutionTests extends TestCase { * @return the attribute value * @throws IllegalStateException if the attribute was not present or was of the wrong type */ - protected Object getRequiredFlowAttribute(String attributeName, Class requiredType) throws IllegalStateException { + protected Object getRequiredFlowAttribute(String attributeName, Class requiredType) + throws IllegalStateException { return getFlowExecution().getActiveSession().getScope().getRequired(attributeName, requiredType); } @@ -284,7 +286,7 @@ public abstract class AbstractFlowExecutionTests extends TestCase { * @return the attribute value * @throws IllegalStateException if the attribute was not present or not of the required type */ - protected Object getRequiredConversationAttribute(String attributeName, Class requiredType) + protected Object getRequiredConversationAttribute(String attributeName, Class requiredType) throws IllegalStateException { return getFlowExecution().getConversationScope().getRequired(attributeName, requiredType); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractXmlFlowExecutionTests.java b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractXmlFlowExecutionTests.java index 095647bc..9f5ff205 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractXmlFlowExecutionTests.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/execution/AbstractXmlFlowExecutionTests.java @@ -113,8 +113,7 @@ public abstract class AbstractXmlFlowExecutionTests extends AbstractExternalized private void registerDependentFlowModels() { FlowDefinitionResource[] modelResources = getModelResources(getResourceFactory()); if (modelResources != null) { - for (int i = 0; i < modelResources.length; i++) { - FlowDefinitionResource modelResource = modelResources[i]; + for (FlowDefinitionResource modelResource : modelResources) { FlowModelBuilder modelBuilder = new XmlFlowModelBuilder(modelResource.getPath(), flowModelRegistry); flowModelRegistry.registerFlowModel(modelResource.getId(), new DefaultFlowModelHolder(modelBuilder)); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/validation/DefaultValidationContext.java b/spring-webflow/src/main/java/org/springframework/webflow/validation/DefaultValidationContext.java index c1b57b1c..677e4c6e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/validation/DefaultValidationContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/validation/DefaultValidationContext.java @@ -43,9 +43,9 @@ public class DefaultValidationContext implements ValidationContext { private MappingResult getMappingResult(String property) { if (mappingResults != null) { - List results = mappingResults.getResults(new PropertyMappingResult(property)); + List results = mappingResults.getResults(new PropertyMappingResult(property)); if (!results.isEmpty()) { - return (MappingResult) results.get(0); + return results.get(0); } } return null; diff --git a/spring-webflow/src/main/java/org/springframework/webflow/validation/ValidationHelper.java b/spring-webflow/src/main/java/org/springframework/webflow/validation/ValidationHelper.java index adb363de..41ae1ab0 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/validation/ValidationHelper.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/validation/ValidationHelper.java @@ -18,7 +18,6 @@ package org.springframework.webflow.validation; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.apache.commons.logging.Log; @@ -279,16 +278,15 @@ public class ValidationHelper { return false; } - private Method findValidationMethod(Object model, Object validator, String methodName, Class context) { - Class modelClass = AopUtils.getTargetClass(model); + private Method findValidationMethod(Object model, Object validator, String methodName, Class context) { + Class modelClass = AopUtils.getTargetClass(model); - List modelSearchClasses = new ArrayList(); + List> modelSearchClasses = new ArrayList>(); while (modelClass != null) { modelSearchClasses.add(modelClass); modelClass = modelClass.getSuperclass(); } - for (Iterator iterator = modelSearchClasses.iterator(); iterator.hasNext();) { - Class searchClass = (Class) iterator.next(); + for (Class searchClass : modelSearchClasses) { Method method = ReflectionUtils.findMethod(validator.getClass(), methodName, new Class[] { searchClass, context }); if (method != null) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/validation/WebFlowMessageCodesResolver.java b/spring-webflow/src/main/java/org/springframework/webflow/validation/WebFlowMessageCodesResolver.java index 0c2d46ca..f592a2ed 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/validation/WebFlowMessageCodesResolver.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/validation/WebFlowMessageCodesResolver.java @@ -1,7 +1,6 @@ package org.springframework.webflow.validation; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.springframework.util.StringUtils; @@ -82,21 +81,18 @@ public class WebFlowMessageCodesResolver implements MessageCodesResolver { * See the {@link DefaultMessageCodesResolver class level Javadoc} for details on the generated codes. * @return the list of codes */ - public String[] resolveMessageCodes(String errorCode, String objectName, String field, Class fieldType) { - List codeList = new ArrayList(); - List fieldList = new ArrayList(); + public String[] resolveMessageCodes(String errorCode, String objectName, String field, Class fieldType) { + List codeList = new ArrayList(); + List fieldList = new ArrayList(); buildFieldList(field, fieldList); - for (Iterator it = fieldList.iterator(); it.hasNext();) { - String fieldInList = (String) it.next(); - codeList - .add(postProcessMessageCode(objectName + CODE_SEPARATOR + fieldInList + CODE_SEPARATOR + errorCode)); + for (String fieldInList : fieldList) { + codeList.add(postProcessMessageCode(objectName + CODE_SEPARATOR + fieldInList + CODE_SEPARATOR + errorCode)); } int dotIndex = field.lastIndexOf('.'); if (dotIndex != -1) { buildFieldList(field.substring(dotIndex + 1), fieldList); } - for (Iterator it = fieldList.iterator(); it.hasNext();) { - String fieldInList = (String) it.next(); + for (String fieldInList : fieldList) { codeList.add(postProcessMessageCode(fieldInList + CODE_SEPARATOR + errorCode)); } if (fieldType != null) { @@ -109,7 +105,7 @@ public class WebFlowMessageCodesResolver implements MessageCodesResolver { /** * Add both keyed and non-keyed entries for the supplied field to the supplied field list. */ - protected void buildFieldList(String field, List fieldList) { + protected void buildFieldList(String field, List fieldList) { fieldList.add(field); String plainField = field; int keyIndex = plainField.lastIndexOf('['); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/TestBean.java b/spring-webflow/src/test/java/org/springframework/webflow/TestBean.java index 8483cc0e..6080e031 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/TestBean.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/TestBean.java @@ -33,7 +33,7 @@ public class TestBean implements Serializable { public boolean executed; - public Map emptyMap; + public Map emptyMap; public void execute() { this.executed = true; @@ -51,9 +51,9 @@ public class TestBean implements Serializable { return datum3; } - public Map getEmptyMap() { + public Map getEmptyMap() { if (emptyMap == null) { - emptyMap = new HashMap(); + emptyMap = new HashMap(); emptyMap.put("foo", null); } return emptyMap; diff --git a/spring-webflow/src/test/java/org/springframework/webflow/TestBeanWithMap.java b/spring-webflow/src/test/java/org/springframework/webflow/TestBeanWithMap.java deleted file mode 100644 index d3c906a3..00000000 --- a/spring-webflow/src/test/java/org/springframework/webflow/TestBeanWithMap.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2004-2008 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.webflow; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -/** - * Simple test bean with a Map property. - */ -public class TestBeanWithMap implements Serializable { - - private Map map = new HashMap(); - - public Map getMap() { - return map; - } - - public void setMap(Map map) { - this.map = map; - } -} diff --git a/spring-webflow/src/test/java/org/springframework/webflow/action/AbstractActionTests.java b/spring-webflow/src/test/java/org/springframework/webflow/action/AbstractActionTests.java index 3b0453cc..295533d9 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/action/AbstractActionTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/action/AbstractActionTests.java @@ -158,7 +158,7 @@ public class AbstractActionTests extends TestCase { } public void testCustomResultCollection() { - LocalAttributeMap collection = new LocalAttributeMap(); + LocalAttributeMap collection = new LocalAttributeMap(); collection.put("result", "value"); Event event = action.result("custom", collection); assertEquals("custom", event.getId()); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/action/CompositeActionTests.java b/spring-webflow/src/test/java/org/springframework/webflow/action/CompositeActionTests.java index 8a18077a..a0451c65 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/action/CompositeActionTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/action/CompositeActionTests.java @@ -37,14 +37,14 @@ public class CompositeActionTests extends TestCase { protected void setUp() throws Exception { super.setUp(); - actionMock = (Action) EasyMock.createMock(Action.class); + actionMock = EasyMock.createMock(Action.class); Action[] actions = new Action[] { actionMock }; tested = new CompositeAction(actions); } public void testDoExecute() throws Exception { MockRequestContext mockRequestContext = new MockRequestContext(); - LocalAttributeMap attributes = new LocalAttributeMap(); + LocalAttributeMap attributes = new LocalAttributeMap(); attributes.put("some key", "some value"); EasyMock.expect(actionMock.execute(mockRequestContext)).andReturn(new Event(this, "some event", attributes)); EasyMock.replay(new Object[] { actionMock }); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/action/DispatchMethodInvokerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/action/DispatchMethodInvokerTests.java index 324bc73c..bb733683 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/action/DispatchMethodInvokerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/action/DispatchMethodInvokerTests.java @@ -52,6 +52,7 @@ public class DispatchMethodInvokerTests extends TestCase { } } + @SuppressWarnings("unused") private class MockClass { private boolean methodCalled = false; diff --git a/spring-webflow/src/test/java/org/springframework/webflow/action/EventFactorySupportTests.java b/spring-webflow/src/test/java/org/springframework/webflow/action/EventFactorySupportTests.java index 30ae92b2..c32cb305 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/action/EventFactorySupportTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/action/EventFactorySupportTests.java @@ -17,7 +17,6 @@ package org.springframework.webflow.action; import junit.framework.TestCase; -import org.springframework.webflow.action.EventFactorySupport; import org.springframework.webflow.execution.Event; /** diff --git a/spring-webflow/src/test/java/org/springframework/webflow/action/FormActionTests.java b/spring-webflow/src/test/java/org/springframework/webflow/action/FormActionTests.java index b5ffab5f..52146b3b 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/action/FormActionTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/action/FormActionTests.java @@ -44,10 +44,6 @@ public class FormActionTests extends TestCase { public TestBean() { } - public TestBean(String prop) { - this.prop = prop; - } - public String getProp() { return prop; } @@ -58,16 +54,6 @@ public class FormActionTests extends TestCase { } private static class OtherTestBean { - - private String otherProp; - - public String getOtherProp() { - return otherProp; - } - - public void setOtherProp(String otherProp) { - this.otherProp = otherProp; - } } public static class TestBeanValidator implements Validator { @@ -77,7 +63,7 @@ public class FormActionTests extends TestCase { return invoked; } - public boolean supports(Class clazz) { + public boolean supports(Class clazz) { return TestBean.class.equals(clazz); } @@ -284,8 +270,8 @@ public class FormActionTests extends TestCase { assertNotNull(formObject); formObject = new TestBean(); TestBean testBean = formObject; - new FormObjectAccessor(context).putFormObject(formObject, action.getFormObjectName(), action - .getFormObjectScope()); + new FormObjectAccessor(context).putFormObject(formObject, action.getFormObjectName(), + action.getFormObjectScope()); formObject = (TestBean) action.getFormObject(context); assertSame(formObject, testBean); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/action/RenderActionTests.java b/spring-webflow/src/test/java/org/springframework/webflow/action/RenderActionTests.java index bf023102..ba12f3e0 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/action/RenderActionTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/action/RenderActionTests.java @@ -16,8 +16,7 @@ public class RenderActionTests extends TestCase { MockRequestContext context = new MockRequestContext(); Event result = action.execute(context); assertEquals("success", result.getId()); - String[] fragments = (String[]) context.getFlashScope().getArray(View.RENDER_FRAGMENTS_ATTRIBUTE, - String[].class); + String[] fragments = context.getFlashScope().getArray(View.RENDER_FRAGMENTS_ATTRIBUTE, String[].class); assertEquals("frag1", fragments[0]); assertEquals("frag2", fragments[1]); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java index 11b2034c..07402156 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowBuilderServicesBeanDefinitionParserTests.java @@ -76,29 +76,29 @@ public class FlowBuilderServicesBeanDefinitionParserTests extends TestCase { public static class TestConversionService implements ConversionService { - public Object executeConversion(Object source, Class targetClass) throws ConversionException { + public Object executeConversion(Object source, Class targetClass) throws ConversionException { throw new UnsupportedOperationException("Auto-generated method stub"); } - public Object executeConversion(String converterId, Object source, Class targetClass) { + public Object executeConversion(String converterId, Object source, Class targetClass) { throw new UnsupportedOperationException("Auto-generated method stub"); } - public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) throws ConversionExecutionException { throw new UnsupportedOperationException("Auto-generated method stub"); } - public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) + public ConversionExecutor getConversionExecutor(String id, Class sourceClass, Class targetClass) throws ConversionExecutorNotFoundException { throw new UnsupportedOperationException("Auto-generated method stub"); } - public Set getConversionExecutors(Class sourceClass) { + public Set getConversionExecutors(Class sourceClass) { throw new UnsupportedOperationException("Auto-generated method stub"); } - public Class getClassForAlias(String alias) throws ConversionExecutionException { + public Class getClassForAlias(String alias) throws ConversionExecutionException { throw new UnsupportedOperationException("Auto-generated method stub"); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowExecutorFactoryBeanTests.java b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowExecutorFactoryBeanTests.java index a4a1fa77..3535fea4 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowExecutorFactoryBeanTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowExecutorFactoryBeanTests.java @@ -18,8 +18,6 @@ import org.springframework.webflow.engine.support.DefaultTargetStateResolver; import org.springframework.webflow.execution.FlowExecutionListener; import org.springframework.webflow.execution.FlowExecutionListenerAdapter; import org.springframework.webflow.execution.factory.StaticFlowExecutionListenerLoader; -import org.springframework.webflow.executor.FlowExecutor; -import org.springframework.webflow.test.MockExternalContext; public class FlowExecutorFactoryBeanTests extends TestCase { private FlowExecutorFactoryBean factoryBean; @@ -62,7 +60,7 @@ public class FlowExecutorFactoryBeanTests extends TestCase { return flow; } }); - Set attributes = new HashSet(); + Set attributes = new HashSet(); attributes.add(new FlowElementAttribute("foo", "bar", null)); factoryBean.setFlowExecutionAttributes(attributes); FlowExecutionListener listener = new FlowExecutionListenerAdapter() { @@ -72,9 +70,6 @@ public class FlowExecutorFactoryBeanTests extends TestCase { factoryBean.setMaxFlowExecutionSnapshots(2); factoryBean.setMaxFlowExecutions(1); factoryBean.afterPropertiesSet(); - FlowExecutor executor = (FlowExecutor) factoryBean.getObject(); - MockExternalContext context = new MockExternalContext(); - - MockExternalContext context2 = new MockExternalContext(); + factoryBean.getObject(); } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParserTests.java b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParserTests.java index 21b482de..97883b4f 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParserTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryBeanDefinitionParserTests.java @@ -56,12 +56,12 @@ public class FlowRegistryBeanDefinitionParserTests extends TestCase { } public void testDefaultFlowBuilderServices() { - Map flowBuilderServicesBeans = context.getBeansOfType(FlowBuilderServices.class); + Map flowBuilderServicesBeans = context.getBeansOfType(FlowBuilderServices.class); assertTrue(flowBuilderServicesBeans.size() > 0); - Iterator i = flowBuilderServicesBeans.values().iterator(); + Iterator i = flowBuilderServicesBeans.values().iterator(); while (i.hasNext()) { - FlowBuilderServices builderServices = (FlowBuilderServices) i.next(); + FlowBuilderServices builderServices = i.next(); assertNotNull(builderServices); assertTrue(builderServices.getExpressionParser() instanceof SpringELExpressionParser); assertTrue(builderServices.getViewFactoryCreator() instanceof MvcViewFactoryCreator); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryFactoryBeanTests.java b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryFactoryBeanTests.java index db85060c..ff1cd413 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryFactoryBeanTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowRegistryFactoryBeanTests.java @@ -20,7 +20,7 @@ public class FlowRegistryFactoryBeanTests extends TestCase { } public void testGetFlowRegistry() throws Exception { - HashSet attributes = new HashSet(); + HashSet attributes = new HashSet(); attributes.add(new FlowElementAttribute("foo", "bar", null)); attributes.add(new FlowElementAttribute("bar", "2", "integer")); FlowLocation location1 = new FlowLocation("flow1", "org/springframework/webflow/config/flow.xml", attributes); @@ -29,7 +29,7 @@ public class FlowRegistryFactoryBeanTests extends TestCase { factoryBean.setFlowBuilderServices(TestFlowBuilderServicesFactory.getServices()); factoryBean.setFlowLocations(flowLocations); factoryBean.afterPropertiesSet(); - FlowDefinitionRegistry registry = (FlowDefinitionRegistry) factoryBean.getObject(); + FlowDefinitionRegistry registry = factoryBean.getObject(); FlowDefinition def = registry.getFlowDefinition("flow1"); assertNotNull(def); assertEquals("flow1", def.getId()); @@ -46,7 +46,7 @@ public class FlowRegistryFactoryBeanTests extends TestCase { factoryBean.setFlowBuilderServices(TestFlowBuilderServicesFactory.getServices()); factoryBean.setFlowLocations(flowLocations); factoryBean.afterPropertiesSet(); - FlowDefinitionRegistry registry = (FlowDefinitionRegistry) factoryBean.getObject(); + FlowDefinitionRegistry registry = factoryBean.getObject(); FlowDefinition def = registry.getFlowDefinition("flow"); assertNotNull(def); assertEquals("flow", def.getId()); @@ -59,7 +59,7 @@ public class FlowRegistryFactoryBeanTests extends TestCase { factoryBean.setFlowLocations(flowLocations); factoryBean.setFlowBuilderServices(TestFlowBuilderServicesFactory.getServices()); factoryBean.afterPropertiesSet(); - FlowDefinitionRegistry registry = (FlowDefinitionRegistry) factoryBean.getObject(); + FlowDefinitionRegistry registry = factoryBean.getObject(); FlowDefinition def = registry.getFlowDefinition("flow"); assertNotNull(def); assertEquals("flow", def.getId()); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletContextMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletContextMapTests.java index d8725ebe..c8387e90 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletContextMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletContextMapTests.java @@ -17,7 +17,6 @@ package org.springframework.webflow.context.portlet; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import junit.framework.TestCase; @@ -94,7 +93,7 @@ public class PortletContextMapTests extends TestCase { } public void testPutAll() { - Map otherMap = new HashMap(); + Map otherMap = new HashMap(); otherMap.put("SomeOtherKey", "SomeOtherValue"); otherMap.put("SomeKey", "SomeUpdatedValue"); tested.putAll(otherMap); @@ -119,7 +118,7 @@ public class PortletContextMapTests extends TestCase { public void testEntrySet() { assertEquals(1, tested.entrySet().size()); - assertEquals("SomeKey", ((Entry) tested.entrySet().iterator().next()).getKey()); - assertEquals("SomeValue", ((Entry) tested.entrySet().iterator().next()).getValue()); + assertEquals("SomeKey", tested.entrySet().iterator().next().getKey()); + assertEquals("SomeValue", tested.entrySet().iterator().next().getValue()); } } \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletExternalContextTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletExternalContextTests.java index a6f47b14..e5d61525 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletExternalContextTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletExternalContextTests.java @@ -115,14 +115,14 @@ public class PortletExternalContextTests extends TestCase { public void testCommitFlowRedirectWithInput() { assertFalse(context.isResponseAllowed()); - LocalAttributeMap input = new LocalAttributeMap(); + LocalAttributeMap input = new LocalAttributeMap(); context.requestFlowDefinitionRedirect("foo", input); assertTrue(context.getFlowDefinitionRedirectRequested()); assertEquals("foo", context.getFlowRedirectFlowId()); assertTrue(context.isResponseComplete()); assertFalse(context.isResponseCompleteFlowExecutionRedirect()); assertFalse(context.isResponseAllowed()); - assertSame(input, context.getFlowRedirectFlowInput()); + assertEquals(input, context.getFlowRedirectFlowInput()); } public void testCommitFlowRedirectRenderRequest() { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestMapTests.java index 15655037..5f33ff8f 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestMapTests.java @@ -68,11 +68,11 @@ public class PortletRequestMapTests extends TestCase { public void testGetAttributeNames() { request.setAttribute("Some key", "Some value"); // perform test - Iterator names = tested.getAttributeNames(); + Iterator names = tested.getAttributeNames(); assertNotNull("Null result unexpected", names); assertTrue("More elements", names.hasNext()); while (names.hasNext()) { - String name = (String) names.next(); + String name = names.next(); if ("Some key".equals(name)) { return; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestParameterMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestParameterMapTests.java index d170ad30..96ca7d7b 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestParameterMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletRequestParameterMapTests.java @@ -76,10 +76,10 @@ public class PortletRequestParameterMapTests extends TestCase { public void testGetAttributeNames() { request.setParameter("Some param", "Some value"); // perform test - Iterator names = tested.getAttributeNames(); + Iterator names = tested.getAttributeNames(); assertNotNull("Null result unexpected", names); assertTrue("More elements", names.hasNext()); - String name = (String) names.next(); + String name = names.next(); assertEquals("Some param", name); } } \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletSessionMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletSessionMapTests.java index 35f726a5..ee6b5b9f 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletSessionMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/portlet/PortletSessionMapTests.java @@ -83,17 +83,17 @@ public class PortletSessionMapTests extends TestCase { public void testGetAttributeNames() { request.getPortletSession().setAttribute("Some key", "Some value"); // perform test - Iterator names = tested.getAttributeNames(); + Iterator names = tested.getAttributeNames(); assertNotNull("Null result unexpected", names); assertTrue("More elements", names.hasNext()); - String name = (String) names.next(); + String name = names.next(); assertEquals("Some key", name); } public void testGetAttributeNamesNullSession() { request.setSession(null); // perform test - Iterator names = tested.getAttributeNames(); + Iterator names = tested.getAttributeNames(); assertNotNull("Null result unexpected", names); assertFalse("No elements expected", names.hasNext()); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/DefaultFlowUrlHandlerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/DefaultFlowUrlHandlerTests.java index 2614efb4..ad6d1a03 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/DefaultFlowUrlHandlerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/DefaultFlowUrlHandlerTests.java @@ -82,7 +82,7 @@ public class DefaultFlowUrlHandlerTests extends TestCase { request.setServletPath("/app"); request.setPathInfo("/foo"); request.setRequestURI("/springtravel/app/foo"); - LocalAttributeMap input = new LocalAttributeMap(new LinkedHashMap()); + LocalAttributeMap input = new LocalAttributeMap(new LinkedHashMap()); input.put("foo", "bar"); input.put("bar", "needs encoding"); input.put("baz", new Integer(1)); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletContextMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletContextMapTests.java index 1b5e4e63..f829edc4 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletContextMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletContextMapTests.java @@ -17,7 +17,6 @@ package org.springframework.webflow.context.servlet; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import junit.framework.TestCase; @@ -93,7 +92,7 @@ public class HttpServletContextMapTests extends TestCase { } public void testPutAll() { - Map otherMap = new HashMap(); + Map otherMap = new HashMap(); otherMap.put("SomeOtherKey", "SomeOtherValue"); otherMap.put("SomeKey", "SomeUpdatedValue"); tested.putAll(otherMap); @@ -118,7 +117,7 @@ public class HttpServletContextMapTests extends TestCase { public void testEntrySet() { assertEquals(1, tested.entrySet().size()); - assertEquals("SomeKey", ((Entry) tested.entrySet().iterator().next()).getKey()); - assertEquals("SomeValue", ((Entry) tested.entrySet().iterator().next()).getValue()); + assertEquals("SomeKey", tested.entrySet().iterator().next().getKey()); + assertEquals("SomeValue", tested.entrySet().iterator().next().getValue()); } } \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletRequestMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletRequestMapTests.java index 526880c0..5dc7d992 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletRequestMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletRequestMapTests.java @@ -68,10 +68,10 @@ public class HttpServletRequestMapTests extends TestCase { request.setAttribute("Some key", "Some value"); request.removeAttribute("javax.servlet.context.tempdir"); // perform test - Iterator names = tested.getAttributeNames(); + Iterator names = tested.getAttributeNames(); assertNotNull("Null result unexpected", names); assertTrue("More elements", names.hasNext()); - String name = (String) names.next(); + String name = names.next(); assertEquals("Some key", name); } } \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletRequestParameterMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletRequestParameterMapTests.java index ce5652d6..fd440987 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletRequestParameterMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpServletRequestParameterMapTests.java @@ -75,10 +75,10 @@ public class HttpServletRequestParameterMapTests extends TestCase { public void testGetAttributeNames() { request.setParameter("Some param", "Some value"); // perform test - Iterator names = tested.getAttributeNames(); + Iterator names = tested.getAttributeNames(); assertNotNull("Null result unexpected", names); assertTrue("More elements", names.hasNext()); - String name = (String) names.next(); + String name = names.next(); assertEquals("Some param", name); } } \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpSessionMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpSessionMapTests.java index c319ed90..1aaad3d4 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpSessionMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/HttpSessionMapTests.java @@ -82,17 +82,17 @@ public class HttpSessionMapTests extends TestCase { public void testGetAttributeNames() { request.getSession().setAttribute("Some key", "Some value"); // perform test - Iterator names = tested.getAttributeNames(); + Iterator names = tested.getAttributeNames(); assertNotNull("Null result unexpected", names); assertTrue("More elements", names.hasNext()); - String name = (String) names.next(); + String name = names.next(); assertEquals("Some key", name); } public void testGetAttributeNamesNullSession() { request.setSession(null); // perform test - Iterator names = tested.getAttributeNames(); + Iterator names = tested.getAttributeNames(); assertNotNull("Null result unexpected", names); assertFalse("No elements expected", names.hasNext()); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/ServletExternalContextTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/ServletExternalContextTests.java index 27814b96..dadddc22 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/ServletExternalContextTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/ServletExternalContextTests.java @@ -111,13 +111,13 @@ public class ServletExternalContextTests extends TestCase { } public void testCommitFlowRedirectWithInput() { - LocalAttributeMap input = new LocalAttributeMap(); + LocalAttributeMap input = new LocalAttributeMap(); context.requestFlowDefinitionRedirect("foo", input); assertTrue(context.getFlowDefinitionRedirectRequested()); assertEquals("foo", context.getFlowRedirectFlowId()); assertTrue(context.isResponseComplete()); assertFalse(context.isResponseCompleteFlowExecutionRedirect()); - assertSame(input, context.getFlowRedirectFlowInput()); + assertEquals(input, context.getFlowRedirectFlowInput()); } public void testCommitExternalRedirect() { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/WebFlow1FlowUrlHandlerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/WebFlow1FlowUrlHandlerTests.java index d9abfcbb..09ac0598 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/WebFlow1FlowUrlHandlerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/context/servlet/WebFlow1FlowUrlHandlerTests.java @@ -36,7 +36,7 @@ public class WebFlow1FlowUrlHandlerTests extends TestCase { public void testCreateFlowDefinitionUrlWithFlowInput() { request.setRequestURI("/springtravel/app/flows"); - LocalAttributeMap input = new LocalAttributeMap(new LinkedHashMap()); + LocalAttributeMap input = new LocalAttributeMap(new LinkedHashMap()); input.put("foo", "bar"); input.put("bar", "needs encoding"); input.put("baz", new Integer(1)); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/conversation/impl/SessionBindingConversationManagerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/conversation/impl/SessionBindingConversationManagerTests.java index af26e1d8..93f6f1d5 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/conversation/impl/SessionBindingConversationManagerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/conversation/impl/SessionBindingConversationManagerTests.java @@ -137,7 +137,7 @@ public class SessionBindingConversationManagerTests extends TestCase { assertNotNull(context.getSessionMap().get("foo")); } - private byte[] passivate(SharedAttributeMap session) throws Exception { + private byte[] passivate(SharedAttributeMap session) throws Exception { // session is serialized out ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); @@ -145,9 +145,10 @@ public class SessionBindingConversationManagerTests extends TestCase { return bout.toByteArray(); } - private SharedAttributeMap activate(byte[] sessionData) throws Exception { + @SuppressWarnings("unchecked") + private SharedAttributeMap activate(byte[] sessionData) throws Exception { // session is serialized back in - return (SharedAttributeMap) new ObjectInputStream(new ByteArrayInputStream(sessionData)).readObject(); + return (SharedAttributeMap) new ObjectInputStream(new ByteArrayInputStream(sessionData)).readObject(); } } \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/core/collection/CollectionUtilsTests.java b/spring-webflow/src/test/java/org/springframework/webflow/core/collection/CollectionUtilsTests.java index cf7d5fb0..5c476905 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/core/collection/CollectionUtilsTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/core/collection/CollectionUtilsTests.java @@ -23,8 +23,8 @@ import junit.framework.TestCase; public class CollectionUtilsTests extends TestCase { public void testSingleEntryMap() { - AttributeMap map1 = CollectionUtils.singleEntryMap("foo", "bar"); - AttributeMap map2 = CollectionUtils.singleEntryMap("foo", "bar"); + AttributeMap map1 = CollectionUtils. singleEntryMap("foo", "bar"); + AttributeMap map2 = CollectionUtils. singleEntryMap("foo", "bar"); assertEquals(map1, map2); } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/core/collection/LocalAttributeMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/core/collection/LocalAttributeMapTests.java index b3795d34..a86dbaa6 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/core/collection/LocalAttributeMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/core/collection/LocalAttributeMapTests.java @@ -27,7 +27,7 @@ import junit.framework.TestCase; */ public class LocalAttributeMapTests extends TestCase { - private LocalAttributeMap attributeMap = new LocalAttributeMap(); + private LocalAttributeMap attributeMap = new LocalAttributeMap(); public void setUp() { attributeMap.put("string", "A string"); @@ -39,7 +39,7 @@ public class LocalAttributeMapTests extends TestCase { attributeMap.put("bigDecimal", new BigDecimal("12345.67")); attributeMap.put("bean", new TestBean()); attributeMap.put("stringArray", new String[] { "1", "2", "3" }); - attributeMap.put("collection", new LinkedList()); + attributeMap.put("collection", new LinkedList()); } public void testGet() { @@ -53,7 +53,7 @@ public class LocalAttributeMapTests extends TestCase { } public void testGetRequiredType() { - TestBean bean = (TestBean) attributeMap.get("bean", TestBean.class); + TestBean bean = attributeMap.get("bean", TestBean.class); assertNotNull(bean); } @@ -94,7 +94,7 @@ public class LocalAttributeMapTests extends TestCase { } public void testGetRequiredOfType() { - TestBean bean = (TestBean) attributeMap.getRequired("bean", TestBean.class); + TestBean bean = attributeMap.getRequired("bean", TestBean.class); assertNotNull(bean); } @@ -108,7 +108,7 @@ public class LocalAttributeMapTests extends TestCase { } public void testGetNumber() { - BigDecimal bd = (BigDecimal) attributeMap.getNumber("bigDecimal", BigDecimal.class); + BigDecimal bd = attributeMap.getNumber("bigDecimal", BigDecimal.class); assertEquals(new BigDecimal("12345.67"), bd); } @@ -123,20 +123,20 @@ public class LocalAttributeMapTests extends TestCase { public void testGetNumberWithDefaultOption() { BigDecimal d = new BigDecimal("1"); - BigDecimal bd = (BigDecimal) attributeMap.getNumber("bigDecimal", BigDecimal.class, d); + BigDecimal bd = attributeMap.getNumber("bigDecimal", BigDecimal.class, d); assertEquals(new BigDecimal("12345.67"), bd); assertNotSame(d, bd); } public void testGetNumberWithDefault() { BigDecimal d = new BigDecimal("1"); - BigDecimal bd = (BigDecimal) attributeMap.getNumber("bogus", BigDecimal.class, d); + BigDecimal bd = attributeMap.getNumber("bogus", BigDecimal.class, d); assertEquals(d, bd); assertSame(d, bd); } public void testGetNumberRequired() { - BigDecimal bd = (BigDecimal) attributeMap.getRequiredNumber("bigDecimal", BigDecimal.class); + BigDecimal bd = attributeMap.getRequiredNumber("bigDecimal", BigDecimal.class); assertEquals(new BigDecimal("12345.67"), bd); } @@ -246,17 +246,17 @@ public class LocalAttributeMapTests extends TestCase { } public void testGetArray() { - String[] i = (String[]) attributeMap.getArray("stringArray", String[].class); + String[] i = attributeMap.getArray("stringArray", String[].class); assertEquals(3, i.length); } public void testGetArrayNull() { - String[] i = (String[]) attributeMap.getArray("A bogus array", String[].class); + String[] i = attributeMap.getArray("A bogus array", String[].class); assertNull(i); } public void testGetArrayRequired() { - String[] i = (String[]) attributeMap.getRequiredArray("stringArray", String[].class); + String[] i = attributeMap.getRequiredArray("stringArray", String[].class); assertEquals(3, i.length); } @@ -269,18 +269,22 @@ public class LocalAttributeMapTests extends TestCase { } } + @SuppressWarnings("unchecked") public void testGetCollection() { - LinkedList i = (LinkedList) attributeMap.getCollection("collection", List.class); + List i = attributeMap.getCollection("collection", List.class); + assertTrue(i instanceof LinkedList); assertEquals(0, i.size()); } + @SuppressWarnings("unchecked") public void testGetCollectionNull() { - LinkedList i = (LinkedList) attributeMap.getCollection("bogus", List.class); + List i = attributeMap.getCollection("bogus", List.class); assertNull(i); } + @SuppressWarnings("unchecked") public void testGetCollectionRequired() { - LinkedList i = (LinkedList) attributeMap.getRequiredCollection("collection", List.class); + List i = attributeMap.getRequiredCollection("collection", List.class); assertEquals(0, i.size()); } @@ -294,20 +298,20 @@ public class LocalAttributeMapTests extends TestCase { } public void testGetMap() { - Map map = attributeMap.asMap(); + Map map = attributeMap.asMap(); assertEquals(10, map.size()); } public void testUnion() { - LocalAttributeMap one = new LocalAttributeMap(); + LocalAttributeMap one = new LocalAttributeMap(); one.put("foo", "bar"); one.put("bar", "baz"); - LocalAttributeMap two = new LocalAttributeMap(); + LocalAttributeMap two = new LocalAttributeMap(); two.put("cat", "coz"); two.put("bar", "boo"); - AttributeMap three = one.union(two); + AttributeMap three = one.union(two); assertEquals(3, three.size()); assertEquals("bar", three.get("foo")); assertEquals("coz", three.get("cat")); @@ -315,10 +319,10 @@ public class LocalAttributeMapTests extends TestCase { } public void testEquality() { - LocalAttributeMap map = new LocalAttributeMap(); + LocalAttributeMap map = new LocalAttributeMap(); map.put("foo", "bar"); - LocalAttributeMap map2 = new LocalAttributeMap(); + LocalAttributeMap map2 = new LocalAttributeMap(); map2.put("foo", "bar"); assertEquals(map, map2); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/core/collection/LocalParameterMapTests.java b/spring-webflow/src/test/java/org/springframework/webflow/core/collection/LocalParameterMapTests.java index 7e1903bd..ffe0d836 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/core/collection/LocalParameterMapTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/core/collection/LocalParameterMapTests.java @@ -31,7 +31,7 @@ public class LocalParameterMapTests extends TestCase { private LocalParameterMap parameterMap; public void setUp() { - Map map = new HashMap(); + Map map = new HashMap(); map.put("string", "A string"); map.put("integer", "12345"); map.put("boolean", "true"); @@ -62,7 +62,7 @@ public class LocalParameterMapTests extends TestCase { } public void testGetRequiredWithConversion() { - Integer value = (Integer) parameterMap.getRequired("integer", Integer.class); + Integer value = parameterMap.getRequired("integer", Integer.class); assertEquals(new Integer(12345), value); } @@ -89,9 +89,10 @@ public class LocalParameterMapTests extends TestCase { assertEquals(new Integer(1), value); } + @SuppressWarnings({ "unchecked", "rawtypes" }) public void testGetWithDefaultAndConversionNotAssignable() { try { - parameterMap.get("bogus", Integer.class, "1"); + parameterMap.get("bogus", (Class) Integer.class, "1"); fail("'1' isn't a integer"); } catch (IllegalArgumentException e) { @@ -119,7 +120,7 @@ public class LocalParameterMapTests extends TestCase { } public void getArrayWithConversion() { - Integer[] values = (Integer[]) parameterMap.getArray("stringArray", Integer.class); + Integer[] values = parameterMap.getArray("stringArray", Integer.class); assertEquals(new Integer(1), values[0]); assertEquals(new Integer(2), values[1]); assertEquals(new Integer(3), values[2]); @@ -155,7 +156,7 @@ public class LocalParameterMapTests extends TestCase { } public void testGetArrayConversion() { - Integer[] i = (Integer[]) parameterMap.getArray("stringArray", Integer.class); + Integer[] i = parameterMap.getArray("stringArray", Integer.class); assertEquals(i.length, 3); assertEquals(new Integer(1), i[0]); assertEquals(new Integer(2), i[1]); @@ -163,24 +164,24 @@ public class LocalParameterMapTests extends TestCase { } public void getRequiredArrayWithConversion() { - Integer[] values = (Integer[]) parameterMap.getRequiredArray("stringArray", Integer.class); + Integer[] values = parameterMap.getRequiredArray("stringArray", Integer.class); assertEquals(new Integer(1), values[0]); assertEquals(new Integer(2), values[1]); assertEquals(new Integer(3), values[2]); } public void testGetNumber() { - Integer value = (Integer) parameterMap.getNumber("integer", Integer.class); + Integer value = parameterMap.getNumber("integer", Integer.class); assertEquals(new Integer(12345), value); } public void testGetRequiredNumber() { - Integer value = (Integer) parameterMap.getRequiredNumber("integer", Integer.class); + Integer value = parameterMap.getRequiredNumber("integer", Integer.class); assertEquals(new Integer(12345), value); } public void testGetNumberWithDefault() { - Integer value = (Integer) parameterMap.getNumber("bogus", Integer.class, new Integer(12345)); + Integer value = parameterMap.getNumber("bogus", Integer.class, new Integer(12345)); assertEquals(new Integer(12345), value); } @@ -240,12 +241,12 @@ public class LocalParameterMapTests extends TestCase { } public void testEquality() { - LocalParameterMap map1 = new LocalParameterMap(new HashMap(parameterMap.asMap())); + LocalParameterMap map1 = new LocalParameterMap(new HashMap(parameterMap.asMap())); assertEquals(parameterMap, map1); } public void testAsAttributeMap() { - AttributeMap map = parameterMap.asAttributeMap(); + AttributeMap map = parameterMap.asAttributeMap(); assertEquals(map.asMap(), parameterMap.asMap()); } } \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImplTests.java b/spring-webflow/src/test/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImplTests.java index 3023ec7c..9f8ef7d3 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImplTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/definition/registry/FlowDefinitionRegistryImplTests.java @@ -123,7 +123,7 @@ public class FlowDefinitionRegistryImplTests extends TestCase { private boolean destroyed; - public MutableAttributeMap getAttributes() { + public MutableAttributeMap getAttributes() { return null; } @@ -174,7 +174,7 @@ public class FlowDefinitionRegistryImplTests extends TestCase { private boolean destroyed; - public MutableAttributeMap getAttributes() { + public MutableAttributeMap getAttributes() { return null; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/ActionStateTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/ActionStateTests.java index ab85bc00..cb2b1f9f 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/ActionStateTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/ActionStateTests.java @@ -74,8 +74,8 @@ public class ActionStateTests extends TestCase { state.getTransitionSet().add(new Transition(on("success"), to("finish"))); state.enter(context); Action[] actions = state.getActionList().toArray(); - for (int i = 0; i < actions.length; i++) { - TestAction action = (TestAction) actions[i]; + for (Action action2 : actions) { + TestAction action = (TestAction) action2; assertEquals(1, action.getExecutionCount()); } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/AnnotatedObjectTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/AnnotatedObjectTests.java index 0cd2b07e..9d5f2c4f 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/AnnotatedObjectTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/AnnotatedObjectTests.java @@ -15,10 +15,10 @@ */ package org.springframework.webflow.engine; -import org.springframework.webflow.core.AnnotatedObject; - import junit.framework.TestCase; +import org.springframework.webflow.core.AnnotatedObject; + public class AnnotatedObjectTests extends TestCase { private AnnotatedObject object = new Flow("foo"); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/EndStateTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/EndStateTests.java index 53eae243..a4fdfdf2 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/EndStateTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/EndStateTests.java @@ -74,7 +74,9 @@ public class EndStateTests extends TestCase { public void testEnterEndStateWithOutputMapper() { Flow flow = new Flow("myFlow") { - public void end(RequestControlContext context, MutableAttributeMap output) throws FlowExecutionException { + @SuppressWarnings("unused") + public void end(RequestControlContext context, MutableAttributeMap output) + throws FlowExecutionException { assertEquals("foo", output.get("y")); } }; diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/EventTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/EventTests.java index 21a5a51d..c489f909 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/EventTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/EventTests.java @@ -53,7 +53,7 @@ public class EventTests extends TestCase { } public void testNewEventWithAttributes() { - LocalAttributeMap attrs = new LocalAttributeMap(); + LocalAttributeMap attrs = new LocalAttributeMap(); attrs.put("name", "value"); Event event = new Event(this, "id", attrs); assertTrue(!event.getAttributes().isEmpty()); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/FlowExecutionHandlerSetTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/FlowExecutionHandlerSetTests.java index 09042c84..f0acb471 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/FlowExecutionHandlerSetTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/FlowExecutionHandlerSetTests.java @@ -49,10 +49,10 @@ public class FlowExecutionHandlerSetTests extends TestCase { */ public static class TestStateExceptionHandler implements FlowExecutionExceptionHandler { - private Class typeToHandle; + private Class typeToHandle; private String resultName; - public TestStateExceptionHandler(Class typeToHandle, String resultName) { + public TestStateExceptionHandler(Class typeToHandle, String resultName) { this.typeToHandle = typeToHandle; this.resultName = resultName; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/FlowTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/FlowTests.java index da951e8d..afb97c9c 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/FlowTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/FlowTests.java @@ -170,7 +170,7 @@ public class FlowTests extends TestCase { public void testStart() { MockRequestControlContext context = new MockRequestControlContext(flow); - flow.start(context, new LocalAttributeMap()); + flow.start(context, new LocalAttributeMap()); assertEquals("Wrong start state", "myState1", context.getCurrentState().getId()); } @@ -189,7 +189,7 @@ public class FlowTests extends TestCase { MockRequestControlContext context = new MockRequestControlContext(flow); TestAction action = new TestAction(); flow.getStartActionList().add(action); - flow.start(context, new LocalAttributeMap()); + flow.start(context, new LocalAttributeMap()); assertEquals("Wrong start state", "myState1", context.getCurrentState().getId()); assertEquals(1, action.getExecutionCount()); } @@ -198,13 +198,13 @@ public class FlowTests extends TestCase { MockRequestControlContext context = new MockRequestControlContext(flow); flow.addVariable(new FlowVariable("var1", new VariableValueFactory() { public Object createInitialValue(RequestContext context) { - return new ArrayList(); + return new ArrayList(); } public void restoreReferences(Object value, RequestContext context) { } })); - flow.start(context, new LocalAttributeMap()); + flow.start(context, new LocalAttributeMap()); context.getFlowScope().getRequired("var1", ArrayList.class); } @@ -212,12 +212,12 @@ public class FlowTests extends TestCase { DefaultMapper attributeMapper = new DefaultMapper(); ExpressionParser parser = new WebFlowSpringELExpressionParser(new SpelExpressionParser()); Expression x = parser.parseExpression("attr", new FluentParserContext().evaluate(AttributeMap.class)); - Expression y = parser.parseExpression("flowScope.attr", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression y = parser.parseExpression("flowScope.attr", + new FluentParserContext().evaluate(RequestContext.class)); attributeMapper.addMapping(new DefaultMapping(x, y)); flow.setInputMapper(attributeMapper); MockRequestControlContext context = new MockRequestControlContext(flow); - LocalAttributeMap sessionInput = new LocalAttributeMap(); + LocalAttributeMap sessionInput = new LocalAttributeMap(); sessionInput.put("attr", "foo"); flow.start(context, sessionInput); assertEquals("foo", context.getFlowScope().get("attr")); @@ -227,12 +227,12 @@ public class FlowTests extends TestCase { DefaultMapper attributeMapper = new DefaultMapper(); ExpressionParser parser = new WebFlowSpringELExpressionParser(new SpelExpressionParser()); Expression x = parser.parseExpression("attr", new FluentParserContext().evaluate(AttributeMap.class)); - Expression y = parser.parseExpression("flowScope.attr", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression y = parser.parseExpression("flowScope.attr", + new FluentParserContext().evaluate(RequestContext.class)); attributeMapper.addMapping(new DefaultMapping(x, y)); flow.setInputMapper(attributeMapper); MockRequestControlContext context = new MockRequestControlContext(flow); - LocalAttributeMap sessionInput = new LocalAttributeMap(); + LocalAttributeMap sessionInput = new LocalAttributeMap(); flow.start(context, sessionInput); assertTrue(context.getFlowScope().contains("attr")); assertNull(context.getFlowScope().get("attr")); @@ -308,7 +308,7 @@ public class FlowTests extends TestCase { TestAction action = new TestAction(); flow.getEndActionList().add(action); MockRequestControlContext context = new MockRequestControlContext(flow); - LocalAttributeMap sessionOutput = new LocalAttributeMap(); + LocalAttributeMap sessionOutput = new LocalAttributeMap(); flow.end(context, "finish", sessionOutput); assertEquals(1, action.getExecutionCount()); } @@ -316,14 +316,14 @@ public class FlowTests extends TestCase { public void testEndWithOutputMapper() { DefaultMapper attributeMapper = new DefaultMapper(); ExpressionParser parser = new WebFlowSpringELExpressionParser(new SpelExpressionParser()); - Expression x = parser.parseExpression("flowScope.attr", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression x = parser.parseExpression("flowScope.attr", + new FluentParserContext().evaluate(RequestContext.class)); Expression y = parser.parseExpression("attr", new FluentParserContext().evaluate(MutableAttributeMap.class)); attributeMapper.addMapping(new DefaultMapping(x, y)); flow.setOutputMapper(attributeMapper); MockRequestControlContext context = new MockRequestControlContext(flow); context.getFlowScope().put("attr", "foo"); - LocalAttributeMap sessionOutput = new LocalAttributeMap(); + LocalAttributeMap sessionOutput = new LocalAttributeMap(); flow.end(context, "finish", sessionOutput); assertEquals("foo", sessionOutput.get("attr")); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/SubflowStateTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/SubflowStateTests.java index 9dd10b85..b01c0326 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/SubflowStateTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/SubflowStateTests.java @@ -22,6 +22,7 @@ import junit.framework.TestCase; import org.springframework.binding.expression.EvaluationException; import org.springframework.binding.expression.support.AbstractGetValueExpression; import org.springframework.binding.mapping.Mapper; +import org.springframework.binding.mapping.MappingResult; import org.springframework.binding.mapping.MappingResults; import org.springframework.binding.mapping.impl.DefaultMappingResults; import org.springframework.webflow.core.collection.AttributeMap; @@ -68,18 +69,19 @@ public class SubflowStateTests extends TestCase { public void testEnterWithInput() { subflowState.setAttributeMapper(new SubflowAttributeMapper() { - public MutableAttributeMap createSubflowInput(RequestContext context) { - return new LocalAttributeMap("foo", "bar"); + public MutableAttributeMap createSubflowInput(RequestContext context) { + return new LocalAttributeMap("foo", "bar"); } - public void mapSubflowOutput(AttributeMap flowOutput, RequestContext context) { + public void mapSubflowOutput(AttributeMap flowOutput, RequestContext context) { } }); subflow.setInputMapper(new Mapper() { + @SuppressWarnings("unchecked") public MappingResults map(Object source, Object target) { - MutableAttributeMap map = (MutableAttributeMap) source; + MutableAttributeMap map = (MutableAttributeMap) source; assertEquals("bar", map.get("foo")); - return new DefaultMappingResults(source, target, Collections.EMPTY_LIST); + return new DefaultMappingResults(source, target, Collections. emptyList()); } }); new State(subflow, "whatev") { @@ -92,11 +94,11 @@ public class SubflowStateTests extends TestCase { public void testReturnWithOutput() { subflowState.setAttributeMapper(new SubflowAttributeMapper() { - public MutableAttributeMap createSubflowInput(RequestContext context) { - return new LocalAttributeMap(); + public MutableAttributeMap createSubflowInput(RequestContext context) { + return new LocalAttributeMap(); } - public void mapSubflowOutput(AttributeMap flowOutput, RequestContext context) { + public void mapSubflowOutput(AttributeMap flowOutput, RequestContext context) { assertEquals("bar", flowOutput.get("foo")); } }); @@ -107,10 +109,11 @@ public class SubflowStateTests extends TestCase { }; new EndState(subflow, "end"); subflow.setOutputMapper(new Mapper() { + @SuppressWarnings("unchecked") public MappingResults map(Object source, Object target) { - MutableAttributeMap map = (MutableAttributeMap) target; + MutableAttributeMap map = (MutableAttributeMap) target; map.put("foo", "bar"); - return new DefaultMappingResults(source, target, Collections.EMPTY_LIST); + return new DefaultMappingResults(source, target, Collections. emptyList()); } }); subflowState.enter(context); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/TestSubflowAttributeMapper.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/TestSubflowAttributeMapper.java index f8c22d55..d24dd2ea 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/TestSubflowAttributeMapper.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/TestSubflowAttributeMapper.java @@ -21,14 +21,14 @@ import org.springframework.webflow.core.collection.MutableAttributeMap; import org.springframework.webflow.execution.RequestContext; class TestSubflowAttributeMapper implements SubflowAttributeMapper { - public MutableAttributeMap createSubflowInput(RequestContext context) { - LocalAttributeMap inputMap = new LocalAttributeMap(); + public MutableAttributeMap createSubflowInput(RequestContext context) { + LocalAttributeMap inputMap = new LocalAttributeMap(); inputMap.put("childInputAttribute", context.getFlowScope().get("parentInputAttribute")); return inputMap; } - public void mapSubflowOutput(AttributeMap subflowOutput, RequestContext context) { - MutableAttributeMap parentAttributes = context.getFlowExecutionContext().getActiveSession().getScope(); + public void mapSubflowOutput(AttributeMap subflowOutput, RequestContext context) { + MutableAttributeMap parentAttributes = context.getFlowExecutionContext().getActiveSession().getScope(); parentAttributes.put("parentOutputAttribute", subflowOutput.get("childInputAttribute")); } } \ No newline at end of file diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/FlowAssemblerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/FlowAssemblerTests.java index 95c629c0..638e7911 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/FlowAssemblerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/FlowAssemblerTests.java @@ -12,7 +12,7 @@ public class FlowAssemblerTests extends TestCase { private FlowBuilderContext builderContext; protected void setUp() { - builder = (FlowBuilder) EasyMock.createMock(FlowBuilder.class); + builder = EasyMock.createMock(FlowBuilder.class); builderContext = new MockFlowBuilderContext("search"); assembler = new FlowAssembler(builder, builderContext); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilderTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilderTests.java index f6e68367..018fd0aa 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilderTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/model/FlowModelFlowBuilderTests.java @@ -1,5 +1,6 @@ package org.springframework.webflow.engine.builder.model; +import java.util.Arrays; import java.util.LinkedList; import junit.framework.TestCase; @@ -18,13 +19,14 @@ import org.springframework.webflow.engine.ViewState; import org.springframework.webflow.engine.builder.FlowAssembler; import org.springframework.webflow.engine.builder.FlowBuilderException; import org.springframework.webflow.engine.impl.FlowExecutionImplFactory; +import org.springframework.webflow.engine.model.AbstractActionModel; +import org.springframework.webflow.engine.model.AbstractStateModel; import org.springframework.webflow.engine.model.AttributeModel; import org.springframework.webflow.engine.model.EndStateModel; import org.springframework.webflow.engine.model.EvaluateModel; import org.springframework.webflow.engine.model.ExceptionHandlerModel; import org.springframework.webflow.engine.model.FlowModel; import org.springframework.webflow.engine.model.InputModel; -import org.springframework.webflow.engine.model.Model; import org.springframework.webflow.engine.model.OutputModel; import org.springframework.webflow.engine.model.PersistenceContextModel; import org.springframework.webflow.engine.model.SecuredModel; @@ -65,37 +67,19 @@ public class FlowModelFlowBuilderTests extends TestCase { } } - private LinkedList singleList(Model model) { - LinkedList list = new LinkedList(); - list.add(model); - return list; - } - - private LinkedList doubleList(Model model, Model model2) { - LinkedList list = new LinkedList(); - list.add(model); - list.add(model2); - return list; - } - - private LinkedList quadList(Model model, Model model2, Model model3, Model model4) { - LinkedList list = new LinkedList(); - list.add(model); - list.add(model2); - list.add(model3); - list.add(model4); - return list; + private LinkedList asList(Class elementClass, T... a) { + return new LinkedList(Arrays.asList(a)); } public void testBuildFlowWithEndState() { - model.setStates(singleList(new EndStateModel("end"))); + model.setStates(asList(AbstractStateModel.class, new EndStateModel("end"))); Flow flow = getFlow(model); assertEquals("flow", flow.getId()); assertEquals("end", flow.getStartState().getId()); } public void testBuildFlowWithDefaultStartState() { - model.setStates(singleList(new EndStateModel("end"))); + model.setStates(asList(AbstractStateModel.class, new EndStateModel("end"))); Flow flow = getFlow(model); assertEquals("flow", flow.getId()); assertEquals("end", flow.getStartState().getId()); @@ -103,7 +87,7 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testBuildFlowWithStartStateAttribute() { model.setStartStateId("end"); - model.setStates(doubleList(new EndStateModel("foo"), new EndStateModel("end"))); + model.setStates(asList(AbstractStateModel.class, new EndStateModel("foo"), new EndStateModel("end"))); Flow flow = getFlow(model); assertEquals("flow", flow.getId()); assertEquals("end", flow.getStartState().getId()); @@ -113,9 +97,9 @@ public class FlowModelFlowBuilderTests extends TestCase { AttributeModel attribute1 = new AttributeModel("foo", "bar"); AttributeModel attribute2 = new AttributeModel("number", "1"); attribute2.setType("integer"); - model.setAttributes(doubleList(attribute1, attribute2)); + model.setAttributes(asList(AttributeModel.class, attribute1, attribute2)); - model.setStates(singleList(new EndStateModel("end"))); + model.setStates(asList(AbstractStateModel.class, new EndStateModel("end"))); Flow flow = getFlow(model); assertEquals("bar", flow.getAttributes().get("foo")); assertEquals(new Integer(1), flow.getAttributes().get("number")); @@ -123,7 +107,7 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testPersistenceContextFlow() { model.setPersistenceContext(new PersistenceContextModel()); - model.setStates(singleList(new EndStateModel("end"))); + model.setStates(asList(AbstractStateModel.class, new EndStateModel("end"))); Flow flow = getFlow(model); assertNotNull(flow.getAttributes().get("persistenceContext")); assertTrue(((Boolean) flow.getAttributes().get("persistenceContext")).booleanValue()); @@ -136,7 +120,7 @@ public class FlowModelFlowBuilderTests extends TestCase { input3.setType("integer"); InputModel input4 = new InputModel("required", "flowScope.boop"); input4.setRequired("true"); - model.setInputs(quadList(input1, input2, input3, input4)); + model.setInputs(asList(InputModel.class, input1, input2, input3, input4)); OutputModel output1 = new OutputModel("differentName", "flowScope.bar"); OutputModel output2 = new OutputModel("number", "flowScope.baz"); @@ -145,21 +129,21 @@ public class FlowModelFlowBuilderTests extends TestCase { output3.setType("integer"); output3.setRequired("true"); OutputModel output4 = new OutputModel("literal", "'a literal'"); - model.setOutputs(quadList(output1, output2, output3, output4)); + model.setOutputs(asList(OutputModel.class, output1, output2, output3, output4)); EndStateModel end = new EndStateModel("end"); - end.setOutputs(singleList(new OutputModel("foo", "flowScope.foo"))); + end.setOutputs(asList(OutputModel.class, new OutputModel("foo", "flowScope.foo"))); EndStateModel notReached = new EndStateModel("notReached"); - notReached.setOutputs(singleList(new OutputModel("notReached", "flowScope.foo"))); + notReached.setOutputs(asList(OutputModel.class, new OutputModel("notReached", "flowScope.foo"))); - model.setStates(doubleList(end, notReached)); + model.setStates(asList(AbstractStateModel.class, end, notReached)); Flow flow = getFlow(model); FlowExecutionImplFactory factory = new FlowExecutionImplFactory(); FlowExecution execution = factory.createFlowExecution(flow); MockExternalContext context = new MockExternalContext(); - MutableAttributeMap map = new LocalAttributeMap(); + MutableAttributeMap map = new LocalAttributeMap(); map.put("foo", "bar"); map.put("number", "3"); map.put("required", "9"); @@ -176,7 +160,7 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testFlowSecured() { model.setSecured(new SecuredModel("ROLE_USER")); - model.setStates(singleList(new EndStateModel("end"))); + model.setStates(asList(AbstractStateModel.class, new EndStateModel("end"))); Flow flow = getFlow(model); SecurityRule rule = (SecurityRule) flow.getAttributes().get(SecurityRule.SECURITY_ATTRIBUTE_NAME); assertNotNull(rule); @@ -188,7 +172,7 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testFlowSecuredState() { EndStateModel end = new EndStateModel("end"); end.setSecured(new SecuredModel("ROLE_USER")); - model.setStates(singleList(end)); + model.setStates(asList(AbstractStateModel.class, end)); Flow flow = getFlow(model); SecurityRule rule = (SecurityRule) flow.getState("end").getAttributes() .get(SecurityRule.SECURITY_ATTRIBUTE_NAME); @@ -199,11 +183,11 @@ public class FlowModelFlowBuilderTests extends TestCase { } public void testFlowSecuredTransition() { - model.setStates(singleList(new EndStateModel("end"))); + model.setStates(asList(AbstractStateModel.class, new EndStateModel("end"))); TransitionModel transition = new TransitionModel(); transition.setTo("end"); transition.setSecured(new SecuredModel("ROLE_USER")); - model.setGlobalTransitions(singleList(transition)); + model.setGlobalTransitions(asList(TransitionModel.class, transition)); Flow flow = getFlow(model); SecurityRule rule = (SecurityRule) flow.getGlobalTransitionSet().toArray()[0].getAttributes().get( SecurityRule.SECURITY_ATTRIBUTE_NAME); @@ -214,16 +198,16 @@ public class FlowModelFlowBuilderTests extends TestCase { } public void testFlowVariable() { - model.setVars(singleList(new VarModel("flow-foo", "org.springframework.webflow.TestBean"))); - model.setStates(singleList(new EndStateModel("end"))); + model.setVars(asList(VarModel.class, new VarModel("flow-foo", "org.springframework.webflow.TestBean"))); + model.setStates(asList(AbstractStateModel.class, new EndStateModel("end"))); Flow flow = getFlow(model); assertEquals("flow-foo", flow.getVariable("flow-foo").getName()); } public void testViewStateVariable() { ViewStateModel view = new ViewStateModel("view"); - view.setVars(singleList(new VarModel("foo", "org.springframework.webflow.TestBean"))); - model.setStates(singleList(view)); + view.setVars(asList(VarModel.class, new VarModel("foo", "org.springframework.webflow.TestBean"))); + model.setStates(asList(AbstractStateModel.class, view)); Flow flow = getFlow(model); assertNotNull(((ViewState) flow.getStateInstance("view")).getVariable("foo")); } @@ -231,7 +215,7 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testViewStateRedirect() { ViewStateModel view = new ViewStateModel("view"); view.setRedirect("true"); - model.setStates(singleList(view)); + model.setStates(asList(AbstractStateModel.class, view)); Flow flow = getFlow(model); assertTrue(((ViewState) flow.getStateInstance("view")).getRedirect()); } @@ -239,7 +223,7 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testViewStatePopup() { ViewStateModel view = new ViewStateModel("view"); view.setPopup("true"); - model.setStates(singleList(view)); + model.setStates(asList(AbstractStateModel.class, view)); Flow flow = getFlow(model); assertTrue(((ViewState) flow.getStateInstance("view")).getPopup()); } @@ -247,7 +231,7 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testViewStateFlowRedirect() { ViewStateModel state = new ViewStateModel("view"); state.setView("flowRedirect:myFlow?input=#{flowScope.foo}"); - model.setStates(singleList(state)); + model.setStates(asList(AbstractStateModel.class, state)); Flow flow = getFlow(model); ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory(); assertTrue(vf instanceof ActionExecutingViewFactory); @@ -258,7 +242,7 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testViewStateExternalRedirect() { ViewStateModel state = new ViewStateModel("view"); state.setView("externalRedirect:http://www.paypal.com?_callbackUrl=#{flowExecutionUri}"); - model.setStates(singleList(state)); + model.setStates(asList(AbstractStateModel.class, state)); Flow flow = getFlow(model); ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory(); assertTrue(vf instanceof ActionExecutingViewFactory); @@ -292,8 +276,8 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testExceptionHandlers() { FlowModel model = new FlowModel(); - model.setStates(singleList(new EndStateModel("state"))); - model.setExceptionHandlers(singleList(new ExceptionHandlerModel("exceptionHandler"))); + model.setStates(asList(AbstractStateModel.class, new EndStateModel("state"))); + model.setExceptionHandlers(asList(ExceptionHandlerModel.class, new ExceptionHandlerModel("exceptionHandler"))); FlowExecutionExceptionHandler handler = new FlowExecutionExceptionHandler() { public boolean canHandle(FlowExecutionException exception) { return true; @@ -313,8 +297,8 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testSetActionWithResultType() throws Exception { SetModel setModel = new SetModel("flowScope.stringArray", "intArray"); setModel.setType("java.lang.String[]"); - model.setOnStartActions(singleList(setModel)); - model.setStates(singleList(new ViewStateModel("view"))); + model.setOnStartActions(asList(AbstractActionModel.class, setModel)); + model.setStates(asList(AbstractStateModel.class, new ViewStateModel("view"))); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); @@ -327,9 +311,9 @@ public class FlowModelFlowBuilderTests extends TestCase { public void testSetActionWithImplicitTypeConversion() throws Exception { SetModel setModel = new SetModel("testBean.stringArray", "intArray"); - model.setOnStartActions(singleList(setModel)); + model.setOnStartActions(asList(AbstractActionModel.class, setModel)); ViewStateModel state = new ViewStateModel("view"); - model.setStates(singleList(state)); + model.setStates(asList(AbstractStateModel.class, state)); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); @@ -345,8 +329,8 @@ public class FlowModelFlowBuilderTests extends TestCase { EvaluateModel evaluateModel = new EvaluateModel("testBean.getIntegers()"); evaluateModel.setResult("flowScope.stringArray"); evaluateModel.setResultType("java.lang.String[]"); - model.setOnStartActions(singleList(evaluateModel)); - model.setStates(singleList(new ViewStateModel("view"))); + model.setOnStartActions(asList(AbstractActionModel.class, evaluateModel)); + model.setStates(asList(AbstractStateModel.class, new ViewStateModel("view"))); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); @@ -361,8 +345,8 @@ public class FlowModelFlowBuilderTests extends TestCase { EvaluateModel evaluateModel = new EvaluateModel("testBean.getIntegers()"); evaluateModel.setResult("flowScope.stringArray"); evaluateModel.setResultType("java.lang.String[]"); - model.setOnStartActions(singleList(evaluateModel)); - model.setStates(singleList(new ViewStateModel("view"))); + model.setOnStartActions(asList(AbstractActionModel.class, evaluateModel)); + model.setStates(asList(AbstractStateModel.class, new ViewStateModel("view"))); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); @@ -376,6 +360,7 @@ public class FlowModelFlowBuilderTests extends TestCase { private static class TestBean { public String[] stringArray; + @SuppressWarnings("unused") public int[] getIntegers() { return new int[] { 1, 2 }; } @@ -408,10 +393,6 @@ public class FlowModelFlowBuilderTests extends TestCase { return model; } - public String getFlowModelId() { - return "flow"; - } - public Resource getFlowModelResource() { return new ClassPathResource("", getClass()); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/support/TextToTransitionCriteriaTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/support/TextToTransitionCriteriaTests.java index de6bfb29..7ba7e7e8 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/support/TextToTransitionCriteriaTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/builder/support/TextToTransitionCriteriaTests.java @@ -45,12 +45,12 @@ public class TextToTransitionCriteriaTests extends TestCase { TransitionCriteria.class); RequestContext ctx = getRequestContext(); assertTrue("Criterion should evaluate to true", criterion.test(ctx)); - assertSame(WildcardTransitionCriteria.INSTANCE, converter.convertSourceToTargetClass("*", - TransitionCriteria.class)); - assertSame(WildcardTransitionCriteria.INSTANCE, converter.convertSourceToTargetClass("", - TransitionCriteria.class)); - assertSame(WildcardTransitionCriteria.INSTANCE, converter.convertSourceToTargetClass(null, - TransitionCriteria.class)); + assertSame(WildcardTransitionCriteria.INSTANCE, + converter.convertSourceToTargetClass("*", TransitionCriteria.class)); + assertSame(WildcardTransitionCriteria.INSTANCE, + converter.convertSourceToTargetClass("", TransitionCriteria.class)); + assertSame(WildcardTransitionCriteria.INSTANCE, + converter.convertSourceToTargetClass(null, TransitionCriteria.class)); } public void testStaticEventId() throws Exception { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactoryTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactoryTests.java index 23a5adc1..0afce274 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactoryTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/impl/FlowExecutionImplFactoryTests.java @@ -80,7 +80,7 @@ public class FlowExecutionImplFactoryTests extends TestCase { } public void testCreateWithExecutionAttributes() { - MutableAttributeMap attributes = new LocalAttributeMap(); + MutableAttributeMap attributes = new LocalAttributeMap(); attributes.put("foo", "bar"); factory.setExecutionAttributes(attributes); FlowExecution execution = factory.createFlowExecution(flowDefinition); @@ -90,7 +90,7 @@ public class FlowExecutionImplFactoryTests extends TestCase { public void testCreateWithExecutionListener() { FlowExecutionListener listener1 = new FlowExecutionListenerAdapter() { - public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { + public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { starting = true; } }; @@ -123,7 +123,7 @@ public class FlowExecutionImplFactoryTests extends TestCase { public void testRestoreExecutionState() { FlowExecutionImpl flowExecution = (FlowExecutionImpl) factory.createFlowExecution(flowDefinition); - LocalAttributeMap executionAttributes = new LocalAttributeMap(); + LocalAttributeMap executionAttributes = new LocalAttributeMap(); factory.setExecutionAttributes(executionAttributes); FlowExecutionListener listener = new FlowExecutionListenerAdapter() { }; @@ -131,7 +131,7 @@ public class FlowExecutionImplFactoryTests extends TestCase { MockFlowExecutionKeyFactory keyFactory = new MockFlowExecutionKeyFactory(); factory.setExecutionKeyFactory(keyFactory); FlowExecutionKey flowExecutionKey = new MockFlowExecutionKey("e1s1"); - LocalAttributeMap conversationScope = new LocalAttributeMap(); + LocalAttributeMap conversationScope = new LocalAttributeMap(); SimpleFlowDefinitionLocator locator = new SimpleFlowDefinitionLocator(); FlowSessionImpl session1 = new FlowSessionImpl(); session1.setFlowId("flow"); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/impl/FlowExecutionImplTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/impl/FlowExecutionImplTests.java index 8ebc1bfa..98bd6fdc 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/impl/FlowExecutionImplTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/impl/FlowExecutionImplTests.java @@ -89,7 +89,7 @@ public class FlowExecutionImplTests extends TestCase { Flow flow = new Flow("flow"); new EndState(flow, "end"); MockFlowExecutionListener mockListener = new MockFlowExecutionListener() { - public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { + public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { super.sessionStarting(context, session, input); context.getMessageContext().addMessage(new MessageBuilder().source("foo").defaultText("bar").build()); } @@ -131,7 +131,7 @@ public class FlowExecutionImplTests extends TestCase { } }; MockFlowExecutionListener mockListener = new MockFlowExecutionListener() { - public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { + public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { super.sessionStarting(context, session, input); assertNotNull(input); } @@ -395,7 +395,7 @@ public class FlowExecutionImplTests extends TestCase { } }; state.getTransitionSet().add(new Transition(new DefaultTargetStateResolver("finish"))); - EndState end = new EndState(flow, "finish"); + new EndState(flow, "finish"); MockFlowExecutionListener mockListener = new MockFlowExecutionListener(); FlowExecutionListener[] listeners = new FlowExecutionListener[] { mockListener }; FlowExecutionImpl execution = new FlowExecutionImpl(flow); @@ -437,10 +437,6 @@ public class FlowExecutionImplTests extends TestCase { return handled; } - public void setHandled(boolean handled) { - this.handled = handled; - } - public boolean canHandle(FlowExecutionException exception) { return true; } @@ -448,7 +444,6 @@ public class FlowExecutionImplTests extends TestCase { public void handle(FlowExecutionException exception, RequestControlContext context) { handled = true; } - } private static class ExceptionThrowingExceptionHandler implements FlowExecutionExceptionHandler { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/AbstractModelTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/AbstractModelTests.java index 4aa724c0..67b1737a 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/AbstractModelTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/AbstractModelTests.java @@ -70,69 +70,69 @@ public class AbstractModelTests extends TestCase { } public void testListMergeAddAtEndFalse() { - LinkedList child = new LinkedList(); + LinkedList child = new LinkedList(); child.add(new SecuredModel("1")); child.add(new SecuredModel("3")); - LinkedList parent = new LinkedList(); + LinkedList parent = new LinkedList(); parent.add(new SecuredModel("2")); SecuredModel match = new SecuredModel("3"); match.setMatch("foo"); parent.add(match); AbstractModel obj = new PersistenceContextModel(); - LinkedList result = obj.merge(child, parent, false); + LinkedList result = obj.merge(child, parent, false); assertEquals(3, result.size()); - assertEquals("2", ((SecuredModel) result.get(0)).getAttributes()); - assertEquals("1", ((SecuredModel) result.get(1)).getAttributes()); - assertEquals("3", ((SecuredModel) result.get(2)).getAttributes()); + assertEquals("2", result.get(0).getAttributes()); + assertEquals("1", result.get(1).getAttributes()); + assertEquals("3", result.get(2).getAttributes()); assertNotSame(parent.get(0), result.get(1)); - assertEquals("foo", ((SecuredModel) result.get(2)).getMatch()); + assertEquals("foo", result.get(2).getMatch()); } public void testListMergeAddAtEndTrue() { - LinkedList child = new LinkedList(); + LinkedList child = new LinkedList(); child.add(new SecuredModel("1")); child.add(new SecuredModel("3")); - LinkedList parent = new LinkedList(); + LinkedList parent = new LinkedList(); parent.add(new SecuredModel("2")); SecuredModel match = new SecuredModel("3"); match.setMatch("foo"); parent.add(match); AbstractModel obj = new PersistenceContextModel(); - LinkedList result = obj.merge(child, parent, true); + LinkedList result = obj.merge(child, parent, true); assertEquals(3, result.size()); - assertEquals("1", ((SecuredModel) result.get(0)).getAttributes()); - assertEquals("3", ((SecuredModel) result.get(1)).getAttributes()); - assertEquals("2", ((SecuredModel) result.get(2)).getAttributes()); + assertEquals("1", result.get(0).getAttributes()); + assertEquals("3", result.get(1).getAttributes()); + assertEquals("2", result.get(2).getAttributes()); assertNotSame(parent.get(0), result.get(1)); - assertEquals("foo", ((SecuredModel) result.get(1)).getMatch()); + assertEquals("foo", result.get(1).getMatch()); } public void testListMergeNullParent() { AbstractModel obj = new PersistenceContextModel(); - LinkedList child = new LinkedList(); - child.add("1"); - LinkedList parent = null; - LinkedList result = obj.merge(child, parent); + LinkedList child = new LinkedList(); + child.add(new SecuredModel("1")); + LinkedList parent = null; + LinkedList result = obj.merge(child, parent); assertEquals(1, result.size()); - assertEquals("1", result.get(0)); + assertEquals("1", result.get(0).getAttributes()); } public void testListMergeNullChild() { - LinkedList child = null; - LinkedList parent = new LinkedList(); + LinkedList child = null; + LinkedList parent = new LinkedList(); parent.add(new SecuredModel("2")); AbstractModel obj = new PersistenceContextModel(); - LinkedList result = obj.merge(child, parent); + LinkedList result = obj.merge(child, parent); assertEquals(1, result.size()); - assertEquals("2", ((SecuredModel) result.get(0)).getAttributes()); + assertEquals("2", result.get(0).getAttributes()); assertNotSame(parent.get(0), result.get(0)); } public void testListMergeNulls() { AbstractModel obj = new PersistenceContextModel(); - LinkedList child = null; - LinkedList parent = null; - LinkedList result = obj.merge(child, parent); + LinkedList child = null; + LinkedList parent = null; + LinkedList result = obj.merge(child, parent); assertEquals(null, result); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/ActionStateModelTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/ActionStateModelTests.java index 5a1345ae..59dbeaac 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/ActionStateModelTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/ActionStateModelTests.java @@ -44,7 +44,7 @@ public class ActionStateModelTests extends TestCase { ActionStateModel child = new ActionStateModel("child"); ActionStateModel parent = new ActionStateModel("parent"); - LinkedList actions = new LinkedList(); + LinkedList actions = new LinkedList(); EvaluateModel eval = new EvaluateModel("foo.bar"); actions.add(eval); parent.setActions(actions); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/DecisionStateModelTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/DecisionStateModelTests.java index c80dee80..327e3411 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/DecisionStateModelTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/DecisionStateModelTests.java @@ -45,13 +45,13 @@ public class DecisionStateModelTests extends TestCase { DecisionStateModel parent = new DecisionStateModel("child"); parent.setSecured(new SecuredModel("secured")); - LinkedList ifs = new LinkedList(); + LinkedList ifs = new LinkedList(); ifs.add(new IfModel("test", "foo")); parent.setIfs(ifs); child.merge(parent); assertNotNull(child.getSecured()); - assertNotNull("test", ((IfModel) child.getIfs().get(0)).getTest()); + assertNotNull("test", child.getIfs().get(0).getTest()); } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/EndStateModelTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/EndStateModelTests.java index 33923ec0..bcd3682c 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/EndStateModelTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/EndStateModelTests.java @@ -46,12 +46,12 @@ public class EndStateModelTests extends TestCase { parent.setCommit("true"); parent.setView("view"); - LinkedList outputs = new LinkedList(); + LinkedList outputs = new LinkedList(); outputs.add(new OutputModel("foo", "bar")); parent.setOutputs(outputs); child.merge(parent); assertEquals("true", child.getCommit()); - assertEquals("bar", ((OutputModel) child.getOutputs().get(0)).getValue()); + assertEquals("bar", child.getOutputs().get(0).getValue()); } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/FlowModelTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/FlowModelTests.java index 89e81090..a06440ba 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/FlowModelTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/FlowModelTests.java @@ -15,6 +15,7 @@ */ package org.springframework.webflow.engine.model; +import java.util.Arrays; import java.util.LinkedList; import junit.framework.TestCase; @@ -38,20 +39,20 @@ public class FlowModelTests extends TestCase { public void testMergeAttributes() { FlowModel child = new FlowModel(); FlowModel parent = new FlowModel(); - child.setAttributes(singleList(new AttributeModel("name", "value"))); + child.setAttributes(asList(AttributeModel.class, new AttributeModel("name", "value"))); AttributeModel parentAttribute1 = new AttributeModel("name", "value"); parentAttribute1.setType("type"); AttributeModel parentAttribute2 = new AttributeModel("name2", "value2"); parentAttribute2.setType("type2"); - parent.setAttributes(doubleList(parentAttribute1, parentAttribute2)); + parent.setAttributes(asList(AttributeModel.class, parentAttribute1, parentAttribute2)); child.merge(parent); assertEquals(2, child.getAttributes().size()); - assertEquals("name", ((AttributeModel) child.getAttributes().get(0)).getName()); - assertEquals("type", ((AttributeModel) child.getAttributes().get(0)).getType()); - assertEquals("name2", ((AttributeModel) child.getAttributes().get(1)).getName()); - assertEquals("type2", ((AttributeModel) child.getAttributes().get(1)).getType()); + assertEquals("name", child.getAttributes().get(0).getName()); + assertEquals("type", child.getAttributes().get(0).getType()); + assertEquals("name2", child.getAttributes().get(1).getName()); + assertEquals("type2", child.getAttributes().get(1).getType()); } public void testMergeSecured() { @@ -75,14 +76,14 @@ public class FlowModelTests extends TestCase { public void testMergeVars() { FlowModel parent = new FlowModel(); - parent.setVars(singleList(new VarModel("name", "value"))); + parent.setVars(asList(VarModel.class, new VarModel("name", "value"))); FlowModel child = new FlowModel(); - child.setVars(singleList(new VarModel("name", "value2"))); + child.setVars(asList(VarModel.class, new VarModel("name", "value2"))); child.merge(parent); assertEquals(1, child.getVars().size()); - assertEquals("value2", ((VarModel) child.getVars().get(0)).getClassName()); + assertEquals("value2", child.getVars().get(0).getClassName()); } public void testMergeMappings() { @@ -101,12 +102,12 @@ public class FlowModelTests extends TestCase { input2.setType("type3"); input2.setRequired("required3"); - child.setInputs(tripleList(input1, input2, input3)); + child.setInputs(asList(InputModel.class, input1, input2, input3)); InputModel parentInput = new InputModel("name3", "value3"); parentInput.setType("type3"); parentInput.setRequired("required3"); - parent.setInputs(singleList(parentInput)); + parent.setInputs(asList(InputModel.class, parentInput)); child.merge(parent); assertEquals(3, child.getInputs().size()); @@ -114,14 +115,15 @@ public class FlowModelTests extends TestCase { public void testMergeOnStart() { FlowModel child = new FlowModel(); - child.setOnStartActions(tripleList(new EvaluateModel("expression"), new RenderModel("expression"), - new SetModel("expression", "value"))); + child.setOnStartActions(asList(AbstractActionModel.class, new EvaluateModel("expression"), new RenderModel( + "expression"), new SetModel("expression", "value"))); FlowModel parent = new FlowModel(); EvaluateModel eval = new EvaluateModel("expression"); eval.setResult("result"); - parent.setOnStartActions(tripleList(eval, new RenderModel("expression"), new SetModel("expression", "value"))); + parent.setOnStartActions(asList(AbstractActionModel.class, eval, new RenderModel("expression"), new SetModel( + "expression", "value"))); child.merge(parent); assertEquals(6, child.getOnStartActions().size()); @@ -130,12 +132,13 @@ public class FlowModelTests extends TestCase { public void testMergeStates() { FlowModel child = new FlowModel(); - child.setStates(doubleList(new ViewStateModel("view"), new EndStateModel("end"))); + child.setStates(asList(AbstractStateModel.class, new ViewStateModel("view"), new EndStateModel("end"))); FlowModel parent = new FlowModel(); ViewStateModel view = new ViewStateModel("view"); view.setView("jsp"); - parent.setStates(tripleList(view, new DecisionStateModel("decider"), new ActionStateModel("action"))); + parent.setStates(asList(AbstractStateModel.class, view, new DecisionStateModel("decider"), + new ActionStateModel("action"))); child.merge(parent); assertEquals(4, child.getStates().size()); @@ -148,7 +151,7 @@ public class FlowModelTests extends TestCase { transition1.setOn("end"); TransitionModel transition2 = new TransitionModel(); transition2.setOn("start"); - child.setGlobalTransitions(doubleList(transition1, transition2)); + child.setGlobalTransitions(asList(TransitionModel.class, transition1, transition2)); FlowModel parent = new FlowModel(); transition1 = new TransitionModel(); @@ -156,22 +159,23 @@ public class FlowModelTests extends TestCase { transition2 = new TransitionModel(); transition2.setOn("end"); transition2.setTo("theend"); - parent.setGlobalTransitions(doubleList(transition1, transition2)); + parent.setGlobalTransitions(asList(TransitionModel.class, transition1, transition2)); child.merge(parent); assertEquals(3, child.getGlobalTransitions().size()); - assertEquals("theend", ((TransitionModel) child.getGlobalTransitions().get(0)).getTo()); + assertEquals("theend", child.getGlobalTransitions().get(0).getTo()); } public void testMergeOnEnd() { FlowModel child = new FlowModel(); - child.setOnEndActions(tripleList(new EvaluateModel("expression"), new RenderModel("expression"), new SetModel( - "expression", "value"))); + child.setOnEndActions(asList(AbstractActionModel.class, new EvaluateModel("expression"), new RenderModel( + "expression"), new SetModel("expression", "value"))); FlowModel parent = new FlowModel(); EvaluateModel eval = new EvaluateModel("expression"); eval.setResult("result"); - parent.setOnEndActions(tripleList(eval, new RenderModel("expression"), new SetModel("expression", "value"))); + parent.setOnEndActions(asList(AbstractActionModel.class, eval, new RenderModel("expression"), new SetModel( + "expression", "value"))); child.merge(parent); assertEquals(6, child.getOnEndActions().size()); @@ -180,10 +184,12 @@ public class FlowModelTests extends TestCase { public void testMergeExceptionHandlers() { FlowModel child = new FlowModel(); - child.setExceptionHandlers(doubleList(new ExceptionHandlerModel("bean1"), new ExceptionHandlerModel("bean2"))); + child.setExceptionHandlers(asList(ExceptionHandlerModel.class, new ExceptionHandlerModel("bean1"), + new ExceptionHandlerModel("bean2"))); FlowModel parent = new FlowModel(); - parent.setExceptionHandlers(doubleList(new ExceptionHandlerModel("bean2"), new ExceptionHandlerModel("bean3"))); + parent.setExceptionHandlers(asList(ExceptionHandlerModel.class, new ExceptionHandlerModel("bean2"), + new ExceptionHandlerModel("bean3"))); child.merge(parent); assertEquals(4, child.getExceptionHandlers().size()); @@ -191,34 +197,17 @@ public class FlowModelTests extends TestCase { public void testMergeBeanImports() { FlowModel child = new FlowModel(); - child.setBeanImports(doubleList(new BeanImportModel("path1"), new BeanImportModel("path2"))); + child.setBeanImports(asList(BeanImportModel.class, new BeanImportModel("path1"), new BeanImportModel("path2"))); FlowModel parent = new FlowModel(); - parent.setBeanImports(doubleList(new BeanImportModel("path1"), new BeanImportModel("path2"))); + parent.setBeanImports(asList(BeanImportModel.class, new BeanImportModel("path1"), new BeanImportModel("path2"))); child.merge(parent); assertEquals(4, child.getBeanImports().size()); } - private LinkedList singleList(Model model) { - LinkedList list = new LinkedList(); - list.add(model); - return list; - } - - private LinkedList doubleList(Model model, Model model2) { - LinkedList list = new LinkedList(); - list.add(model); - list.add(model2); - return list; - } - - private LinkedList tripleList(Model model, Model model2, Model model3) { - LinkedList list = new LinkedList(); - list.add(model); - list.add(model2); - list.add(model3); - return list; + private LinkedList asList(Class elementClass, T... a) { + return new LinkedList(Arrays.asList(a)); } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/ViewStateModelTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/ViewStateModelTests.java index 22aefae4..1b47e1b9 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/ViewStateModelTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/ViewStateModelTests.java @@ -44,12 +44,12 @@ public class ViewStateModelTests extends TestCase { ViewStateModel child = new ViewStateModel("child"); ViewStateModel parent = new ViewStateModel("parent"); - LinkedList attributes = new LinkedList(); + LinkedList attributes = new LinkedList(); attributes.add(new AttributeModel("foo", "bar")); parent.setAttributes(attributes); BinderModel binder = new BinderModel(); - LinkedList bindings = new LinkedList(); + LinkedList bindings = new LinkedList(); bindings.add(new BindingModel("foo", "fooConverter", "true")); binder.setBindings(bindings); parent.setBinder(binder); @@ -61,7 +61,7 @@ public class ViewStateModelTests extends TestCase { parent.setModel("fooModel"); parent.setView("fooView"); - LinkedList transitions = new LinkedList(); + LinkedList transitions = new LinkedList(); TransitionModel tx = new TransitionModel(); tx.setOn("submit"); tx.setTo("bar"); @@ -69,17 +69,17 @@ public class ViewStateModelTests extends TestCase { parent.setTransitions(transitions); EvaluateModel eval = new EvaluateModel("foo.bar"); - LinkedList actions = new LinkedList(); + LinkedList actions = new LinkedList(); actions.add(eval); parent.setOnEntryActions(actions); parent.setOnExitActions(actions); parent.setOnRenderActions(actions); - LinkedList vars = new LinkedList(); + LinkedList vars = new LinkedList(); vars.add(new VarModel("foo", "class")); parent.setVars(vars); - LinkedList eh = new LinkedList(); + LinkedList eh = new LinkedList(); eh.add(new ExceptionHandlerModel("foo")); parent.setExceptionHandlers(eh); @@ -90,13 +90,13 @@ public class ViewStateModelTests extends TestCase { assertEquals("true", child.getPopup()); assertEquals("fooModel", child.getModel()); assertEquals("fooView", child.getView()); - assertEquals("bar", ((AttributeModel) child.getAttributes().get(0)).getValue()); - assertEquals("foo", ((BindingModel) child.getBinder().getBindings().get(0)).getProperty()); - assertEquals("bar", ((TransitionModel) child.getTransitions().get(0)).getTo()); + assertEquals("bar", child.getAttributes().get(0).getValue()); + assertEquals("foo", child.getBinder().getBindings().get(0).getProperty()); + assertEquals("bar", child.getTransitions().get(0).getTo()); assertEquals("foo.bar", ((EvaluateModel) child.getOnEntryActions().get(0)).getExpression()); assertEquals("foo.bar", ((EvaluateModel) child.getOnExitActions().get(0)).getExpression()); assertEquals("foo.bar", ((EvaluateModel) child.getOnRenderActions().get(0)).getExpression()); - assertEquals("foo", ((VarModel) child.getVars().get(0)).getName()); - assertEquals("foo", ((ExceptionHandlerModel) child.getExceptionHandlers().get(0)).getBean()); + assertEquals("foo", child.getVars().get(0).getName()); + assertEquals("foo", child.getExceptionHandlers().get(0).getBean()); } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilderTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilderTests.java index 19915556..143daa21 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilderTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/builder/xml/XmlFlowModelBuilderTests.java @@ -12,14 +12,8 @@ import org.springframework.webflow.engine.Flow; import org.springframework.webflow.engine.builder.FlowAssembler; import org.springframework.webflow.engine.builder.model.FlowModelFlowBuilder; import org.springframework.webflow.engine.impl.FlowExecutionImplFactory; -import org.springframework.webflow.engine.model.AbstractStateModel; -import org.springframework.webflow.engine.model.AttributeModel; -import org.springframework.webflow.engine.model.BindingModel; -import org.springframework.webflow.engine.model.ExceptionHandlerModel; import org.springframework.webflow.engine.model.FlowModel; import org.springframework.webflow.engine.model.SecuredModel; -import org.springframework.webflow.engine.model.TransitionModel; -import org.springframework.webflow.engine.model.VarModel; import org.springframework.webflow.engine.model.ViewStateModel; import org.springframework.webflow.engine.model.builder.DefaultFlowModelHolder; import org.springframework.webflow.engine.model.builder.FlowModelBuilder; @@ -51,7 +45,7 @@ public class XmlFlowModelBuilderTests extends TestCase { builder.build(); FlowModel flow = builder.getFlowModel(); assertNull(flow.getStartStateId()); - assertEquals("end", ((AbstractStateModel) flow.getStates().get(0)).getId()); + assertEquals("end", flow.getStates().get(0).getId()); } public void testBuildFlowWithDefaultStartState() { @@ -61,7 +55,7 @@ public class XmlFlowModelBuilderTests extends TestCase { builder.build(); FlowModel flow = builder.getFlowModel(); assertNull(flow.getStartStateId()); - assertEquals("end", ((AbstractStateModel) flow.getStates().get(0)).getId()); + assertEquals("end", flow.getStates().get(0).getId()); } public void testBuildFlowWithStartStateAttribute() { @@ -79,8 +73,8 @@ public class XmlFlowModelBuilderTests extends TestCase { builder.init(); builder.build(); FlowModel flow = builder.getFlowModel(); - assertEquals("bar", ((AttributeModel) flow.getAttributes().get(0)).getValue()); - assertEquals("number", ((AttributeModel) flow.getAttributes().get(1)).getName()); + assertEquals("bar", flow.getAttributes().get(0).getValue()); + assertEquals("number", flow.getAttributes().get(1).getName()); } public void testPersistenceContextFlow() { @@ -109,7 +103,7 @@ public class XmlFlowModelBuilderTests extends TestCase { builder.init(); builder.build(); FlowModel flow = builder.getFlowModel(); - SecuredModel secured = ((AbstractStateModel) flow.getStates().get(0)).getSecured(); + SecuredModel secured = flow.getStates().get(0).getSecured(); assertNotNull(secured); assertEquals("ROLE_USER", secured.getAttributes()); } @@ -120,7 +114,7 @@ public class XmlFlowModelBuilderTests extends TestCase { builder.init(); builder.build(); FlowModel flow = builder.getFlowModel(); - SecuredModel secured = ((TransitionModel) flow.getGlobalTransitions().get(0)).getSecured(); + SecuredModel secured = flow.getGlobalTransitions().get(0).getSecured(); assertNotNull(secured); assertEquals("ROLE_USER", secured.getAttributes()); } @@ -131,8 +125,8 @@ public class XmlFlowModelBuilderTests extends TestCase { builder.init(); builder.build(); FlowModel flow = builder.getFlowModel(); - assertEquals("flow-foo", ((VarModel) flow.getVars().get(0)).getName()); - assertEquals("conversation-foo", ((VarModel) flow.getVars().get(1)).getName()); + assertEquals("flow-foo", flow.getVars().get(0).getName()); + assertEquals("conversation-foo", flow.getVars().get(1).getName()); } public void testViewStateVariable() { @@ -141,7 +135,7 @@ public class XmlFlowModelBuilderTests extends TestCase { builder.init(); builder.build(); FlowModel flow = builder.getFlowModel(); - assertEquals("foo", ((VarModel) ((ViewStateModel) flow.getStates().get(0)).getVars().get(0)).getName()); + assertEquals("foo", ((ViewStateModel) flow.getStates().get(0)).getVars().get(0).getName()); } public void testViewStateModelBinding() { @@ -152,8 +146,8 @@ public class XmlFlowModelBuilderTests extends TestCase { FlowModel flow = builder.getFlowModel(); ViewStateModel model = (ViewStateModel) flow.getStates().get(0); assertEquals("formObject", model.getModel()); - assertEquals("objectProperty", ((BindingModel) model.getBinder().getBindings().get(0)).getProperty()); - assertEquals("customConverter", ((BindingModel) model.getBinder().getBindings().get(0)).getConverter()); + assertEquals("objectProperty", model.getBinder().getBindings().get(0).getProperty()); + assertEquals("customConverter", model.getBinder().getBindings().get(0).getConverter()); } public void testViewStateRedirect() { @@ -184,7 +178,7 @@ public class XmlFlowModelBuilderTests extends TestCase { FlowModel flow = registry.getFlowModel("child"); assertEquals(1, flow.getGlobalTransitions().size()); assertEquals(2, flow.getStates().size()); - assertEquals("view", ((AbstractStateModel) flow.getStates().get(0)).getId()); + assertEquals("view", flow.getStates().get(0).getId()); } public void testMergeParentNotFound() { @@ -289,17 +283,12 @@ public class XmlFlowModelBuilderTests extends TestCase { XmlFlowModelBuilder builder = new XmlFlowModelBuilder(res); DefaultFlowModelHolder holder = new DefaultFlowModelHolder(builder); FlowModel model = holder.getFlowModel(); - assertEquals("foo1", ((ExceptionHandlerModel) model.getExceptionHandlers().get(0)).getBean()); - assertEquals("foo2", - ((ExceptionHandlerModel) model.getStateById("state1").getExceptionHandlers().get(0)).getBean()); - assertEquals("foo3", - ((ExceptionHandlerModel) model.getStateById("state2").getExceptionHandlers().get(0)).getBean()); - assertEquals("foo4", - ((ExceptionHandlerModel) model.getStateById("state3").getExceptionHandlers().get(0)).getBean()); - assertEquals("foo5", - ((ExceptionHandlerModel) model.getStateById("state4").getExceptionHandlers().get(0)).getBean()); - assertEquals("foo6", - ((ExceptionHandlerModel) model.getStateById("state5").getExceptionHandlers().get(0)).getBean()); + assertEquals("foo1", model.getExceptionHandlers().get(0).getBean()); + assertEquals("foo2", model.getStateById("state1").getExceptionHandlers().get(0).getBean()); + assertEquals("foo3", model.getStateById("state2").getExceptionHandlers().get(0).getBean()); + assertEquals("foo4", model.getStateById("state3").getExceptionHandlers().get(0).getBean()); + assertEquals("foo5", model.getStateById("state4").getExceptionHandlers().get(0).getBean()); + assertEquals("foo6", model.getStateById("state5").getExceptionHandlers().get(0).getBean()); } public void testFormActionValidatorMethod() { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/registry/DefaultFlowModelHolderTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/registry/DefaultFlowModelHolderTests.java index 8e086bae..a9b457dd 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/model/registry/DefaultFlowModelHolderTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/model/registry/DefaultFlowModelHolderTests.java @@ -25,7 +25,7 @@ public class DefaultFlowModelHolderTests extends TestCase { public void testGetFlowDefinition() { FlowModel flow = holder.getFlowModel(); assertNull(flow.getStartStateId()); - assertEquals("end", ((AbstractStateModel) flow.getStates().get(0)).getId()); + assertEquals("end", flow.getStates().get(0).getId()); } public void testGetFlowDefinitionWithChangesRefreshed() { @@ -33,14 +33,14 @@ public class DefaultFlowModelHolderTests extends TestCase { holder.refresh(); flow = holder.getFlowModel(); assertNull(flow.getStartStateId()); - assertEquals("end", ((AbstractStateModel) flow.getStates().get(0)).getId()); + assertEquals("end", flow.getStates().get(0).getId()); } public class SimpleFlowBuilder implements FlowModelBuilder { public FlowModel getFlowModel() throws FlowModelBuilderException { FlowModel flow = new FlowModel(); - flow.setStates(new LinkedList(Collections.singletonList(new EndStateModel("end")))); + flow.setStates(new LinkedList(Collections.singletonList(new EndStateModel("end")))); return flow; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/support/NotTransitionCriteriaTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/support/NotTransitionCriteriaTests.java index 9fd6cacd..dad5898b 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/support/NotTransitionCriteriaTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/support/NotTransitionCriteriaTests.java @@ -15,11 +15,11 @@ */ package org.springframework.webflow.engine.support; +import junit.framework.TestCase; + import org.springframework.webflow.engine.WildcardTransitionCriteria; import org.springframework.webflow.test.MockRequestContext; -import junit.framework.TestCase; - /** * Unit tests for {@link NotTransitionCriteria}. * diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/support/TransitionCriteriaChainTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/support/TransitionCriteriaChainTests.java index 5e216b6d..8ce77a2a 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/support/TransitionCriteriaChainTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/support/TransitionCriteriaChainTests.java @@ -15,6 +15,8 @@ */ package org.springframework.webflow.engine.support; +import junit.framework.TestCase; + import org.springframework.webflow.action.EventFactorySupport; import org.springframework.webflow.engine.TransitionCriteria; import org.springframework.webflow.execution.Action; @@ -23,8 +25,6 @@ import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.RequestContext; import org.springframework.webflow.test.MockRequestContext; -import junit.framework.TestCase; - /** * Unit tests for {@link TransitionCriteriaChain}. * diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/support/TransitionExecutingFlowExecutionExceptionHandlerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/support/TransitionExecutingFlowExecutionExceptionHandlerTests.java index 47fc5105..902ffcc7 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/support/TransitionExecutingFlowExecutionExceptionHandlerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/support/TransitionExecutingFlowExecutionExceptionHandlerTests.java @@ -86,7 +86,8 @@ public class TransitionExecutingFlowExecutionExceptionHandlerTests extends TestC handler.add(TestException.class, "end"); flow.getExceptionHandlerSet().add(handler); FlowExecutionListener listener = new FlowExecutionListenerAdapter() { - public void sessionEnding(RequestContext context, FlowSession session, MutableAttributeMap output) { + @SuppressWarnings("unused") + public void sessionEnding(RequestContext context, FlowSession session, MutableAttributeMap output) { assertTrue(context.getFlashScope().contains("flowExecutionException")); assertTrue(context.getFlashScope().contains("rootCauseException")); assertTrue(context.getFlashScope().get("rootCauseException") instanceof TestException); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/execution/MockFlowExecutionListener.java b/spring-webflow/src/test/java/org/springframework/webflow/execution/MockFlowExecutionListener.java index c9cabd96..8479f3b9 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/execution/MockFlowExecutionListener.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/execution/MockFlowExecutionListener.java @@ -224,7 +224,7 @@ public class MockFlowExecutionListener extends FlowExecutionListenerAdapter { sessionCreatingCount++; } - public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { + public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap input) { sessionStartingCount++; sessionStarting = true; flowNestingLevel++; @@ -273,13 +273,13 @@ public class MockFlowExecutionListener extends FlowExecutionListenerAdapter { resumingCount++; } - public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output) { + public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap output) { sessionEnding = true; sessionEndingCount++; flowNestingLevel--; } - public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output) { + public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap output) { assertStarted(); Assert.state(sessionEnding, "Should have been ending"); sessionEnding = false; diff --git a/spring-webflow/src/test/java/org/springframework/webflow/execution/repository/impl/DefaultFlowExecutionRepositoryTests.java b/spring-webflow/src/test/java/org/springframework/webflow/execution/repository/impl/DefaultFlowExecutionRepositoryTests.java index 59f950e7..8da3d054 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/execution/repository/impl/DefaultFlowExecutionRepositoryTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/execution/repository/impl/DefaultFlowExecutionRepositoryTests.java @@ -268,26 +268,19 @@ public class DefaultFlowExecutionRepositoryTests extends TestCase { private final ConversationId ID = new SimpleConversationId(new Integer(12345)); - private boolean locked; - private boolean ended; - private Map attributes = new HashMap(); + private Map attributes = new HashMap(); public boolean hasEnded() { return ended; } - public boolean isLocked() { - return locked; - } - public ConversationId getId() { return ID; } public void lock() { - locked = true; } public Object getAttribute(Object name) { @@ -307,7 +300,6 @@ public class DefaultFlowExecutionRepositoryTests extends TestCase { } public void unlock() { - locked = false; } } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/executor/FlowExecutorImplTests.java b/spring-webflow/src/test/java/org/springframework/webflow/executor/FlowExecutorImplTests.java index cc851048..8d7f016f 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/executor/FlowExecutorImplTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/executor/FlowExecutorImplTests.java @@ -30,19 +30,19 @@ public class FlowExecutorImplTests extends TestCase { private FlowExecutionLock lock; protected void setUp() { - locator = (FlowDefinitionLocator) EasyMock.createMock(FlowDefinitionLocator.class); - definition = (FlowDefinition) EasyMock.createMock(FlowDefinition.class); - factory = (FlowExecutionFactory) EasyMock.createMock(FlowExecutionFactory.class); - execution = (FlowExecution) EasyMock.createMock(FlowExecution.class); - repository = (FlowExecutionRepository) EasyMock.createMock(FlowExecutionRepository.class); - lock = (FlowExecutionLock) EasyMock.createMock(FlowExecutionLock.class); + locator = EasyMock.createMock(FlowDefinitionLocator.class); + definition = EasyMock.createMock(FlowDefinition.class); + factory = EasyMock.createMock(FlowExecutionFactory.class); + execution = EasyMock.createMock(FlowExecution.class); + repository = EasyMock.createMock(FlowExecutionRepository.class); + lock = EasyMock.createMock(FlowExecutionLock.class); flowExecutor = new FlowExecutorImpl(locator, factory, repository); } public void testLaunchFlowExecution() { String flowId = "foo"; - MutableAttributeMap input = null; + MutableAttributeMap input = null; MockExternalContext context = new MockExternalContext(); EasyMock.expect(locator.getFlowDefinition(flowId)).andReturn(definition); @@ -80,7 +80,7 @@ public class FlowExecutorImplTests extends TestCase { public void testLaunchFlowExecutionEndsAfterProcessing() { String flowId = "foo"; - MutableAttributeMap input = null; + MutableAttributeMap input = null; MockExternalContext context = new MockExternalContext(); EasyMock.expect(locator.getFlowDefinition(flowId)).andReturn(definition); @@ -163,7 +163,7 @@ public class FlowExecutorImplTests extends TestCase { EasyMock.expect(execution.getDefinition()).andReturn(definition); EasyMock.expect(definition.getId()).andReturn("foo"); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("foo", "bar"); EasyMock.expect(execution.getOutcome()).andReturn(new FlowExecutionOutcome("finish", output)); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/expression/WebFlowOgnlExpressionParserTests.java b/spring-webflow/src/test/java/org/springframework/webflow/expression/WebFlowOgnlExpressionParserTests.java index 30b6e6bb..09f62baa 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/expression/WebFlowOgnlExpressionParserTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/expression/WebFlowOgnlExpressionParserTests.java @@ -26,7 +26,7 @@ public class WebFlowOgnlExpressionParserTests extends TestCase { private WebFlowOgnlExpressionParser parser = new WebFlowOgnlExpressionParser(); public void testResolveMap() { - LocalAttributeMap map = new LocalAttributeMap(); + LocalAttributeMap map = new LocalAttributeMap(); map.put("foo", "bar"); Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(AttributeMap.class)); Expression exp2 = parser.parseExpression("bogus", new FluentParserContext().evaluate(AttributeMap.class)); @@ -35,7 +35,7 @@ public class WebFlowOgnlExpressionParserTests extends TestCase { } public void testSetMap() { - LocalAttributeMap map = new LocalAttributeMap(); + LocalAttributeMap map = new LocalAttributeMap(); map.put("foo", "bar"); Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(MutableAttributeMap.class)); Expression exp2 = parser @@ -48,8 +48,8 @@ public class WebFlowOgnlExpressionParserTests extends TestCase { public void testResolveFlowRequestContext() { MockRequestContext context = new MockRequestContext(); - Expression exp = parser.parseExpression("flowRequestContext", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression exp = parser.parseExpression("flowRequestContext", + new FluentParserContext().evaluate(RequestContext.class)); assertSame(context, exp.getValue(context)); } @@ -167,8 +167,8 @@ public class WebFlowOgnlExpressionParserTests extends TestCase { StaticApplicationContext ac = new StaticApplicationContext(); ac.getBeanFactory().registerSingleton("multiAction", new FormAction()); context.getRootFlow().setApplicationContext(ac); - Expression exp = parser.parseExpression("multiAction.setupForm", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression exp = parser.parseExpression("multiAction.setupForm", + new FluentParserContext().evaluate(RequestContext.class)); AnnotatedAction action = (AnnotatedAction) exp.getValue(context); assertSame(ac.getBean("multiAction"), action.getTargetAction()); assertEquals("setupForm", action.getMethod()); @@ -176,11 +176,11 @@ public class WebFlowOgnlExpressionParserTests extends TestCase { public void testResolveEventAttributes() { MockRequestContext context = new MockRequestContext(); - LocalAttributeMap attributes = new LocalAttributeMap(); + LocalAttributeMap attributes = new LocalAttributeMap(); attributes.put("foo", "bar"); context.setCurrentEvent(new Event(this, "event", attributes)); - Expression exp = parser.parseExpression("currentEvent.attributes.foo", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression exp = parser.parseExpression("currentEvent.attributes.foo", + new FluentParserContext().evaluate(RequestContext.class)); assertEquals("bar", exp.getValue(context)); } @@ -191,8 +191,8 @@ public class WebFlowOgnlExpressionParserTests extends TestCase { ac.refresh(); context.getRootFlow().setApplicationContext(ac); context.getMockExternalContext().setLocale(Locale.FRANCE); - Expression exp = parser.parseExpression("resourceBundle.foo", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression exp = parser.parseExpression("resourceBundle.foo", + new FluentParserContext().evaluate(RequestContext.class)); assertEquals("bar", exp.getValue(context)); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/FlowDependentELResolverTestCase.java b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/FlowDependentELResolverTestCase.java index 454ac972..384a7950 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/FlowDependentELResolverTestCase.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/FlowDependentELResolverTestCase.java @@ -3,6 +3,7 @@ package org.springframework.webflow.expression.el; import java.util.List; import javax.el.ELContext; +import javax.el.ELResolver; import junit.framework.TestCase; @@ -29,20 +30,20 @@ public abstract class FlowDependentELResolverTestCase extends TestCase { } public void testGetType_NoActiveFlow() { - assertNull("getType should return null when no flow is active", context.getELResolver().getType(context, null, - getBaseVariable())); + assertNull("getType should return null when no flow is active", + context.getELResolver().getType(context, null, getBaseVariable())); assertFalse(context.isPropertyResolved()); } public void testGetValue_NoActiveFlow() { - assertNull("getValue should return null when no flow is active", context.getELResolver().getValue(context, - null, getBaseVariable())); + assertNull("getValue should return null when no flow is active", + context.getELResolver().getValue(context, null, getBaseVariable())); assertFalse(context.isPropertyResolved()); } public void testIsReadOnly_NoActiveFlow() { - assertFalse("isReadOnly should return false when no flow is active", context.getELResolver().isReadOnly( - context, null, getBaseVariable())); + assertFalse("isReadOnly should return false when no flow is active", + context.getELResolver().isReadOnly(context, null, getBaseVariable())); assertFalse(context.isPropertyResolved()); } @@ -62,6 +63,6 @@ public abstract class FlowDependentELResolverTestCase extends TestCase { protected abstract String getBaseVariable(); - protected abstract List getCustomResolvers(); + protected abstract List getCustomResolvers(); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/FlowResourceELResolverTests.java b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/FlowResourceELResolverTests.java index cf441084..028fcdde 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/FlowResourceELResolverTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/FlowResourceELResolverTests.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import javax.el.ELResolver; import javax.el.PropertyNotFoundException; import javax.el.PropertyNotWritableException; @@ -27,8 +28,8 @@ public class FlowResourceELResolverTests extends FlowDependentELResolverTestCase ms.addMessage("foo.bar", Locale.getDefault(), "hello"); RequestContextHolder.setRequestContext(new MockRequestContext()); - assertEquals("Message should resolve to a type of String", String.class, context.getELResolver().getType( - context, ms, "foo.bar")); + assertEquals("Message should resolve to a type of String", String.class, + context.getELResolver().getType(context, ms, "foo.bar")); } public void testGetType_InvalidCode() { @@ -58,8 +59,8 @@ public class FlowResourceELResolverTests extends FlowDependentELResolverTestCase ms.addMessage("foo.bar", Locale.getDefault(), "hello"); RequestContextHolder.setRequestContext(new MockRequestContext()); - assertEquals("Message should resolve to a valid message value", "hello", context.getELResolver().getValue( - context, ms, "foo.bar")); + assertEquals("Message should resolve to a valid message value", "hello", + context.getELResolver().getValue(context, ms, "foo.bar")); } public void testGetValue_InvalidCode() { @@ -77,8 +78,8 @@ public class FlowResourceELResolverTests extends FlowDependentELResolverTestCase public void testIsReadOnly_BaseVariable() { RequestContextHolder.setRequestContext(new MockRequestContext()); - assertTrue("isReadOnly should return true for the base variable", context.getELResolver().isReadOnly(context, - null, getBaseVariable())); + assertTrue("isReadOnly should return true for the base variable", + context.getELResolver().isReadOnly(context, null, getBaseVariable())); } public void testIsReadOnly_MessageSourceBase() { @@ -114,8 +115,8 @@ public class FlowResourceELResolverTests extends FlowDependentELResolverTestCase return FlowResourceELResolver.RESOURCE_BUNDLE_KEY; } - protected List getCustomResolvers() { - List resolvers = new ArrayList(); + protected List getCustomResolvers() { + List resolvers = new ArrayList(); resolvers.add(new FlowResourceELResolver()); return resolvers; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/ImplicitFlowVariableELResolverTests.java b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/ImplicitFlowVariableELResolverTests.java index 854966d8..6756807b 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/ImplicitFlowVariableELResolverTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/ImplicitFlowVariableELResolverTests.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import javax.el.ELResolver; import javax.el.PropertyNotWritableException; import org.springframework.binding.message.MessageContext; @@ -22,7 +23,7 @@ import org.springframework.webflow.test.MockRequestContext; public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolverTestCase { - private static final List vars = new ArrayList(); + private static final List vars = new ArrayList(); { vars.add("requestParameters"); vars.add("requestScope"); @@ -40,22 +41,22 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver public void testGetType_RequestParameters() { RequestContextHolder.setRequestContext(new MockRequestContext()); - assertTrue(ClassUtils.isAssignable(ParameterMap.class, context.getELResolver().getType(context, null, - "requestParameters"))); + assertTrue(ClassUtils.isAssignable(ParameterMap.class, + context.getELResolver().getType(context, null, "requestParameters"))); assertTrue(context.isPropertyResolved()); } public void testGetType_RequestScope() { RequestContextHolder.setRequestContext(new MockRequestContext()); - assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, context.getELResolver().getType(context, null, - "requestScope"))); + assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, + context.getELResolver().getType(context, null, "requestScope"))); assertTrue(context.isPropertyResolved()); } public void testGetType_FlashScope() { RequestContextHolder.setRequestContext(new MockRequestContext()); - assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, context.getELResolver().getType(context, null, - "flashScope"))); + assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, + context.getELResolver().getType(context, null, "flashScope"))); assertTrue(context.isPropertyResolved()); } @@ -64,43 +65,43 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver RequestContextHolder.setRequestContext(requestContext); initView(requestContext); - assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, context.getELResolver().getType(context, null, - "viewScope"))); + assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, + context.getELResolver().getType(context, null, "viewScope"))); assertTrue(context.isPropertyResolved()); } public void testGetType_FlowScope() { RequestContextHolder.setRequestContext(new MockRequestContext()); - assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, context.getELResolver().getType(context, null, - "flowScope"))); + assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, + context.getELResolver().getType(context, null, "flowScope"))); assertTrue(context.isPropertyResolved()); } public void testGetType_ConversationScope() { RequestContextHolder.setRequestContext(new MockRequestContext()); - assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, context.getELResolver().getType(context, null, - "conversationScope"))); + assertTrue(ClassUtils.isAssignable(MutableAttributeMap.class, + context.getELResolver().getType(context, null, "conversationScope"))); assertTrue(context.isPropertyResolved()); } public void testGetType_MessageContext() { RequestContextHolder.setRequestContext(new MockRequestContext()); - assertTrue(ClassUtils.isAssignable(MessageContext.class, context.getELResolver().getType(context, null, - "messageContext"))); + assertTrue(ClassUtils.isAssignable(MessageContext.class, + context.getELResolver().getType(context, null, "messageContext"))); assertTrue(context.isPropertyResolved()); } public void testGetType_ExternalContext() { RequestContextHolder.setRequestContext(new MockRequestContext()); - assertTrue(ClassUtils.isAssignable(ExternalContext.class, context.getELResolver().getType(context, null, - "externalContext"))); + assertTrue(ClassUtils.isAssignable(ExternalContext.class, + context.getELResolver().getType(context, null, "externalContext"))); assertTrue(context.isPropertyResolved()); } public void testGetType_FlowExecutionContext() { RequestContextHolder.setRequestContext(new MockRequestContext()); - assertTrue(ClassUtils.isAssignable(FlowExecutionContext.class, context.getELResolver().getType(context, null, - "flowExecutionContext"))); + assertTrue(ClassUtils.isAssignable(FlowExecutionContext.class, + context.getELResolver().getType(context, null, "flowExecutionContext"))); assertTrue(context.isPropertyResolved()); } @@ -109,8 +110,8 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver ((MockFlowExecutionContext) requestContext.getFlowExecutionContext()).setKey(new MockFlowExecutionKey("e1s1")); RequestContextHolder.setRequestContext(requestContext); - assertTrue(ClassUtils.isAssignable(String.class, context.getELResolver().getType(context, null, - "flowExecutionUrl"))); + assertTrue(ClassUtils.isAssignable(String.class, + context.getELResolver().getType(context, null, "flowExecutionUrl"))); assertTrue(context.isPropertyResolved()); } @@ -119,8 +120,8 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver ((MockExternalContext) requestContext.getExternalContext()).setCurrentUser("jjg"); RequestContextHolder.setRequestContext(requestContext); - assertTrue(ClassUtils.isAssignable(Principal.class, context.getELResolver().getType(context, null, - "currentUser"))); + assertTrue(ClassUtils.isAssignable(Principal.class, + context.getELResolver().getType(context, null, "currentUser"))); assertTrue(context.isPropertyResolved()); } @@ -135,8 +136,8 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver public void testGetValue_RequestParameters() { MockRequestContext requestContext = new MockRequestContext(); RequestContextHolder.setRequestContext(requestContext); - assertSame(requestContext.getRequestParameters(), context.getELResolver().getValue(context, null, - "requestParameters")); + assertSame(requestContext.getRequestParameters(), + context.getELResolver().getValue(context, null, "requestParameters")); assertTrue(context.isPropertyResolved()); } @@ -172,8 +173,8 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver public void testGetValue_ConversationScope() { MockRequestContext requestContext = new MockRequestContext(); RequestContextHolder.setRequestContext(requestContext); - assertSame(requestContext.getConversationScope(), context.getELResolver().getValue(context, null, - "conversationScope")); + assertSame(requestContext.getConversationScope(), + context.getELResolver().getValue(context, null, "conversationScope")); assertTrue(context.isPropertyResolved()); } @@ -188,16 +189,16 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver public void testGetValue_ExternalContext() { MockRequestContext requestContext = new MockRequestContext(); RequestContextHolder.setRequestContext(requestContext); - assertSame(requestContext.getExternalContext(), context.getELResolver().getValue(context, null, - "externalContext")); + assertSame(requestContext.getExternalContext(), + context.getELResolver().getValue(context, null, "externalContext")); assertTrue(context.isPropertyResolved()); } public void testGetValue_FlowExecutionContext() { MockRequestContext requestContext = new MockRequestContext(); RequestContextHolder.setRequestContext(requestContext); - assertSame(requestContext.getFlowExecutionContext(), context.getELResolver().getValue(context, null, - "flowExecutionContext")); + assertSame(requestContext.getFlowExecutionContext(), + context.getELResolver().getValue(context, null, "flowExecutionContext")); assertTrue(context.isPropertyResolved()); } @@ -205,8 +206,8 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver MockRequestContext requestContext = new MockRequestContext(); ((MockFlowExecutionContext) requestContext.getFlowExecutionContext()).setKey(new MockFlowExecutionKey("e1s1")); RequestContextHolder.setRequestContext(requestContext); - assertEquals(requestContext.getFlowExecutionUrl(), context.getELResolver().getValue(context, null, - "flowExecutionUrl")); + assertEquals(requestContext.getFlowExecutionUrl(), + context.getELResolver().getValue(context, null, "flowExecutionUrl")); assertTrue(context.isPropertyResolved()); } @@ -214,8 +215,8 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver MockRequestContext requestContext = new MockRequestContext(); ((MockExternalContext) requestContext.getExternalContext()).setCurrentUser("jjg"); RequestContextHolder.setRequestContext(requestContext); - assertSame(requestContext.getExternalContext().getCurrentUser(), context.getELResolver().getValue(context, - null, "currentUser")); + assertSame(requestContext.getExternalContext().getCurrentUser(), + context.getELResolver().getValue(context, null, "currentUser")); assertTrue(context.isPropertyResolved()); } @@ -229,18 +230,18 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver public void testIsReadOnly_AllVars() { RequestContextHolder.setRequestContext(new MockRequestContext()); - Iterator i = vars.iterator(); + Iterator i = vars.iterator(); while (i.hasNext()) { - String var = (String) i.next(); + String var = i.next(); assertTrue(context.getELResolver().isReadOnly(context, null, var)); } } public void testSetValue_AllVars() { RequestContextHolder.setRequestContext(new MockRequestContext()); - Iterator i = vars.iterator(); + Iterator i = vars.iterator(); while (i.hasNext()) { - String var = (String) i.next(); + String var = i.next(); try { context.getELResolver().setValue(context, null, var, new Object()); fail("setValue should not be allowed"); @@ -254,8 +255,8 @@ public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolver return "flowScope"; } - protected List getCustomResolvers() { - List resolvers = new ArrayList(); + protected List getCustomResolvers() { + List resolvers = new ArrayList(); resolvers.add(new ImplicitFlowVariableELResolver()); return resolvers; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/ScopeSearchingELResolverTests.java b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/ScopeSearchingELResolverTests.java index 24dd6620..5dca7b22 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/ScopeSearchingELResolverTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/ScopeSearchingELResolverTests.java @@ -3,6 +3,8 @@ package org.springframework.webflow.expression.el; import java.util.ArrayList; import java.util.List; +import javax.el.ELResolver; + import org.springframework.webflow.execution.RequestContextHolder; import org.springframework.webflow.test.MockRequestContext; @@ -226,13 +228,13 @@ public class ScopeSearchingELResolverTests extends FlowDependentELResolverTestCa return "foo"; } - protected List getCustomResolvers() { - List resolvers = new ArrayList(); + protected List getCustomResolvers() { + List resolvers = new ArrayList(); resolvers.add(new ScopeSearchingELResolver()); return resolvers; } - private static class MyBean { + public static class MyBean { private String bar = ""; diff --git a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/WebFlowELExpressionParserTests.java b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/WebFlowELExpressionParserTests.java index f943c0eb..b02143c1 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/expression/el/WebFlowELExpressionParserTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/expression/el/WebFlowELExpressionParserTests.java @@ -27,7 +27,7 @@ public class WebFlowELExpressionParserTests extends TestCase { private WebFlowELExpressionParser parser = new WebFlowELExpressionParser(new ExpressionFactoryImpl()); public void testResolveMap() { - LocalAttributeMap map = new LocalAttributeMap(); + LocalAttributeMap map = new LocalAttributeMap(); map.put("foo", "bar"); Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(AttributeMap.class)); Expression exp2 = parser.parseExpression("bogus", new FluentParserContext().evaluate(AttributeMap.class)); @@ -36,7 +36,7 @@ public class WebFlowELExpressionParserTests extends TestCase { } public void testSetMap() { - LocalAttributeMap map = new LocalAttributeMap(); + LocalAttributeMap map = new LocalAttributeMap(); map.put("foo", "bar"); Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(MutableAttributeMap.class)); Expression exp2 = parser @@ -49,8 +49,8 @@ public class WebFlowELExpressionParserTests extends TestCase { public void testResolveFlowRequestContext() { MockRequestContext context = new MockRequestContext(); - Expression exp = parser.parseExpression("flowRequestContext", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression exp = parser.parseExpression("flowRequestContext", + new FluentParserContext().evaluate(RequestContext.class)); assertSame(context, exp.getValue(context)); } @@ -164,8 +164,8 @@ public class WebFlowELExpressionParserTests extends TestCase { StaticApplicationContext ac = new StaticApplicationContext(); ac.getBeanFactory().registerSingleton("multiAction", new FormAction()); context.getRootFlow().setApplicationContext(ac); - Expression exp = parser.parseExpression("multiAction.setupForm", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression exp = parser.parseExpression("multiAction.setupForm", + new FluentParserContext().evaluate(RequestContext.class)); AnnotatedAction action = (AnnotatedAction) exp.getValue(context); assertSame(ac.getBean("multiAction"), action.getTargetAction()); assertEquals("setupForm", action.getMethod()); @@ -173,11 +173,11 @@ public class WebFlowELExpressionParserTests extends TestCase { public void testResolveEventAttributes() { MockRequestContext context = new MockRequestContext(); - LocalAttributeMap attributes = new LocalAttributeMap(); + LocalAttributeMap attributes = new LocalAttributeMap(); attributes.put("foo", "bar"); context.setCurrentEvent(new Event(this, "event", attributes)); - Expression exp = parser.parseExpression("currentEvent.attributes.foo", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression exp = parser.parseExpression("currentEvent.attributes.foo", + new FluentParserContext().evaluate(RequestContext.class)); assertEquals("bar", exp.getValue(context)); } @@ -194,8 +194,8 @@ public class WebFlowELExpressionParserTests extends TestCase { ac.refresh(); context.getRootFlow().setApplicationContext(ac); context.getMockExternalContext().setLocale(Locale.FRANCE); - Expression exp = parser.parseExpression("resourceBundle.foo", new FluentParserContext() - .evaluate(RequestContext.class)); + Expression exp = parser.parseExpression("resourceBundle.foo", + new FluentParserContext().evaluate(RequestContext.class)); assertEquals("bar", exp.getValue(context)); } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/expression/spel/ScopeSearchingPropertyAccessorTests.java b/spring-webflow/src/test/java/org/springframework/webflow/expression/spel/ScopeSearchingPropertyAccessorTests.java index e340f314..9c193a39 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/expression/spel/ScopeSearchingPropertyAccessorTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/expression/spel/ScopeSearchingPropertyAccessorTests.java @@ -37,7 +37,7 @@ public class ScopeSearchingPropertyAccessorTests extends TestCase { } public void testGetSpecificTargetClasses() throws Exception { - Class[] classes = accessor.getSpecificTargetClasses(); + Class[] classes = accessor.getSpecificTargetClasses(); assertEquals(1, classes.length); assertEquals(RequestContext.class, classes[0]); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapterTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapterTests.java index a33cf7ef..3123abd7 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapterTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/FlowHandlerAdapterTests.java @@ -42,13 +42,13 @@ public class FlowHandlerAdapterTests extends TestCase { private PortletExternalContext actionContext; private PortletExternalContext renderContext; private FlowHandler flowHandler; - private LocalAttributeMap flowInput = null; + private LocalAttributeMap flowInput = null; private boolean handleException; private boolean handleExecutionOutcome; private boolean handleExecutionOutcomeCalled; protected void setUp() throws Exception { - flowExecutor = (FlowExecutor) EasyMock.createMock(FlowExecutor.class); + flowExecutor = EasyMock.createMock(FlowExecutor.class); controller = new FlowHandlerAdapter() { protected PortletExternalContext createPortletExternalContext(PortletRequest request, PortletResponse response) { @@ -79,11 +79,11 @@ public class FlowHandlerAdapterTests extends TestCase { return "foo"; } - public MutableAttributeMap createExecutionInputMap(RenderRequest request) { + public MutableAttributeMap createExecutionInputMap(RenderRequest request) { return null; } - public MutableAttributeMap createResourceExecutionInputMap(ResourceRequest request) { + public MutableAttributeMap createResourceExecutionInputMap(ResourceRequest request) { return null; } @@ -192,7 +192,7 @@ public class FlowHandlerAdapterTests extends TestCase { handleExecutionOutcome = true; actionRequest.setContextPath("/springtravel"); actionRequest.addParameter("execution", "12345"); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); flowExecutor.resumeExecution("12345", actionContext); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/PortletMvcViewTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/PortletMvcViewTests.java index 7a28a049..c2514d3b 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/PortletMvcViewTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/portlet/PortletMvcViewTests.java @@ -32,8 +32,7 @@ public class PortletMvcViewTests extends TestCase { context.getMockExternalContext().setNativeRequest(request); context.getMockExternalContext().setNativeResponse(response); context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1")); - org.springframework.web.servlet.View mvcView = (org.springframework.web.servlet.View) EasyMock - .createMock(org.springframework.web.servlet.View.class); + org.springframework.web.servlet.View mvcView = EasyMock.createMock(org.springframework.web.servlet.View.class); AbstractMvcView view = new PortletMvcView(mvcView, context); view.render(); assertNotNull(request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE)); @@ -54,8 +53,7 @@ public class PortletMvcViewTests extends TestCase { context.getMockExternalContext().setNativeRequest(new MockHttpServletRequest()); context.getMockExternalContext().setNativeResponse(new MockHttpServletResponse()); context.getMockFlowExecutionContext().setKey(new MockFlowExecutionKey("c1v1")); - org.springframework.web.servlet.View mvcView = (org.springframework.web.servlet.View) EasyMock - .createMock(org.springframework.web.servlet.View.class); + org.springframework.web.servlet.View mvcView = EasyMock.createMock(org.springframework.web.servlet.View.class); AbstractMvcView view = new PortletMvcView(mvcView, context); view.setExpressionParser(new WebFlowSpringELExpressionParser(new SpelExpressionParser())); view.setMessageCodesResolver(new WebFlowMessageCodesResolver()); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowControllerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowControllerTests.java index 420b8350..4f8d94e4 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowControllerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowControllerTests.java @@ -33,7 +33,7 @@ public class FlowControllerTests extends TestCase { private ServletExternalContext context; protected void setUp() throws Exception { - executor = (FlowExecutor) EasyMock.createMock(FlowExecutor.class); + executor = EasyMock.createMock(FlowExecutor.class); controller = new FlowController(); FlowHandlerAdapter handlerAdapter = new FlowHandlerAdapter() { protected ServletExternalContext createServletExternalContext(HttpServletRequest request, @@ -79,7 +79,7 @@ public class FlowControllerTests extends TestCase { request.setRequestURI("/springtravel/app/foo"); request.setMethod("GET"); executor.launchExecution("foo", null, context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); FlowExecutionResult result = FlowExecutionResult.createEndedResult("foo", outcome); @@ -98,7 +98,7 @@ public class FlowControllerTests extends TestCase { request.setRequestURI("/springtravel/app/foo"); request.setMethod("POST"); request.addParameter("execution", "12345"); - Map parameters = new HashMap(); + Map parameters = new HashMap(); request.setParameters(parameters); executor.resumeExecution("12345", context); FlowExecutionResult result = FlowExecutionResult.createPausedResult("foo", "123456"); @@ -116,10 +116,10 @@ public class FlowControllerTests extends TestCase { request.setRequestURI("/springtravel/app/foo"); request.setMethod("POST"); request.addParameter("execution", "12345"); - Map parameters = new HashMap(); + Map parameters = new HashMap(); request.setParameters(parameters); executor.resumeExecution("12345", context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); FlowExecutionResult result = FlowExecutionResult.createEndedResult("foo", outcome); @@ -166,8 +166,8 @@ public class FlowControllerTests extends TestCase { assertNull(mv); assertEquals(null, response.getRedirectedUrl()); assertEquals("true", response.getHeader(SpringJavascriptAjaxHandler.POPUP_VIEW_HEADER)); - assertEquals("/springtravel/app/foo?execution=12345", response - .getHeader(SpringJavascriptAjaxHandler.REDIRECT_URL_HEADER)); + assertEquals("/springtravel/app/foo?execution=12345", + response.getHeader(SpringJavascriptAjaxHandler.REDIRECT_URL_HEADER)); EasyMock.verify(new Object[] { executor }); } @@ -180,7 +180,7 @@ public class FlowControllerTests extends TestCase { request.addParameter("ajaxSource", "this"); context.setAjaxRequest(true); context.requestFlowExecutionRedirect(); - LocalAttributeMap inputMap = new LocalAttributeMap(); + LocalAttributeMap inputMap = new LocalAttributeMap(); inputMap.put("ajaxSource", "this"); executor.launchExecution("foo", inputMap, context); FlowExecutionResult result = FlowExecutionResult.createPausedResult("foo", "12345"); @@ -190,8 +190,8 @@ public class FlowControllerTests extends TestCase { assertNull(mv); assertEquals(null, response.getRedirectedUrl()); assertEquals(null, response.getHeader(SpringJavascriptAjaxHandler.POPUP_VIEW_HEADER)); - assertEquals("/springtravel/app/foo?execution=12345", response - .getHeader(SpringJavascriptAjaxHandler.REDIRECT_URL_HEADER)); + assertEquals("/springtravel/app/foo?execution=12345", + response.getHeader(SpringJavascriptAjaxHandler.REDIRECT_URL_HEADER)); EasyMock.verify(new Object[] { executor }); } @@ -201,11 +201,11 @@ public class FlowControllerTests extends TestCase { request.setPathInfo("/foo"); request.setRequestURI("/springtravel/app/foo"); request.setMethod("GET"); - LocalAttributeMap input = new LocalAttributeMap(); + LocalAttributeMap input = new LocalAttributeMap(); input.put("baz", "boop"); context.requestFlowDefinitionRedirect("bar", input); executor.launchExecution("foo", null, context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); FlowExecutionResult result = FlowExecutionResult.createEndedResult("foo", outcome); @@ -274,14 +274,14 @@ public class FlowControllerTests extends TestCase { } public void testLaunchFlowWithCustomFlowHandler() throws Exception { - final LocalAttributeMap input = new LocalAttributeMap(); + final LocalAttributeMap input = new LocalAttributeMap(); input.put("bar", "boop"); controller.registerFlowHandler(new FlowHandler() { public String getFlowId() { return "foo"; } - public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { + public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { return input; } @@ -309,14 +309,14 @@ public class FlowControllerTests extends TestCase { } public void testHandleFlowOutcomeCustomFlowHandler() throws Exception { - final LocalAttributeMap input = new LocalAttributeMap(); + final LocalAttributeMap input = new LocalAttributeMap(); input.put("bar", "boop"); controller.registerFlowHandler(new FlowHandler() { public String getFlowId() { return "foo"; } - public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { + public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { return input; } @@ -339,7 +339,7 @@ public class FlowControllerTests extends TestCase { request.setRequestURI("/springtravel/app/foo"); request.setMethod("GET"); executor.launchExecution("foo", input, context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); FlowExecutionResult result = FlowExecutionResult.createEndedResult("foo", outcome); @@ -360,7 +360,7 @@ public class FlowControllerTests extends TestCase { return "foo"; } - public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { + public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { return null; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapterTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapterTests.java index a2888c2d..dba7ad10 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapterTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowHandlerAdapterTests.java @@ -31,12 +31,12 @@ public class FlowHandlerAdapterTests extends TestCase { private MockHttpServletResponse response; private ServletExternalContext context; private FlowHandler flowHandler; - private LocalAttributeMap flowInput = new LocalAttributeMap(); + private LocalAttributeMap flowInput = new LocalAttributeMap(); private boolean handleException; private boolean handleExecutionOutcome; protected void setUp() throws Exception { - flowExecutor = (FlowExecutor) EasyMock.createMock(FlowExecutor.class); + flowExecutor = EasyMock.createMock(FlowExecutor.class); flowHandlerAdapter = new FlowHandlerAdapter() { protected ServletExternalContext createServletExternalContext(HttpServletRequest request, HttpServletResponse response) { @@ -51,7 +51,7 @@ public class FlowHandlerAdapterTests extends TestCase { flowHandlerAdapter.afterPropertiesSet(); flowHandler = new FlowHandler() { - public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { + public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { assertEquals(FlowHandlerAdapterTests.this.request, request); return flowInput; } @@ -102,10 +102,10 @@ public class FlowHandlerAdapterTests extends TestCase { request.setPathInfo("/whatever"); request.setRequestURI("/springtravel/app/whatever"); request.setMethod("GET"); - Map parameters = new HashMap(); + Map parameters = new HashMap(); request.setParameters(parameters); flowExecutor.launchExecution("foo", flowInput, context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); FlowExecutionResult result = FlowExecutionResult.createEndedResult("foo", outcome); @@ -122,11 +122,11 @@ public class FlowHandlerAdapterTests extends TestCase { request.setPathInfo("/whatever"); request.setRequestURI("/springtravel/app/whatever"); request.setMethod("GET"); - Map parameters = new HashMap(); + Map parameters = new HashMap(); request.setParameters(parameters); context.setAjaxRequest(true); flowExecutor.launchExecution("foo", flowInput, context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); FlowExecutionResult result = FlowExecutionResult.createEndedResult("foo", outcome); @@ -160,10 +160,10 @@ public class FlowHandlerAdapterTests extends TestCase { request.setRequestURI("/springtravel/app/foo"); request.setMethod("POST"); request.addParameter("execution", "12345"); - Map parameters = new HashMap(); + Map parameters = new HashMap(); request.setParameters(parameters); flowExecutor.resumeExecution("12345", context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); FlowExecutionResult result = FlowExecutionResult.createEndedResult("foo", outcome); @@ -182,10 +182,10 @@ public class FlowHandlerAdapterTests extends TestCase { request.setRequestURI("/springtravel/app/foo"); request.setMethod("POST"); request.addParameter("execution", "12345"); - Map parameters = new HashMap(); + Map parameters = new HashMap(); request.setParameters(parameters); flowExecutor.resumeExecution("12345", context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); context.recordResponseComplete(); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); @@ -221,13 +221,13 @@ public class FlowHandlerAdapterTests extends TestCase { request.setPathInfo("/foo"); request.setRequestURI("/springtravel/app/foo"); request.setMethod("GET"); - Map parameters = new HashMap(); + Map parameters = new HashMap(); request.setParameters(parameters); - LocalAttributeMap input = new LocalAttributeMap(); + LocalAttributeMap input = new LocalAttributeMap(); input.put("baz", "boop"); context.requestFlowDefinitionRedirect("bar", input); flowExecutor.launchExecution("foo", flowInput, context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); FlowExecutionResult result = FlowExecutionResult.createEndedResult("foo", outcome); @@ -473,7 +473,7 @@ public class FlowHandlerAdapterTests extends TestCase { request.setPathInfo("/foo"); request.setRequestURI("/springtravel/app/foo"); request.setMethod("GET"); - Map parameters = new HashMap(); + Map parameters = new HashMap(); request.setParameters(parameters); flowExecutor.launchExecution("foo", flowInput, context); FlowException flowException = new FlowException("Error") { @@ -531,7 +531,7 @@ public class FlowHandlerAdapterTests extends TestCase { request.setRequestURI("/springtravel/app/foo"); request.setMethod("GET"); flowExecutor.launchExecution("foo", flowInput, context); - LocalAttributeMap output = new LocalAttributeMap(); + LocalAttributeMap output = new LocalAttributeMap(); output.put("bar", "baz"); FlowExecutionOutcome outcome = new FlowExecutionOutcome("finish", output); FlowExecutionResult result = FlowExecutionResult.createEndedResult("foo", outcome); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowHandlerMappingTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowHandlerMappingTests.java index 63585a56..90360b50 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowHandlerMappingTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/FlowHandlerMappingTests.java @@ -88,12 +88,10 @@ public class FlowHandlerMappingTests extends TestCase { } public ApplicationContext getApplicationContext() { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } public ClassLoader getClassLoader() { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } @@ -102,37 +100,30 @@ public class FlowHandlerMappingTests extends TestCase { } public String[] getPossibleOutcomes() { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } public StateDefinition getStartState() { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } public StateDefinition getState(String id) throws IllegalArgumentException { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } public boolean inDevelopment() { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } - public MutableAttributeMap getAttributes() { - // TODO Auto-generated method stub + public MutableAttributeMap getAttributes() { throw new UnsupportedOperationException("Auto-generated method stub"); } public String getCaption() { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } public String getDescription() { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } @@ -143,8 +134,7 @@ public class FlowHandlerMappingTests extends TestCase { public static class CustomFlowHandler implements FlowHandler { - public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { - // TODO Auto-generated method stub + public MutableAttributeMap createExecutionInputMap(HttpServletRequest request) { throw new UnsupportedOperationException("Auto-generated method stub"); } @@ -153,13 +143,11 @@ public class FlowHandlerMappingTests extends TestCase { } public String handleException(FlowException e, HttpServletRequest request, HttpServletResponse response) { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } public String handleExecutionOutcome(FlowExecutionOutcome outcome, HttpServletRequest request, HttpServletResponse response) { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Auto-generated method stub"); } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/ServletMvcViewTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/ServletMvcViewTests.java index 711f4f18..97655726 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/ServletMvcViewTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/servlet/ServletMvcViewTests.java @@ -23,7 +23,7 @@ public class ServletMvcViewTests extends TestCase { private boolean renderCalled; - private Map model; + private Map model; public void testRender() throws Exception { MockRequestContext context = new MockRequestContext(); @@ -58,11 +58,11 @@ public class ServletMvcViewTests extends TestCase { return "text/html"; } - public void render(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { + public void render(Map model, HttpServletRequest request, HttpServletResponse response) + throws Exception { renderCalled = true; ServletMvcViewTests.this.model = model; } - } public static class BindBean { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/AbstractBindingModelTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/AbstractBindingModelTests.java index 0623dac6..6f9f05a5 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/AbstractBindingModelTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/AbstractBindingModelTests.java @@ -13,6 +13,7 @@ import org.springframework.binding.convert.service.DefaultConversionService; import org.springframework.binding.expression.Expression; import org.springframework.binding.expression.ExpressionParser; import org.springframework.binding.mapping.Mapping; +import org.springframework.binding.mapping.MappingResult; import org.springframework.binding.mapping.impl.DefaultMappingResults; import org.springframework.binding.mapping.results.TypeConversionError; import org.springframework.binding.message.DefaultMessageContext; @@ -66,10 +67,11 @@ public abstract class AbstractBindingModelTests extends TestCase { assertEquals(new Integer(3), model.getRawFieldValue("datum2")); } + @SuppressWarnings("deprecation") public void testGetFieldValueConvertedWithCustomConverter() { testBean.datum2 = 3; conversionService.addConverter("customConverter", new StringToObject(Integer.class) { - protected Object toObject(String string, Class targetClass) throws Exception { + protected Object toObject(String string, Class targetClass) throws Exception { return Integer.valueOf(string); } @@ -84,9 +86,9 @@ public abstract class AbstractBindingModelTests extends TestCase { } public void testGetFieldValueError() { - Map source = new HashMap(); + Map source = new HashMap(); source.put("datum2", "bogus"); - List mappingResults = new ArrayList(); + List mappingResults = new ArrayList(); Mapping mapping = new Mapping() { public Expression getSourceExpression() { return expressionParser.parseExpression("datum2", null); @@ -124,7 +126,7 @@ public abstract class AbstractBindingModelTests extends TestCase { assertEquals(null, error.getRejectedValue()); assertTrue(!error.isBindingFailure()); - FieldError error2 = (FieldError) model.getFieldErrors().get(0); + FieldError error2 = model.getFieldErrors().get(0); assertEquals(error, error2); } @@ -150,7 +152,7 @@ public abstract class AbstractBindingModelTests extends TestCase { model.pushNestedPath("nestedBean"); assertEquals("test", model.getFieldValue("datum1")); assertEquals("0", model.getFieldValue("datum2")); - Class clazz = model.getFieldType("datum2"); + Class clazz = model.getFieldType("datum2"); assertTrue(int.class.equals(clazz) || Integer.class.equals(clazz)); messages.addMessage(new MessageBuilder().source("nestedBean.datum2").error().defaultText("Error").build()); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/BindingModelSwf1370Tests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/BindingModelSwf1370Tests.java index dd05932e..a229161a 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/BindingModelSwf1370Tests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/BindingModelSwf1370Tests.java @@ -36,10 +36,10 @@ public class BindingModelSwf1370Tests extends TestCase { assertEquals("111", model.getFieldValue("responses[1].value")); } - private class Question { + public static class Question { }; - private class Response { + public static class Response { private int value; @@ -56,7 +56,7 @@ public class BindingModelSwf1370Tests extends TestCase { } } - private class TestBeanWithQuestionResponseMap { + public static class TestBeanWithQuestionResponseMap { private Map responses = new HashMap(); public TestBeanWithQuestionResponseMap(Question question) { @@ -72,7 +72,8 @@ public class BindingModelSwf1370Tests extends TestCase { } } - private class QuestionConverter implements org.springframework.core.convert.converter.Converter { + public static class QuestionConverter implements + org.springframework.core.convert.converter.Converter { private Map map = new HashMap(); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java index cc2a2fd4..fb3cecac 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java @@ -49,7 +49,7 @@ public class MvcViewTests extends TestCase { private boolean renderCalled; - private Map model; + private Map model; public void testRender() throws Exception { MockRequestControlContext context = new MockRequestControlContext(); @@ -269,7 +269,7 @@ public class MvcViewTests extends TestCase { throw new EvaluationException(Object.class, "foo", "Model expression failed to evaluate"); } - public Class getValueType(Object context) throws EvaluationException { + public Class getValueType(Object context) throws EvaluationException { return Object.class; } @@ -449,6 +449,7 @@ public class MvcViewTests extends TestCase { assertEquals(null, bindBean.getBeanProperty().getName()); } + @SuppressWarnings("deprecation") public void testResumeEventModelBindingCustomConverter() throws Exception { MockRequestContext context = new MockRequestContext(); context.putRequestParameter("_eventId", "submit"); @@ -642,7 +643,7 @@ public class MvcViewTests extends TestCase { super(view, context); } - protected void doRender(Map model) throws Exception { + protected void doRender(Map model) throws Exception { getView().render(model, (HttpServletRequest) getRequestContext().getExternalContext().getNativeRequest(), (HttpServletResponse) getRequestContext().getExternalContext().getNativeResponse()); } @@ -655,7 +656,8 @@ public class MvcViewTests extends TestCase { return "text/html"; } - public void render(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { + public void render(Map model, HttpServletRequest request, HttpServletResponse response) + throws Exception { renderCalled = true; MvcViewTests.this.model = model; } @@ -673,8 +675,8 @@ public class MvcViewTests extends TestCase { private String[] stringArrayProperty; private Integer[] integerArrayProperty; private int[] primitiveArrayProperty; - private List listProperty; - private Map mapProperty; + private List listProperty; + private Map mapProperty; private boolean validationMethodInvoked; public BindBean() { @@ -753,19 +755,19 @@ public class MvcViewTests extends TestCase { this.primitiveArrayProperty = primitiveArrayProperty; } - public List getListProperty() { + public List getListProperty() { return listProperty; } - public void setListProperty(List listProperty) { + public void setListProperty(List listProperty) { this.listProperty = listProperty; } - public Map getMapProperty() { + public Map getMapProperty() { return mapProperty; } - public void setMapProperty(Map mapProperty) { + public void setMapProperty(Map mapProperty) { this.mapProperty = mapProperty; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/persistence/HibernateFlowExecutionListenerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/persistence/HibernateFlowExecutionListenerTests.java index 38904711..7284b1d2 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/persistence/HibernateFlowExecutionListenerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/persistence/HibernateFlowExecutionListenerTests.java @@ -85,7 +85,7 @@ public class HibernateFlowExecutionListenerTests extends TestCase { hibernateListener.resuming(context); assertSessionBound(); - hibernateTemplate.executeWithNativeSession(new HibernateCallback() { + hibernateTemplate.executeWithNativeSession(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { assertSame("Should have been original instance", hibSession, session); return null; @@ -234,7 +234,7 @@ public class HibernateFlowExecutionListenerTests extends TestCase { context.setActiveSession(flowSession); assertSessionBound(); - TestBean bean = (TestBean) hibernateTemplate.get(TestBean.class, Long.valueOf(0)); + TestBean bean = hibernateTemplate.get(TestBean.class, Long.valueOf(0)); assertFalse("addresses should not be initialized", Hibernate.isInitialized(bean.getAddresses())); hibernateListener.paused(context); assertFalse("addresses should not be initialized", Hibernate.isInitialized(bean.getAddresses())); @@ -267,7 +267,7 @@ public class HibernateFlowExecutionListenerTests extends TestCase { new ClassPathResource("org/springframework/webflow/persistence/TestBean.hbm.xml"), new ClassPathResource("org/springframework/webflow/persistence/TestAddress.hbm.xml") }); factory.afterPropertiesSet(); - return (SessionFactory) factory.getObject(); + return factory.getObject(); } private void assertSessionNotBound() { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/persistence/JpaFlowExecutionListenerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/persistence/JpaFlowExecutionListenerTests.java index 612b1c0b..18559a91 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/persistence/JpaFlowExecutionListenerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/persistence/JpaFlowExecutionListenerTests.java @@ -20,6 +20,7 @@ import org.springframework.webflow.execution.FlowExecutionException; import org.springframework.webflow.test.MockFlowSession; import org.springframework.webflow.test.MockRequestContext; +@SuppressWarnings("deprecation") public class JpaFlowExecutionListenerTests extends TestCase { private EntityManagerFactory entityManagerFactory; diff --git a/spring-webflow/src/test/java/org/springframework/webflow/persistence/JpaPersistenceContextPropagationTests.java b/spring-webflow/src/test/java/org/springframework/webflow/persistence/JpaPersistenceContextPropagationTests.java index 588d7920..48359817 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/persistence/JpaPersistenceContextPropagationTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/persistence/JpaPersistenceContextPropagationTests.java @@ -10,6 +10,7 @@ import org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter; import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.webflow.execution.FlowExecutionListener; +@SuppressWarnings("deprecation") public class JpaPersistenceContextPropagationTests extends AbstractPersistenceContextPropagationTests { private EntityManagerFactory entityManagerFactory; diff --git a/spring-webflow/src/test/java/org/springframework/webflow/persistence/TestBean.java b/spring-webflow/src/test/java/org/springframework/webflow/persistence/TestBean.java index fd6caba0..7b5f3088 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/persistence/TestBean.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/persistence/TestBean.java @@ -24,7 +24,7 @@ public class TestBean { private String name; - private Set addresses = new HashSet(); + private Set addresses = new HashSet(); private int count; @@ -57,11 +57,11 @@ public class TestBean { return name; } - public Set getAddresses() { + public Set getAddresses() { return addresses; } - public void setAddresses(Set addresses) { + public void setAddresses(Set addresses) { this.addresses = addresses; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/security/SecurityFlowExecutionListenerTests.java b/spring-webflow/src/test/java/org/springframework/webflow/security/SecurityFlowExecutionListenerTests.java index 1a41df97..bd308e92 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/security/SecurityFlowExecutionListenerTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/security/SecurityFlowExecutionListenerTests.java @@ -1,7 +1,9 @@ package org.springframework.webflow.security; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; +import java.util.List; import junit.framework.TestCase; @@ -13,7 +15,6 @@ import org.springframework.security.core.authority.GrantedAuthorityImpl; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextImpl; -import org.springframework.webflow.core.collection.LocalAttributeMap; import org.springframework.webflow.definition.FlowDefinition; import org.springframework.webflow.engine.Flow; import org.springframework.webflow.engine.StubViewFactory; @@ -37,7 +38,7 @@ public class SecurityFlowExecutionListenerTests extends TestCase { RequestContext context = new MockRequestContext(); Flow flow = new Flow("flow"); SecurityRule rule = getSecurityRuleAnyAuthorized(); - ((LocalAttributeMap) flow.getAttributes()).put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule); + flow.getAttributes().put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule); configureSecurityContext(); listener.sessionCreating(context, flow); } @@ -56,7 +57,7 @@ public class SecurityFlowExecutionListenerTests extends TestCase { Flow flow = new Flow("flow"); ViewState state = new ViewState(flow, "view", new StubViewFactory()); SecurityRule rule = getSecurityRuleAllAuthorized(); - ((LocalAttributeMap) state.getAttributes()).put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule); + state.getAttributes().put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule); configureSecurityContext(); listener.stateEntering(context, state); } @@ -73,7 +74,7 @@ public class SecurityFlowExecutionListenerTests extends TestCase { RequestContext context = new MockRequestContext(); Transition transition = new Transition(new DefaultTargetStateResolver("target")); SecurityRule rule = getSecurityRuleAnyAuthorized(); - ((LocalAttributeMap) transition.getAttributes()).put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule); + transition.getAttributes().put(SecurityRule.SECURITY_ATTRIBUTE_NAME, rule); configureSecurityContext(); listener.transitionExecuting(context, transition); } @@ -117,7 +118,7 @@ public class SecurityFlowExecutionListenerTests extends TestCase { private SecurityRule getSecurityRuleAnyAuthorized() { SecurityRule rule = new SecurityRule(); rule.setComparisonType(SecurityRule.COMPARISON_ANY); - Collection attributes = new HashSet(); + Collection attributes = new HashSet(); attributes.add("ROLE_1"); attributes.add("ROLE_A"); rule.setAttributes(attributes); @@ -127,7 +128,7 @@ public class SecurityFlowExecutionListenerTests extends TestCase { private SecurityRule getSecurityRuleAnyDenied() { SecurityRule rule = new SecurityRule(); rule.setComparisonType(SecurityRule.COMPARISON_ANY); - Collection attributes = new HashSet(); + Collection attributes = new HashSet(); attributes.add("ROLE_A"); attributes.add("ROLE_B"); rule.setAttributes(attributes); @@ -137,7 +138,7 @@ public class SecurityFlowExecutionListenerTests extends TestCase { private SecurityRule getSecurityRuleAllAuthorized() { SecurityRule rule = new SecurityRule(); rule.setComparisonType(SecurityRule.COMPARISON_ALL); - Collection attributes = new HashSet(); + Collection attributes = new HashSet(); attributes.add("ROLE_1"); attributes.add("ROLE_3"); rule.setAttributes(attributes); @@ -147,7 +148,7 @@ public class SecurityFlowExecutionListenerTests extends TestCase { private SecurityRule getSecurityRuleAllDenied() { SecurityRule rule = new SecurityRule(); rule.setComparisonType(SecurityRule.COMPARISON_ALL); - Collection attributes = new HashSet(); + Collection attributes = new HashSet(); attributes.add("ROLE_1"); attributes.add("ROLE_A"); rule.setAttributes(attributes); @@ -155,8 +156,8 @@ public class SecurityFlowExecutionListenerTests extends TestCase { } private Authentication getAuthentication() { - GrantedAuthority[] authorities = { new GrantedAuthorityImpl("ROLE_1"), new GrantedAuthorityImpl("ROLE_2"), - new GrantedAuthorityImpl("ROLE_3") }; + List authorities = Arrays. asList(new GrantedAuthorityImpl("ROLE_1"), + new GrantedAuthorityImpl("ROLE_2"), new GrantedAuthorityImpl("ROLE_3")); return new UsernamePasswordAuthenticationToken("test", "", authorities); } } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/security/SecurityRuleTests.java b/spring-webflow/src/test/java/org/springframework/webflow/security/SecurityRuleTests.java index ac89ecb3..f7cff118 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/security/SecurityRuleTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/security/SecurityRuleTests.java @@ -9,14 +9,14 @@ import junit.framework.TestCase; public class SecurityRuleTests extends TestCase { public void testConvertAttributesToCommaSeparatedString() { - Collection attributes = new ArrayList(); + Collection attributes = new ArrayList(); attributes.add("ROLE_1"); attributes.add("ROLE_2"); Assert.assertEquals("ROLE_1, ROLE_2", SecurityRule.securityAttributesToCommaDelimitedList(attributes)); } public void testConvertAttributesFromCommaSeparatedString() { - Collection attributes = SecurityRule.commaDelimitedListToSecurityAttributes(" ,,ROLE_1, ROLE_2"); + Collection attributes = SecurityRule.commaDelimitedListToSecurityAttributes(" ,,ROLE_1, ROLE_2"); Assert.assertEquals(2, attributes.size()); Assert.assertTrue(attributes.contains("ROLE_1")); Assert.assertTrue(attributes.contains("ROLE_2")); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/test/MockActionTests.java b/spring-webflow/src/test/java/org/springframework/webflow/test/MockActionTests.java index 7b823361..6601f7be 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/test/MockActionTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/test/MockActionTests.java @@ -22,7 +22,7 @@ public class MockActionTests extends TestCase { public void testMockActionExecuteCustomResultAttributes() { MockAction action = new MockAction("foo"); - LocalAttributeMap resultAttributes = new LocalAttributeMap(); + LocalAttributeMap resultAttributes = new LocalAttributeMap(); resultAttributes.put("bar", "baz"); action.setResultAttributes(resultAttributes); Event e = action.execute(new MockRequestContext()); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/test/SearchFlowExecutionTests.java b/spring-webflow/src/test/java/org/springframework/webflow/test/SearchFlowExecutionTests.java index 5f150dd3..eb17f1ed 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/test/SearchFlowExecutionTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/test/SearchFlowExecutionTests.java @@ -87,9 +87,10 @@ public class SearchFlowExecutionTests extends AbstractXmlFlowExecutionTests { protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) { Flow mockDetailFlow = new Flow("detail-flow"); mockDetailFlow.setInputMapper(new Mapper() { + @SuppressWarnings("unchecked") public MappingResults map(Object source, Object target) { assertEquals("id of value 1 not provided as input by calling search flow", new Long(1), - ((AttributeMap) source).get("id")); + ((AttributeMap) source).get("id")); return null; } }); @@ -100,8 +101,8 @@ public class SearchFlowExecutionTests extends AbstractXmlFlowExecutionTests { } public static class TestPhoneBook { - public List search(Object criteria) { - ArrayList res = new ArrayList(); + public List search(Object criteria) { + ArrayList res = new ArrayList(); res.add(new Object()); return res; } diff --git a/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelErrors.java b/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelErrors.java index 043eadc2..00c153ab 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelErrors.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelErrors.java @@ -18,7 +18,7 @@ package org.springframework.webflow.validation; import org.springframework.validation.Errors; /** - * Support class for {@link ValidationHelperTest} + * Support class for {@link ValidationHelperTests} */ public class StubModelErrors { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelErrorsOverridden.java b/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelErrorsOverridden.java index 830379a1..12d37827 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelErrorsOverridden.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelErrorsOverridden.java @@ -18,7 +18,7 @@ package org.springframework.webflow.validation; import org.springframework.validation.Errors; /** - * Support class for {@link ValidationHelperTest} + * Support class for {@link ValidationHelperTests} */ public class StubModelErrorsOverridden extends StubModelValidationContext { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelValidationContext.java b/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelValidationContext.java index ec9c3c44..ebc16266 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelValidationContext.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/validation/StubModelValidationContext.java @@ -19,7 +19,7 @@ import org.springframework.binding.message.MessageBuilder; import org.springframework.binding.validation.ValidationContext; /** - * Support class for {@link ValidationHelperTest} + * Support class for {@link ValidationHelperTests} */ public class StubModelValidationContext { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/validation/ValidationHelperTests.java b/spring-webflow/src/test/java/org/springframework/webflow/validation/ValidationHelperTests.java index 4de512ac..e45e2d60 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/validation/ValidationHelperTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/validation/ValidationHelperTests.java @@ -374,7 +374,7 @@ public class ValidationHelperTests extends TestCase { fallbackInvoked = true; } - public boolean supports(Class clazz) { + public boolean supports(Class clazz) { return true; } }