aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
diff options
context:
space:
mode:
authorMatthias Klose <doko@gcc.gnu.org>2008-06-28 13:29:13 +0000
committerMatthias Klose <doko@gcc.gnu.org>2008-06-28 13:29:13 +0000
commite0441a5bfb29083a532307ba2b1fd6d6d13944ba (patch)
tree602cd7aa7c947386134690d8e0f6b53abcdeacb9 /libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
parent15c151967dd1cde61b79d26374f608f63a29d411 (diff)
downloadgcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.zip
gcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.tar.gz
gcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.tar.bz2
Import GNU Classpath (classpath-0_97_2-release).
libjava/ 2008-06-28 Matthias Klose <doko@ubuntu.com> Import GNU Classpath (classpath-0_97_2-release). * Regenerate class and header files. * Regenerate auto* files. * gcj/javaprims.h: Define jobjectRefType. * jni.cc (_Jv_JNI_GetObjectRefType): New (stub only). (_Jv_JNIFunctions): Initialize GetObjectRefType. * gnu/classpath/jdwp/VMVirtualMachine.java, java/security/VMSecureRandom.java: Merge from classpath. * HACKING: Fix typo. * ChangeLog-2007: New file. * configure.ac: Set JAVAC, pass --disable-regen-headers to classpath. libjava/classpath/ 2008-06-28 Matthias Klose <doko@ubuntu.com> * m4/ac_prog_javac.m4: Disable check for JAVAC, when not configured with --enable-java-maintainer-mode. * aclocal.m4, configure: Regenerate. * native/jni/gstreamer-peer/Makefile.am: Do not link with libclasspathnative. * native/jni/gstreamer-peer/Makefile.in: Regenerate. * tools/Makefile.am, lib/Makefile.am: Use JAVAC for setting JCOMPILER, drop flags not understood by gcj. From-SVN: r137223
Diffstat (limited to 'libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java')
-rw-r--r--libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java61
1 files changed, 35 insertions, 26 deletions
diff --git a/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
index 9f587946..a1afe78 100644
--- a/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
+++ b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
@@ -202,7 +202,7 @@ public class DefaultMutableTreeNode
*/
public void remove(int index)
{
- MutableTreeNode child = (MutableTreeNode) children.remove(index);
+ MutableTreeNode child = children.remove(index);
child.setParent(null);
}
@@ -553,7 +553,7 @@ public class DefaultMutableTreeNode
{
node = node.getParent();
size = node.getChildCount();
- index = ((Integer) stack.pop()).intValue() + 1;
+ index = stack.pop().intValue() + 1;
current--;
}
while (index >= size
@@ -1052,10 +1052,10 @@ public class DefaultMutableTreeNode
/** Provides an enumeration of a tree in breadth-first traversal
* order.
*/
- static class BreadthFirstEnumeration implements Enumeration
+ static class BreadthFirstEnumeration implements Enumeration<TreeNode>
{
- LinkedList queue = new LinkedList();
+ LinkedList<TreeNode> queue = new LinkedList<TreeNode>();
BreadthFirstEnumeration(TreeNode node)
{
@@ -1067,14 +1067,16 @@ public class DefaultMutableTreeNode
return !queue.isEmpty();
}
- public Object nextElement()
+ @SuppressWarnings("unchecked")
+ public TreeNode nextElement()
{
if (queue.isEmpty())
throw new NoSuchElementException("No more elements left.");
- TreeNode node = (TreeNode) queue.removeFirst();
+ TreeNode node = queue.removeFirst();
- Enumeration children = node.children();
+ Enumeration<TreeNode> children =
+ (Enumeration<TreeNode>) node.children();
while (children.hasMoreElements())
queue.add(children.nextElement());
@@ -1085,16 +1087,18 @@ public class DefaultMutableTreeNode
/** Provides an enumeration of a tree traversing it
* preordered.
*/
- static class PreorderEnumeration implements Enumeration
+ static class PreorderEnumeration implements Enumeration<TreeNode>
{
TreeNode next;
- Stack childrenEnums = new Stack();
+ Stack<Enumeration<TreeNode>> childrenEnums =
+ new Stack<Enumeration<TreeNode>>();
+ @SuppressWarnings("unchecked")
PreorderEnumeration(TreeNode node)
{
next = node;
- childrenEnums.push(node.children());
+ childrenEnums.push((Enumeration<TreeNode>) node.children());
}
public boolean hasMoreElements()
@@ -1102,14 +1106,14 @@ public class DefaultMutableTreeNode
return next != null;
}
- public Object nextElement()
+ public TreeNode nextElement()
{
if (next == null)
throw new NoSuchElementException("No more elements left.");
- Object current = next;
+ TreeNode current = next;
- Enumeration children = (Enumeration) childrenEnums.peek();
+ Enumeration<TreeNode> children = childrenEnums.peek();
// Retrieves the next element.
next = traverse(children);
@@ -1117,13 +1121,14 @@ public class DefaultMutableTreeNode
return current;
}
- private TreeNode traverse(Enumeration children)
+ @SuppressWarnings("unchecked")
+ private TreeNode traverse(Enumeration<TreeNode> children)
{
// If more children are available step down.
if (children.hasMoreElements())
{
- TreeNode child = (TreeNode) children.nextElement();
- childrenEnums.push(child.children());
+ TreeNode child = children.nextElement();
+ childrenEnums.push((Enumeration<TreeNode>) child.children());
return child;
}
@@ -1137,7 +1142,7 @@ public class DefaultMutableTreeNode
return null;
else
{
- return traverse((Enumeration) childrenEnums.peek());
+ return traverse(childrenEnums.peek());
}
}
}
@@ -1145,16 +1150,18 @@ public class DefaultMutableTreeNode
/** Provides an enumeration of a tree traversing it
* postordered (= depth-first).
*/
- static class PostorderEnumeration implements Enumeration
+ static class PostorderEnumeration implements Enumeration<TreeNode>
{
Stack<TreeNode> nodes = new Stack<TreeNode>();
- Stack childrenEnums = new Stack();
+ Stack<Enumeration<TreeNode>> childrenEnums =
+ new Stack<Enumeration<TreeNode>>();
+ @SuppressWarnings("unchecked")
PostorderEnumeration(TreeNode node)
{
nodes.push(node);
- childrenEnums.push(node.children());
+ childrenEnums.push((Enumeration<TreeNode>) node.children());
}
public boolean hasMoreElements()
@@ -1162,24 +1169,26 @@ public class DefaultMutableTreeNode
return !nodes.isEmpty();
}
- public Object nextElement()
+ public TreeNode nextElement()
{
if (nodes.isEmpty())
throw new NoSuchElementException("No more elements left!");
- Enumeration children = (Enumeration) childrenEnums.peek();
+ Enumeration<TreeNode> children = childrenEnums.peek();
return traverse(children);
}
- private Object traverse(Enumeration children)
+ @SuppressWarnings("unchecked")
+ private TreeNode traverse(Enumeration<TreeNode> children)
{
if (children.hasMoreElements())
{
- TreeNode node = (TreeNode) children.nextElement();
+ TreeNode node = children.nextElement();
nodes.push(node);
- Enumeration newChildren = node.children();
+ Enumeration<TreeNode> newChildren =
+ (Enumeration<TreeNode>) node.children();
childrenEnums.push(newChildren);
return traverse(newChildren);
@@ -1190,7 +1199,7 @@ public class DefaultMutableTreeNode
// Returns the node whose children
// have all been visited. (= postorder)
- Object next = nodes.peek();
+ TreeNode next = nodes.peek();
nodes.pop();
return next;