You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by aw...@apache.org on 2006/08/01 22:00:48 UTC
svn commit: r427760 [3/4] - in
/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad:
bean/ bean/util/ change/ component/ config/ context/ convert/ event/
logging/ model/ render/ resource/ util/ validator/ webapp/
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/RowKeySetChangeEvent.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/RowKeySetChangeEvent.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/RowKeySetChangeEvent.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/RowKeySetChangeEvent.java Tue Aug 1 15:00:44 2006
@@ -31,9 +31,11 @@
* @param addedSet This is the Set of keys that have just been added.
* @param removedSet This is the Set of keys that have just been removed.
*/
- public RowKeySetChangeEvent(UIComponent source,
- RowKeySet removedSet,
- RowKeySet addedSet)
+ // FIXME: What is the parametrized type inside RowKeySet?
+ public RowKeySetChangeEvent(
+ UIComponent source,
+ RowKeySet<Object> removedSet,
+ RowKeySet<Object> addedSet)
{
this(source, removedSet, addedSet, false);
}
@@ -44,9 +46,11 @@
* @param oldSet This is the Set of keys before any changes.
* @param newSet This is the Set of keys after any changes.
*/
- public RowKeySetChangeEvent(RowKeySet oldSet,
- RowKeySet newSet,
- UIComponent source)
+ // FIXME: What is the parametrized type inside RowKeySet?
+ public RowKeySetChangeEvent(
+ RowKeySet<Object> oldSet,
+ RowKeySet<Object> newSet,
+ UIComponent source)
{
// "oldSet" is very often the actual instance-on-the-component.
// so make sure that we clone this object, so that subsequent mutations of
@@ -56,10 +60,12 @@
this(source, oldSet, newSet, true);
}
- private RowKeySetChangeEvent(UIComponent source,
- RowKeySet oldRemoved,
- RowKeySet newAdded,
- boolean needsDiff)
+ // FIXME: What is the parametrized type inside RowKeySet?
+ private RowKeySetChangeEvent(
+ UIComponent source,
+ RowKeySet<Object> oldRemoved,
+ RowKeySet<Object> newAdded,
+ boolean needsDiff)
{
super(source);
@@ -71,7 +77,7 @@
/**
* Gets the Set of keys that have just been added.
*/
- public RowKeySet getAddedSet()
+ public RowKeySet<Object> getAddedSet()
{
_diff();
return _newAdded;
@@ -80,7 +86,7 @@
/**
* Gets the Set of keys that have just been removed.
*/
- public RowKeySet getRemovedSet()
+ public RowKeySet<Object> getRemovedSet()
{
_diff();
return _oldRemoved;
@@ -90,9 +96,9 @@
{
if (_needsDiff)
{
- RowKeySet removed = _oldRemoved.clone();
+ RowKeySet<Object> removed = _oldRemoved.clone();
removed.removeAll(_newAdded);
- RowKeySet added = _newAdded.clone();
+ RowKeySet<Object> added = _newAdded.clone();
added.removeAll(_oldRemoved);
_needsDiff = false;
@@ -103,6 +109,7 @@
// set1 - oldSet or removed elements
// set2 = newSet or added elements
- private RowKeySet _oldRemoved, _newAdded;
+ private RowKeySet<Object> _oldRemoved;
+ private RowKeySet<Object> _newAdded;
private boolean _needsDiff;
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/SelectionEvent.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/SelectionEvent.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/SelectionEvent.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/SelectionEvent.java Tue Aug 1 15:00:44 2006
@@ -31,7 +31,11 @@
* @param unselected the set of rowKeys that have just been unselected.
* @param selected the set of rowKeys that have just been selected.
*/
- public SelectionEvent(UIComponent source, RowKeySet unselected, RowKeySet selected)
+ // FIXME: What is the parametrized type inside RowKeySet?
+ public SelectionEvent(
+ UIComponent source,
+ RowKeySet<Object> unselected,
+ RowKeySet<Object> selected)
{
super(source, unselected, selected);
}
@@ -41,18 +45,23 @@
* @param oldSet the set of rowKeys before any changes.
* @param newSet the set of rowKeys after any changes.
*/
- public SelectionEvent(RowKeySet oldSet, RowKeySet newSet, UIComponent source)
+ public SelectionEvent(
+ RowKeySet<Object> oldSet,
+ RowKeySet<Object> newSet,
+ UIComponent source)
{
super(oldSet, newSet, source);
}
+ @Override
public void processListener(FacesListener listener)
{
((SelectionListener) listener).processSelection(this);
}
+ @Override
public boolean isAppropriateListener(FacesListener listener)
{
return (listener instanceof SelectionListener);
- }
+ }
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/SortEvent.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/SortEvent.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/SortEvent.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/SortEvent.java Tue Aug 1 15:00:44 2006
@@ -16,24 +16,25 @@
package org.apache.myfaces.trinidad.event;
import java.util.List;
+
import javax.faces.component.UIComponent;
import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
+import org.apache.myfaces.trinidad.model.SortCriterion;
+
/**
* The Event generated when a Collection is to be sorted.
* @author The Oracle ADF Faces Team
*/
public final class SortEvent extends FacesEvent
{
- private final List _criteria;
-
/**
* Creates a new SortEvent.
* @param criteria each element must be of type SortCriterion
* @see org.apache.myfaces.trinidad.model.SortCriterion
*/
- public SortEvent(UIComponent source, List criteria)
+ public SortEvent(UIComponent source, List<SortCriterion> criteria)
{
super(source);
_criteria = criteria;
@@ -43,18 +44,23 @@
* Each element of this List is of type SortCriterion
* @see org.apache.myfaces.trinidad.model.SortCriterion
*/
- public List getSortCriteria()
+ public List<SortCriterion> getSortCriteria()
{
return _criteria;
}
+ @Override
public boolean isAppropriateListener(FacesListener listener)
{
return (listener instanceof SortListener);
}
+ @Override
public void processListener(FacesListener listener)
{
((SortListener) listener).processSort(this);
}
+
+
+ private final List<SortCriterion> _criteria;
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/logging/TrinidadLogRecord.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/logging/TrinidadLogRecord.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/logging/TrinidadLogRecord.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/logging/TrinidadLogRecord.java Tue Aug 1 15:00:44 2006
@@ -29,6 +29,7 @@
}
+ @Override
public String getSourceClassName()
{
if (_needToInferCaller)
@@ -37,12 +38,14 @@
return super.getSourceClassName();
}
+ @Override
public void setSourceClassName(String sourceClassName)
{
_needToInferCaller = false;
super.setSourceClassName(sourceClassName);
}
+ @Override
public String getSourceMethodName()
{
if (_needToInferCaller)
@@ -51,6 +54,7 @@
return super.getSourceMethodName();
}
+ @Override
public void setSourceMethodName(String sourceMethodName)
{
_needToInferCaller = false;
@@ -114,9 +118,10 @@
transient private boolean _needToInferCaller = true;
- static private final String _JDK_LOG_CLASS =
- "java.util.logging.Logger";
- static private final String _ADF_LOG_CLASS =
- "org.apache.myfaces.trinidad.logging.TrinidadLogger";
+ private static final String _JDK_LOG_CLASS =
+ "java.util.logging.Logger";
+
+ private static final String _ADF_LOG_CLASS =
+ "org.apache.myfaces.trinidad.logging.TrinidadLogger";
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/logging/TrinidadLogger.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/logging/TrinidadLogger.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/logging/TrinidadLogger.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/logging/TrinidadLogger.java Tue Aug 1 15:00:44 2006
@@ -15,12 +15,8 @@
*/
package org.apache.myfaces.trinidad.logging;
-
-import java.io.ObjectStreamException;
-
import java.util.Locale;
import java.util.ResourceBundle;
-import java.util.logging.Filter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
@@ -36,11 +32,6 @@
public class TrinidadLogger
{
- private TrinidadLogger(String name)
- {
- _log = Logger.getLogger(name);
- }
-
private TrinidadLogger(Logger log)
{
if (log == null)
@@ -48,12 +39,6 @@
_log = log;
}
- private TrinidadLogger(String name, String resourceBundleName)
- {
- _log = Logger.getLogger(name, resourceBundleName);
- }
-
-
/**
* Get the Java logger from an ADF Logger.
*
@@ -143,7 +128,7 @@
* @param c A class instance for the logger.
* @return a suitable Logger
*/
- public static TrinidadLogger createTrinidadLogger(Class c)
+ public static TrinidadLogger createTrinidadLogger(Class<?> c)
{
if (c == null)
throw new IllegalArgumentException("Class required");
@@ -167,7 +152,7 @@
*
* @return a suitable Logger
*/
- public static TrinidadLogger createTrinidadLogger(Class c, String resourceBundleName)
+ public static TrinidadLogger createTrinidadLogger(Class<?> c, String resourceBundleName)
{
if (c == null)
throw new IllegalArgumentException("Class required");
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/BaseMenuModel.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/BaseMenuModel.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/BaseMenuModel.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/BaseMenuModel.java Tue Aug 1 15:00:44 2006
@@ -44,41 +44,49 @@
{
}
+ @Override
public Object getContainerRowKey(Object childKey)
{
return _treeModel.getContainerRowKey(childKey);
}
+ @Override
public void enterContainer()
{
_treeModel.enterContainer();
}
+ @Override
public void exitContainer()
{
_treeModel.exitContainer();
}
+ @Override
public int getRowCount()
{
return _treeModel.getRowCount();
}
+ @Override
public Object getRowData()
{
return _treeModel.getRowData();
}
+ @Override
public int getRowIndex()
{
return _treeModel.getRowIndex();
}
+ @Override
public Object getRowKey()
{
return _treeModel.getRowKey();
}
+ @Override
public Object getWrappedData()
{
// since we don't know how to adapt an ordinary POJO into a
@@ -86,26 +94,31 @@
return _treeModel;
}
+ @Override
public boolean isContainer()
{
return _treeModel.isContainer();
}
+ @Override
public boolean isRowAvailable()
{
return _treeModel.isRowAvailable();
}
+ @Override
public void setRowIndex(int index)
{
_treeModel.setRowIndex(index);
}
+ @Override
public void setRowKey(Object key)
{
_treeModel.setRowKey(key);
}
+ @Override
public void setWrappedData(Object data)
{
// since we don't know how to adapt an ordinary POJO into a
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ChildPropertyTreeModel.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ChildPropertyTreeModel.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ChildPropertyTreeModel.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ChildPropertyTreeModel.java Tue Aug 1 15:00:44 2006
@@ -119,6 +119,7 @@
/**
* Gets the rowKey of the current row.
*/
+ @Override
public Object getRowKey()
{
final int sz = _path.size() - 1;
@@ -129,7 +130,7 @@
// have to clone the path here. otherwise, we have to say that
// this tree model cannot be mutated while accessing the path
// returned by this method.
- List path = new ArrayList(sz+1);
+ List<Object> path = new ArrayList<Object>(sz+1);
if (sz > 0)
{
for(int i=0; i<sz; i++)
@@ -147,13 +148,15 @@
* is made current.
* @param rowKey use null to access the root collection
*/
+ @SuppressWarnings("unchecked")
+ @Override
public void setRowKey(Object rowKey)
{
Node root = _getNode(0);
_path.clear();
_path.add(root);
- List path = (List) rowKey;
+ List<Object> path = (List<Object>) rowKey;
if ((path == null) || (path.size() == 0))
{
setRowIndex(-1);
@@ -171,29 +174,35 @@
_setRowKey(path.get(lastIndex));
}
+ @SuppressWarnings("unchecked")
+ @Override
public Object getContainerRowKey(Object childKey)
{
- List path = (List) childKey;
+ List<Object> path = (List<Object>) childKey;
if ((path == null) || (path.size() <= 1))
return null;
return path.subList(0, path.size() - 1);
}
+ @Override
public int getRowCount()
{
return _getModel().getRowCount();
}
+ @Override
public Object getRowData()
{
return _getModel().getRowData();
}
+ @Override
public boolean isRowAvailable()
{
return _getModel().isRowAvailable();
}
+ @Override
public boolean isContainer()
{
Object rowData = getRowData();
@@ -201,6 +210,7 @@
return (value != null);
}
+ @Override
public void enterContainer()
{
Object rowData = getRowData();
@@ -210,6 +220,7 @@
_path.add(node);
}
+ @Override
public void exitContainer()
{
int sz = _path.size();
@@ -222,6 +233,7 @@
/**
* Gets the instance being wrapped by this TreeModel.
*/
+ @Override
public Object getWrappedData()
{
return _wrappedData;
@@ -231,6 +243,7 @@
* Sets the instance being wrapped by this TreeModel.
* Calling this method sets the path to empty.
*/
+ @Override
public void setWrappedData(Object data)
{
Node root = _getNode(0);
@@ -255,27 +268,32 @@
_childProperty = childProperty;
}
+ @Override
public int getRowIndex()
{
return _getModel().getRowIndex();
}
+ @Override
public void setRowIndex(int rowIndex)
{
_getModel().setRowIndex(rowIndex);
}
+ @Override
public boolean isSortable(String property)
{
return _getModel().isSortable(property);
}
- public List getSortCriteria()
+ @Override
+ public List<SortCriterion> getSortCriteria()
{
return _getModel().getSortCriteria();
}
- public void setSortCriteria(List criteria)
+ @Override
+ public void setSortCriteria(List<SortCriterion> criteria)
{
_getModel().setSortCriteria(criteria);
}
@@ -328,8 +346,7 @@
private Node _getNode(int index)
{
- Node node = (Node) _path.get(index);
- return node;
+ return _path.get(index);
}
private CollectionModel _getModel()
@@ -357,7 +374,7 @@
}
}
- private final List _path = new ArrayList(5);
+ private final List<Node> _path = new ArrayList<Node>(5);
private String _childProperty = null;
private Object _wrappedData = null;
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModel.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModel.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModel.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModel.java Tue Aug 1 15:00:44 2006
@@ -111,7 +111,8 @@
* An empty list is returned if this collection is not sorted.
* @see SortCriterion
*/
- public List getSortCriteria()
+ @SuppressWarnings("unchecked")
+ public List<SortCriterion> getSortCriteria()
{
return Collections.EMPTY_LIST;
}
@@ -123,7 +124,7 @@
* the same as an empty list.
* @see SortCriterion
*/
- public void setSortCriteria(List criteria)
+ public void setSortCriteria(List<SortCriterion> criteria)
{
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/DefaultBoundedRangeModel.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/DefaultBoundedRangeModel.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/DefaultBoundedRangeModel.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/DefaultBoundedRangeModel.java Tue Aug 1 15:00:44 2006
@@ -57,11 +57,13 @@
_value = value;
}
+ @Override
public long getMaximum()
{
return _maximum;
}
+ @Override
public long getValue()
{
return _value;
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ModelUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ModelUtils.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ModelUtils.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ModelUtils.java Tue Aug 1 15:00:44 2006
@@ -40,9 +40,9 @@
* The collection must not be modified while this iterator is being used.
* The Iterator is not modifiable.
*/
- public static Iterator getRowKeyIterator(final CollectionModel model)
+ public static Iterator<Object> getRowKeyIterator(final CollectionModel model)
{
- Iterator iter = new Iterator()
+ Iterator<Object> iter = new Iterator<Object>()
{
public boolean hasNext()
{
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/PathHelper.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/PathHelper.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/PathHelper.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/PathHelper.java Tue Aug 1 15:00:44 2006
@@ -23,8 +23,11 @@
*/
class PathHelper
{
+ @SuppressWarnings("unchecked")
protected PathHelper()
{
+ _path = Collections.EMPTY_LIST;
+ _rowKey = null;
}
/**
@@ -56,10 +59,10 @@
* Gets the current path.
* @return a List, with each element a rowKey String
*/
- public final List getPath()
+ public final List<String> getPath()
{
int sz = _path.size();
- List path = new ArrayList(sz+1);
+ List<String> path = new ArrayList<String>(sz+1);
if (sz > 0)
{
for(int i=0; i<sz; i++)
@@ -85,13 +88,14 @@
* Sets the path.
* @param path a List with each element a rowKey String
*/
- public final void setPath(List path)
+ @SuppressWarnings("unchecked")
+ public final void setPath(List<String> path)
{
int sz = (path==null) ? 0 : path.size();
if (sz > 0)
{
- _path = new ArrayList(sz);
+ _path = new ArrayList<PathElement>(sz);
int lastIndex = sz - 1;
for(int i=0; i<lastIndex; i++)
@@ -99,7 +103,7 @@
setRowKey(path.get(i).toString());
pushPath();
}
- setRowKey((String) path.get(lastIndex));
+ setRowKey(path.get(lastIndex));
}
else
{
@@ -140,7 +144,7 @@
Object data = pushPath(parentData, _rowKey);
if (_path == Collections.EMPTY_LIST)
- _path = new ArrayList(5);
+ _path = new ArrayList<PathElement>(5);
_path.add(new PathHelper.PathElement(_rowKey, data));
@@ -168,7 +172,7 @@
int sz = _path.size();
if (sz > 0)
{
- PathHelper.PathElement lastPath = (PathElement) _path.remove(sz-1);
+ PathHelper.PathElement lastPath = _path.remove(sz-1);
_rowKey = lastPath.rowKey;
}
else
@@ -177,11 +181,11 @@
private PathHelper.PathElement _getPathElement(int index)
{
- return (PathElement) _path.get(index);
+ return _path.get(index);
}
- private String _rowKey = null;
- private List _path = Collections.EMPTY_LIST;
+ private String _rowKey;
+ private List<PathElement> _path;
private static final class PathElement
{
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ProcessUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ProcessUtils.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ProcessUtils.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ProcessUtils.java Tue Aug 1 15:00:44 2006
@@ -319,6 +319,7 @@
* session and request map.
* @return the rowKey to the "max visited" node.
*/
+ @SuppressWarnings("unchecked")
public static Object getMaxVisitedRowKey(
MenuModel model,
Object maxPathKey
@@ -326,7 +327,8 @@
{
//TODO - what if maxPathKey is null
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
- Map requestMap = externalContext.getRequestMap();
+ //FIXME As of JSF 1.2, the request map is <String, Object>
+ Map<Object, Object> requestMap = externalContext.getRequestMap();
@@ -398,13 +400,15 @@
return maxPath;
}
+ @SuppressWarnings("unchecked")
public static void clearMaxPath(
Object maxPathKey
)
{
if (maxPathKey != null)
{
- Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
+ // FIXME As of JSF 1.2, the request map is <String, Object>
+ Map<Object, Object> sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
sessionMap.put(maxPathKey, null);
}
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySet.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySet.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySet.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySet.java Tue Aug 1 15:00:44 2006
@@ -42,6 +42,7 @@
/**
* @deprecated remove asap
*/
+ @Deprecated
public abstract boolean isContainedByDefault();
/**
@@ -85,6 +86,7 @@
* it otherwise.
* @return true if the row is now added. false otherwise.
*/
+ @SuppressWarnings("unchecked")
public final boolean invert()
{
E rowkey = (E) getCollectionModel().getRowKey();
@@ -119,6 +121,7 @@
* @return true if this set changed. ie: true is returned if this set
* did not previously contain the current key.
*/
+ @SuppressWarnings("unchecked")
public final boolean add()
{
E rowkey = (E) getCollectionModel().getRowKey();
@@ -189,11 +192,13 @@
* This implementation simply calls
* {@link Object#clone}
*/
- public RowKeySet clone()
+ @SuppressWarnings("unchecked")
+ @Override
+ public RowKeySet<E> clone()
{
try
{
- return (RowKeySet) super.clone();
+ return (RowKeySet<E>) super.clone();
}
catch (CloneNotSupportedException e)
{
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySetImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySetImpl.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySetImpl.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySetImpl.java Tue Aug 1 15:00:44 2006
@@ -42,7 +42,6 @@
*/
public final class RowKeySetImpl<E> extends RowKeySet<E> implements Externalizable
{
-
/**
* Creates an initially empty RowKeySet.
*/
@@ -55,9 +54,12 @@
* Creates a new RowKeySet.
* @param addAll whether to add every rowKey to this set.
*/
+ @SuppressWarnings("unchecked")
public RowKeySetImpl(boolean addAll)
{
_default = addAll;
+ _set = Collections.EMPTY_SET;
+ _model = null;
}
/**
@@ -74,6 +76,7 @@
* Adds the current rowKey to this set.
* @return true if this set changed
*/
+ @Override
public boolean add(E rowKey)
{
return _setSelected(rowKey, true);
@@ -94,9 +97,10 @@
* it otherwise.
* @return true if the row is now added. false otherwise.
*/
+ @Override
public boolean invert(E rowKey)
{
- Set set = _getSet(true);
+ Set<E> set = _getSet(true);
if (!set.add(rowKey))
{
set.remove(rowKey);
@@ -114,6 +118,7 @@
* not previously in this set will be added.
* This method executes in constant time.
*/
+ @Override
public void invertAll()
{
_default = !_default;
@@ -123,11 +128,13 @@
* Adds every rowKey to this set.
* This method executes in constant time.
*/
+ @Override
public void addAll()
{
_selectAll(true);
}
+ @Override
public boolean isContainedByDefault()
{
return _default;
@@ -148,7 +155,7 @@
{
if (c instanceof RowKeySetImpl)
{
- RowKeySetImpl other = (RowKeySetImpl) c;
+ RowKeySetImpl<E> other = (RowKeySetImpl<E>) c;
if (other._default)
{
// the other Set has all keys added by default. It will be too
@@ -165,7 +172,7 @@
{
if (c instanceof RowKeySetImpl)
{
- RowKeySetImpl other = (RowKeySetImpl) c;
+ RowKeySetImpl<E> other = (RowKeySetImpl<E>) c;
if (other._default)
{
// the other Set has all keys added by default. It will be too
@@ -177,10 +184,10 @@
return super.addAll(c);
}
- private boolean _processAll(RowKeySetImpl other, boolean addAll)
+ private boolean _processAll(RowKeySetImpl<E> other, boolean addAll)
{
- Set set = _getSet(false);
- Set otherSet = other._getSet(false);
+ Set<E> set = _getSet(false);
+ Set<E> otherSet = other._getSet(false);
if (_default == addAll)
{
// This Set already uses the correct default state. So all we have to do
@@ -235,6 +242,7 @@
* This method is called by component writers who need to set the models
* used by their components on this set.
*/
+ @Override
public final void setCollectionModel(CollectionModel model)
{
_model = model;
@@ -246,11 +254,13 @@
* Gets the number of rowKeys in this set (if known).
* @return -1 if the number of rowKeys is unknown.
*/
+ @Override
public int getSize()
{
return _getSize(false);
}
+ @Override
public int size()
{
return _getSize(true);
@@ -268,7 +278,8 @@
* The CollectionModel and this Set should not be mutated while the
* iterator is being used.
*/
- public Iterator<E> iterator()
+ @Override
+ public Iterator<E> iterator()
{
return _default ? _getNotInSetRowKeyIterator() : _getInSetRowKeyIterator();
}
@@ -314,6 +325,7 @@
* @param rowKey the rowKey of the item.
* @return true if this set changed
*/
+ @SuppressWarnings("unchecked")
private boolean _setSelected(Object rowKey, boolean isSelected)
{
if (isSelected == _default)
@@ -326,24 +338,25 @@
}
else
{
- Set set = _getSet(true);
- return set.add(rowKey);
+ return _getSet(true).add((E)rowKey);
}
}
- private Iterator _getNotInSetRowKeyIterator()
+ @SuppressWarnings("unchecked")
+ private Iterator<E> _getNotInSetRowKeyIterator()
{
CollectionModel table = getCollectionModel();
- final Iterator rowKeyIterator = ModelUtils.getRowKeyIterator(table);
- final Set set = _getSet(false);
- Iterator iter = new Iterator()
+ final Iterator<E> rowKeyIterator = (Iterator<E>)ModelUtils.getRowKeyIterator(table);
+ final Set<E> set = _getSet(false);
+ Iterator<E> iter = new Iterator<E>()
{
- public Object next()
+ public E next()
{
if (!hasNext())
throw new NoSuchElementException();
_current = _next;
_next = _next();
+ _first = false;
return _current;
}
@@ -351,7 +364,7 @@
{
if (_current == null)
throw new IllegalStateException("No element to remove");
- Set mutable = _getSet(true);
+ Set<E> mutable = _getSet(true);
// since this is the not-in-set iterator, we "remove" the element
// by adding it to the Set:
mutable.add(_current);
@@ -360,41 +373,42 @@
public boolean hasNext()
{
- return (_next != null);
+ return (_next != null || _first);
}
- private Object _next()
+ private E _next()
{
while(rowKeyIterator.hasNext())
{
- Object rowKey = rowKeyIterator.next();
+ E rowKey = rowKeyIterator.next();
if (!set.contains(rowKey))
return rowKey;
}
return null;
}
- private Object _next = Boolean.FALSE; // init to a fake value
- private Object _current = null;
+ private boolean _first = true;
+ private E _next = null;
+ private E _current = null;
};
iter.next(); // initialize;
return iter;
}
- private Iterator _getInSetRowKeyIterator()
+ private Iterator<E> _getInSetRowKeyIterator()
{
- Set set = _getSet(false);
- return set.iterator();
+ return _getSet(false).iterator();
}
+ @SuppressWarnings("unchecked")
private void _selectAll(boolean isSelected)
{
_default = isSelected;
_set = Collections.EMPTY_SET;
}
- private Set _getSet(boolean create)
+ private Set<E> _getSet(boolean create)
{
if (create && (_set == Collections.EMPTY_SET))
{
@@ -403,15 +417,15 @@
return _set;
}
- private Set _createSet(int sz)
+ private Set<E> _createSet(int sz)
{
// must be cloneable:
- return new HashSet(sz);
+ return new HashSet<E>(sz);
}
private boolean _isSelected(Object rowKey)
{
- Set set = _getSet(false);
+ Set<E> set = _getSet(false);
boolean isInSet = set.contains(rowKey);
return isInSet ^ _default;
}
@@ -420,10 +434,10 @@
public void writeExternal(ObjectOutput out) throws IOException
{
out.writeBoolean(_default);
- Set set = _getSet(false);
+ Set<E> set = _getSet(false);
int sz = set.size();
out.writeInt(sz);
- Iterator iter = set.iterator();
+ Iterator<E> iter = set.iterator();
for(int i=0; i<sz; i++)
{
out.writeObject(iter.next());
@@ -431,6 +445,7 @@
}
// see java.io.Externalizable
+ @SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException
{
@@ -441,7 +456,7 @@
_set = _createSet(sz);
for(int i=0; i<sz; i++)
{
- _set.add(in.readObject());
+ _set.add((E)in.readObject());
}
}
else
@@ -453,10 +468,11 @@
* Keys may be added or removed from the clone without affecting
* this instance.
*/
- public RowKeySetImpl clone()
+ @Override
+ public RowKeySetImpl<E> clone()
{
- RowKeySetImpl clone = (RowKeySetImpl) super.clone();
- Set set = _getSet(false);
+ RowKeySetImpl<E> clone = (RowKeySetImpl<E>) super.clone();
+ Set<E> set = _getSet(false);
clone._set = _clone(set);
return clone;
}
@@ -467,12 +483,13 @@
* If the other Set is empty, then the clone is immutable
* (although the remove, removeAll and retainAll) methods will still work.
*/
- private Set _clone(Set other)
+ @SuppressWarnings("unchecked")
+ private <T> Set<T> _clone(Set<T> other)
{
if (other.isEmpty())
return Collections.EMPTY_SET;
else
- return (Set) ((HashSet) other).clone();
+ return (Set<T>) ((HashSet<T>) other).clone();
}
/**
@@ -480,15 +497,17 @@
* The current rowKey (that is used by some of the methods in this class)
* is obtained from this CollectionModel.
*/
+ @Override
protected CollectionModel getCollectionModel()
{
assert _model != null : "There is no CollectionModel associated with this set";
return _model;
}
- private boolean _default;
- private Set _set = Collections.EMPTY_SET;
- private transient CollectionModel _model = null;
private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(RowKeySetImpl.class);
+
+ private boolean _default;
+ private Set<E> _set;
+ private transient CollectionModel _model;
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySetTreeImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySetTreeImpl.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySetTreeImpl.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeySetTreeImpl.java Tue Aug 1 15:00:44 2006
@@ -57,6 +57,7 @@
* Tests to see if the given rowKey is included in this Set.
* @return true If the rowKey is included in this Set.
*/
+ @SuppressWarnings("unchecked")
@Override
public boolean contains(Object rowKey)
{
@@ -66,6 +67,9 @@
/**
* @deprecated do not use. this will be removed post Tier 1.
*/
+ @SuppressWarnings("unchecked")
+ @Override
+ @Deprecated
public boolean isContainedByDefault()
{
TreeModel model = getCollectionModel();
@@ -73,6 +77,7 @@
return new Search().find(rowkey).isDefaultContained;
}
+ @Override
public Iterator<E> iterator()
{
return new PathIterator();
@@ -84,6 +89,7 @@
* @see #remove(Object)
* @see #addAll()
*/
+ @Override
public boolean add(E rowKey)
{
return _setContained(rowKey, true);
@@ -95,6 +101,7 @@
* @see #add(E)
* @see #removeAll()
*/
+ @SuppressWarnings("unchecked")
@Override
public boolean remove(Object rowKey)
{
@@ -107,6 +114,7 @@
* @see #add(E)
* @see #removeAll()
*/
+ @Override
public void addAll()
{
_selectAll(true);
@@ -119,6 +127,7 @@
* @see #clear()
* @see #addAll()
*/
+ @Override
public void removeAll()
{
_selectAll(false);
@@ -135,7 +144,7 @@
{
if (other instanceof RowKeySetTreeImpl)
{
- RowKeySetTreeImpl otherset = (RowKeySetTreeImpl) other;
+ RowKeySetTreeImpl<E> otherset = (RowKeySetTreeImpl<E>) other;
return _processOperation(this._root, otherset._root, true);
}
return super.addAll(other);
@@ -152,7 +161,7 @@
{
if (other instanceof RowKeySetTreeImpl)
{
- RowKeySetTreeImpl otherset = (RowKeySetTreeImpl) other;
+ RowKeySetTreeImpl<E> otherset = (RowKeySetTreeImpl<E>) other;
return _processOperation(this._root, otherset._root, false);
}
return super.removeAll(other);
@@ -259,6 +268,7 @@
* Does not force the underlying model to compute its size.
* @return -1 if the number of elements is unknown.
*/
+ @Override
public int getSize()
{
return _getSize(null, _root, getCollectionModel(), false);
@@ -269,6 +279,7 @@
* This might force the underlying model to compute its size.
* @return a non-negative number.
*/
+ @Override
public int size()
{
return _getSize(null, _root, getCollectionModel(), true);
@@ -284,6 +295,7 @@
* Sets the TreeModel associated with this Set.
* @param model This must be of type {@link TreeModel}
*/
+ @Override
public final void setCollectionModel(CollectionModel model)
{
_model = (TreeModel) model;
@@ -293,9 +305,10 @@
* Creates a clone of this Set. RowKeys may be added/removed from the
* clone without affecting this instance.
*/
- public RowKeySetTreeImpl clone()
+ @Override
+ public RowKeySetTreeImpl<E> clone()
{
- RowKeySetTreeImpl clone = (RowKeySetTreeImpl) super.clone();
+ RowKeySetTreeImpl<E> clone = (RowKeySetTreeImpl<E>) super.clone();
clone._root = _root.clone();
return clone;
}
@@ -303,6 +316,8 @@
/**
* @deprecated not implemented.
*/
+ @Deprecated
+ @Override
public void invertAll()
{
// TODO
@@ -315,6 +330,7 @@
* get parent rowKeys, from child rowKeys.
* @see TreeModel#getRowKey
*/
+ @Override
protected TreeModel getCollectionModel()
{
return _model;
@@ -328,6 +344,7 @@
*
* @param exclusions any rowKeys present in this Set are excluded from the count.
*/
+ @SuppressWarnings("unchecked")
private int _getTreeSize(TreeModel model, Set<E> exclusions)
{
int sz = 0;
@@ -399,10 +416,12 @@
* adds or removes all the paths rooted at the current path
* @param isSelectAll if true does an add-all. else does remove-all.
*/
+ @SuppressWarnings("unchecked")
private void _selectAll(final boolean isSelectAll)
{
Search search = new Search()
{
+ @Override
protected boolean create(Node<E> parent, E rowkey)
{
// if the parent does not have the correct default, then
@@ -411,6 +430,7 @@
return (parent.isDefaultContained != isSelectAll);
}
+ @Override
protected Node<E> found(Node<E> child)
{
child.isDefaultContained = isSelectAll;
@@ -429,11 +449,13 @@
{
Search search = new Search()
{
+ @Override
protected Node<E> notFound(Node<E> parent, E rowkey)
{
return parent.isDefaultContained ? parent : null;
}
+ @Override
protected Node<E> found(Node<E> child)
{
return (child.isDefaultContained ^ child.isDifferent) ? child : null;
@@ -453,6 +475,7 @@
{
Search search = new Search()
{
+ @Override
protected boolean create(Node<E> parent, E rowkey)
{
// only need to create child deltas, if the parent's
@@ -460,6 +483,7 @@
return parent.isDefaultContained != isContained;
}
+ @Override
protected Node<E> notFound(Node<E> parent, E rowkey)
{
return null;
@@ -538,6 +562,8 @@
}
}
+ @SuppressWarnings("unchecked")
+ @Override
public Node<K> clone()
{
Node<K> clone = (Node<K>) super.clone();
@@ -567,13 +593,14 @@
return result;
}
+ @SuppressWarnings("unchecked")
public Node<E> find(E rowkey)
{
Node<E> current = _root;
if (rowkey != null)
{
TreeModel model = getCollectionModel();
- List<E> parentkeys = model.getAllAncestorContainerRowKeys(rowkey);
+ List<E> parentkeys = (List<E>)model.getAllAncestorContainerRowKeys(rowkey);
List<E> allkeys = new ArrayList<E>(parentkeys.size() + 1);
allkeys.addAll(parentkeys);
allkeys.add(rowkey);
@@ -624,6 +651,7 @@
{
Search search = new Search()
{
+ @Override
protected Node<E> notFound(Node<E> parent, E rowkey)
{
return parent.isDefaultContained ? parent : null;
@@ -634,6 +662,7 @@
((!current.isEmpty()) || current.isDefaultContained);
}
+ @SuppressWarnings("unchecked")
private E _next()
{
TreeModel model = getCollectionModel();
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortCriterion.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortCriterion.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortCriterion.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortCriterion.java Tue Aug 1 15:00:44 2006
@@ -56,6 +56,7 @@
return _property;
}
+ @Override
public boolean equals(Object obj)
{
if (this == obj)
@@ -71,6 +72,7 @@
return false;
}
+ @Override
public int hashCode()
{
int hc = getProperty().hashCode();
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/SortableModel.java Tue Aug 1 15:00:44 2006
@@ -51,16 +51,19 @@
{
}
+ @Override
public Object getRowData()
{
return _model.getRowData();
}
+ @Override
public Object getWrappedData()
{
return _wrappedData;
}
+ @Override
public boolean isRowAvailable()
{
return _model.isRowAvailable();
@@ -72,6 +75,7 @@
* {@link DataModel}.
* @see ModelUtils#toDataModel
*/
+ @Override
public void setWrappedData(Object data)
{
_baseIndicesList = null;
@@ -81,17 +85,20 @@
_wrappedData = data;
}
+ @Override
public int getRowCount()
{
return _model.getRowCount();
}
+ @Override
public void setRowIndex(int rowIndex)
{
int baseIndex = _toBaseIndex(rowIndex);
_model.setRowIndex(baseIndex);
}
+ @Override
public int getRowIndex()
{
int baseIndex = _model.getRowIndex();
@@ -102,6 +109,7 @@
* Gets the row key of the current row
* @inheritDoc
*/
+ @Override
public Object getRowKey()
{
return isRowAvailable()
@@ -113,6 +121,7 @@
* Finds the row with the matching key and makes it current
* @inheritDoc
*/
+ @Override
public void setRowKey(Object key)
{
setRowIndex(_toRowIndex((String) key));
@@ -123,6 +132,7 @@
* @param property The name of the property to sort the underlying collection by.
* @return true, if the property implements java.lang.Comparable
*/
+ @Override
public boolean isSortable(String property)
{
final int oldIndex = _model.getRowIndex();
@@ -159,14 +169,17 @@
}
}
- public List getSortCriteria()
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<SortCriterion> getSortCriteria()
{
return (_sortCriterion == null)
? Collections.EMPTY_LIST
: Collections.singletonList(_sortCriterion);
}
- public void setSortCriteria(List criteria)
+ @Override
+ public void setSortCriteria(List<SortCriterion> criteria)
{
if ((criteria == null) || (criteria.isEmpty()))
{
@@ -176,7 +189,7 @@
}
else
{
- SortCriterion sc = (SortCriterion) criteria.get(0);
+ SortCriterion sc = criteria.get(0);
if ((_sortCriterion == null) || (!_sortCriterion.equals(sc)))
{
_sortCriterion = sc;
@@ -185,6 +198,7 @@
}
}
+ @Override
public String toString()
{
return "SortableModel[" + _model + "]";
@@ -229,10 +243,10 @@
if (_model.isRowAvailable())
{
FacesContext context = FacesContext.getCurrentInstance();
- Comparator comp =
+ Comparator<Integer> comp =
new Comp(context. getApplication().getPropertyResolver(), property);
if (!isAscending)
- comp = new Inverter(comp);
+ comp = new Inverter<Integer>(comp);
Collections.sort(_baseIndicesList, comp);
_sortedIndicesList = null;
@@ -248,7 +262,7 @@
_sortedIndicesList = (IntList) _baseIndicesList.clone();
for(int i=0; i<_baseIndicesList.size(); i++)
{
- Integer base = (Integer) _baseIndicesList.get(i);
+ Integer base = _baseIndicesList.get(i);
_sortedIndicesList.set(base.intValue(), new Integer(i));
}
}
@@ -261,14 +275,14 @@
return _convertIndex(sortedIndex, _baseIndicesList);
}
- private int _convertIndex(int index, List indices)
+ private int _convertIndex(int index, List<Integer> indices)
{
if (index < 0) // -1 is special
return index;
if ((indices != null) && (indices.size() > index))
{
- index = ((Integer) indices.get(index)).intValue();
+ index = indices.get(index).intValue();
}
return index;
}
@@ -290,7 +304,7 @@
}
- private static final class IntList extends ArrayList implements Cloneable
+ private static final class IntList extends ArrayList<Integer> implements Cloneable
{
public IntList(int size)
{
@@ -307,7 +321,7 @@
}
}
- private final class Comp implements Comparator
+ private final class Comp implements Comparator<Integer>
{
public Comp(PropertyResolver resolver, String property)
{
@@ -315,10 +329,11 @@
_prop = property;
}
- public int compare(Object o1, Object o2)
+ @SuppressWarnings("unchecked")
+ public int compare(Integer o1, Integer o2)
{
- int index1 = ((Integer) o1).intValue();
- int index2 = ((Integer) o2).intValue();
+ int index1 = o1.intValue();
+ int index2 = o2.intValue();
_model.setRowIndex(index1);
Object instance1 = _model.getRowData();
@@ -340,7 +355,7 @@
// So test before we cast:
if (value1 instanceof Comparable)
{
- return ((Comparable) value1).compareTo(value2);
+ return ((Comparable<Object>) value1).compareTo(value2);
}
else
{
@@ -354,19 +369,19 @@
private final String _prop;
}
- private static final class Inverter implements Comparator
+ private static final class Inverter<T> implements Comparator<T>
{
- public Inverter(Comparator comp)
+ public Inverter(Comparator<T> comp)
{
_comp = comp;
}
- public int compare(Object o1, Object o2)
+ public int compare(T o1, T o2)
{
return _comp.compare(o2, o1);
}
- private final Comparator _comp;
+ private final Comparator<T> _comp;
}
private SortCriterion _sortCriterion = null;
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/TreeModel.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/TreeModel.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/TreeModel.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/TreeModel.java Tue Aug 1 15:00:44 2006
@@ -175,7 +175,8 @@
* The first rowKey (in this list) is the top most container. The last
* rowKey is the immediate container of the given childRowKey.
*/
- public List getAllAncestorContainerRowKeys(Object childRowKey)
+ @SuppressWarnings("unchecked")
+ public List<Object> getAllAncestorContainerRowKeys(Object childRowKey)
{
if (childRowKey == null)
return Collections.EMPTY_LIST;
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ViewIdPropertyMenuModel.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ViewIdPropertyMenuModel.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ViewIdPropertyMenuModel.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ViewIdPropertyMenuModel.java Tue Aug 1 15:00:44 2006
@@ -68,7 +68,7 @@
public ViewIdPropertyMenuModel()
{
super();
- _focusPathMap = new HashMap();
+ _focusPathMap = new HashMap<Object, Object>();
}
/**
*
@@ -82,11 +82,12 @@
throws IntrospectionException
{
super(instance);
- _focusPathMap = new HashMap();
+ _focusPathMap = new HashMap<Object, Object>();
setViewIdProperty(viewIdProperty);
setWrappedData(instance);
}
+ @Override
public void setWrappedData(Object data)
{
super.setWrappedData(data);
@@ -116,7 +117,7 @@
*
* @return the rowKey to the node with the current viewId or null if the current viewId can't be found
*/
-
+ @Override
public Object getFocusRowKey()
{
String currentViewId = getCurrentViewId();
@@ -182,7 +183,7 @@
private static void _addToMap(
FacesContext context,
TreeModel tree,
- Map focusPathMap,
+ Map<Object, Object> focusPathMap,
String viewIdProperty
)
{
@@ -214,7 +215,7 @@
}
- private final Map _focusPathMap;
+ private final Map<Object, Object> _focusPathMap;
private String _viewIdProperty = null;
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/DialogRenderKitService.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/DialogRenderKitService.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/DialogRenderKitService.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/DialogRenderKitService.java Tue Aug 1 15:00:44 2006
@@ -70,9 +70,9 @@
FacesContext context,
UIViewRoot targetRoot,
UIComponent source,
- Map processParameters,
+ Map<?, ?> processParameters,
boolean useWindow,
- Map windowProperties);
+ Map<?, ?> windowProperties);
/**
* Called to return from a dialog.
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/ExtendedRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/ExtendedRenderer.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/ExtendedRenderer.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/ExtendedRenderer.java Tue Aug 1 15:00:44 2006
@@ -36,6 +36,7 @@
*
* @return true, always
*/
+ @Override
public final boolean getRendersChildren()
{
return true;
@@ -47,16 +48,16 @@
* @param context the Faces context
* @param component the component to render
*/
+ @SuppressWarnings("unchecked")
public void decodeChildren(
FacesContext context,
UIComponent component)
{
// Process all the facets and children of this component
- Iterator kids = component.getFacetsAndChildren();
+ Iterator<UIComponent> kids = component.getFacetsAndChildren();
while (kids.hasNext())
{
- UIComponent kid = (UIComponent) kids.next();
- kid.processDecodes(context);
+ kids.next().processDecodes(context);
}
}
@@ -66,16 +67,16 @@
* @param context the Faces context
* @param component the component to render
*/
+ @SuppressWarnings("unchecked")
public void validateChildren(
FacesContext context,
UIComponent component)
{
// Process all the facets and children of this component
- Iterator kids = component.getFacetsAndChildren();
+ Iterator<UIComponent> kids = component.getFacetsAndChildren();
while (kids.hasNext())
{
- UIComponent kid = (UIComponent) kids.next();
- kid.processValidators(context);
+ kids.next().processValidators(context);
}
}
@@ -85,16 +86,16 @@
* @param context the Faces context
* @param component the component to render
*/
+ @SuppressWarnings("unchecked")
public void updateChildren(
FacesContext context,
UIComponent component)
{
// Process all the facets and children of this component
- Iterator kids = component.getFacetsAndChildren();
+ Iterator<UIComponent> kids = component.getFacetsAndChildren();
while (kids.hasNext())
{
- UIComponent kid = (UIComponent) kids.next();
- kid.processUpdates(context);
+ kids.next().processUpdates(context);
}
}
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/InternalView.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/InternalView.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/InternalView.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/InternalView.java Tue Aug 1 15:00:44 2006
@@ -30,7 +30,7 @@
* InternalViews should be registered with a .properties-syntax file at
* <code>/META-INF/org.apache.myfaces.trinidad.render.InternalView.properties</code>
*/
-abstract public class InternalView
+public abstract class InternalView
{
/**
* Creates the UIViewRoot.
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/AggregatingResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/AggregatingResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/AggregatingResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/AggregatingResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -95,10 +95,11 @@
* @return a aggregate url
* @throws IOException when something bad happens
*/
+ @Override
protected URL getURL(String path) throws IOException
{
int len = _paths.length;
- ArrayList urls = new ArrayList(len);
+ ArrayList<URL> urls = new ArrayList<URL>(len);
for(int i = 0; i < len; i++)
{
URL u = _target.getResource(_paths[i]);
@@ -114,7 +115,7 @@
}
urls.trimToSize();
- URL[] urlArray = (URL[])urls.toArray(new URL[0]);
+ URL[] urlArray = urls.toArray(new URL[0]);
AggregatingURLStreamHandler handler = new AggregatingURLStreamHandler(urlArray, _separator);
return new URL("aggregating", null, -1, path, handler);
@@ -168,6 +169,7 @@
* @return a URLConnection
* @throws IOException when something bad happens
*/
+ @Override
protected URLConnection openConnection(URL u) throws IOException
{
int len = _urls.length;
@@ -198,6 +200,7 @@
}
}
+ @Override
public void connect() throws IOException
{
for (int i=0, len = _connections.length; i < len; i++)
@@ -206,6 +209,7 @@
}
}
+ @Override
public InputStream getInputStream() throws IOException
{
boolean hasseparator = (_separator!=null);
@@ -229,14 +233,16 @@
streams[++streamCounter] = new separatorInputStream(_separator);
}
}
- return new SequenceInputStream(new ArrayEnumeration(streams));
+ return new SequenceInputStream(new ArrayEnumeration<InputStream>(streams));
}
+ @Override
public String getContentType()
{
return _connections[0].getContentType();
}
+ @Override
public int getContentLength()
{
int totalContentLength = _contentLength;
@@ -276,6 +282,7 @@
return totalContentLength;
}
+ @Override
public long getLastModified()
{
long maxLastModified = -1;
@@ -294,6 +301,7 @@
return maxLastModified;
}
+ @Override
public String getHeaderField(
String name)
{
@@ -321,12 +329,12 @@
}
- private class ArrayEnumeration implements Enumeration
+ private class ArrayEnumeration<T> implements Enumeration<T>
{
- private Object[] _array;
- private int _len;
- private int _pointer = 0;
- public ArrayEnumeration(Object[] array)
+ private T[] _array;
+ private int _len;
+ private int _pointer = 0;
+ public ArrayEnumeration(T[] array)
{
_array = array;
_len = array.length;
@@ -337,7 +345,7 @@
return _pointer < _len;
}
- public Object nextElement() throws NoSuchElementException
+ public T nextElement() throws NoSuchElementException
{
try
{
@@ -366,6 +374,7 @@
_length = _separator.length;
}
+ @Override
public int read() throws IOException
{
if(_index < _length)
@@ -376,6 +385,7 @@
return -1;
}
+ @Override
public int read(byte[] b, int off, int len) throws IOException
{
int bytesLeft = available();
@@ -394,6 +404,7 @@
}
}
+ @Override
public long skip(long n) throws IOException
{
int bytesLeft = available();
@@ -414,6 +425,7 @@
}
}
+ @Override
public int available() throws IOException
{
return _length - _index;
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/CachingResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/CachingResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/CachingResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/CachingResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -48,7 +48,7 @@
{
super(parent);
- _cache = new HashMap();
+ _cache = new HashMap<String, URL>();
}
/**
@@ -61,11 +61,12 @@
*
* @throws java.io.IOException if an I/O error occurs
*/
+ @Override
protected URL findResource(
String path
) throws IOException
{
- URL url = (URL)_cache.get(path);
+ URL url = _cache.get(path);
if (url == null)
{
@@ -81,7 +82,7 @@
return url;
}
- private final Map _cache;
+ private final Map<String, URL> _cache;
/**
* URLStreamHandler to cache URL contents and URLConnection headers.
@@ -94,6 +95,7 @@
_delegate = delegate;
}
+ @Override
protected URLConnection openConnection(
URL url
) throws IOException
@@ -156,32 +158,38 @@
_handler = handler;
}
+ @Override
public void connect() throws IOException
{
// cache: no-op
}
+ @Override
public String getContentType()
{
return _conn.getContentType();
}
+ @Override
public int getContentLength()
{
return _conn.getContentLength();
}
+ @Override
public long getLastModified()
{
return _conn.getLastModified();
}
+ @Override
public String getHeaderField(
String name)
{
return _conn.getHeaderField(name);
}
+ @Override
public InputStream getInputStream() throws IOException
{
return _handler.getInputStream(_conn);
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ClassLoaderResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ClassLoaderResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ClassLoaderResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -75,6 +75,7 @@
_resourcePrefix = _getResourcePrefix(rootPackage);
}
+ @Override
protected URL findResource(
String path) throws IOException
{
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/DirectoryResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/DirectoryResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/DirectoryResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/DirectoryResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -69,6 +69,7 @@
_directory = directory;
}
+ @Override
protected URL findResource(
String path) throws IOException
{
@@ -84,7 +85,11 @@
// return null if relative paths were used,
// or if the file does not exist,
// otherwise return an URL to the file resource
- return (isContained && file.exists()) ? file.toURL() : null;
+ // 2006-08-01: -= Simon Lessard =-
+ // File.toURL is deprecated in JDK 6.0 because the method
+ // does not escape invalid characters, toURI().toURL is the
+ // preferred way as of JDK 6.0.
+ return (isContained && file.exists()) ? file.toURI().toURL() : null;
}
private final File _directory;
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/DynamicResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/DynamicResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/DynamicResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/DynamicResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -68,6 +68,7 @@
* @return a URL for this resource
* @throws IOException when something bad happens
*/
+ @Override
protected URL findResource(String path) throws IOException
{
if (_path.equals(path))
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ProxyResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ProxyResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ProxyResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ProxyResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -22,6 +22,7 @@
import java.net.URLConnection;
import java.net.URLStreamHandler;
+import java.util.List;
import java.util.Map;
import java.io.OutputStream;
import java.security.Permission;
@@ -45,6 +46,7 @@
super(parent);
}
+ @Override
public URL getResource(
String path) throws IOException
{
@@ -66,6 +68,7 @@
_proxied = proxied;
}
+ @Override
protected URLConnection openConnection(
URL url
) throws IOException
@@ -91,171 +94,205 @@
_delegate = proxied.openConnection();
}
+ @Override
public void addRequestProperty(String key, String value)
{
getURLConnection().addRequestProperty(key, value);
}
+ @Override
public void connect() throws IOException
{
getURLConnection().connect();
}
+ @Override
public boolean getAllowUserInteraction()
{
return getURLConnection().getAllowUserInteraction();
}
+ @Override
public Object getContent() throws IOException
{
return getURLConnection().getContent();
}
+ @Override
public Object getContent(Class[] classes) throws IOException
{
return getURLConnection().getContent(classes);
}
+ @Override
public String getContentEncoding()
{
return getURLConnection().getContentEncoding();
}
+ @Override
public int getContentLength()
{
return getURLConnection().getContentLength();
}
+ @Override
public String getContentType()
{
return ProxyResourceLoader.this.getContentType(getURLConnection());
}
+ @Override
public long getDate()
{
return getURLConnection().getDate();
}
+ @Override
public boolean getDefaultUseCaches()
{
return getURLConnection().getDefaultUseCaches();
}
+ @Override
public boolean getDoInput()
{
return getURLConnection().getDoInput();
}
+ @Override
public boolean getDoOutput()
{
return getURLConnection().getDoOutput();
}
+ @Override
public long getExpiration()
{
return getURLConnection().getExpiration();
}
+ @Override
public String getHeaderField(int n)
{
return getURLConnection().getHeaderField(n);
}
+ @Override
public String getHeaderField(String name)
{
return getURLConnection().getHeaderField(name);
}
+ @Override
public long getHeaderFieldDate(String name, long Default)
{
return getURLConnection().getHeaderFieldDate(name, Default);
}
+ @Override
public int getHeaderFieldInt(String name, int Default)
{
return getURLConnection().getHeaderFieldInt(name, Default);
}
+ @Override
public String getHeaderFieldKey(int n)
{
return getURLConnection().getHeaderFieldKey(n);
}
- public Map getHeaderFields()
+ @Override
+ public Map<String, List<String>> getHeaderFields()
{
return getURLConnection().getHeaderFields();
}
+ @Override
public long getIfModifiedSince()
{
return getURLConnection().getIfModifiedSince();
}
+ @Override
public InputStream getInputStream() throws IOException
{
return getURLConnection().getInputStream();
}
+ @Override
public long getLastModified()
{
return getURLConnection().getLastModified();
}
+ @Override
public OutputStream getOutputStream() throws IOException
{
return getURLConnection().getOutputStream();
}
+ @Override
public Permission getPermission() throws IOException
{
return getURLConnection().getPermission();
}
- public Map getRequestProperties()
+ @Override
+ public Map<String, List<String>> getRequestProperties()
{
return getURLConnection().getRequestProperties();
}
+ @Override
public String getRequestProperty(String key)
{
return getURLConnection().getRequestProperty(key);
}
+ @Override
public boolean getUseCaches()
{
return getURLConnection().getUseCaches();
}
+ @Override
public void setAllowUserInteraction(boolean allowuserinteraction)
{
getURLConnection().setAllowUserInteraction(allowuserinteraction);
}
+ @Override
public void setDefaultUseCaches(boolean defaultusecaches)
{
getURLConnection().setDefaultUseCaches(defaultusecaches);
}
+ @Override
public void setDoInput(boolean doinput)
{
getURLConnection().setDoInput(doinput);
}
+ @Override
public void setDoOutput(boolean dooutput)
{
getURLConnection().setDoOutput(dooutput);
}
+ @Override
public void setIfModifiedSince(long ifmodifiedsince)
{
getURLConnection().setIfModifiedSince(ifmodifiedsince);
}
+ @Override
public void setRequestProperty(String key, String value)
{
getURLConnection().setRequestProperty(key, value);
}
+ @Override
public void setUseCaches(boolean usecaches)
{
getURLConnection().setUseCaches(usecaches);
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/RegexResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/RegexResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/RegexResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/RegexResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -29,6 +29,12 @@
* A resource loader implementation which loads resources
* by pattern matching the requested resource path to a
* registered resource loader.
+ *
+ * Change history
+ * 2006-08-01: -= Simon Lessard =-
+ * Changed to use a list of entry rather than a dual typed
+ * one to add more type safety with minimal memory overhaul
+ * and get a really small performance gain.
*
* @author The Oracle ADF Faces Team
*/
@@ -39,23 +45,19 @@
*/
public RegexResourceLoader()
{
- _loaders = new ArrayList();
+ _loaders = new ArrayList<RegexResourceNode>();
}
+ @Override
protected URL findResource(
String path) throws IOException
{
- Iterator iter = _loaders.iterator();
- while (iter.hasNext())
+ for(RegexResourceNode node : _loaders)
{
- Pattern pattern = (Pattern) iter.next();
- assert iter.hasNext();
- ResourceLoader loader = (ResourceLoader) iter.next();
-
- Matcher matcher = pattern.matcher(path);
+ Matcher matcher = node.getPattern().matcher(path);
if (matcher.matches())
{
- return loader.getResource(matcher.group(1));
+ return node.getResourceLoader().getResource(matcher.group(1));
}
}
@@ -74,8 +76,7 @@
{
Pattern pattern = Pattern.compile(regex);
_checkPathRegex(regex);
- _loaders.add(pattern);
- _loaders.add(loader);
+ _loaders.add(new RegexResourceNode(pattern,loader));
}
/**
@@ -86,14 +87,19 @@
protected void deregister(
String regex)
{
- Pattern pattern = Pattern.compile(regex);
+ // -= Simon Lessard =-
+ // Regex compilation can be expensive and the variable
+ // is only used for equals purpose, so use the other way
+ // around instead, that is get the expression out of the
+ // compiled patterns through Pattern.pattern().
+ // Pattern pattern = Pattern.compile(regex);
- for (int i = 0; i < _loaders.size(); i += 2)
+ Iterator<RegexResourceNode> nodeIterator = _loaders.iterator();
+ while(nodeIterator.hasNext())
{
- if (pattern.equals(_loaders.get(i)))
+ if(regex.equals(nodeIterator.next().getPattern().pattern()))
{
- _loaders.remove(i);
- _loaders.remove(i);
+ nodeIterator.remove();
return;
}
}
@@ -116,6 +122,28 @@
"\" does not have leading slash");
}
}
+
+ private static class RegexResourceNode
+ {
+ public RegexResourceNode(Pattern pattern, ResourceLoader loader)
+ {
+ _pattern = pattern;
+ _loader = loader;
+ }
+
+ public Pattern getPattern()
+ {
+ return _pattern;
+ }
+
+ public ResourceLoader getResourceLoader()
+ {
+ return _loader;
+ }
+
+ private ResourceLoader _loader;
+ private Pattern _pattern;
+ }
- private final List _loaders;
+ private final List<RegexResourceNode> _loaders;
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -31,6 +31,16 @@
public class ResourceLoader
{
/**
+ * Returns the shared resource loader that always returns null.
+ *
+ * @return null for any resource path
+ */
+ public static ResourceLoader getNullResourceLoader()
+ {
+ return _NULL_RESOURCE_LOADER;
+ }
+
+ /**
* Finds the resource with the given name. A resource is some data
* (images, audio, text, etc) that can be accessed by class code in a way
* that is independent of the location of the code.
@@ -120,20 +130,10 @@
{
this(null);
}
-
- /**
- * Returns the shared resource loader that always returns null.
- *
- * @return null for any resource path
- */
- static public ResourceLoader getNullResourceLoader()
- {
- return _NULL_RESOURCE_LOADER;
- }
-
- private final ResourceLoader _parent;
- static private final ResourceLoader _NULL_RESOURCE_LOADER =
+ private static final ResourceLoader _NULL_RESOURCE_LOADER =
new ResourceLoader();
+
+ private final ResourceLoader _parent;
}
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ServletContextResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ServletContextResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ServletContextResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/ServletContextResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -55,6 +55,7 @@
_context = context;
}
+ @Override
protected URL findResource(
String path) throws IOException
{
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/StringContentResourceLoader.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/StringContentResourceLoader.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/StringContentResourceLoader.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/resource/StringContentResourceLoader.java Tue Aug 1 15:00:44 2006
@@ -32,17 +32,18 @@
{
super(path, parent);
}
-
- protected URL getURL(String path) throws IOException
+
+ protected String getContentType(String path)
{
- return new URL("dynamic", null, -1, path, new StringContentURLStreamHandler(getString(path), getContentType(path)));
+ return "text";
}
protected abstract String getString(String path) throws IOException;
-
- protected String getContentType(String path)
+
+ @Override
+ protected URL getURL(String path) throws IOException
{
- return "text";
+ return new URL("dynamic", null, -1, path, new StringContentURLStreamHandler(getString(path), getContentType(path)));
}
/**
@@ -73,6 +74,7 @@
* @return a connection containing the string of data
* @throws IOException when something bad happens
*/
+ @Override
protected URLConnection openConnection(URL u) throws IOException
{
return new StringContentURLConnection(u, _buff, _contentType);
@@ -92,27 +94,32 @@
_contentType = contentType;
}
+ @Override
public void connect() throws IOException
{
connected = true;
}
+ @Override
public String getContentEncoding()
{
//No content Encoding in Strings (like gzip or deflate)
return null;
}
+ @Override
public int getContentLength()
{
return _buff.length;
}
+ @Override
public String getContentType()
{
return _contentType;
}
+ @Override
public String getHeaderField(String name)
{
if("content-encoding".equals(name))
@@ -131,6 +138,7 @@
return null;
}
+ @Override
public InputStream getInputStream() throws IOException
{
return new ByteArrayInputStream(_buff);
Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ArrayMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ArrayMap.java?rev=427760&r1=427759&r2=427760&view=diff
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ArrayMap.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ArrayMap.java Tue Aug 1 15:00:44 2006
@@ -90,6 +90,7 @@
/**
* Returns the key at a specific index in the map.
*/
+ @SuppressWarnings("unchecked")
public K getKey(int index)
{
if ((index < 0) || (index >= size()))
@@ -101,6 +102,7 @@
/**
* Returns the value at a specific index in the map.
*/
+ @SuppressWarnings("unchecked")
public V getValue(int index)
{
if ((index < 0) || (index >= size()))
@@ -247,11 +249,13 @@
//
// GENERIC MAP API
//
+ @Override
public int size()
{
return _size;
}
+ @Override
public boolean containsValue(Object value)
{
int entryCount = size() * 2;
@@ -265,6 +269,7 @@
}
+ @Override
public boolean containsKey(Object key)
{
int entryCount = size() * 2;
@@ -277,12 +282,13 @@
return false;
}
- /**
+ /**
* Returns an enumeration of the keys in this map.
* the Iterator methods on the returned object to fetch the elements
* sequentially.
*/
- public Iterator<K> keys()
+ @SuppressWarnings("unchecked")
+ public Iterator<K> keys()
{
int size = _size;
@@ -301,11 +307,11 @@
/**
* Returns an Iterator of keys in the array.
*/
- static public Iterator getKeys(Object[] array)
+ public static Iterator<Object> getKeys(Object[] array)
{
if (array == null)
return null;
- ArrayList keyList = new ArrayList();
+ ArrayList<Object> keyList = new ArrayList<Object>();
int i = array.length-2;
while(i>=0)
{
@@ -319,11 +325,11 @@
/**
* Returns an Iterator of values in the array.
*/
- static public Iterator getValues(Object[] array)
+ public static Iterator<Object> getValues(Object[] array)
{
if (array == null)
return null;
- ArrayList valueList = new ArrayList();
+ ArrayList<Object> valueList = new ArrayList<Object>();
int i = array.length-1;
while(i>=0)
{
@@ -337,13 +343,15 @@
/**
* Clones the map.
*/
+ @SuppressWarnings("unchecked")
+ @Override
public Object clone()
{
try
{
- ArrayMap am = (ArrayMap) super.clone();
+ ArrayMap<K, V> am = (ArrayMap<K, V>) super.clone();
- am._array = (Object[]) _array.clone();
+ am._array = _array.clone();
am._size = _size;
am._increment = _increment;
return am;
@@ -355,20 +363,23 @@
}
}
+ @Override
public Set<Map.Entry<K,V>> entrySet()
{
if (_entrySet == null)
{
_entrySet = new AbstractSet<Map.Entry<K,V>>()
{
+ @Override
public int size()
{
return ArrayMap.this.size();
}
+ @Override
public Iterator<Map.Entry<K,V>> iterator()
{
- return new Iterator()
+ return new Iterator<Map.Entry<K,V>>()
{
public boolean hasNext()
{
@@ -419,12 +430,12 @@
{
public K getKey()
{
- return (K) ArrayMap.this.getKey(index);
+ return ArrayMap.this.getKey(index);
}
public V getValue()
{
- return (V) ArrayMap.this.getValue(index);
+ return ArrayMap.this.getValue(index);
}
public V setValue(V value)
@@ -434,15 +445,18 @@
return oldValue;
}
+ @SuppressWarnings("unchecked")
+ @Override
public boolean equals(Object o)
{
if (!(o instanceof Map.Entry))
return false;
- Map.Entry e = (Map.Entry)o;
+ Map.Entry<K,V> e = (Map.Entry<K,V>)o;
return _equals(getKey(), e.getKey()) &&
_equals(getValue(), e.getValue());
}
+ @Override
public int hashCode()
{
Object key = getKey();
@@ -464,17 +478,22 @@
return _entrySet;
}
+ @SuppressWarnings("unchecked")
+ @Override
public V get(Object key)
{
return (V) getByEquality(_array, key);
//return getByIdentity(_array, key);
}
+ @SuppressWarnings("unchecked")
public V getByIdentity(Object key)
{
return (V) getByIdentity(_array, key);
}
+ @SuppressWarnings("unchecked")
+ @Override
public V put(K key, V value)
{
if (value == null)
@@ -512,6 +531,8 @@
return (V) o;
}
+ @SuppressWarnings("unchecked")
+ @Override
public V remove(Object key)
{
Object[] array = _array;
@@ -529,6 +550,7 @@
/**
* Removes all elements from the ArrayMap.
*/
+ @Override
public void clear()
{
int size = _size;
@@ -547,7 +569,7 @@
* Adds the key/value pair to the array, returning a
* new array if necessary.
*/
- static private Object[] _addToArray(Object[] array,
+ private static Object[] _addToArray(Object[] array,
Object key,
Object value,
int increment)
@@ -569,7 +591,7 @@
return newArray;
}
- static private boolean _equals(Object a, Object b)
+ private static boolean _equals(Object a, Object b)
{
if (a == null)
return b == null;
@@ -580,5 +602,5 @@
private Object[] _array;
private int _size;
private int _increment;
- private Set<Map.Entry<K,V>> _entrySet;
+ private Set<Map.Entry<K,V>> _entrySet;
}