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 8c9e3a33..ad2009c5 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
@@ -23,16 +23,15 @@ import java.util.NoSuchElementException;
import org.springframework.util.Assert;
/**
- * Iterator that combines multiple other iterators. This is a simple implementation
- * that just maintains a list of iterators which are invoked in sequence untill
- * all iterators are exhausted.
+ * Iterator that combines multiple other iterators. This is a simple implementation that just maintains a list of
+ * iterators which are invoked in sequence untill all iterators are exhausted.
*
* @author Erwin Vervaet
*/
public class CompositeIterator implements Iterator {
private List iterators = new LinkedList();
-
+
private boolean inUse = false;
/**
@@ -40,7 +39,7 @@ public class CompositeIterator implements Iterator {
*/
public CompositeIterator() {
}
-
+
/**
* Add given iterator to this composite.
*/
@@ -54,8 +53,8 @@ public class CompositeIterator implements Iterator {
public boolean hasNext() {
inUse = true;
- for (Iterator it = iterators.iterator(); it.hasNext(); ) {
- if (((Iterator)it.next()).hasNext()) {
+ for (Iterator it = iterators.iterator(); it.hasNext();) {
+ if (((Iterator) it.next()).hasNext()) {
return true;
}
}
@@ -64,8 +63,8 @@ public class CompositeIterator implements Iterator {
public Object next() {
inUse = true;
- for (Iterator it = iterators.iterator(); it.hasNext(); ) {
- Iterator iterator = (Iterator)it.next();
+ for (Iterator it = iterators.iterator(); it.hasNext();) {
+ Iterator iterator = (Iterator) it.next();
if (iterator.hasNext()) {
return iterator.next();
}
@@ -75,5 +74,5 @@ public class CompositeIterator implements Iterator {
public void remove() {
throw new UnsupportedOperationException("Remove is not supported");
- }
+ }
}
\ No newline at end of file
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 de09a400..419712c3 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
@@ -21,8 +21,8 @@ import java.util.Map;
import org.springframework.util.Assert;
/**
- * A simple, generic decorator for getting attributes out of a map. May be
- * instantiated directly or used as a base class as a convenience.
+ * A simple, generic decorator for getting attributes out of a map. May be instantiated directly or used as a base class
+ * as a convenience.
*
* @author Keith Donald
*/
@@ -43,14 +43,13 @@ public class MapAccessor implements MapAdaptable {
}
// implementing MapAdaptable
-
+
public Map asMap() {
return map;
}
/**
- * Returns a value in the map, returning the defaultValue if no value was
- * found.
+ * Returns a value in the map, returning the defaultValue if no value was found.
* @param key the key
* @param defaultValue the default
* @return the attribute value
@@ -63,27 +62,24 @@ public class MapAccessor implements MapAdaptable {
}
/**
- * Returns a value in the map, asserting it is of the required type if
- * present and returning null if not found.
+ * Returns a value in the map, asserting it is of the required type if present and returning null if
+ * not found.
* @param key the key
* @param requiredType the required type
* @return the value
- * @throws IllegalArgumentException if the key is present but the value is
- * not of the required type
+ * @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 {
return get(key, requiredType, null);
}
/**
- * Returns a value in the map of the specified type, returning the
- * defaultValue if no value is found.
+ * Returns a value in the map of the specified type, returning the defaultValue if no value is found.
* @param key the key
* @param requiredType the required type
* @param defaultValue the default
* @return the attribute value
- * @throws IllegalArgumentException if the key is present but the value is
- * not of the required type
+ * @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) {
if (!map.containsKey(key)) {
@@ -93,8 +89,7 @@ public class MapAccessor implements MapAdaptable {
}
/**
- * Returns a value in the map, throwing an exception if the attribute is not
- * present and of the correct type.
+ * Returns a value in the map, throwing an exception if the attribute is not present and of the correct type.
* @param key the key
* @return the value
*/
@@ -104,8 +99,7 @@ public class MapAccessor implements MapAdaptable {
}
/**
- * Returns an value in the map, asserting it is present and of the required
- * type.
+ * Returns an value in the map, asserting it is present and of the required type.
* @param key the key
* @param requiredType the required type
* @return the value
@@ -116,217 +110,195 @@ public class MapAccessor implements MapAdaptable {
}
/**
- * Returns a string value in the map, returning null if no
- * value was found.
+ * Returns a string value in the map, returning null if no value was found.
* @param key the key
* @return the string value
- * @throws IllegalArgumentException if the key is present but the value is
- * not a string
+ * @throws IllegalArgumentException if the key is present but the value is not a string
*/
public String getString(Object key) throws IllegalArgumentException {
return getString(key, null);
}
/**
- * Returns a string value in the map, returning the defaultValue if no value
- * was found.
+ * Returns a string value in the map, returning the defaultValue if no value was found.
* @param key the key
* @param defaultValue the default
* @return the string value
- * @throws IllegalArgumentException if the key is present but the value is
- * not a string
+ * @throws IllegalArgumentException if the key is present but the value is not a string
*/
public String getString(Object key, String defaultValue) throws IllegalArgumentException {
if (!map.containsKey(key)) {
return defaultValue;
}
- return (String)assertKeyValueOfType(key, String.class);
+ return (String) assertKeyValueOfType(key, String.class);
}
/**
- * Returns a string value in the map, throwing an exception if the attribute
- * is not present and of the correct type.
+ * Returns a string value in the map, throwing an exception if the attribute is not present and of the correct type.
* @param key the key
* @return the string value
- * @throws IllegalArgumentException if the key is not present or present but
- * the value is not a string
+ * @throws IllegalArgumentException if the key is not present or present but the value is not a string
*/
public String getRequiredString(Object key) throws IllegalArgumentException {
assertContainsKey(key);
- return (String)assertKeyValueOfType(key, String.class);
+ return (String) assertKeyValueOfType(key, String.class);
}
/**
- * Returns a collection value in the map, returning null if
- * no value was found.
+ * Returns a collection value in the map, returning null if no value was found.
* @param key the key
* @return the collection value
- * @throws IllegalArgumentException if the key is present but the value is
- * not a collection
+ * @throws IllegalArgumentException if the key is present but the value is not a collection
*/
public Collection getCollection(Object key) throws IllegalArgumentException {
if (!map.containsKey(key)) {
return null;
}
- return (Collection)assertKeyValueOfType(key, Collection.class);
+ return (Collection) assertKeyValueOfType(key, Collection.class);
}
/**
- * Returns a collection value in the map, asserting it is of the required
- * type if present and returning null if not found.
+ * Returns a collection value in the map, asserting it is of the required type if present and returning
+ * null if not found.
* @param key the key
* @return the collection value
- * @throws IllegalArgumentException if the key is present but the value is
- * not a collection
+ * @throws IllegalArgumentException if the key is present but the value is not a collection
*/
public Collection getCollection(Object key, Class requiredType) throws IllegalArgumentException {
if (!map.containsKey(key)) {
return null;
}
assertAssignableTo(Collection.class, requiredType);
- return (Collection)assertKeyValueOfType(key, requiredType);
+ return (Collection) assertKeyValueOfType(key, requiredType);
}
/**
- * Returns a collection value in the map, throwing an exception if not
- * found.
+ * Returns a collection value in the map, throwing an exception if not found.
* @param key the key
* @return the collection value
- * @throws IllegalArgumentException if the key is not present or present but
- * the value is not a collection
+ * @throws IllegalArgumentException if the key is not present or present but the value is not a collection
*/
public Collection getRequiredCollection(Object key) throws IllegalArgumentException {
assertContainsKey(key);
- return (Collection)assertKeyValueOfType(key, Collection.class);
+ return (Collection) assertKeyValueOfType(key, Collection.class);
}
/**
- * Returns a collection value in the map, asserting it is of the required
- * type if present and throwing an exception if not found.
+ * Returns a collection value in the map, asserting it is of the required type if present and throwing an exception
+ * if not found.
* @param key the key
* @return the collection value
- * @throws IllegalArgumentException if the key is not present or present but
- * the value is not a collection of the required type
+ * @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 {
assertContainsKey(key);
assertAssignableTo(Collection.class, requiredType);
- return (Collection)assertKeyValueOfType(key, requiredType);
+ return (Collection) assertKeyValueOfType(key, requiredType);
}
/**
- * Returns a array value in the map, asserting it is of the required type if
- * present and returning null if not found.
+ * Returns a array value in the map, asserting it is of the required type if present and returning null
+ * if not found.
* @param key the key
* @return the array value
- * @throws IllegalArgumentException if the key is present but the value is
- * not an array of the required type
+ * @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 {
assertAssignableTo(Object[].class, requiredType);
if (!map.containsKey(key)) {
return null;
}
- return (Object[])assertKeyValueOfType(key, requiredType);
+ return (Object[]) assertKeyValueOfType(key, requiredType);
}
/**
- * Returns an array value in the map, asserting it is of the required type
- * if present and throwing an exception if not found.
+ * Returns an array value in the map, asserting it is of the required type if present and throwing an exception if
+ * not found.
* @param key the key
* @return the array value
- * @throws IllegalArgumentException if the key is not present or present but
- * the value is not a array of the required type
+ * @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 {
assertContainsKey(key);
assertAssignableTo(Object[].class, requiredType);
- return (Object[])assertKeyValueOfType(key, requiredType);
+ return (Object[]) assertKeyValueOfType(key, requiredType);
}
/**
- * Returns a number value in the map that is of the specified type,
- * returning null if no value was found.
+ * Returns a number value in the map that is of the specified type, returning null if no value was
+ * found.
* @param key the key
* @param requiredType the required number type
* @return the numbervalue
- * @throws IllegalArgumentException if the key is present but the value is
- * not a number of the required type
+ * @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 {
return getNumber(key, requiredType, null);
}
/**
- * Returns a number attribute value in the map of the specified type,
- * returning the defaultValue if no value was found.
+ * Returns a number attribute value in the map of the specified type, returning the defaultValue if no value was
+ * found.
* @param key the attribute name
* @return the number value
* @param defaultValue the default
- * @throws IllegalArgumentException if the key is present but the value is
- * not a number of the required type
+ * @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 {
if (!map.containsKey(key)) {
return defaultValue;
}
assertAssignableTo(Number.class, requiredType);
- return (Number)assertKeyValueOfType(key, requiredType);
+ return (Number) assertKeyValueOfType(key, requiredType);
}
/**
- * Returns a number value in the map, throwing an exception if the attribute
- * is not present and of the correct type.
+ * Returns a number value in the map, throwing an exception if the attribute is not present and of the correct type.
* @param key the key
* @return the number value
- * @throws IllegalArgumentException if the key is not present or present but
- * the value is not a number of the required type
+ * @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 {
assertContainsKey(key);
- return (Number)assertKeyValueOfType(key, requiredType);
+ return (Number) assertKeyValueOfType(key, requiredType);
}
/**
- * Returns an integer value in the map, returning null if no
- * value was found.
+ * Returns an integer value in the map, returning null if no value was found.
* @param key the key
* @return the integer value
- * @throws IllegalArgumentException if the key is present but the value is
- * not an integer
+ * @throws IllegalArgumentException if the key is present but the value is not an integer
*/
public Integer getInteger(Object key) throws IllegalArgumentException {
return getInteger(key, null);
}
/**
- * Returns an integer value in the map, returning the defaultValue if no
- * value was found.
+ * Returns an integer value in the map, returning the defaultValue if no value was found.
* @param key the key
* @param defaultValue the default
* @return the integer value
- * @throws IllegalArgumentException if the key is present but the value is
- * not an integer
+ * @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 (Integer) getNumber(key, Integer.class, defaultValue);
}
/**
- * Returns an integer value in the map, throwing an exception if the value
- * is not present and of the correct type.
+ * Returns an integer value in the map, throwing an exception if the value is not present and of the correct type.
* @param key the attribute name
* @return the integer attribute value
- * @throws IllegalArgumentException if the key is not present or present but
- * the value is not an integer
+ * @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 (Integer) getRequiredNumber(key, Integer.class);
}
/**
- * Returns a long value in the map, returning null if no
- * value was found.
+ * Returns a long value in the map, returning null if no value was found.
* @param key the key
* @return the long value
* @throws IllegalArgumentException if the key is present but not a long
@@ -336,69 +308,59 @@ public class MapAccessor implements MapAdaptable {
}
/**
- * Returns a long value in the map, returning the defaultValue if no value
- * was found.
+ * Returns a long value in the map, returning the defaultValue if no value was found.
* @param key the key
* @param defaultValue the default
* @return the long attribute value
- * @throws IllegalArgumentException if the key is present but the value is
- * not a long
+ * @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 (Long) getNumber(key, Long.class, defaultValue);
}
/**
- * Returns a long value in the map, throwing an exception if the value is
- * not present and of the correct type.
+ * Returns a long value in the map, throwing an exception if the value is not present and of the correct type.
* @param key the key
* @return the long attribute value
- * @throws IllegalArgumentException if the key is not present or present but
- * the value is not a long
+ * @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 (Long) getRequiredNumber(key, Long.class);
}
/**
- * Returns a boolean value in the map, returning null if no
- * value was found.
+ * Returns a boolean value in the map, returning null if no value was found.
* @param key the key
* @return the boolean value
- * @throws IllegalArgumentException if the key is present but the value is
- * not a boolean
+ * @throws IllegalArgumentException if the key is present but the value is not a boolean
*/
public Boolean getBoolean(Object key) throws IllegalArgumentException {
return getBoolean(key, null);
}
/**
- * Returns a boolean value in the map, returning the defaultValue if no
- * value was found.
+ * Returns a boolean value in the map, returning the defaultValue if no value was found.
* @param key the key
* @param defaultValue the default
* @return the boolean value
- * @throws IllegalArgumentException if the key is present but the value is
- * not a boolean
+ * @throws IllegalArgumentException if the key is present but the value is not a boolean
*/
public Boolean getBoolean(Object key, Boolean defaultValue) throws IllegalArgumentException {
if (!map.containsKey(key)) {
return defaultValue;
}
- return (Boolean)assertKeyValueOfType(key, Boolean.class);
+ return (Boolean) assertKeyValueOfType(key, Boolean.class);
}
/**
- * Returns a boolean value in the map, throwing an exception if the value is
- * not present and of the correct type.
+ * Returns a boolean value in the map, throwing an exception if the value is not present and of the correct type.
* @param key the attribute
* @return the boolean value
- * @throws IllegalArgumentException if the key is not present or present but
- * the value is not a boolean
+ * @throws IllegalArgumentException if the key is not present or present but the value is not a boolean
*/
public Boolean getRequiredBoolean(Object key) throws IllegalArgumentException {
assertContainsKey(key);
- return (Boolean)assertKeyValueOfType(key, Boolean.class);
+ return (Boolean) assertKeyValueOfType(key, Boolean.class);
}
/**
@@ -414,8 +376,7 @@ public class MapAccessor implements MapAdaptable {
}
/**
- * Indicates if the attribute is present in the attribute map and of the
- * required type.
+ * Indicates if the attribute is present in the attribute map and of the required type.
* @param key the attribute name
* @return true if present and of the required type, false if not present.
*/
@@ -423,8 +384,7 @@ public class MapAccessor implements MapAdaptable {
if (map.containsKey(key)) {
assertKeyValueOfType(key, requiredType);
return true;
- }
- else {
+ } else {
return false;
}
}
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 ce3e7ef5..0f83697c 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
@@ -25,11 +25,11 @@ import java.util.Map;
public interface MapAdaptable {
/**
- * Returns this object's contents as a {@link Map}. The returned map may or
- * may not be modifiable depending on this implementation.
+ * Returns this object's contents as a {@link Map}. The returned map may or may not be modifiable depending on this
+ * implementation.
*
- * Warning: this operation may be called frequently; if so care should be - * taken so that the map contents (if calculated) be cached as appropriate. + * Warning: this operation may be called frequently; if so care should be taken so that the map contents (if + * calculated) be cached as appropriate. * @return the object's contents as a map */ public Map asMap(); 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 fb1379a1..8652fe8a 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 @@ -18,20 +18,18 @@ package org.springframework.binding.collection; import java.util.Map; /** - * A simple subinterface of {@link Map} that exposes a mutex that - * application code can synchronize on. + * A simple subinterface of {@link Map} that exposes a mutex that application code can synchronize on. *
- * Expected to be implemented by Maps that are backed by shared objects that
- * require synchronization between multiple threads. An example would be the
- * HTTP session map.
+ * Expected to be implemented by Maps that are backed by shared objects that require synchronization between multiple
+ * threads. An example would be the HTTP session map.
*
* @author Keith Donald
*/
public interface SharedMap extends Map {
/**
- * Returns the shared mutex that may be synchronized on using a
- * synchronized block. The returned mutex is guaranteed to be non-null.
+ * Returns the shared mutex that may be synchronized on using a synchronized block. The returned mutex is guaranteed
+ * to be non-null.
*
* Example usage:
*
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 3d7910af..f2033af4 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
@@ -23,9 +23,8 @@ import java.util.Set;
import org.springframework.core.style.ToStringCreator;
/**
- * A map decorator that implements SharedMap. By default, simply
- * returns the map itself as the mutex. Subclasses may override to return a
- * different mutex object.
+ * A map decorator that implements SharedMap. By default, simply returns the map itself as the mutex.
+ * Subclasses may override to return a different mutex object.
*
* @author Keith Donald
*/
@@ -43,7 +42,7 @@ public class SharedMapDecorator implements SharedMap, Serializable {
public SharedMapDecorator(Map map) {
this.map = map;
}
-
+
// implementing Map
public void clear() {
@@ -93,7 +92,7 @@ public class SharedMapDecorator implements SharedMap, Serializable {
public Collection values() {
return map.values();
}
-
+
// implementing SharedMap
public Object getMutex() {
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 be49017a..d571ad0d 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
@@ -22,24 +22,24 @@ import java.util.NoSuchElementException;
import java.util.Set;
/**
- * Base class for map adapters whose keys are String values. Concrete
- * classes need only implement the abstract hook methods defined by this class.
+ * Base class for map adapters whose keys are String values. Concrete classes need only implement the abstract hook
+ * methods defined by this class.
*
* @author Keith Donald
*/
public abstract class StringKeyedMapAdapter implements Map {
-
+
private Set keySet;
private Collection values;
private Set entrySet;
-
+
// implementing Map
public void clear() {
for (Iterator it = getAttributeNames(); it.hasNext();) {
- removeAttribute((String)it.next());
+ removeAttribute((String) it.next());
}
}
@@ -52,7 +52,7 @@ public abstract class StringKeyedMapAdapter implements Map {
return false;
}
for (Iterator it = getAttributeNames(); it.hasNext();) {
- Object aValue = getAttribute((String)it.next());
+ Object aValue = getAttribute((String) it.next());
if (value.equals(aValue)) {
return true;
}
@@ -85,7 +85,7 @@ public abstract class StringKeyedMapAdapter implements Map {
public void putAll(Map map) {
for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry)it.next();
+ Entry entry = (Entry) it.next();
setAttribute(entry.getKey().toString(), entry.getValue());
}
}
@@ -109,40 +109,38 @@ public abstract class StringKeyedMapAdapter implements Map {
public Collection values() {
return (values != null) ? values : (values = new Values());
}
-
+
// hook methods
/**
- * Hook method that needs to be implemented by concrete subclasses.
- * Gets a value associated with a key.
+ * Hook method that needs to be implemented by concrete subclasses. Gets a value associated with a key.
* @param key the key to lookup
* @return the associated value, or null if none
*/
protected abstract Object getAttribute(String key);
/**
- * Hook method that needs to be implemented by concrete subclasses.
- * Puts a key-value pair in the map, overwriting any possible earlier
- * value associated with the same key.
+ * Hook method that needs to be implemented by concrete subclasses. Puts a key-value pair in the map, overwriting
+ * any possible earlier value associated with the same key.
* @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);
/**
- * Hook method that needs to be implemented by concrete subclasses.
- * Removes a key and its associated value from the map.
+ * Hook method that needs to be implemented by concrete subclasses. Removes a key and its associated value from the
+ * map.
* @param key the key to remove
*/
protected abstract void removeAttribute(String key);
/**
- * Hook method that needs to be implemented by concrete subclasses.
- * Returns an enumeration listing all keys known to the map.
+ * Hook method that needs to be implemented by concrete subclasses. Returns an enumeration listing all keys known to
+ * the map.
* @return the key enumeration
*/
protected abstract Iterator getAttributeNames();
-
+
// internal helper classes
private abstract class AbstractSet extends java.util.AbstractSet {
@@ -233,7 +231,7 @@ public abstract class StringKeyedMapAdapter implements Map {
if (!(o instanceof Entry)) {
return false;
}
- Entry entry = (Entry)o;
+ Entry entry = (Entry) o;
Object key = entry.getKey();
Object value = entry.getValue();
if (key == null || value == null) {
@@ -246,13 +244,13 @@ public abstract class StringKeyedMapAdapter implements Map {
if (!(o instanceof Entry)) {
return false;
}
- Entry entry = (Entry)o;
+ Entry entry = (Entry) o;
Object key = entry.getKey();
Object value = entry.getValue();
if (key == null || value == null || !value.equals(StringKeyedMapAdapter.this.get(key))) {
return false;
}
- return StringKeyedMapAdapter.this.remove(((Entry)o).getKey()) != null;
+ return StringKeyedMapAdapter.this.remove(((Entry) o).getKey()) != null;
}
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionContext.java b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionContext.java
index 684c6d51..9396f7fc 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/ConversionContext.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/ConversionContext.java
@@ -18,13 +18,10 @@ package org.springframework.binding.convert;
/**
* A context object with two main responsibities:
*
- * Specifically, encapsulates knowledge about how to convert source objects to a
- * specific target type using a specific converter.
+ * Specifically, encapsulates knowledge about how to convert source objects to a specific target type using a specific
+ * converter.
*
* @author Keith Donald
*/
@@ -74,7 +74,7 @@ public class ConversionExecutor {
public Class getTargetClass() {
return targetClass;
}
-
+
/**
* Returns the converter that will perform the conversion.
* @return the converter
@@ -94,8 +94,7 @@ public class ConversionExecutor {
/**
* Execute the conversion for the provided source object.
* @param source the source object to convert
- * @param context the conversion context, useful for influencing the
- * behavior of the converter
+ * @param context the conversion context, useful for influencing the behavior of the converter
*/
public Object execute(Object source, ConversionContext context) throws ConversionException {
if (getTargetClass().isInstance(source)) {
@@ -103,8 +102,8 @@ public class ConversionExecutor {
return source;
}
if (source != null && !getSourceClass().isInstance(source)) {
- throw new ConversionException(getSourceClass(), source, getTargetClass(),
- "Source object '" + source + "' is expected to be an instance of " + getSourceClass());
+ throw new ConversionException(getSourceClass(), source, getTargetClass(), "Source object '" + source
+ + "' is expected to be an instance of " + getSourceClass());
}
return converter.convert(source, targetClass, context);
}
@@ -113,7 +112,7 @@ public class ConversionExecutor {
if (!(o instanceof ConversionExecutor)) {
return false;
}
- ConversionExecutor other = (ConversionExecutor)o;
+ ConversionExecutor other = (ConversionExecutor) o;
return sourceClass.equals(other.sourceClass) && targetClass.equals(other.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 3a1973fd..f435233a 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
@@ -16,52 +16,44 @@
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.
+ * 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.
*
* @author Keith Donald
*/
public interface ConversionService {
/**
- * Return a conversion executor command object capable of converting source
- * objects of the specified sourceClass to instances of the
- * targetClass.
+ * Return a conversion executor command object capable of converting source objects of the specified
+ * sourceClass to instances of the targetClass.
*
- * The returned ConversionExecutor is thread-safe and may safely be cached
- * for use in client code.
+ * The returned ConversionExecutor is thread-safe and may safely be cached for use in client code.
* @param sourceClass the source class to convert from
* @param targetClass the target class to convert to
* @return the executor that can execute instance conversion, never null
- * @throws ConversionException an exception occured retrieving a converter
- * for the source-to-target pair
+ * @throws ConversionException an exception occured retrieving a converter for the source-to-target pair
*/
- public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
- throws ConversionException;
+ public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) throws ConversionException;
/**
- * Return a conversion executor command object capable of converting source
- * objects of the specified sourceClass to target objects of
- * the type associated with the specified alias.
+ * Return a conversion executor command object capable of converting source objects of the specified
+ * sourceClass to target objects of the type associated with the specified alias.
* @param sourceClass the sourceClass
* @param targetAlias the target alias
* @return the conversion executor, or null if the alias cannot be found
- * @throws ConversionException an exception occured retrieving a converter
- * for the source-to-target pair
+ * @throws ConversionException an exception occured retrieving a converter for the source-to-target pair
*/
public ConversionExecutor getConversionExecutorByTargetAlias(Class sourceClass, String targetAlias)
throws ConversionException;
/**
- * Return all conversion executors capable of converting source objects of
- * the the specified sourceClass.
+ * Return all conversion executors capable of converting source objects of the the specified
+ * sourceClass.
* @param sourceClass the source class to convert from
* @return the matching conversion executors
* @throws ConversionException an exception occured retrieving the converters
*/
- public ConversionExecutor[] getConversionExecutorsForSource(Class sourceClass)
- throws ConversionException;
+ public ConversionExecutor[] getConversionExecutorsForSource(Class sourceClass) throws ConversionException;
/**
* Return the class with the specified alias.
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/Converter.java b/spring-binding/src/main/java/org/springframework/binding/convert/Converter.java
index 8ce04ca1..f1cb60e4 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/Converter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/Converter.java
@@ -16,8 +16,8 @@
package org.springframework.binding.convert;
/**
- * A type converter converts objects from one type to another. They may support
- * conversion of multiple source types to multiple target types.
+ * A type converter converts objects from one type to another. They may support conversion of multiple source types to
+ * multiple target types.
*
* Implementations of this interface are thread-safe.
*
@@ -38,14 +38,11 @@ public interface Converter {
public Class[] getTargetClasses();
/**
- * Convert the provided source object argument to an instance of the
- * specified target class.
- * @param source the source object to convert, its class must be one of the
- * supported sourceClasses
- * @param targetClass the target class to convert the source to, must be one
- * of the supported targetClasses
- * @param context an optional conversion context that may be used to
- * influence the conversion process
+ * Convert the provided source object argument to an instance of the specified target class.
+ * @param source the source object to convert, its class must be one of the supported sourceClasses
+ * @param targetClass the target class to convert the source to, must be one of the supported
+ * targetClasses
+ * @param context an optional conversion context that may be used to influence the conversion process
* @return the converted object, an instance of the target type
* @throws ConversionException an exception occured during the conversion
*/
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/AbstractConverter.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/AbstractConverter.java
index eaa1db19..974845a2 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/AbstractConverter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/AbstractConverter.java
@@ -27,42 +27,36 @@ import org.springframework.binding.convert.Converter;
public abstract class AbstractConverter implements Converter {
/**
- * Convenience convert method that converts the provided source to the first
- * target object supported by this converter. Useful when a converter only
- * supports conversion to a single target.
+ * Convenience convert method that converts the provided source to the first target object supported by this
+ * converter. Useful when a converter only supports conversion to a single target.
* @param source the source to convert
* @return the converted object
- * @throws ConversionException an exception occured converting the source
- * value
+ * @throws ConversionException an exception occured converting the source value
*/
public Object convert(Object source) throws ConversionException {
return convert(source, getTargetClasses()[0], null);
}
/**
- * Convenience convert method that converts the provided source to the
- * target class specified with an empty conversion context.
+ * Convenience convert method that converts the provided source to the target class specified with an empty
+ * conversion context.
* @param source the source to convert
- * @param targetClass the target class to convert the source to, must be one
- * of the supported targetClasses
+ * @param targetClass the target class to convert the source to, must be one of the supported
+ * targetClasses
* @return the converted object
- * @throws ConversionException an exception occured converting the source
- * value
+ * @throws ConversionException an exception occured converting the source value
*/
public Object convert(Object source, Class targetClass) throws ConversionException {
return convert(source, targetClass, null);
}
/**
- * Convenience convert method that converts the provided source to the first
- * target object supported by this converter. Useful when a converter only
- * supports conversion to a single target.
+ * Convenience convert method that converts the provided source to the first target object supported by this
+ * converter. Useful when a converter only supports conversion to a single target.
* @param source the source to convert
- * @param context the conversion context, useful for influencing the
- * behavior of the converter
+ * @param context the conversion context, useful for influencing the behavior of the converter
* @return the converted object
- * @throws ConversionException an exception occured converting the source
- * value
+ * @throws ConversionException an exception occured converting the source value
*/
public Object convert(Object source, ConversionContext context) throws ConversionException {
return convert(source, getTargetClasses()[0], context);
@@ -71,11 +65,9 @@ public abstract class AbstractConverter implements Converter {
public Object convert(Object source, Class targetClass, ConversionContext context) throws ConversionException {
try {
return doConvert(source, targetClass, context);
- }
- catch (ConversionException e) {
+ } catch (ConversionException e) {
throw e;
- }
- catch (Throwable e) {
+ } catch (Throwable e) {
// wrap in a ConversionException
if (targetClass == null) {
targetClass = getTargetClasses()[0];
@@ -85,15 +77,12 @@ public abstract class AbstractConverter implements Converter {
}
/**
- * Template method subclasses should override to actually perform the type
- * conversion.
+ * Template method subclasses should override to actually perform the type conversion.
* @param source the source to convert from
* @param targetClass the target type to convert to
- * @param context an optional conversion context that may be used to
- * influence the conversion process, could be null
+ * @param context an optional conversion context that may be used to influence the conversion process, could be null
* @return the converted source value
- * @throws Exception an exception occured, will be wrapped in a conversion
- * exception if necessary
+ * @throws Exception an exception occured, will be wrapped in a conversion exception if necessary
*/
protected abstract Object doConvert(Object source, Class targetClass, ConversionContext context) throws Exception;
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/AbstractFormattingConverter.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/AbstractFormattingConverter.java
index 40618875..e2acfcac 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/AbstractFormattingConverter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/AbstractFormattingConverter.java
@@ -18,9 +18,8 @@ package org.springframework.binding.convert.support;
import org.springframework.binding.format.FormatterFactory;
/**
- * A converter that delegates to a formatter to perform the conversion.
- * Formatters are typically not thread safe, so we use a FormatterFactory that
- * is expected to provide us with thread-safe instances as necessary.
+ * A converter that delegates to a formatter to perform the conversion. Formatters are typically not thread safe, so we
+ * use a FormatterFactory that is expected to provide us with thread-safe instances as necessary.
*
* @author Keith Donald
*/
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/CompositeConversionService.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/CompositeConversionService.java
index a5192ef9..d44e5023 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/CompositeConversionService.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/CompositeConversionService.java
@@ -25,16 +25,15 @@ import org.springframework.binding.convert.ConversionService;
import org.springframework.util.Assert;
/**
- * A conversion service that delegates to an ordered chain of other conversion
- * services. The first correct reply received from a conversion service in
- * the chain is returned to the caller.
+ * A conversion service that delegates to an ordered chain of other conversion services. The first correct reply
+ * received from a conversion service in the chain is returned to the caller.
*
* @author Erwin Vervaet
*/
public class CompositeConversionService implements ConversionService {
-
+
private ConversionService[] chain;
-
+
/**
* Create a new composite conversion service.
* @param conversionServices the conversion services in the chain
@@ -43,28 +42,24 @@ public class CompositeConversionService implements ConversionService {
Assert.notNull(conversionServices, "The conversion services chain is required");
this.chain = conversionServices;
}
-
+
/**
- * Returns the conversion services in the chain managed by this
- * composite conversion service.
+ * Returns the conversion services in the chain managed by this composite conversion service.
*/
public ConversionService[] getConversionServices() {
return chain;
}
- public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass)
- throws ConversionException {
+ public ConversionExecutor getConversionExecutor(Class sourceClass, Class targetClass) throws ConversionException {
for (int i = 0; i < chain.length; i++) {
try {
return chain[i].getConversionExecutor(sourceClass, targetClass);
- }
- catch (ConversionException e) {
+ } catch (ConversionException e) {
// ignore and try the next conversion service in the chain
}
}
- throw new ConversionException(sourceClass, targetClass,
- "No converter registered to convert from sourceClass '" + sourceClass +
- "' to target class '" + targetClass + "'");
+ throw new ConversionException(sourceClass, targetClass, "No converter registered to convert from sourceClass '"
+ + sourceClass + "' to target class '" + targetClass + "'");
}
public ConversionExecutor getConversionExecutorByTargetAlias(Class sourceClass, String targetAlias)
@@ -76,29 +71,25 @@ public class CompositeConversionService implements ConversionService {
if (res != null) {
return res;
}
- }
- catch (ConversionException e) {
+ } catch (ConversionException e) {
exceptionThrown = true;
}
}
if (exceptionThrown) {
- throw new ConversionException(sourceClass,
- "No converter registered to convert from sourceClass '" + sourceClass +
- "' to aliased target type '" + targetAlias + "'");
- }
- else {
+ throw new ConversionException(sourceClass, "No converter registered to convert from sourceClass '"
+ + sourceClass + "' to aliased target type '" + targetAlias + "'");
+ } else {
// alias was not recognized by any conversion service in the chain
return null;
}
}
- public ConversionExecutor[] getConversionExecutorsForSource(Class sourceClass)
- throws ConversionException {
+ public ConversionExecutor[] getConversionExecutorsForSource(Class sourceClass) throws ConversionException {
Set executors = new HashSet();
for (int i = 0; i < chain.length; i++) {
executors.addAll(Arrays.asList(chain[i].getConversionExecutorsForSource(sourceClass)));
}
- return (ConversionExecutor[])executors.toArray(new ConversionExecutor[executors.size()]);
+ return (ConversionExecutor[]) executors.toArray(new ConversionExecutor[executors.size()]);
}
public Class getClassByAlias(String alias) throws ConversionException {
@@ -108,8 +99,7 @@ public class CompositeConversionService implements ConversionService {
if (res != null) {
return res;
}
- }
- catch (ConversionException e) {
+ } catch (ConversionException e) {
// ignore and try the next conversion service in the chain
}
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/ConversionServiceAware.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/ConversionServiceAware.java
index 0ccc87ac..5c5f1686 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/ConversionServiceAware.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/ConversionServiceAware.java
@@ -18,16 +18,14 @@ package org.springframework.binding.convert.support;
import org.springframework.binding.convert.ConversionService;
/**
- * Marker interface that denotes an object has a dependency on a conversion
- * service that is expected to be fulfilled.
+ * Marker interface that denotes an object has a dependency on a conversion service that is expected to be fulfilled.
*
* @author Keith Donald
*/
public interface ConversionServiceAware {
/**
- * Set the conversion service this object should be made aware of (as it
- * presumably depends on it).
+ * Set the conversion service this object should be made aware of (as it presumably depends on it).
*
* @param conversionService the conversion service
*/
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/ConversionServiceAwareConverter.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/ConversionServiceAwareConverter.java
index 4f095cdd..1c5bc8b4 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/ConversionServiceAwareConverter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/ConversionServiceAwareConverter.java
@@ -20,8 +20,7 @@ import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.expression.Expression;
/**
- * Base class for converters that use other converters to convert things, thus
- * they are conversion-service aware.
+ * Base class for converters that use other converters to convert things, thus they are conversion-service aware.
*
* @author Keith Donald
*/
@@ -33,8 +32,8 @@ public abstract class ConversionServiceAwareConverter extends AbstractConverter
private ConversionService conversionService;
/**
- * Default constructor, expectes to conversion service to be injected
- * using {@link #setConversionService(ConversionService)}.
+ * Default constructor, expectes to conversion service to be injected using
+ * {@link #setConversionService(ConversionService)}.
*/
protected ConversionServiceAwareConverter() {
}
@@ -61,8 +60,7 @@ public abstract class ConversionServiceAwareConverter extends AbstractConverter
}
/**
- * Returns a conversion executor capable of converting string objects to the
- * specified target class.
+ * Returns a conversion executor capable of converting string objects to the specified target class.
* @param targetClass the target class
* @return the conversion executor, never null
*/
@@ -71,19 +69,17 @@ public abstract class ConversionServiceAwareConverter extends AbstractConverter
}
/**
- * Returns a conversion executor capable of converting string objects to the
- * target class aliased by the provided alias.
+ * Returns a conversion executor capable of converting string objects to the target class aliased by the provided
+ * alias.
* @param targetAlias the target class alias, e.g "long" or "float"
- * @return the conversion executor, or null if no suitable
- * converter exists for alias
+ * @return the conversion executor, or null if no suitable converter exists for alias
*/
protected ConversionExecutor fromStringToAliased(String targetAlias) {
return getConversionService().getConversionExecutorByTargetAlias(String.class, targetAlias);
}
/**
- * Returns a conversion executor capable of converting objects from one
- * class to another.
+ * Returns a conversion executor capable of converting objects from one class to another.
* @param sourceClass the source class to convert from
* @param targetClass the target class to convert to
* @return the conversion executor, never null
@@ -93,12 +89,12 @@ public abstract class ConversionServiceAwareConverter extends AbstractConverter
}
/**
- * Helper that parsers the given expression string into an expression, using
- * the installed String->Expression converter.
+ * Helper that parsers the given expression string into an expression, using the installed String->Expression
+ * converter.
* @param expressionString the expression string to parse
* @return the parsed, evaluatable expression
*/
protected Expression parseExpression(String expressionString) {
- return (Expression)fromStringTo(Expression.class).execute(expressionString);
+ return (Expression) fromStringTo(Expression.class).execute(expressionString);
}
}
\ No newline at end of file
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/ConverterPropertyEditorAdapter.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/ConverterPropertyEditorAdapter.java
index dcf95faf..27ed638d 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/ConverterPropertyEditorAdapter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/ConverterPropertyEditorAdapter.java
@@ -23,9 +23,8 @@ import org.springframework.util.Assert;
/**
* Adapts a Converter to the PropertyEditor interface.
*
- * Note: with a converter, only forward conversion from-string-to-value is - * supported. Value-to-string conversion is not supported. If you need this - * capability, use a Formatter with a FormatterPropertyEditor adapter. + * Note: with a converter, only forward conversion from-string-to-value is supported. Value-to-string conversion is not + * supported. If you need this capability, use a Formatter with a FormatterPropertyEditor adapter. * * @see org.springframework.binding.format.Formatter * @see org.springframework.binding.format.support.FormatterPropertyEditor diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/CustomConverterConfigurer.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/CustomConverterConfigurer.java index 9bf14643..e5e2af11 100644 --- a/spring-binding/src/main/java/org/springframework/binding/convert/support/CustomConverterConfigurer.java +++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/CustomConverterConfigurer.java @@ -24,12 +24,10 @@ import org.springframework.binding.convert.ConversionService; import org.springframework.util.Assert; /** - * Registers all 'from string' converters known to a conversion service with - * a Spring bean factory. + * Registers all 'from string' converters known to a conversion service with a Spring bean factory. *
- * Acts as bean factory post processor, registering property editor adapters for
- * each supported conversion with a java.lang.String sourceClass.
- * This makes for very convenient use with the Spring container.
+ * Acts as bean factory post processor, registering property editor adapters for each supported conversion with a
+ * java.lang.String sourceClass. This makes for very convenient use with the Spring container.
*
* @author Keith Donald
*/
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/DefaultConversionService.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/DefaultConversionService.java
index e198e9fd..8b995fde 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/DefaultConversionService.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/DefaultConversionService.java
@@ -22,17 +22,15 @@ import org.springframework.binding.format.support.SimpleFormatterFactory;
import org.springframework.core.enums.LabeledEnum;
/**
- * Default, local implementation of a conversion service. Will automatically
- * register from string converters for a number of standard Java
- * types like Class, Number, Boolean and so on.
+ * Default, local implementation of a conversion service. Will automatically register from string converters for
+ * a number of standard Java types like Class, Number, Boolean and so on.
*
* @author Keith Donald
*/
public class DefaultConversionService extends GenericConversionService {
/**
- * Creates a new default conversion service, installing the default
- * converters.
+ * Creates a new default conversion service, installing the default converters.
*/
public DefaultConversionService() {
addDefaultConverters();
@@ -46,7 +44,7 @@ public class DefaultConversionService extends GenericConversionService {
addConverter(new TextToNumber(new SimpleFormatterFactory()));
addConverter(new TextToBoolean());
addConverter(new TextToLabeledEnum());
-
+
// we're not using addDefaultAlias here for efficiency reasons
addAlias("string", String.class);
addAlias("short", Short.class);
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/GenericConversionService.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/GenericConversionService.java
index f4299f8a..61aea74b 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/GenericConversionService.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/GenericConversionService.java
@@ -33,24 +33,21 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
- * Base implementation of a conversion service. Initially empty, e.g. no converters
- * are registered by default.
+ * Base implementation of a conversion service. Initially empty, e.g. no converters are registered by default.
*
* @author Keith Donald
*/
public class GenericConversionService implements ConversionService {
/**
- * An indexed map of converters. Each entry key is a source class that can
- * be converted from, and each entry value is a map of target classes that
- * can be convertered to, ultimately mapping to a specific converter that
- * can perform the source->target conversion.
+ * An indexed map of converters. Each entry key is a source class that can be converted from, and each entry value
+ * is a map of target classes that can be convertered to, ultimately mapping to a specific converter that can
+ * perform the source->target conversion.
*/
private Map sourceClassConverters = new HashMap();
/**
- * A map of string aliases to convertible classes. Allows lookup of
- * converters by alias.
+ * A map of string aliases to convertible classes. Allows lookup of converters by alias.
*/
private Map aliasMap = new HashMap();
@@ -74,16 +71,15 @@ public class GenericConversionService implements ConversionService {
}
/**
- * Add given converter to this conversion service. If the converter is
- * {@link ConversionServiceAware}, it will get the conversion service
- * injected.
+ * Add given converter to this conversion service. If the converter is {@link ConversionServiceAware}, it will get
+ * the conversion service injected.
*/
public void addConverter(Converter converter) {
Class[] sourceClasses = converter.getSourceClasses();
Class[] targetClasses = converter.getTargetClasses();
for (int i = 0; i < sourceClasses.length; i++) {
Class sourceClass = sourceClasses[i];
- Map sourceMap = (Map)sourceClassConverters.get(sourceClass);
+ Map sourceMap = (Map) sourceClassConverters.get(sourceClass);
if (sourceMap == null) {
sourceMap = new HashMap();
sourceClassConverters.put(sourceClass, sourceMap);
@@ -94,14 +90,13 @@ public class GenericConversionService implements ConversionService {
}
}
if (converter instanceof ConversionServiceAware) {
- ((ConversionServiceAware)converter).setConversionService(this);
+ ((ConversionServiceAware) converter).setConversionService(this);
}
}
/**
- * Add all given converters. If the converters are
- * {@link ConversionServiceAware}, they will get the conversion service
- * injected.
+ * Add all given converters. If the converters are {@link ConversionServiceAware}, they will get the conversion
+ * service injected.
*/
public void addConverters(Converter[] converters) {
for (int i = 0; i < converters.length; i++) {
@@ -110,9 +105,8 @@ public class GenericConversionService implements ConversionService {
}
/**
- * Add given converter with an alias to the conversion service. If the
- * converter is {@link ConversionServiceAware}, it will get the conversion
- * service injected.
+ * Add given converter with an alias to the conversion service. If the converter is {@link ConversionServiceAware},
+ * it will get the conversion service injected.
*/
public void addConverter(Converter converter, String alias) {
aliasMap.put(alias, converter);
@@ -127,8 +121,8 @@ public class GenericConversionService implements ConversionService {
}
/**
- * Generate a conventions based alias for given target type. For instance,
- * "java.lang.Boolean" will get the "boolean" alias.
+ * Generate a conventions based alias for given target type. For instance, "java.lang.Boolean" will get the
+ * "boolean" alias.
*/
public void addDefaultAlias(Class targetType) {
addAlias(StringUtils.uncapitalize(ClassUtils.getShortName(targetType)), targetType);
@@ -148,16 +142,14 @@ public class GenericConversionService implements ConversionService {
if (converter != null) {
// we found a converter
return new ConversionExecutor(sourceClass, targetClass, converter);
- }
- else {
+ } else {
if (parent != null) {
// try the parent
return parent.getConversionExecutor(sourceClass, targetClass);
- }
- else {
+ } else {
throw new ConversionException(sourceClass, targetClass,
- "No converter registered to convert from sourceClass '" + sourceClass +
- "' to target class '" + targetClass + "'");
+ "No converter registered to convert from sourceClass '" + sourceClass + "' to target class '"
+ + targetClass + "'");
}
}
}
@@ -172,18 +164,15 @@ public class GenericConversionService implements ConversionService {
if (parent != null) {
// try the parent
return parent.getConversionExecutorByTargetAlias(sourceClass, alias);
- }
- else {
+ } else {
// not aliased
return null;
}
- }
- else if (targetType instanceof Class) {
- return getConversionExecutor(sourceClass, (Class)targetType);
- }
- else {
+ } else if (targetType instanceof Class) {
+ return getConversionExecutor(sourceClass, (Class) targetType);
+ } else {
Assert.isInstanceOf(Converter.class, targetType, "Not a converter: ");
- Converter conv = (Converter)targetType;
+ Converter conv = (Converter) targetType;
return new ConversionExecutor(sourceClass, Object.class, conv);
}
}
@@ -195,23 +184,22 @@ public class GenericConversionService implements ConversionService {
if (parent != null) {
// use the parent
return parent.getConversionExecutorsForSource(sourceClass);
- }
- else {
+ } else {
// no converters for source class
return new ConversionExecutor[0];
}
- }
- else {
+ } else {
Set executors = new HashSet();
if (parent != null) {
executors.addAll(Arrays.asList(parent.getConversionExecutorsForSource(sourceClass)));
}
Iterator it = sourceTargetConverters.entrySet().iterator();
while (it.hasNext()) {
- Map.Entry entry = (Map.Entry)it.next();
- executors.add(new ConversionExecutor(sourceClass, (Class)entry.getKey(), (Converter)entry.getValue()));
+ Map.Entry entry = (Map.Entry) it.next();
+ executors
+ .add(new ConversionExecutor(sourceClass, (Class) entry.getKey(), (Converter) entry.getValue()));
}
- return (ConversionExecutor[])executors.toArray(new ConversionExecutor[executors.size()]);
+ return (ConversionExecutor[]) executors.toArray(new ConversionExecutor[executors.size()]);
}
}
@@ -220,28 +208,26 @@ public class GenericConversionService implements ConversionService {
Object clazz = aliasMap.get(alias);
if (clazz != null) {
Assert.isInstanceOf(Class.class, clazz, "Not a Class alias '" + alias + "': ");
- return (Class)clazz;
- }
- else {
+ return (Class) clazz;
+ } else {
if (parent != null) {
- // try parent service
- return parent.getClassByAlias(alias);
- }
- else {
+ // try parent service
+ return parent.getClassByAlias(alias);
+ } else {
// alias does not index a class, return null
return null;
}
}
}
-
+
// internal helpers
private Map findConvertersForSource(Class sourceClass) {
LinkedList classQueue = new LinkedList();
classQueue.addFirst(sourceClass);
while (!classQueue.isEmpty()) {
- sourceClass = (Class)classQueue.removeLast();
- Map sourceTargetConverters = (Map)sourceClassConverters.get(sourceClass);
+ sourceClass = (Class) classQueue.removeLast();
+ Map sourceTargetConverters = (Map) sourceClassConverters.get(sourceClass);
if (sourceTargetConverters != null && !sourceTargetConverters.isEmpty()) {
return sourceTargetConverters;
}
@@ -261,8 +247,8 @@ public class GenericConversionService implements ConversionService {
LinkedList classQueue = new LinkedList();
classQueue.addFirst(targetClass);
while (!classQueue.isEmpty()) {
- targetClass = (Class)classQueue.removeLast();
- Converter converter = (Converter)sourceTargetConverters.get(targetClass);
+ targetClass = (Class) classQueue.removeLast();
+ Converter converter = (Converter) sourceTargetConverters.get(targetClass);
if (converter != null) {
return converter;
}
@@ -277,13 +263,12 @@ public class GenericConversionService implements ConversionService {
}
return null;
}
-
+
// subclassing support
/**
- * Returns an indexed map of converters. Each entry key is a source class that
- * can be converted from, and each entry value is a map of target classes that
- * can be convertered to, ultimately mapping to a specific converter that can
+ * Returns an indexed map of converters. Each entry key is a source class that can be converted from, and each entry
+ * value is a map of target classes that can be convertered to, ultimately mapping to a specific converter that can
* perform the source->target conversion.
*/
protected Map getSourceClassConverters() {
@@ -291,8 +276,8 @@ public class GenericConversionService implements ConversionService {
}
/**
- * Returns a map of known aliases. Each entry key is a String alias and the
- * associated value is either a target class or a converter.
+ * Returns a map of known aliases. Each entry key is a String alias and the associated value is either a target
+ * class or a converter.
*/
protected Map getAliasMap() {
return aliasMap;
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToBoolean.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToBoolean.java
index 0c2d5b9e..459cd1e1 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToBoolean.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToBoolean.java
@@ -19,8 +19,7 @@ import org.springframework.binding.convert.ConversionContext;
import org.springframework.util.StringUtils;
/**
- * Converts a textual representation of a boolean object to a Boolean
- * instance.
+ * Converts a textual representation of a boolean object to a Boolean instance.
*
* @author Keith Donald
*/
@@ -54,8 +53,8 @@ public class TextToBoolean extends AbstractConverter {
}
/**
- * Create a text to boolean converter. Take given special string representations
- * of true and false into account.
+ * Create a text to boolean converter. Take given special string representations of true and false into
+ * account.
* @param trueString special true string to consider
* @param falseString special false string to consider
*/
@@ -73,27 +72,22 @@ public class TextToBoolean extends AbstractConverter {
}
protected Object doConvert(Object source, Class targetClass, ConversionContext context) throws Exception {
- String text = (String)source;
+ String text = (String) source;
if (!StringUtils.hasText(text)) {
return null;
- }
- else if (this.trueString != null && text.equalsIgnoreCase(this.trueString)) {
+ } else if (this.trueString != null && text.equalsIgnoreCase(this.trueString)) {
return Boolean.TRUE;
- }
- else if (this.falseString != null && text.equalsIgnoreCase(this.falseString)) {
+ } else if (this.falseString != null && text.equalsIgnoreCase(this.falseString)) {
return Boolean.FALSE;
- }
- else if (this.trueString == null
+ } else if (this.trueString == null
&& (text.equalsIgnoreCase(VALUE_TRUE) || text.equalsIgnoreCase(VALUE_ON)
|| text.equalsIgnoreCase(VALUE_YES) || text.equals(VALUE_1))) {
return Boolean.TRUE;
- }
- else if (this.falseString == null
+ } else if (this.falseString == null
&& (text.equalsIgnoreCase(VALUE_FALSE) || text.equalsIgnoreCase(VALUE_OFF)
|| text.equalsIgnoreCase(VALUE_NO) || text.equals(VALUE_0))) {
return Boolean.FALSE;
- }
- else {
+ } else {
throw new IllegalArgumentException("Invalid boolean value [" + text + "]");
}
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToClass.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToClass.java
index ad0e7e89..6576c2e8 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToClass.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToClass.java
@@ -21,8 +21,7 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
- * Converts a textual representation of a class object to a Class
- * instance.
+ * Converts a textual representation of a class object to a Class instance.
*
* @author Keith Donald
*/
@@ -41,19 +40,17 @@ public class TextToClass extends ConversionServiceAwareConverter {
}
protected Object doConvert(Object source, Class targetClass, ConversionContext context) throws Exception {
- String text = (String)source;
+ String text = (String) source;
if (StringUtils.hasText(text)) {
String classNameOrAlias = text.trim();
if (classNameOrAlias.startsWith(CLASS_PREFIX)) {
return ClassUtils.forName(text.substring(CLASS_PREFIX.length()));
- }
- else if (classNameOrAlias.startsWith(ALIAS_PREFIX)) {
+ } else if (classNameOrAlias.startsWith(ALIAS_PREFIX)) {
String alias = text.substring(ALIAS_PREFIX.length());
Class clazz = getConversionService().getClassByAlias(alias);
Assert.notNull(clazz, "No class found associated with type alias '" + alias + "'");
return clazz;
- }
- else {
+ } else {
// try first an aliased based lookup
if (getConversionService() != null) {
Class aliasedClass = getConversionService().getClassByAlias(classNameOrAlias);
@@ -64,8 +61,7 @@ public class TextToClass extends ConversionServiceAwareConverter {
// treat as a class name
return ClassUtils.forName(classNameOrAlias);
}
- }
- else {
+ } else {
return null;
}
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToExpression.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToExpression.java
index c632d1ad..311d3d36 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToExpression.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToExpression.java
@@ -62,11 +62,10 @@ public class TextToExpression extends AbstractConverter {
}
protected Object doConvert(Object source, Class targetClass, ConversionContext context) throws Exception {
- String expressionString = (String)source;
+ String expressionString = (String) source;
if (getExpressionParser().isDelimitedExpression(expressionString)) {
- return getExpressionParser().parseExpression((String)source);
- }
- else {
+ return getExpressionParser().parseExpression((String) source);
+ } else {
return new StaticExpression(expressionString);
}
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToLabeledEnum.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToLabeledEnum.java
index 441f86ad..cebaaef3 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToLabeledEnum.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToLabeledEnum.java
@@ -20,8 +20,7 @@ import org.springframework.binding.format.support.LabeledEnumFormatter;
import org.springframework.core.enums.LabeledEnum;
/**
- * Converter that converts textual representations of enum
- * instances to a specific instance of LabeledEnum.
+ * Converter that converts textual representations of enum instances to a specific instance of LabeledEnum.
*
* @author Keith Donald
*/
@@ -38,6 +37,6 @@ public class TextToLabeledEnum extends AbstractConverter {
}
protected Object doConvert(Object source, Class targetClass, ConversionContext context) throws Exception {
- return labeledEnumFormatter.parseValue((String)source, targetClass);
+ return labeledEnumFormatter.parseValue((String) source, targetClass);
}
}
\ No newline at end of file
diff --git a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToNumber.java b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToNumber.java
index 050a06eb..9f67a642 100644
--- a/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToNumber.java
+++ b/spring-binding/src/main/java/org/springframework/binding/convert/support/TextToNumber.java
@@ -23,8 +23,8 @@ import org.springframework.binding.format.FormatterFactory;
import org.springframework.binding.format.support.SimpleFormatterFactory;
/**
- * Converts textual representations of numbers to a Number
- * specialization. Delegates to a synchronized formatter to parse text strings.
+ * Converts textual representations of numbers to a Number specialization. Delegates to a synchronized
+ * formatter to parse text strings.
*
* @author Keith Donald
*/
@@ -55,6 +55,6 @@ public class TextToNumber extends AbstractFormattingConverter {
}
protected Object doConvert(Object source, Class targetClass, ConversionContext context) throws Exception {
- return getFormatterFactory().getNumberFormatter(targetClass).parseValue((String)source, targetClass);
+ return getFormatterFactory().getNumberFormatter(targetClass).parseValue((String) source, targetClass);
}
}
\ No newline at end of file
diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationAttempt.java b/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationAttempt.java
index d011e73d..f2a50bc3 100644
--- a/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationAttempt.java
+++ b/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationAttempt.java
@@ -77,7 +77,6 @@ public class EvaluationAttempt {
}
protected ToStringCreator createToString(ToStringCreator creator) {
- return creator.append("expression", expression).append("target", target).append("context",
- context);
+ return creator.append("expression", expression).append("target", target).append("context", context);
}
}
\ No newline at end of file
diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationContext.java b/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationContext.java
index dcd2c972..26231287 100644
--- a/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationContext.java
+++ b/spring-binding/src/main/java/org/springframework/binding/expression/EvaluationContext.java
@@ -20,10 +20,8 @@ import java.util.Map;
/**
* A context object with two main responsibities:
*
- * IMPLEMENTATION NOTE: Ognl 2.6.7 expression objects do not respect equality
- * properly, so the equality operations defined within this class do not
- * function properly.
+ * IMPLEMENTATION NOTE: Ognl 2.6.7 expression objects do not respect equality properly, so the equality operations
+ * defined within this class do not function properly.
*
* @author Keith Donald
*/
@@ -71,14 +70,12 @@ class OgnlExpression implements SettableExpression {
Map contextAttributes = (context != null ? context.getAttributes() : Collections.EMPTY_MAP);
try {
return Ognl.getValue(expression, contextAttributes, target);
- }
- catch (OgnlException e) {
+ } catch (OgnlException e) {
if (e.getReason() != null && e.getReason() != e) {
// unwrap the OgnlException since the actual exception is wrapped inside it
// and there is not generic (getCause) way to get to it later on
throw new EvaluationException(new EvaluationAttempt(this, target, context), e.getReason());
- }
- else {
+ } else {
throw new EvaluationException(new EvaluationAttempt(this, target, context), e);
}
}
@@ -89,8 +86,7 @@ class OgnlExpression implements SettableExpression {
Map contextAttributes = (context != null ? context.getAttributes() : Collections.EMPTY_MAP);
try {
Ognl.setValue(expression, contextAttributes, target, value);
- }
- catch (OgnlException e) {
+ } catch (OgnlException e) {
throw new EvaluationException(new SetValueAttempt(this, target, value, context), e);
}
}
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 5b21dfe6..195e08e5 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
@@ -39,8 +39,7 @@ public class OgnlExpressionParser extends AbstractExpressionParser {
public SettableExpression doParseSettableExpression(String expressionString) throws ParserException {
try {
return new OgnlExpression(Ognl.parseExpression(expressionString));
- }
- catch (OgnlException e) {
+ } catch (OgnlException e) {
throw new ParserException(expressionString, e);
}
}
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 a5a21bb3..e2cddb83 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
@@ -91,12 +91,10 @@ public abstract class AbstractExpressionParser implements ExpressionParser {
int suffixIndex = expressionString.indexOf(getExpressionSuffix(), prefixIndex);
if (suffixIndex == -1) {
return false;
- }
- else {
+ } else {
if (suffixIndex == prefixIndex + getExpressionPrefix().length()) {
return false;
- }
- else {
+ } else {
return true;
}
}
@@ -106,30 +104,27 @@ public abstract class AbstractExpressionParser implements ExpressionParser {
Expression[] expressions = parseExpressions(expressionString);
if (expressions.length == 1) {
return expressions[0];
- }
- else {
+ } else {
return new CompositeStringExpression(expressions);
}
}
- public final SettableExpression parseSettableExpression(String expressionString)
- throws ParserException, UnsupportedOperationException {
+ public final SettableExpression parseSettableExpression(String expressionString) throws ParserException,
+ UnsupportedOperationException {
expressionString = expressionString.trim();
// a settable expression should just be a single expression
if (expressionString.startsWith(getExpressionPrefix()) && expressionString.endsWith(getExpressionSuffix())) {
- expressionString = expressionString.substring(getExpressionPrefix().length(),
- expressionString.length() - getExpressionSuffix().length());
+ expressionString = expressionString.substring(getExpressionPrefix().length(), expressionString.length()
+ - getExpressionSuffix().length());
}
return doParseSettableExpression(expressionString);
}
/**
- * Helper that parses given expression string using the configured parser.
- * The expression string can contain any number of expressions all contained
- * in "${...}" markers. For instance: "foo${expr0}bar${expr1}". The static
- * pieces of text will also be returned as Expressions that just return that
- * static piece of text. As a result, evaluating all returned expressions
- * and concatenating the results produces the complete evaluated string.
+ * Helper that parses given expression string using the configured parser. The expression string can contain any
+ * number of expressions all contained in "${...}" markers. For instance: "foo${expr0}bar${expr1}". The static
+ * pieces of text will also be returned as Expressions that just return that static piece of text. As a result,
+ * evaluating all returned expressions and concatenating the results produces the complete evaluated string.
* @param expressionString the expression string
* @return the parsed expressions
* @throws ParserException when the expressions cannot be parsed
@@ -146,74 +141,64 @@ public abstract class AbstractExpressionParser implements ExpressionParser {
expressions.add(new StaticExpression(expressionString.substring(startIdx, prefixIndex)));
startIdx = prefixIndex;
}
- int nextPrefixIndex = expressionString.indexOf(getExpressionPrefix(),
- prefixIndex + getExpressionPrefix().length());
+ int nextPrefixIndex = expressionString.indexOf(getExpressionPrefix(), prefixIndex
+ + getExpressionPrefix().length());
int suffixIndex;
- if (nextPrefixIndex == -1) {
+ if (nextPrefixIndex == -1) {
// this is the last expression in the expression string
- suffixIndex = expressionString.lastIndexOf(getExpressionSuffix());
- }
- else {
+ suffixIndex = expressionString.lastIndexOf(getExpressionSuffix());
+ } else {
// another expression exists after this one in the expression string
- suffixIndex = expressionString.lastIndexOf(getExpressionSuffix(), nextPrefixIndex);
- }
+ suffixIndex = expressionString.lastIndexOf(getExpressionSuffix(), nextPrefixIndex);
+ }
if (suffixIndex < (prefixIndex + getExpressionPrefix().length())) {
throw new ParserException(expressionString, "No ending suffix '" + getExpressionSuffix()
+ "' for expression starting at character " + prefixIndex + ": "
+ expressionString.substring(prefixIndex), null);
- }
- else if (suffixIndex == prefixIndex + getExpressionPrefix().length()) {
+ } else if (suffixIndex == prefixIndex + getExpressionPrefix().length()) {
throw new ParserException(expressionString, "No expression defined within delimiter '"
- + getExpressionPrefix() + getExpressionSuffix() + "' at character " + prefixIndex,
- null);
- }
- else {
+ + getExpressionPrefix() + getExpressionSuffix() + "' at character " + prefixIndex, null);
+ } else {
String expr = expressionString.substring(prefixIndex + getExpressionPrefix().length(),
suffixIndex);
expressions.add(doParseExpression(expr));
startIdx = suffixIndex + 1;
}
- }
- else {
+ } else {
if (startIdx == 0) {
// treat entire string as one expression
expressions.add(doParseExpression(expressionString));
- }
- else {
+ } else {
// no more ${expressions} found in string
expressions.add(new StaticExpression(expressionString.substring(startIdx)));
}
startIdx = expressionString.length();
}
}
- }
- else {
+ } else {
expressions.add(new StaticExpression(expressionString));
}
return (Expression[]) expressions.toArray(new Expression[expressions.size()]);
}
-
+
// template methods
/**
- * Template method for parsing a filtered expression string. Subclasses should
- * override.
+ * Template method for parsing a filtered expression string. Subclasses should override.
* @param expressionString the expression string
* @return the parsed expression
* @throws ParserException an exception occured during parsing
*/
protected abstract Expression doParseExpression(String expressionString) throws ParserException;
-
+
/**
- * Template method for parsing a filtered settable expression string. Subclasses
- * should override.
+ * Template method for parsing a filtered settable expression string. Subclasses should override.
* @param expressionString the expression string
* @return the parsed expression
* @throws ParserException an exception occured during parsing
- * @throws UnsupportedOperationException this parser does not support
- * settable expressions
+ * @throws UnsupportedOperationException this parser does not support settable expressions
*/
- protected abstract SettableExpression doParseSettableExpression(String expressionString)
- throws ParserException, UnsupportedOperationException;
+ protected abstract SettableExpression doParseSettableExpression(String expressionString) throws ParserException,
+ UnsupportedOperationException;
}
\ No newline at end of file
diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/BeanWrapperExpression.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/BeanWrapperExpression.java
index 170be0c3..1e67ed4c 100644
--- a/spring-binding/src/main/java/org/springframework/binding/expression/support/BeanWrapperExpression.java
+++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/BeanWrapperExpression.java
@@ -48,15 +48,14 @@ class BeanWrapperExpression implements SettableExpression {
if (!(o instanceof BeanWrapperExpression)) {
return false;
}
- BeanWrapperExpression other = (BeanWrapperExpression)o;
+ BeanWrapperExpression other = (BeanWrapperExpression) o;
return expression.equals(other.expression);
}
public Object evaluate(Object target, EvaluationContext context) throws EvaluationException {
try {
return new BeanWrapperImpl(target).getPropertyValue(expression);
- }
- catch (BeansException e) {
+ } catch (BeansException e) {
throw new EvaluationException(new EvaluationAttempt(this, target, context), e);
}
}
@@ -65,8 +64,7 @@ class BeanWrapperExpression implements SettableExpression {
try {
Assert.notNull(target, "The target object to evaluate is required");
new BeanWrapperImpl(target).setPropertyValue(expression, value);
- }
- catch (BeansException e) {
+ } catch (BeansException e) {
throw new EvaluationException(new SetValueAttempt(this, target, value, context), e);
}
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/expression/support/BeanWrapperExpressionParser.java b/spring-binding/src/main/java/org/springframework/binding/expression/support/BeanWrapperExpressionParser.java
index abea91ff..bd4f6b96 100644
--- a/spring-binding/src/main/java/org/springframework/binding/expression/support/BeanWrapperExpressionParser.java
+++ b/spring-binding/src/main/java/org/springframework/binding/expression/support/BeanWrapperExpressionParser.java
@@ -25,7 +25,7 @@ import org.springframework.binding.expression.SettableExpression;
* @author Keith Donald
*/
public class BeanWrapperExpressionParser extends AbstractExpressionParser {
-
+
protected Expression doParseExpression(String expressionString) throws ParserException {
return doParseSettableExpression(expressionString);
}
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 82d206f1..e18136a6 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
@@ -27,7 +27,7 @@ import org.springframework.util.Assert;
/**
* A settable expression that adds non-null values to a collection.
- *
+ *
* @author Keith Donald
*/
public class CollectionAddingExpression implements SettableExpression {
@@ -52,13 +52,13 @@ public class CollectionAddingExpression implements SettableExpression {
public void evaluateToSet(Object target, Object value, EvaluationContext context) throws EvaluationException {
Object result = evaluate(target, context);
if (result == null) {
- throw new EvaluationException(new SetValueAttempt(this, target, value, null),
- new IllegalArgumentException("The collection expression evaluated to a [null] reference"));
+ throw new EvaluationException(new SetValueAttempt(this, target, value, null), new IllegalArgumentException(
+ "The collection expression evaluated to a [null] reference"));
}
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);
}
}
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 3070894c..89ce2581 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
@@ -34,8 +34,8 @@ public class CompositeStringExpression implements Expression {
/**
* Creates a new composite string expression.
- * @param expressions the ordered set of expressions that when evaluated
- * will have their results stringed together to build the composite string
+ * @param expressions the ordered set of expressions that when evaluated will have their results stringed together
+ * to build the composite string
*/
public CompositeStringExpression(Expression[] expressions) {
this.expressions = expressions;
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 dec94e9e..7ed9bdf9 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
@@ -21,8 +21,7 @@ import org.springframework.binding.expression.Expression;
import org.springframework.util.ObjectUtils;
/**
- * A simple expression evaluator that just returns a fixed result on each
- * evaluation.
+ * A simple expression evaluator that just returns a fixed result on each evaluation.
*
* @author Keith Donald
*/
@@ -44,8 +43,7 @@ public class StaticExpression implements Expression {
public int hashCode() {
if (value == null) {
return 0;
- }
- else {
+ } else {
return value.hashCode();
}
}
@@ -54,7 +52,7 @@ public class StaticExpression implements Expression {
if (!(o instanceof StaticExpression)) {
return false;
}
- StaticExpression other = (StaticExpression)o;
+ StaticExpression other = (StaticExpression) o;
return ObjectUtils.nullSafeEquals(value, other.value);
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/Formatter.java b/spring-binding/src/main/java/org/springframework/binding/format/Formatter.java
index e3db0db6..b77fa088 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/Formatter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/Formatter.java
@@ -16,8 +16,7 @@
package org.springframework.binding.format;
/**
- * A lightweight interface for formatting a value and parsing a value from its
- * formatted form.
+ * A lightweight interface for formatting a value and parsing a value from its formatted form.
*
* @author Keith Donald
*/
@@ -32,8 +31,7 @@ public interface Formatter {
public String formatValue(Object value) throws IllegalArgumentException;
/**
- * Parse the formatted string representation of a value, restoring the
- * value.
+ * Parse the formatted string representation of a value, restoring the value.
* @param formattedString the formatted string representation
* @param targetClass the target class to convert the formatted value to
* @return the parsed value
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/FormatterFactory.java b/spring-binding/src/main/java/org/springframework/binding/format/FormatterFactory.java
index 7a2cb209..76618e8c 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/FormatterFactory.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/FormatterFactory.java
@@ -18,9 +18,8 @@ package org.springframework.binding.format;
/**
* Source for shared and commonly used Formatters.
*
- * Formatters are typically not thread safe as Format objects
- * aren't thread safe: so implementations of this service should take care to
- * synchronize them as neccessary.
+ * Formatters are typically not thread safe as Format objects aren't thread safe: so implementations of
+ * this service should take care to synchronize them as neccessary.
*
* @see java.text.Format
*
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/InvalidFormatException.java b/spring-binding/src/main/java/org/springframework/binding/format/InvalidFormatException.java
index e6c61b11..23643ade 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/InvalidFormatException.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/InvalidFormatException.java
@@ -44,7 +44,8 @@ public class InvalidFormatException extends NestedRuntimeException {
* @param cause the underlying cause of this exception
*/
public InvalidFormatException(String invalidValue, String expectedFormat, Throwable cause) {
- super("Invalid format for value '" + invalidValue + "'; the expected format was '" + expectedFormat + "'", cause);
+ super("Invalid format for value '" + invalidValue + "'; the expected format was '" + expectedFormat + "'",
+ cause);
this.invalidValue = invalidValue;
this.expectedFormat = expectedFormat;
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/support/AbstractFormatter.java b/spring-binding/src/main/java/org/springframework/binding/format/support/AbstractFormatter.java
index df4327b8..cc0294e1 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/support/AbstractFormatter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/support/AbstractFormatter.java
@@ -62,18 +62,16 @@ public abstract class AbstractFormatter implements Formatter {
Assert.isTrue(!isEmpty(value), "Object to format cannot be empty");
return doFormatValue(value);
}
-
+
/**
- * Template method subclasses should override to encapsulate formatting
- * logic.
+ * Template method subclasses should override to encapsulate formatting logic.
* @param value the value to format
* @return the formatted string representation
*/
protected abstract String doFormatValue(Object value);
/**
- * Returns the formatted form of an empty value. Default implementation
- * just returns the empty string.
+ * Returns the formatted form of an empty value. Default implementation just returns the empty string.
*/
protected String getEmptyFormattedValue() {
return "";
@@ -85,8 +83,7 @@ public abstract class AbstractFormatter implements Formatter {
return getEmptyValue();
}
return doParseValue(formattedString, targetClass);
- }
- catch (ParseException ex) {
+ } catch (ParseException ex) {
throw new InvalidFormatException(formattedString, getExpectedFormat(targetClass), ex);
}
}
@@ -102,16 +99,15 @@ public abstract class AbstractFormatter implements Formatter {
ParseException;
/**
- * Returns the empty value (resulting from parsing an empty input string).
- * This default implementation just returns null.
+ * Returns the empty value (resulting from parsing an empty input string). This default implementation just returns
+ * null.
*/
protected Object getEmptyValue() {
return null;
}
/**
- * Returns the expected string format for the given target class.
- * The default implementation just returns null.
+ * Returns the expected string format for the given target class. The default implementation just returns null.
*/
protected String getExpectedFormat(Class targetClass) {
return null;
@@ -123,11 +119,9 @@ public abstract class AbstractFormatter implements Formatter {
protected boolean isEmpty(Object o) {
if (o == null) {
return true;
- }
- else if (o instanceof String) {
- return !StringUtils.hasText((String)o);
- }
- else {
+ } else if (o instanceof String) {
+ return !StringUtils.hasText((String) o);
+ } else {
return false;
}
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/support/AbstractFormatterFactory.java b/spring-binding/src/main/java/org/springframework/binding/format/support/AbstractFormatterFactory.java
index 23a585d9..165e35fa 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/support/AbstractFormatterFactory.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/support/AbstractFormatterFactory.java
@@ -24,8 +24,8 @@ import org.springframework.context.i18n.LocaleContext;
import org.springframework.context.i18n.SimpleLocaleContext;
/**
- * Base class for formatter factories. Manages the locale used by the produced
- * formatters using Spring's {@link org.springframework.context.i18n.LocaleContext} system.
+ * Base class for formatter factories. Manages the locale used by the produced formatters using Spring's
+ * {@link org.springframework.context.i18n.LocaleContext} system.
*
* @author Keith Donald
*/
@@ -38,8 +38,7 @@ public abstract class AbstractFormatterFactory implements FormatterFactory {
private Style defaultTimeStyle = Style.MEDIUM;
/**
- * Sets the locale context used. Defaults to a {@link SimpleLocaleContext} holding
- * the system default locale.
+ * Sets the locale context used. Defaults to a {@link SimpleLocaleContext} holding the system default locale.
*/
public void setLocaleContext(LocaleContext localeContext) {
this.localeContext = localeContext;
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/support/DateFormatter.java b/spring-binding/src/main/java/org/springframework/binding/format/support/DateFormatter.java
index f094beca..7c938a38 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/support/DateFormatter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/support/DateFormatter.java
@@ -31,8 +31,7 @@ public class DateFormatter extends AbstractFormatter {
private DateFormat dateFormat;
/**
- * Constructs a date formatter that will delegate to the specified date
- * format.
+ * Constructs a date formatter that will delegate to the specified date format.
* @param dateFormat the date format to use
*/
public DateFormatter(DateFormat dateFormat) {
@@ -40,8 +39,7 @@ public class DateFormatter extends AbstractFormatter {
}
/**
- * Constructs a date formatter that will delegate to the specified date
- * format.
+ * Constructs a date formatter that will delegate to the specified date format.
* @param dateFormat the date format to use
* @param allowEmpty should this formatter allow empty input arguments?
*/
@@ -52,7 +50,7 @@ public class DateFormatter extends AbstractFormatter {
// convert from date to string
protected String doFormatValue(Object date) {
- return dateFormat.format((Date)date);
+ return dateFormat.format((Date) date);
}
// convert back from string to date
@@ -64,6 +62,6 @@ public class DateFormatter extends AbstractFormatter {
* Convenience method to parse a date.
*/
public Date parseDate(String formattedString) throws InvalidFormatException {
- return (Date)parseValue(formattedString, Date.class);
+ return (Date) parseValue(formattedString, Date.class);
}
}
\ No newline at end of file
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/support/LabeledEnumFormatter.java b/spring-binding/src/main/java/org/springframework/binding/format/support/LabeledEnumFormatter.java
index a2f1cb45..c148226c 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/support/LabeledEnumFormatter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/support/LabeledEnumFormatter.java
@@ -53,7 +53,7 @@ public class LabeledEnumFormatter extends AbstractFormatter {
}
protected String doFormatValue(Object value) {
- LabeledEnum labeledEnum = (LabeledEnum)value;
+ LabeledEnum labeledEnum = (LabeledEnum) value;
return labeledEnum.getLabel();
}
@@ -71,6 +71,6 @@ public class LabeledEnumFormatter extends AbstractFormatter {
* Convenience method to parse a LabeledEnum.
*/
public LabeledEnum parseLabeledEnum(String formattedString, Class enumClass) throws InvalidFormatException {
- return (LabeledEnum)parseValue(formattedString, enumClass);
+ return (LabeledEnum) parseValue(formattedString, enumClass);
}
}
\ No newline at end of file
diff --git a/spring-binding/src/main/java/org/springframework/binding/format/support/NumberFormatter.java b/spring-binding/src/main/java/org/springframework/binding/format/support/NumberFormatter.java
index 59a110eb..d1d78565 100644
--- a/spring-binding/src/main/java/org/springframework/binding/format/support/NumberFormatter.java
+++ b/spring-binding/src/main/java/org/springframework/binding/format/support/NumberFormatter.java
@@ -23,18 +23,17 @@ import org.springframework.binding.format.InvalidFormatException;
import org.springframework.util.NumberUtils;
/**
- * Converts from various Number specializations to
- * String and back.
+ * Converts from various Number specializations to String and back.
*
* @author Keith Donald
*/
public class NumberFormatter extends AbstractFormatter {
private NumberFormat numberFormat;
-
+
/**
- * Default constructor. The formatter will use "toString" when formatting
- * a value and "valueOf" when parsing a value.
+ * Default constructor. The formatter will use "toString" when formatting a value and "valueOf" when parsing a
+ * value.
*/
public NumberFormatter() {
}
@@ -61,8 +60,7 @@ public class NumberFormatter extends AbstractFormatter {
if (this.numberFormat != null) {
// use NumberFormat for rendering value
return this.numberFormat.format(number);
- }
- else {
+ } else {
// use toString method for rendering value
return number.toString();
}
@@ -78,38 +76,38 @@ public class NumberFormatter extends AbstractFormatter {
return NumberUtils.parseNumber(text, targetClass);
}
}
-
+
// convenience methods
public Byte parseByte(String formattedString) throws InvalidFormatException {
- return (Byte)parseValue(formattedString, Byte.class);
+ return (Byte) parseValue(formattedString, Byte.class);
}
public Short parseShort(String formattedString) throws InvalidFormatException {
- return (Short)parseValue(formattedString, Short.class);
+ return (Short) parseValue(formattedString, Short.class);
}
public Integer parseInteger(String formattedString) throws InvalidFormatException {
- return (Integer)parseValue(formattedString, Integer.class);
+ return (Integer) parseValue(formattedString, Integer.class);
}
public Long parseLong(String formattedString) throws InvalidFormatException {
- return (Long)parseValue(formattedString, Long.class);
+ return (Long) parseValue(formattedString, Long.class);
}
public Float parseFloat(String formattedString) throws InvalidFormatException {
- return (Float)parseValue(formattedString, Float.class);
+ return (Float) parseValue(formattedString, Float.class);
}
public Double parseDouble(String formattedString) throws InvalidFormatException {
- return (Double)parseValue(formattedString, Double.class);
+ return (Double) parseValue(formattedString, Double.class);
}
public BigInteger parseBigInteger(String formattedString) throws InvalidFormatException {
- return (BigInteger)parseValue(formattedString, BigInteger.class);
+ return (BigInteger) parseValue(formattedString, BigInteger.class);
}
-
+
public BigDecimal parseBigDecimal(String formattedString) throws InvalidFormatException {
- return (BigDecimal)parseValue(formattedString, BigDecimal.class);
+ return (BigDecimal) parseValue(formattedString, BigDecimal.class);
}
}
\ No newline at end of file
diff --git a/spring-binding/src/main/java/org/springframework/binding/mapping/AttributeMapper.java b/spring-binding/src/main/java/org/springframework/binding/mapping/AttributeMapper.java
index cba73828..89af6730 100644
--- a/spring-binding/src/main/java/org/springframework/binding/mapping/AttributeMapper.java
+++ b/spring-binding/src/main/java/org/springframework/binding/mapping/AttributeMapper.java
@@ -18,9 +18,8 @@ package org.springframework.binding.mapping;
/**
* A lightweight service interface for mapping between two attribute sources.
*
- * Implementations of this interface are expected to encapsulate the mapping
- * configuration information as well as the logic to act on it to perform
- * mapping between a given source and target attribute source.
+ * Implementations of this interface are expected to encapsulate the mapping configuration information as well as the
+ * logic to act on it to perform mapping between a given source and target attribute source.
*
* @author Keith Donald
*/
diff --git a/spring-binding/src/main/java/org/springframework/binding/mapping/DefaultAttributeMapper.java b/spring-binding/src/main/java/org/springframework/binding/mapping/DefaultAttributeMapper.java
index b054036a..5de07f65 100644
--- a/spring-binding/src/main/java/org/springframework/binding/mapping/DefaultAttributeMapper.java
+++ b/spring-binding/src/main/java/org/springframework/binding/mapping/DefaultAttributeMapper.java
@@ -23,8 +23,7 @@ import java.util.List;
import org.springframework.core.style.ToStringCreator;
/**
- * Generic attributes mapper implementation that allows mappings to be
- * configured programatically.
+ * Generic attributes mapper implementation that allows mappings to be configured programatically.
*
* @author Erwin Vervaet
* @author Keith Donald
@@ -49,7 +48,7 @@ public class DefaultAttributeMapper implements AttributeMapper {
/**
* Add a set of mappings.
- * @param mappings the mappings
+ * @param mappings the mappings
*/
public void addMappings(AttributeMapper[] mappings) {
if (mappings == null) {
@@ -63,14 +62,14 @@ public class DefaultAttributeMapper implements AttributeMapper {
* @return the list of mappings
*/
public AttributeMapper[] getMappings() {
- return (AttributeMapper[])mappings.toArray(new AttributeMapper[mappings.size()]);
+ return (AttributeMapper[]) mappings.toArray(new AttributeMapper[mappings.size()]);
}
public void map(Object source, Object target, MappingContext context) {
if (mappings != null) {
Iterator it = mappings.iterator();
while (it.hasNext()) {
- AttributeMapper mapping = (AttributeMapper)it.next();
+ AttributeMapper mapping = (AttributeMapper) it.next();
mapping.map(source, target, context);
}
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/mapping/Mapping.java b/spring-binding/src/main/java/org/springframework/binding/mapping/Mapping.java
index 13926ace..c58db23b 100644
--- a/spring-binding/src/main/java/org/springframework/binding/mapping/Mapping.java
+++ b/spring-binding/src/main/java/org/springframework/binding/mapping/Mapping.java
@@ -24,10 +24,8 @@ import org.springframework.core.style.ToStringCreator;
import org.springframework.util.Assert;
/**
- * A single mapping definition, encapulating the information neccessary to map
- * the result of evaluating an expression on a source object to a property on a
- * target object, optionally applying a type conversion during the mapping
- * process.
+ * A single mapping definition, encapulating the information neccessary to map the result of evaluating an expression on
+ * a source object to a property on a target object, optionally applying a type conversion during the mapping process.
*
* @author Keith Donald
*/
@@ -51,8 +49,7 @@ public class Mapping implements AttributeMapper {
private final ConversionExecutor typeConverter;
/**
- * Whether or not this is a required mapping; if true, the source expression
- * must return a non-null value.
+ * Whether or not this is a required mapping; if true, the source expression must return a non-null value.
*/
private boolean required;
@@ -62,8 +59,7 @@ public class Mapping implements AttributeMapper {
* @param targetExpression the target expression
* @param typeConverter a type converter
*/
- public Mapping(Expression sourceExpression, SettableExpression targetExpression,
- ConversionExecutor typeConverter) {
+ public Mapping(Expression sourceExpression, SettableExpression targetExpression, ConversionExecutor typeConverter) {
this(sourceExpression, targetExpression, typeConverter, false);
}
@@ -85,9 +81,8 @@ public class Mapping implements AttributeMapper {
}
/**
- * Map the sourceAttribute in to the
- * targetAttribute target map, performing type conversion if
- * necessary.
+ * Map the sourceAttribute in to the targetAttribute target map, performing type
+ * conversion if necessary.
* @param source The source data structure
* @param target The target data structure
*/
@@ -99,8 +94,7 @@ public class Mapping implements AttributeMapper {
throw new RequiredMappingException("This mapping is required; evaluation of expression '"
+ sourceExpression + "' against source of type [" + source.getClass()
+ "] must return a non-null value");
- }
- else {
+ } else {
// source expression returned no value, simply abort mapping
return;
}
@@ -121,9 +115,8 @@ public class Mapping implements AttributeMapper {
if (!(o instanceof Mapping)) {
return false;
}
- Mapping other = (Mapping)o;
- return sourceExpression.equals(other.sourceExpression)
- && targetExpression.equals(other.targetExpression);
+ Mapping other = (Mapping) o;
+ return sourceExpression.equals(other.sourceExpression) && targetExpression.equals(other.targetExpression);
}
public int hashCode() {
diff --git a/spring-binding/src/main/java/org/springframework/binding/mapping/MappingBuilder.java b/spring-binding/src/main/java/org/springframework/binding/mapping/MappingBuilder.java
index a7cd3f8b..6d836956 100644
--- a/spring-binding/src/main/java/org/springframework/binding/mapping/MappingBuilder.java
+++ b/spring-binding/src/main/java/org/springframework/binding/mapping/MappingBuilder.java
@@ -25,8 +25,8 @@ import org.springframework.binding.expression.support.CollectionAddingExpression
import org.springframework.util.Assert;
/**
- * A stateful builder that builds {@link Mapping} objects. Designed for
- * convenience to build mappings in a clear, readable manner.
+ * A stateful builder that builds {@link Mapping} objects. Designed for convenience to build mappings in a clear,
+ * readable manner.
*
* Example usage: * @@ -35,8 +35,8 @@ import org.springframework.util.Assert; * Mapping result = mapping.source("foo").target("bar").from(String.class).to(Long.class).value(); * * - * Calling the {@link #value()} result method clears out this builder's state so - * it can be reused to build another mapping. + * Calling the {@link #value()} result method clears out this builder's state so it can be reused to build another + * mapping. * * @author Keith Donald * @author Erwin Vervaet @@ -77,10 +77,9 @@ public class MappingBuilder { * Whether or not the built mapping is a required mapping. */ private boolean required; - + /** - * Creates a mapping builder that uses the expression parser to parse - * attribute mapping expressions. + * Creates a mapping builder that uses the expression parser to parse attribute mapping expressions. * @param expressionParser the expression parser */ public MappingBuilder(ExpressionParser expressionParser) { @@ -89,9 +88,8 @@ public class MappingBuilder { } /** - * Sets the conversion service that will convert the object returned by - * evaluating the source expression to the {@link #to(Class)} type if - * necessary. + * Sets the conversion service that will convert the object returned by evaluating the source expression to the + * {@link #to(Class)} type if necessary. * @param conversionService the conversion service */ public void setConversionService(ConversionService conversionService) { @@ -114,7 +112,7 @@ public class MappingBuilder { * @return this, to support call-chaining */ public MappingBuilder target(String expressionString) { - targetExpression = (SettableExpression)expressionParser.parseExpression(expressionString); + targetExpression = (SettableExpression) expressionParser.parseExpression(expressionString); return this; } @@ -124,15 +122,13 @@ public class MappingBuilder { * @return this, to support call-chaining */ public MappingBuilder targetCollection(String expressionString) { - targetExpression = new CollectionAddingExpression( - expressionParser.parseSettableExpression(expressionString)); + targetExpression = new CollectionAddingExpression(expressionParser.parseSettableExpression(expressionString)); return this; } /** - * Sets the expected type of the object returned by evaluating the source - * expression. Used in conjunction with {@link #to(Class)} to perform a type - * conversion during the mapping process. + * Sets the expected type of the object returned by evaluating the source expression. Used in conjunction with + * {@link #to(Class)} to perform a type conversion during the mapping process. * @param sourceType the source type * @return this, to support call-chaining */ @@ -159,17 +155,16 @@ public class MappingBuilder { this.required = true; return this; } - + /** - * The logical GoF builder getResult method, returning a fully constructed - * Mapping from the configured pieces. Once called, the state of this - * builder is nulled out to support building a new mapping object again. + * The logical GoF builder getResult method, returning a fully constructed Mapping from the configured pieces. Once + * called, the state of this builder is nulled out to support building a new mapping object again. * @return the mapping result */ public Mapping value() { Assert.notNull(sourceExpression, "The source expression must be set at a minimum"); if (targetExpression == null) { - targetExpression = (SettableExpression)sourceExpression; + targetExpression = (SettableExpression) sourceExpression; } ConversionExecutor typeConverter = null; if (sourceType != null) { @@ -179,14 +174,13 @@ public class MappingBuilder { Mapping result; if (required) { result = new RequiredMapping(sourceExpression, targetExpression, typeConverter); - } - else { + } else { result = new Mapping(sourceExpression, targetExpression, typeConverter); } reset(); return result; } - + /** * Reset this mapping builder. */ diff --git a/spring-binding/src/main/java/org/springframework/binding/mapping/MappingContext.java b/spring-binding/src/main/java/org/springframework/binding/mapping/MappingContext.java index 3595fb97..73aa66c9 100644 --- a/spring-binding/src/main/java/org/springframework/binding/mapping/MappingContext.java +++ b/spring-binding/src/main/java/org/springframework/binding/mapping/MappingContext.java @@ -18,13 +18,10 @@ package org.springframework.binding.mapping; /** * A context object with two main responsibities: *
null
- * if the method has no parameters
+ * @param parameterTypes the method's parameter types, or null if the method has no parameters
*/
public MethodKey(Class declaredType, String methodName, Class[] parameterTypes) {
Assert.notNull(declaredType, "The method's declared type is required");
@@ -83,8 +81,8 @@ public class MethodKey implements Serializable {
}
/**
- * Returns the method parameter types. Could contain null values
- * if no type was specified for the corresponding parameter.
+ * Returns the method parameter types. Could contain null values if no type was specified for the corresponding
+ * parameter.
*/
public Class[] getParameterTypes() {
return parameterTypes;
@@ -108,13 +106,11 @@ public class MethodKey implements Serializable {
protected Method resolveMethod() throws InvalidMethodKeyException {
try {
return declaredType.getMethod(methodName, parameterTypes);
- }
- catch (NoSuchMethodException e) {
+ } catch (NoSuchMethodException e) {
Method method = findMethodConsiderAssignableParameterTypes();
if (method != null) {
return method;
- }
- else {
+ } else {
throw new InvalidMethodKeyException(this, e);
}
}
@@ -140,8 +136,7 @@ public class MethodKey implements Serializable {
if (isAssignable(candidateType, parameterType)) {
numberOfCorrectArguments++;
}
- }
- else {
+ } else {
// just match on a null param type (effectively 'any')
numberOfCorrectArguments++;
}
@@ -202,16 +197,14 @@ public class MethodKey implements Serializable {
}
/**
- * Convenience method that returns the parameter types describing the
- * signature of the method as a string.
+ * Convenience method that returns the parameter types describing the signature of the method as a string.
*/
private String parameterTypesString() {
StringBuffer parameterTypesString = new StringBuffer();
for (int i = 0; i < parameterTypes.length; i++) {
if (parameterTypes[i] == null) {
parameterTypesString.append("NOTE: Pulled from - * ClassUtils in Spring 2.0 for 1.2.8 compatability. + * Determine if the given target type is assignable from the given value type, assuming setting by reflection. + * Considers primitive wrapper classes as assignable to the corresponding primitive types. + *
+ * NOTE: Pulled from ClassUtils in Spring 2.0 for 1.2.8 compatability.
* @param targetType the target type
- * @param valueType the value type that should be assigned to the target
- * type
+ * @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) {
@@ -238,8 +230,8 @@ public class MethodKey implements Serializable {
}
/**
- * Map with primitive wrapper type as key and corresponding primitive type
- * as value, for example: Integer.class -> int.class.
+ * 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);
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 cade750e..3daeafdc 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
@@ -19,9 +19,8 @@ import org.springframework.core.style.ToStringCreator;
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
+ * 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}.
*
* @author Keith Donald
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 e6f65798..45888eef 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
@@ -22,8 +22,7 @@ import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
- * A named method parameter. Each parameter has an identifying name and is of a
- * specified type (class).
+ * A named method parameter. Each parameter has an identifying name and is of a specified type (class).
*
* @author Keith Donald
*/
@@ -35,14 +34,13 @@ public class Parameter {
private Class type;
/**
- * The name of the parameter as an evaluatable expression, e.g
- * "accountNumber".
+ * The name of the parameter as an evaluatable expression, e.g "accountNumber".
*/
private Expression name;
/**
- * Create a new named parameter definition. Named parameters are capable of resolving
- * parameter values (arguments) from argument sources.
+ * Create a new named parameter definition. Named parameters are capable of resolving parameter values (arguments)
+ * from argument sources.
* @param type the parameter type, may be null
* @param name the name the method argument expression (required)
*/
@@ -53,8 +51,7 @@ public class Parameter {
}
/**
- * Returns the parameter type. Could be null if no parameter type
- * was specified.
+ * Returns the parameter type. Could be null if no parameter type was specified.
*/
public Class getType() {
return type;
@@ -68,8 +65,7 @@ public class Parameter {
}
/**
- * Evaluate this method parameter against the provided argument source,
- * returning a single method argument value.
+ * Evaluate this method parameter against the provided argument source, returning a single method argument value.
* @param argumentSource the meyhod argument source
* @param context the evaluation context
* @return the method argument value
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 f900efd5..54bcca30 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
@@ -95,16 +95,15 @@ public class Parameters {
}
/**
- * Get an array containing each parameter type. The resulting array
- * could contain null values if the corresponding parameters did
- * not specify a parameter type.
+ * Get an array containing each parameter type. The resulting array could contain null values if the corresponding
+ * parameters did not specify a parameter type.
* @return the types
*/
public Class[] getTypesArray() {
int i = 0;
Class[] types = new Class[parameters.size()];
for (Iterator it = parameters.iterator(); it.hasNext();) {
- Parameter param = (Parameter)it.next();
+ Parameter param = (Parameter) it.next();
types[i] = param.getType();
i++;
}
@@ -126,14 +125,14 @@ 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 (Parameter) parameters.get(index);
}
public boolean equals(Object obj) {
if (!(obj instanceof Parameters)) {
return false;
}
- Parameters other = (Parameters)obj;
+ Parameters other = (Parameters) obj;
return parameters.equals(other.parameters);
}
diff --git a/spring-binding/src/main/java/org/springframework/binding/method/TextToMethodSignature.java b/spring-binding/src/main/java/org/springframework/binding/method/TextToMethodSignature.java
index b015918e..2cf85125 100644
--- a/spring-binding/src/main/java/org/springframework/binding/method/TextToMethodSignature.java
+++ b/spring-binding/src/main/java/org/springframework/binding/method/TextToMethodSignature.java
@@ -25,20 +25,17 @@ import org.springframework.binding.convert.support.ConversionServiceAwareConvert
import org.springframework.binding.expression.Expression;
/**
- * Converter that takes an encoded string representation and produces a
- * corresponding MethodSignature object.
+ * Converter that takes an encoded string representation and produces a corresponding MethodSignature
+ * object.
*
* This converter supports the following encoded forms: *