You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2011/11/30 21:41:51 UTC
svn commit: r1208765 -
/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
Author: oheger
Date: Wed Nov 30 20:41:50 2011
New Revision: 1208765
URL: http://svn.apache.org/viewvc?rev=1208765&view=rev
Log:
Java 1.5 compatibility: Javadocs, raw types, for loops, etc.
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java?rev=1208765&r1=1208764&r2=1208765&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java Wed Nov 30 20:41:50 2011
@@ -19,7 +19,6 @@ package org.apache.commons.configuration
import java.lang.reflect.Array;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import org.apache.commons.beanutils.DynaBean;
@@ -37,8 +36,8 @@ import org.apache.commons.logging.LogFac
* implements a {@link java.util.Map} interface so that it can be used in
* JSP 2.0 Expression Language expressions.
*
- * <p>The <code>ConfigurationDynaBean</code> maps nested and mapped properties
- * to the appropriate <code>Configuration</code> subset using the
+ * <p>The {@code ConfigurationDynaBean} maps nested and mapped properties
+ * to the appropriate {@code Configuration} subset using the
* {@link org.apache.commons.configuration.Configuration#subset}
* method. Similarly, indexed properties reference lists of configuration
* properties using the
@@ -63,7 +62,7 @@ public class ConfigurationDynaBean exten
private static Log log = LogFactory.getLog(ConfigurationDynaBean.class);
/**
- * Creates a new instance of <code>ConfigurationDynaBean</code> and sets
+ * Creates a new instance of {@code ConfigurationDynaBean} and sets
* the configuration this bean is associated with.
*
* @param configuration the configuration
@@ -91,11 +90,10 @@ public class ConfigurationDynaBean exten
if (value instanceof Collection)
{
- Collection collection = (Collection) value;
- Iterator iterator = collection.iterator();
- while (iterator.hasNext())
+ Collection<?> collection = (Collection<?>) value;
+ for (Object v : collection)
{
- getConfiguration().addProperty(name, iterator.next());
+ getConfiguration().addProperty(name, v);
}
}
else if (value.getClass().isArray())
@@ -162,7 +160,7 @@ public class ConfigurationDynaBean exten
+ "' is not indexed.");
}
- List list = getConfiguration().getList(name);
+ List<Object> list = getConfiguration().getList(name);
return list.get(index);
}
@@ -200,7 +198,10 @@ public class ConfigurationDynaBean exten
if (property instanceof List)
{
- List list = (List) property;
+ // This is safe because multiple values of a configuration property
+ // are always stored as lists of type Object.
+ @SuppressWarnings("unchecked")
+ List<Object> list = (List<Object>) property;
list.set(index, value);
getConfiguration().setProperty(name, list);
}