dev@javaserverfaces.java.net

Re: [REVIEW] Additional Findbugs corrections

From: Roger Kitain <Roger.Kitain_at_Sun.COM>
Date: Thu, 19 May 2005 12:58:57 -0400

r=rogerk

Ryan Lubke wrote:

> SECTION: Modified Files
> ----------------------------
> M jsf-api/src/javax/faces/component/SelectItemsIterator.java
> - removed unused ivar
>
> M jsf-api/src/javax/faces/component/UIComponentBase.java
> M jsf-api/src/javax/faces/model/ResultSetDataModel.java
> - made private classes static nested classes
> - replaced use of keySet() with entrySet() in cases where
> both key and value were needed.
> - removed unused ivar
>
> M jsf-api/src/javax/faces/component/UISelectMany.java
> M jsf-api/src/javax/faces/component/UISelectOne.java
> - made private classes static nested classes
>
> M jsf-api/src/javax/faces/webapp/FacesServlet.java
> - removed unused ivar
>
>
> SECTION: Diffs
> ----------------------------
> Index: jsf-api/src/javax/faces/component/SelectItemsIterator.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-api/src/javax/faces/component/SelectItemsIterator.java,v
>
> retrieving revision 1.6
> diff -u -r1.6 SelectItemsIterator.java
> --- jsf-api/src/javax/faces/component/SelectItemsIterator.java 12
> Jul 2004 14:26:04 -0000 1.6
> +++ jsf-api/src/javax/faces/component/SelectItemsIterator.java 19
> May 2005 15:22:39 -0000
> @@ -39,7 +39,6 @@
> */
> public SelectItemsIterator(UIComponent parent) {
>
> - this.parent = parent;
> this.kids = parent.getChildren().iterator();
>
> }
> @@ -59,12 +58,6 @@
> * <p>Iterator over the children of the parent component.</p>
> */
> private Iterator kids = null;
> -
> -
> - /**
> - * <p>The parent {_at_link UIComponent} whose children are being
> iterated.</p>
> - */
> - private UIComponent parent = null;
>
>
> // --------------------------------------------------------
> Iterator Methods
> Index: jsf-api/src/javax/faces/component/UIComponentBase.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-api/src/javax/faces/component/UIComponentBase.java,v
>
> retrieving revision 1.108
> diff -u -r1.108 UIComponentBase.java
> --- jsf-api/src/javax/faces/component/UIComponentBase.java 18 May
> 2005 00:52:41 -0000 1.108
> +++ jsf-api/src/javax/faces/component/UIComponentBase.java 19 May
> 2005 15:22:40 -0000
> @@ -28,9 +28,12 @@
> import java.util.NoSuchElementException;
> import java.util.Set;
> import java.util.WeakHashMap;
> -import javax.el.ValueExpression;
> +import java.util.logging.Level;
> +import java.util.logging.Logger;
> +
> import javax.el.ELContext;
> import javax.el.ELException;
> +import javax.el.ValueExpression;
> import javax.faces.FacesException;
> import javax.faces.FactoryFinder;
> import javax.faces.context.FacesContext;
> @@ -38,12 +41,9 @@
> import javax.faces.event.AbortProcessingException;
> import javax.faces.event.FacesEvent;
> import javax.faces.event.FacesListener;
> -import javax.faces.render.Renderer;
> import javax.faces.render.RenderKit;
> import javax.faces.render.RenderKitFactory;
> -
> -import java.util.logging.Logger;
> -import java.util.logging.Level;
> +import javax.faces.render.Renderer;
>
>
> /**
> @@ -1210,11 +1210,6 @@
> // -------------------------------------------------------
> Protected Methods
>
>
> - // Cache a reference to the FacesContext the first time it is
> requested
> - // This is *not* part of the saved state of the component
> - private transient FacesContext facesContext = null;
> -
> -
> protected FacesContext getFacesContext() {
>
> // PENDING(edburns): we can't use the cache ivar because we
> @@ -1294,11 +1289,10 @@
> attributes = getAttributes();
> if ( values[0] != null ) {
> HashMap attributesCopy = (HashMap)values[0];
> - Iterator it = attributesCopy.keySet().iterator();
> - while ( it.hasNext()) {
> - Object key = it.next();
> - Object value = attributesCopy.get(key);
> - attributes.put(key, value);
> + for (Iterator i = attributesCopy.entrySet().iterator();
> + i.hasNext(); ) {
> + Map.Entry entry = (Map.Entry) i.next();
> + attributes.put(entry.getKey(), entry.getValue());
> }
> }
> bindings = restoreBindingsState(context, values[1]);
> @@ -1608,10 +1602,9 @@
> if (map == null) {
> throw new NullPointerException();
> }
> - Iterator keys = map.keySet().iterator();
> - while (keys.hasNext()) {
> - Object key = keys.next();
> - put(key, map.get(key));
> + for (Iterator i = map.entrySet().iterator(); i.hasNext();
> ) {
> + Map.Entry entry = (Map.Entry) i.next();
> + put(entry.getKey(), entry.getValue());
> }
> }
>
> @@ -1791,7 +1784,7 @@
>
>
> // Private implementation of ListIterator for ChildrenList
> - private class ChildrenListIterator implements ListIterator {
> + private static class ChildrenListIterator implements ListIterator {
>
>
> public ChildrenListIterator(ChildrenList list) {
> @@ -1882,7 +1875,7 @@
>
>
> // Private implementation of Iterator for getFacetsAndChildren()
> - private class FacetsAndChildrenIterator implements Iterator {
> + private static class FacetsAndChildrenIterator implements Iterator {
>
> public FacetsAndChildrenIterator(List list) {
> this.iterator = list.iterator();
> @@ -1952,6 +1945,10 @@
> Object key = keys.next();
> put(key, map.get(key));
> }
> + for (Iterator i = map.entrySet().iterator(); i.hasNext();
> ) {
> + Map.Entry entry = (Map.Entry) i.next();
> + put(entry.getKey(), entry.getValue());
> + }
> }
>
> public Object remove(Object key) {
> @@ -1975,7 +1972,7 @@
>
>
> // Private implementation of Set for FacetsMap.getEntrySet()
> - private class FacetsMapEntrySet extends AbstractSet {
> + private static class FacetsMapEntrySet extends AbstractSet {
>
> public FacetsMapEntrySet(FacetsMap map) {
> this.map = map;
> @@ -2070,7 +2067,7 @@
>
>
> // Private implementation of Map.Entry for FacetsMapEntrySet
> - private class FacetsMapEntrySetEntry implements Map.Entry {
> + private static class FacetsMapEntrySetEntry implements Map.Entry {
>
> public FacetsMapEntrySetEntry(FacetsMap map, Object key) {
> this.map = map;
> @@ -2134,7 +2131,7 @@
>
>
> // Private implementation of Set for
> FacetsMap.getEntrySet().iterator()
> - private class FacetsMapEntrySetIterator implements Iterator {
> + private static class FacetsMapEntrySetIterator implements Iterator {
>
> public FacetsMapEntrySetIterator(FacetsMap map) {
> this.map = map;
> @@ -2166,7 +2163,7 @@
>
>
> // Private implementation of Set for FacetsMap.getKeySet()
> - private class FacetsMapKeySet extends AbstractSet {
> + private static class FacetsMapKeySet extends AbstractSet {
>
> public FacetsMapKeySet(FacetsMap map) {
> this.map = map;
> @@ -2250,7 +2247,7 @@
>
>
> // Private implementation of Set for FacetsMap.getKeySet().iterator()
> - private class FacetsMapKeySetIterator implements Iterator {
> + private static class FacetsMapKeySetIterator implements Iterator {
>
> public FacetsMapKeySetIterator(FacetsMap map) {
> this.map = map;
> @@ -2282,7 +2279,7 @@
>
>
> // Private implementation of Collection for FacetsMap.values()
> - private class FacetsMapValues extends AbstractCollection {
> + private static class FacetsMapValues extends AbstractCollection {
>
> public FacetsMapValues(FacetsMap map) {
> this.map = map;
> @@ -2319,7 +2316,7 @@
>
>
> // Private implementation of Iterator for
> FacetsMap.values().iterator()
> - private class FacetsMapValuesIterator implements Iterator {
> + private static class FacetsMapValuesIterator implements Iterator {
>
> public FacetsMapValuesIterator(FacetsMap map) {
> this.map = map;
> Index: jsf-api/src/javax/faces/component/UISelectMany.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-api/src/javax/faces/component/UISelectMany.java,v
>
> retrieving revision 1.54
> diff -u -r1.54 UISelectMany.java
> --- jsf-api/src/javax/faces/component/UISelectMany.java 5 May 2005
> 20:51:04 -0000 1.54
> +++ jsf-api/src/javax/faces/component/UISelectMany.java 19 May 2005
> 15:22:41 -0000
> @@ -484,7 +484,7 @@
> }
>
>
> - class ArrayIterator implements Iterator {
> + static class ArrayIterator implements Iterator {
>
> public ArrayIterator(Object items[]) {
> this.items = items;
> Index: jsf-api/src/javax/faces/component/UISelectOne.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-api/src/javax/faces/component/UISelectOne.java,v
>
> retrieving revision 1.47
> diff -u -r1.47 UISelectOne.java
> --- jsf-api/src/javax/faces/component/UISelectOne.java 5 May 2005
> 20:51:04 -0000 1.47
> +++ jsf-api/src/javax/faces/component/UISelectOne.java 19 May 2005
> 15:22:41 -0000
> @@ -163,7 +163,7 @@
> }
>
>
> - class ArrayIterator implements Iterator {
> + static class ArrayIterator implements Iterator {
>
> public ArrayIterator(Object items[]) {
> this.items = items;
> Index: jsf-api/src/javax/faces/model/ResultSetDataModel.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-api/src/javax/faces/model/ResultSetDataModel.java,v
>
> retrieving revision 1.27
> diff -u -r1.27 ResultSetDataModel.java
> --- jsf-api/src/javax/faces/model/ResultSetDataModel.java 12 May
> 2004 18:29:14 -0000 1.27
> +++ jsf-api/src/javax/faces/model/ResultSetDataModel.java 19 May
> 2005 15:22:41 -0000
> @@ -13,7 +13,6 @@
> import java.sql.ResultSet;
> import java.sql.ResultSetMetaData;
> import java.sql.SQLException;
> -import java.sql.Types;
> import java.util.AbstractCollection;
> import java.util.AbstractSet;
> import java.util.Collection;
> @@ -22,8 +21,8 @@
> import java.util.Map;
> import java.util.Set;
> import java.util.TreeMap;
> +
> import javax.faces.FacesException;
> -import javax.faces.el.PropertyNotFoundException;
>
>
> /**
> @@ -69,10 +68,6 @@
> // ------------------------------------------------------ Instance
> Variables
>
>
> - // The row index for the row whose column values may be read or
> written
> - private int current = -1;
> -
> -
> // The current row index (zero relative)
> private int index = -1;
>
> @@ -355,11 +350,10 @@
> }
>
> public boolean containsValue(Object value) {
> - Iterator keys = keySet().iterator();
> - while (keys.hasNext()) {
> - Object key = keys.next();
> - Object contained = get(key);
> - if (value == null) {
> + for (Iterator i = entrySet().iterator(); i .hasNext(); ) {
> + Map.Entry entry = (Map.Entry) i.next();
> + Object contained = entry.getValue();
> + if (value == null) {
> if (contained == null) {
> return (true);
> }
> @@ -416,11 +410,10 @@
> }
> }
>
> - public void putAll(Map map) {
> - Iterator keys = map.keySet().iterator();
> - while (keys.hasNext()) {
> - Object key = keys.next();
> - put(key, map.get(key));
> + public void putAll(Map map) { + for
> (Iterator i = map.entrySet().iterator(); i.hasNext(); ) {
> + Map.Entry entry = (Map.Entry) i.next();
> + put(entry.getKey(), entry.getValue());
> }
> }
>
> @@ -615,7 +608,7 @@
>
> // Private implementation of Set that implements the keySet()
> behavior
> // for ResultSetMap
> - private class ResultSetKeys extends AbstractSet {
> + private static class ResultSetKeys extends AbstractSet {
>
> public ResultSetKeys(ResultSetMap map) {
> this.map = map;
> @@ -674,14 +667,12 @@
>
> // Private implementation of Iterator that implements the iterator()
> // behavior for the Set returned by keySet() from ResultSetMap
> - private class ResultSetKeysIterator implements Iterator {
> + private static class ResultSetKeysIterator implements Iterator {
>
> public ResultSetKeysIterator(ResultSetMap map) {
> - this.map = map;
> this.keys = map.realKeys();
> }
>
> - private ResultSetMap map = null;
> private Iterator keys = null;
>
> public boolean hasNext() {
> @@ -702,7 +693,7 @@
>
> // Private implementation of Collection that implements the behavior
> // for the Collection returned by values() from ResultSetMap
> - private class ResultSetValues extends AbstractCollection {
> + private static class ResultSetValues extends AbstractCollection {
>
> public ResultSetValues(ResultSetMap map) {
> this.map = map;
> @@ -751,7 +742,7 @@
>
> // Private implementation of Iterator that implements the behavior
> // for the Iterator returned by values().iterator() from ResultSetMap
> - private class ResultSetValuesIterator implements Iterator {
> + private static class ResultSetValuesIterator implements Iterator {
>
> public ResultSetValuesIterator(ResultSetMap map) {
> this.map = map;
> Index: jsf-api/src/javax/faces/webapp/FacesServlet.java
> ===================================================================
> RCS file:
> /cvs/javaserverfaces-sources/jsf-api/src/javax/faces/webapp/FacesServlet.java,v
>
> retrieving revision 1.24
> diff -u -r1.24 FacesServlet.java
> --- jsf-api/src/javax/faces/webapp/FacesServlet.java 26 Feb 2004
> 20:31:19 -0000 1.24
> +++ jsf-api/src/javax/faces/webapp/FacesServlet.java 19 May 2005
> 15:22:41 -0000
> @@ -11,10 +11,9 @@
>
>
> import java.io.IOException;
> +
> import javax.faces.FacesException;
> import javax.faces.FactoryFinder;
> -import javax.faces.application.Application;
> -import javax.faces.application.ApplicationFactory;
> import javax.faces.context.FacesContext;
> import javax.faces.context.FacesContextFactory;
> import javax.faces.lifecycle.Lifecycle;
> @@ -54,12 +53,6 @@
>
>
> /**
> - * <p>The {_at_link Application} instance for this web application.</p>
> - */
> - private Application application = null;
> -
> -
> - /**
> * <p>Factory for {_at_link FacesContext} instances.</p>
> */
> private FacesContextFactory facesContextFactory = null;
> @@ -82,7 +75,6 @@
> */
> public void destroy() {
>
> - application = null;
> facesContextFactory = null;
> lifecycle = null;
> servletConfig = null;
> @@ -128,20 +120,6 @@
> facesContextFactory = (FacesContextFactory)
> FactoryFinder.getFactory
> (FactoryFinder.FACES_CONTEXT_FACTORY);
> - } catch (FacesException e) {
> - Throwable rootCause = e.getCause();
> - if (rootCause == null) {
> - throw e;
> - } else {
> - throw new ServletException(e.getMessage(), rootCause);
> - }
> - }
> -
> - // Acquire our Application instance
> - try {
> - ApplicationFactory applicationFactory = (ApplicationFactory)
> -
> FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
> - application = applicationFactory.getApplication();
> } catch (FacesException e) {
> Throwable rootCause = e.getCause();
> if (rootCause == null) {
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>