This patch adds type parameters to a number of collections in the javax.swing classes.
ChangeLog:
2008-02-17 Andrew John Hughes <[EMAIL PROTECTED]>
* javax/swing/tree/FixedHeightLayoutCache.java,
* javax/swing/tree/VariableHeightLayoutCache.java,
* javax/swing/undo/StateEdit.java:
Use type parameters with collections classes.
--
Andrew :)
Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
Index: javax/swing/tree/FixedHeightLayoutCache.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/tree/FixedHeightLayoutCache.java,v
retrieving revision 1.18
diff -u -3 -p -u -r1.18 FixedHeightLayoutCache.java
--- javax/swing/tree/FixedHeightLayoutCache.java 10 Dec 2006 20:25:49 -0000 1.18
+++ javax/swing/tree/FixedHeightLayoutCache.java 17 Feb 2008 16:55:31 -0000
@@ -135,7 +135,7 @@ public class FixedHeightLayoutCache
}
}
- LinkedList lpath = new LinkedList();
+ LinkedList<Object> lpath = new LinkedList<Object>();
NodeRecord rp = this;
while (rp != null)
{
@@ -173,17 +173,17 @@ public class FixedHeightLayoutCache
/**
* The set of all expanded tree nodes.
*/
- Set expanded = new HashSet();
+ Set<Object> expanded = new HashSet<Object>();
/**
* Maps nodes to the row numbers.
*/
- Hashtable nodes = new Hashtable();
+ Hashtable<Object,NodeRecord> nodes = new Hashtable<Object,NodeRecord>();
/**
* Maps row numbers to nodes.
*/
- Hashtable row2node = new Hashtable();
+ Hashtable<Integer,Object> row2node = new Hashtable<Integer,Object>();
/**
* If true, the row map must be recomputed before using.
@@ -338,7 +338,7 @@ public class FixedHeightLayoutCache
if (dirty)
update();
Object last = path.getLastPathComponent();
- NodeRecord r = (NodeRecord) nodes.get(last);
+ NodeRecord r = nodes.get(last);
if (r == null)
// This node is not visible.
{
@@ -373,7 +373,7 @@ public class FixedHeightLayoutCache
return null;
else
{
- NodeRecord r = (NodeRecord) nodes.get(last);
+ NodeRecord r = nodes.get(last);
return r.getPath();
}
}
@@ -391,7 +391,7 @@ public class FixedHeightLayoutCache
if (dirty) update();
- NodeRecord r = (NodeRecord) nodes.get(path.getLastPathComponent());
+ NodeRecord r = nodes.get(path.getLastPathComponent());
if (r == null)
return - 1;
else
@@ -413,13 +413,13 @@ public class FixedHeightLayoutCache
// As the rows have arbitrary height, we need to iterate.
NodeRecord best = null;
NodeRecord r;
- Enumeration en = nodes.elements();
+ Enumeration<NodeRecord> en = nodes.elements();
int dist = Integer.MAX_VALUE;
while (en.hasMoreElements() && dist > 0)
{
- r = (NodeRecord) en.nextElement();
+ r = en.nextElement();
if (best == null)
{
best = r;
@@ -474,7 +474,7 @@ public class FixedHeightLayoutCache
}
/**
- * Get the enumeration over all visible pathes that start from the given
+ * Get the enumeration over all visible paths that start from the given
* parent path.
*
* @param parentPath the parent path
@@ -491,7 +491,7 @@ public class FixedHeightLayoutCache
for (int i = 0; i < parentPath.getPathCount(); i++)
{
node = parentPath.getPathComponent(i);
- nr = (NodeRecord) nodes.get(node);
+ nr = nodes.get(node);
if (nr.row >= 0)
p.add(node);
}
@@ -583,10 +583,10 @@ public class FixedHeightLayoutCache
if (dirty)
update();
totalHeight = 0;
- Enumeration en = nodes.elements();
+ Enumeration<NodeRecord> en = nodes.elements();
while (en.hasMoreElements())
{
- NodeRecord nr = (NodeRecord) en.nextElement();
+ NodeRecord nr = en.nextElement();
Rectangle r = nr.getBounds();
totalHeight += r.height;
}
@@ -602,10 +602,10 @@ public class FixedHeightLayoutCache
update();
maximalWidth = 0;
- Enumeration en = nodes.elements();
+ Enumeration<NodeRecord> en = nodes.elements();
while (en.hasMoreElements())
{
- NodeRecord nr = (NodeRecord) en.nextElement();
+ NodeRecord nr = en.nextElement();
Rectangle r = nr.getBounds();
if (r.x + r.width > maximalWidth)
maximalWidth = r.x + r.width;
Index: javax/swing/tree/VariableHeightLayoutCache.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/tree/VariableHeightLayoutCache.java,v
retrieving revision 1.20
diff -u -3 -p -u -r1.20 VariableHeightLayoutCache.java
--- javax/swing/tree/VariableHeightLayoutCache.java 10 Dec 2006 20:25:49 -0000 1.20
+++ javax/swing/tree/VariableHeightLayoutCache.java 17 Feb 2008 16:55:31 -0000
@@ -138,7 +138,7 @@ public class VariableHeightLayoutCache
}
}
- LinkedList lpath = new LinkedList();
+ LinkedList<Object> lpath = new LinkedList<Object>();
NodeRecord rp = this;
while (rp != null)
{
@@ -146,7 +146,7 @@ public class VariableHeightLayoutCache
if (rp.parent != null)
{
Object parent = rp.parent;
- rp = (NodeRecord) nodes.get(parent);
+ rp = nodes.get(parent);
// Add the root node, even if it is not visible.
if (rp == null)
lpath.addFirst(parent);
@@ -171,17 +171,17 @@ public class VariableHeightLayoutCache
/**
* The set of all expanded tree nodes.
*/
- Set expanded = new HashSet();
+ Set<Object> expanded = new HashSet<Object>();
/**
* Maps nodes to the row numbers.
*/
- Hashtable nodes = new Hashtable();
+ Hashtable<Object,NodeRecord> nodes = new Hashtable<Object,NodeRecord>();
/**
* Maps row numbers to nodes.
*/
- ArrayList row2node = new ArrayList();
+ ArrayList<Object> row2node = new ArrayList<Object>();
/**
* If true, the row map must be recomputed before using.
@@ -292,7 +292,7 @@ public class VariableHeightLayoutCache
*/
public void invalidatePathBounds(TreePath path)
{
- NodeRecord r = (NodeRecord) nodes.get(path.getLastPathComponent());
+ NodeRecord r = nodes.get(path.getLastPathComponent());
if (r != null)
r.bounds = null;
}
@@ -354,7 +354,7 @@ public class VariableHeightLayoutCache
Object last = path.getLastPathComponent();
Rectangle result = null;
- NodeRecord r = (NodeRecord) nodes.get(last);
+ NodeRecord r = nodes.get(last);
if (r != null)
{
// The RI allows null arguments for rect, in which case a new Rectangle
@@ -405,7 +405,7 @@ public class VariableHeightLayoutCache
if (dirty)
update();
- NodeRecord r = (NodeRecord) nodes.get(path.getLastPathComponent());
+ NodeRecord r = nodes.get(path.getLastPathComponent());
if (r == null)
return - 1;
else
@@ -427,13 +427,13 @@ public class VariableHeightLayoutCache
// As the rows have arbitrary height, we need to iterate.
NodeRecord best = null;
NodeRecord r;
- Enumeration en = nodes.elements();
+ Enumeration<NodeRecord> en = nodes.elements();
int dist = Integer.MAX_VALUE;
while (en.hasMoreElements() && dist > 0)
{
- r = (NodeRecord) en.nextElement();
+ r = en.nextElement();
if (best == null)
{
best = r;
@@ -488,7 +488,7 @@ public class VariableHeightLayoutCache
}
/**
- * Get the enumeration over all visible pathes that start from the given
+ * Get the enumeration over all visible paths that start from the given
* parent path.
*
* @param parentPath the parent path
@@ -505,7 +505,7 @@ public class VariableHeightLayoutCache
for (int i = 0; i < parentPath.getPathCount(); i++)
{
node = parentPath.getPathComponent(i);
- nr = (NodeRecord) nodes.get(node);
+ nr = nodes.get(node);
if (nr != null && nr.row >= 0)
p.add(node);
}
@@ -603,7 +603,7 @@ public class VariableHeightLayoutCache
int rowCount = getRowCount();
if (rowCount > 0)
{
- NodeRecord last = (NodeRecord) nodes.get(row2node.get(rowCount - 1));
+ NodeRecord last = nodes.get(row2node.get(rowCount - 1));
height = last.bounds.y + last.bounds.height;
}
return height;
@@ -618,10 +618,10 @@ public class VariableHeightLayoutCache
update();
maximalWidth = 0;
- Enumeration en = nodes.elements();
+ Enumeration<NodeRecord> en = nodes.elements();
while (en.hasMoreElements())
{
- NodeRecord nr = (NodeRecord) en.nextElement();
+ NodeRecord nr = en.nextElement();
if (nr != null)
{
Rectangle r = nr.getBounds();
Index: javax/swing/undo/StateEdit.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/undo/StateEdit.java,v
retrieving revision 1.10
diff -u -3 -p -u -r1.10 StateEdit.java
--- javax/swing/undo/StateEdit.java 10 Dec 2006 20:25:49 -0000 1.10
+++ javax/swing/undo/StateEdit.java 17 Feb 2008 16:55:31 -0000
@@ -177,8 +177,8 @@ public class StateEdit
{
object = obj;
undoRedoName = name;
- preState = new Hashtable();
- postState = new Hashtable();
+ preState = new Hashtable<Object,Object>();
+ postState = new Hashtable<Object,Object>();
obj.storeState(preState);
}
signature.asc
Description: Digital signature
