diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-02-28 23:50:09 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-02-28 23:50:09 +0000 |
commit | fa061b7189bfcd21a02ccac393da26ed92f4b21b (patch) | |
tree | fe6495a24ff49d8088f8e8769b483db47a255cc6 | |
parent | c0daa0df39fcb3be58fba09bb936f515368b085e (diff) | |
download | classpath-fa061b7189bfcd21a02ccac393da26ed92f4b21b.tar.gz |
2008-02-28 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/util/EmptyEnumeration.java:
Add generic type parameter.
* java/lang/ClassLoader.java:
Use EmptyEnumeration with type parameter.
* java/util/zip/ZipFile.java:
Likewise.
* javax/swing/text/html/StyleSheet.java,
* javax/swing/text/html/ViewAttributeSet.java:
Add generics.
* javax/swing/tree/DefaultMutableTreeNode.java:
Use EmptyEnumeration with type parameter.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | gnu/java/util/EmptyEnumeration.java | 18 | ||||
-rw-r--r-- | java/lang/ClassLoader.java | 2 | ||||
-rw-r--r-- | java/util/zip/ZipFile.java | 2 | ||||
-rw-r--r-- | javax/swing/text/html/StyleSheet.java | 37 | ||||
-rw-r--r-- | javax/swing/text/html/ViewAttributeSet.java | 6 | ||||
-rw-r--r-- | javax/swing/tree/DefaultMutableTreeNode.java | 2 |
7 files changed, 43 insertions, 38 deletions
@@ -1,5 +1,19 @@ 2008-02-28 Andrew John Hughes <gnu_andrew@member.fsf.org> + * gnu/java/util/EmptyEnumeration.java: + Add generic type parameter. + * java/lang/ClassLoader.java: + Use EmptyEnumeration with type parameter. + * java/util/zip/ZipFile.java: + Likewise. + * javax/swing/text/html/StyleSheet.java, + * javax/swing/text/html/ViewAttributeSet.java: + Add generics. + * javax/swing/tree/DefaultMutableTreeNode.java: + Use EmptyEnumeration with type parameter. + +2008-02-28 Andrew John Hughes <gnu_andrew@member.fsf.org> + PR classpath/28664 * include/Makefile.am: Add generation of header file java_math_VMBigInteger.h diff --git a/gnu/java/util/EmptyEnumeration.java b/gnu/java/util/EmptyEnumeration.java index 46a82d6cb..ca2c56d73 100644 --- a/gnu/java/util/EmptyEnumeration.java +++ b/gnu/java/util/EmptyEnumeration.java @@ -51,25 +51,19 @@ import java.util.NoSuchElementException; * * @author Mark Wielaard (mark@klomp.org) */ -public final class EmptyEnumeration implements Enumeration, Serializable +public final class EmptyEnumeration<T> implements Enumeration<T>, Serializable { /** The only instance of this class */ - private static final EmptyEnumeration instance = new EmptyEnumeration(); + private static final EmptyEnumeration<Object> instance = + new EmptyEnumeration<Object>(); /** - * Private constructor that creates a new empty Enumeration. - */ - private EmptyEnumeration() - { - } - - /** - * Returns the only instance of this class. + * Returns an instance of this class for Object. * It can be shared by multiple objects and threads. * * @return the common empty enumeration */ - public static EmptyEnumeration getInstance() + public static EmptyEnumeration<Object> getInstance() { return instance; } @@ -89,7 +83,7 @@ public final class EmptyEnumeration implements Enumeration, Serializable * * @throws NoSuchElementException this is empty */ - public Object nextElement() + public T nextElement() { throw new NoSuchElementException(); } diff --git a/java/lang/ClassLoader.java b/java/lang/ClassLoader.java index 3d7c32cc9..591406ac4 100644 --- a/java/lang/ClassLoader.java +++ b/java/lang/ClassLoader.java @@ -659,7 +659,7 @@ public abstract class ClassLoader */ protected Enumeration<URL> findResources(String name) throws IOException { - return (Enumeration<URL>) EmptyEnumeration.getInstance(); + return new EmptyEnumeration<URL>(); } /** diff --git a/java/util/zip/ZipFile.java b/java/util/zip/ZipFile.java index 3b34bd1f5..7cf7007ed 100644 --- a/java/util/zip/ZipFile.java +++ b/java/util/zip/ZipFile.java @@ -340,7 +340,7 @@ public class ZipFile implements ZipConstants } catch (IOException ioe) { - return EmptyEnumeration.getInstance(); + return new EmptyEnumeration<ZipEntry>(); } } diff --git a/javax/swing/text/html/StyleSheet.java b/javax/swing/text/html/StyleSheet.java index 01f19fd7b..fb17442b4 100644 --- a/javax/swing/text/html/StyleSheet.java +++ b/javax/swing/text/html/StyleSheet.java @@ -182,7 +182,7 @@ public class StyleSheet extends StyleContext */ private class CSSStyle extends SimpleAttributeSet - implements Style, Comparable + implements Style, Comparable<CSSStyle> { static final int PREC_UA = 0; @@ -229,9 +229,8 @@ public class StyleSheet extends StyleContext * Sorts the rule according to the style's precedence and the * selectors specificity. */ - public int compareTo(Object o) + public int compareTo(CSSStyle other) { - CSSStyle other = (CSSStyle) o; return other.precedence + other.selector.getSpecificity() - precedence - selector.getSpecificity(); } @@ -247,18 +246,18 @@ public class StyleSheet extends StyleContext /** * The linked style sheets stored. */ - private ArrayList linked; + private ArrayList<StyleSheet> linked; /** * Maps element names (selectors) to AttributSet (the corresponding style * information). */ - ArrayList css = new ArrayList(); + ArrayList<CSSStyle> css = new ArrayList<CSSStyle>(); /** * Maps selectors to their resolved styles. */ - private HashMap resolvedStyles; + private HashMap<String,Style> resolvedStyles; /** * Constructs a StyleSheet. @@ -267,7 +266,7 @@ public class StyleSheet extends StyleContext { super(); baseFontSize = 4; // Default font size from CSS - resolvedStyles = new HashMap(); + resolvedStyles = new HashMap<String,Style>(); } /** @@ -283,7 +282,7 @@ public class StyleSheet extends StyleContext { // Create list of the element and all of its parents, starting // with the bottommost element. - ArrayList path = new ArrayList(); + ArrayList<Element> path = new ArrayList<Element>(); Element el; AttributeSet atts; for (el = e; el != null; el = el.getParentElement()) @@ -295,7 +294,7 @@ public class StyleSheet extends StyleContext // We append the actual element after this loop. for (int i = count - 1; i > 0; i--) { - el = (Element) path.get(i); + el = path.get(i); atts = el.getAttributes(); Object name = atts.getAttribute(StyleConstants.NameAttribute); selector.append(name.toString()); @@ -322,7 +321,7 @@ public class StyleSheet extends StyleContext selector.append(' '); } selector.append(t.toString()); - el = (Element) path.get(0); + el = path.get(0); atts = el.getAttributes(); // For leaf elements, we have to fetch the tag specific attributes. if (el.isLeaf()) @@ -372,7 +371,7 @@ public class StyleSheet extends StyleContext */ private Style getResolvedStyle(String selector, List path, HTML.Tag tag) { - Style style = (Style) resolvedStyles.get(selector); + Style style = resolvedStyles.get(selector); if (style == null) style = resolveStyle(selector, path, tag); return style; @@ -439,11 +438,9 @@ public class StyleSheet extends StyleContext { // FIXME: This style resolver is not correct. But it works good enough for // the default.css. - int count = tags.length; - ArrayList styles = new ArrayList(); - for (Iterator i = css.iterator(); i.hasNext();) + ArrayList<CSSStyle> styles = new ArrayList<CSSStyle>(); + for (CSSStyle style : css) { - CSSStyle style = (CSSStyle) i.next(); if (style.selector.matches(tags, attributes)) styles.add(style); } @@ -453,10 +450,10 @@ public class StyleSheet extends StyleContext { for (int i = linked.size() - 1; i >= 0; i--) { - StyleSheet ss = (StyleSheet) linked.get(i); + StyleSheet ss = linked.get(i); for (int j = ss.css.size() - 1; j >= 0; j--) { - CSSStyle style = (CSSStyle) ss.css.get(j); + CSSStyle style = ss.css.get(j); if (style.selector.matches(tags, attributes)) styles.add(style); } @@ -615,7 +612,7 @@ public class StyleSheet extends StyleContext if (linked != null) { linkedSS = new StyleSheet[linked.size()]; - linkedSS = (StyleSheet[]) linked.toArray(linkedSS); + linkedSS = linked.toArray(linkedSS); } else { @@ -1446,8 +1443,8 @@ public class StyleSheet extends StyleContext */ private Map attributeSetToMap(AttributeSet atts) { - HashMap map = new HashMap(); - Enumeration keys = atts.getAttributeNames(); + HashMap<String,String> map = new HashMap<String,String>(); + Enumeration<?> keys = atts.getAttributeNames(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); diff --git a/javax/swing/text/html/ViewAttributeSet.java b/javax/swing/text/html/ViewAttributeSet.java index 25db89fc4..8838646d5 100644 --- a/javax/swing/text/html/ViewAttributeSet.java +++ b/javax/swing/text/html/ViewAttributeSet.java @@ -83,7 +83,7 @@ class ViewAttributeSet { styleSheet = ss; view = v; - ArrayList atts = new ArrayList(); + ArrayList<AttributeSet> atts = new ArrayList<AttributeSet>(); Element el = v.getElement(); AttributeSet elAtts = el.getAttributes(); @@ -93,7 +93,7 @@ class ViewAttributeSet if (el.isLeaf()) { - Enumeration n = elAtts.getAttributeNames(); + Enumeration<?> n = elAtts.getAttributeNames(); while (n.hasMoreElements()) { Object key = n.nextElement(); @@ -115,7 +115,7 @@ class ViewAttributeSet } AttributeSet[] atts1 = new AttributeSet[atts.size()]; - atts1 = (AttributeSet[]) atts.toArray(atts1); + atts1 = atts.toArray(atts1); init(atts1); } diff --git a/javax/swing/tree/DefaultMutableTreeNode.java b/javax/swing/tree/DefaultMutableTreeNode.java index a1afe7813..34a70c19b 100644 --- a/javax/swing/tree/DefaultMutableTreeNode.java +++ b/javax/swing/tree/DefaultMutableTreeNode.java @@ -68,7 +68,7 @@ public class DefaultMutableTreeNode * children. */ public static final Enumeration<TreeNode> EMPTY_ENUMERATION = - EmptyEnumeration.getInstance(); + new EmptyEnumeration<TreeNode>(); /** * The parent of this node (possibly <code>null</code>). |