diff options
Diffstat (limited to 'libjava/classpath/javax/swing')
15 files changed, 73 insertions, 68 deletions
diff --git a/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java b/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java index cc61889d76f..45381d60e87 100644 --- a/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java +++ b/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java @@ -1454,7 +1454,7 @@ public class HTMLEditorKit try { styleSheet = new StyleSheet(); - Class c = HTMLEditorKit.class; + Class<?> c = HTMLEditorKit.class; InputStream in = c.getResourceAsStream(DEFAULT_CSS); InputStreamReader r = new InputStreamReader(in); styleSheet.loadRules(r, null); diff --git a/libjava/classpath/javax/swing/text/html/HTMLWriter.java b/libjava/classpath/javax/swing/text/html/HTMLWriter.java index 6cc23df9aab..6a5e6ed58fe 100644 --- a/libjava/classpath/javax/swing/text/html/HTMLWriter.java +++ b/libjava/classpath/javax/swing/text/html/HTMLWriter.java @@ -79,9 +79,9 @@ public class HTMLWriter private HTMLDocument htmlDoc = null; /** - * Used to keep track of which embeded has been written out. + * Used to keep track of which embedded has been written out. */ - private HashSet openEmbededTagHashSet = null; + private HashSet<HTML.Tag> openEmbeddedTagHashSet = null; private String new_line_str = "" + NEWLINE; @@ -95,7 +95,7 @@ public class HTMLWriter private int doc_len = -1; private int doc_offset_remaining = -1; private int doc_len_remaining = -1; - private HashSet htmlFragmentParentHashSet = null; + private HashSet<Element> htmlFragmentParentHashSet = null; private Element startElem = null; private Element endElem = null; private boolean fg_pass_start_elem = false; @@ -112,7 +112,7 @@ public class HTMLWriter super(writer, doc); outWriter = writer; htmlDoc = doc; - openEmbededTagHashSet = new HashSet(); + openEmbeddedTagHashSet = new HashSet<HTML.Tag>(); } // public HTMLWriter(Writer writer, HTMLDocument doc) /** @@ -129,13 +129,13 @@ public class HTMLWriter super(writer, doc, pos, len); outWriter = writer; htmlDoc = doc; - openEmbededTagHashSet = new HashSet(); + openEmbeddedTagHashSet = new HashSet<HTML.Tag>(); doc_pos = pos; doc_offset_remaining = pos; doc_len = len; doc_len_remaining = len; - htmlFragmentParentHashSet = new HashSet(); + htmlFragmentParentHashSet = new HashSet<Element>(); } // public HTMLWriter(Writer writer, HTMLDocument doc, int pos, int len) /** @@ -197,7 +197,8 @@ public class HTMLWriter } // else // NOTE: close out remaining open embeded tags. - Object[] tag_arr = openEmbededTagHashSet.toArray(); + HTML.Tag[] tag_arr = + openEmbeddedTagHashSet.toArray(new HTML.Tag[openEmbeddedTagHashSet.size()]); for (int i = 0; i < tag_arr.length; i++) { @@ -219,8 +220,8 @@ public class HTMLWriter protected void writeAttributes(AttributeSet attrSet) throws IOException { - Enumeration attrNameEnum = attrSet.getAttributeNames(); - + Enumeration<?> attrNameEnum = attrSet.getAttributeNames(); + while (attrNameEnum.hasMoreElements()) { Object key = attrNameEnum.nextElement(); @@ -502,7 +503,7 @@ public class HTMLWriter protected void writeEmbeddedTags(AttributeSet attrSet) throws IOException { - Enumeration attrNameEnum = attrSet.getAttributeNames(); + Enumeration<?> attrNameEnum = attrSet.getAttributeNames(); while (attrNameEnum.hasMoreElements()) { @@ -511,12 +512,12 @@ public class HTMLWriter if (key instanceof HTML.Tag) { - if (!openEmbededTagHashSet.contains(key)) + if (!openEmbeddedTagHashSet.contains(key)) { writeRaw("<" + key); writeAttributes((AttributeSet) value); writeRaw(">"); - openEmbededTagHashSet.add(key); + openEmbeddedTagHashSet.add((HTML.Tag) key); } // if(!openEmbededTagHashSet.contains(key)) } // if(key instanceof HTML.Tag) } // while(attrNameEnum.hasMoreElements()) @@ -535,16 +536,17 @@ public class HTMLWriter protected void closeOutUnwantedEmbeddedTags(AttributeSet attrSet) throws IOException { - Object[] tag_arr = openEmbededTagHashSet.toArray(); + HTML.Tag[] tag_arr = + openEmbeddedTagHashSet.toArray(new HTML.Tag[openEmbeddedTagHashSet.size()]); for (int i = 0; i < tag_arr.length; i++) { - HTML.Tag key = (HTML.Tag) tag_arr[i]; + HTML.Tag key = tag_arr[i]; if (!attrSet.isDefined(key)) { writeRaw("</" + key.toString() + ">"); - openEmbededTagHashSet.remove(key); + openEmbeddedTagHashSet.remove(key); } // if(!attrSet.isDefined(key)) } // for(int i = 0; i < tag_arr.length; i++) @@ -645,7 +647,7 @@ public class HTMLWriter if (matchNameAttribute(attrSet, HTML.Tag.TITLE)) { boolean fg_is_end_tag = false; - Enumeration attrNameEnum = attrSet.getAttributeNames(); + Enumeration<?> attrNameEnum = attrSet.getAttributeNames(); while (attrNameEnum.hasMoreElements()) { @@ -860,7 +862,7 @@ public class HTMLWriter if (matchNameAttribute(attrSet, HTML.Tag.TITLE)) { boolean fg_is_end_tag = false; - Enumeration attrNameEnum = attrSet.getAttributeNames(); + Enumeration<?> attrNameEnum = attrSet.getAttributeNames(); while (attrNameEnum.hasMoreElements()) { @@ -996,7 +998,7 @@ public class HTMLWriter private void writeAllAttributes(AttributeSet attrSet) throws IOException { - Enumeration attrNameEnum = attrSet.getAttributeNames(); + Enumeration<?> attrNameEnum = attrSet.getAttributeNames(); while (attrNameEnum.hasMoreElements()) { diff --git a/libjava/classpath/javax/swing/text/html/ImageView.java b/libjava/classpath/javax/swing/text/html/ImageView.java index bf906e4500e..bb6af4f451f 100644 --- a/libjava/classpath/javax/swing/text/html/ImageView.java +++ b/libjava/classpath/javax/swing/text/html/ImageView.java @@ -323,8 +323,6 @@ public class ImageView extends View */ public float getPreferredSpan(int axis) { - AttributeSet attrs = getAttributes(); - Image image = getImage(); if (axis == View.X_AXIS) @@ -522,7 +520,6 @@ public class ImageView extends View Image newIm = getImage(); if (newIm != null) { - AttributeSet atts = getAttributes(); // Fetch width. Length l = spans[X_AXIS]; if (l != null) diff --git a/libjava/classpath/javax/swing/text/html/MinimalHTMLWriter.java b/libjava/classpath/javax/swing/text/html/MinimalHTMLWriter.java index acb2c04acc2..9f5f019fa37 100644 --- a/libjava/classpath/javax/swing/text/html/MinimalHTMLWriter.java +++ b/libjava/classpath/javax/swing/text/html/MinimalHTMLWriter.java @@ -48,8 +48,9 @@ import javax.swing.text.Style; import javax.swing.text.StyledDocument; import java.io.Writer; import java.io.IOException; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.Enumeration; -import java.util.Stack; import java.awt.Color; /** @@ -61,7 +62,7 @@ import java.awt.Color; public class MinimalHTMLWriter extends AbstractWriter { private StyledDocument doc; - private Stack tagStack; + private Deque<String> tagStack; private boolean inFontTag = false; /** @@ -73,7 +74,7 @@ public class MinimalHTMLWriter extends AbstractWriter { super(w, doc); this.doc = doc; - tagStack = new Stack(); + tagStack = new ArrayDeque<String>(); } /** @@ -87,7 +88,7 @@ public class MinimalHTMLWriter extends AbstractWriter { super(w, doc, pos, len); this.doc = doc; - tagStack = new Stack(); + tagStack = new ArrayDeque<String>(); } /** @@ -315,7 +316,7 @@ public class MinimalHTMLWriter extends AbstractWriter { if(doc instanceof DefaultStyledDocument) { - Enumeration styles = ((DefaultStyledDocument)doc).getStyleNames(); + Enumeration<?> styles = ((DefaultStyledDocument)doc).getStyleNames(); while(styles.hasMoreElements()) writeStyle(doc.getStyle((String)styles.nextElement())); } @@ -332,7 +333,7 @@ public class MinimalHTMLWriter extends AbstractWriter */ protected void writeAttributes(AttributeSet attr) throws IOException { - Enumeration attribs = attr.getAttributeNames(); + Enumeration<?> attribs = attr.getAttributeNames(); while(attribs.hasMoreElements()) { Object attribName = attribs.nextElement(); @@ -422,8 +423,8 @@ public class MinimalHTMLWriter extends AbstractWriter */ private void endOpenTags() throws IOException { - while(!tagStack.empty()) - write((String)tagStack.pop()); + while(tagStack.size() > 0) + write(tagStack.pop()); if( inFontTag() ) { diff --git a/libjava/classpath/javax/swing/text/html/MultiAttributeSet.java b/libjava/classpath/javax/swing/text/html/MultiAttributeSet.java index 0f1145084e1..296144460ac 100644 --- a/libjava/classpath/javax/swing/text/html/MultiAttributeSet.java +++ b/libjava/classpath/javax/swing/text/html/MultiAttributeSet.java @@ -57,7 +57,7 @@ class MultiAttributeSet * The Enumeration for the multiplexed names. */ private class MultiNameEnumeration - implements Enumeration + implements Enumeration<Object> { /** * The index of the current AttributeSet. @@ -67,7 +67,7 @@ class MultiAttributeSet /** * The names Enumeration of the current AttributeSet. */ - private Enumeration current; + private Enumeration<?> current; /** * Creates a new instance. @@ -147,7 +147,7 @@ class MultiAttributeSet public boolean containsAttributes(AttributeSet attributes) { boolean ret = true; - Enumeration e = attributes.getAttributeNames(); + Enumeration<?> e = attributes.getAttributeNames(); while (ret && e.hasMoreElements()) { Object key = e.nextElement(); @@ -186,7 +186,7 @@ class MultiAttributeSet return n; } - public Enumeration getAttributeNames() + public Enumeration<?> getAttributeNames() { return new MultiNameEnumeration(); } diff --git a/libjava/classpath/javax/swing/text/html/MultiStyle.java b/libjava/classpath/javax/swing/text/html/MultiStyle.java index 3937bff75a9..2f43a19c282 100644 --- a/libjava/classpath/javax/swing/text/html/MultiStyle.java +++ b/libjava/classpath/javax/swing/text/html/MultiStyle.java @@ -51,7 +51,7 @@ import javax.swing.text.Style; * * @author Roman Kennke (kennke@aicas.com) */ -public class MultiStyle +class MultiStyle extends MultiAttributeSet implements Style { @@ -118,7 +118,7 @@ public class MultiStyle attributes.removeAttribute(name); } - public void removeAttributes(Enumeration names) + public void removeAttributes(Enumeration<?> names) { attributes.removeAttribute(names); } diff --git a/libjava/classpath/javax/swing/text/html/ObjectView.java b/libjava/classpath/javax/swing/text/html/ObjectView.java index d6a77c06aad..9d900441bb1 100644 --- a/libjava/classpath/javax/swing/text/html/ObjectView.java +++ b/libjava/classpath/javax/swing/text/html/ObjectView.java @@ -88,7 +88,7 @@ public class ObjectView extends ComponentView String classId = (String) atts.getAttribute("classid"); try { - Class objectClass = Class.forName(classId); + Class<?> objectClass = Class.forName(classId); Object instance = objectClass.newInstance(); comp = (Component) instance; } diff --git a/libjava/classpath/javax/swing/text/html/StyleSheet.java b/libjava/classpath/javax/swing/text/html/StyleSheet.java index 08578c80fad..c4ddddb7395 100644 --- a/libjava/classpath/javax/swing/text/html/StyleSheet.java +++ b/libjava/classpath/javax/swing/text/html/StyleSheet.java @@ -369,7 +369,7 @@ public class StyleSheet extends StyleContext * * @return the resolved style */ - private Style getResolvedStyle(String selector, List path, HTML.Tag tag) + private Style getResolvedStyle(String selector, List<Element> path, HTML.Tag tag) { Style style = resolvedStyles.get(selector); if (style == null) @@ -380,7 +380,7 @@ public class StyleSheet extends StyleContext /** * Resolves a style. This creates arrays that hold the tag names, * class and id attributes and delegates the work to - * {@link #resolveStyle(String, String[], Map[])}. + * {@link #resolveStyle(String, String[], List<Map<String,String>>)}. * * @param selector the selector * @param path the Element path @@ -388,14 +388,15 @@ public class StyleSheet extends StyleContext * * @return the resolved style */ - private Style resolveStyle(String selector, List path, HTML.Tag tag) + private Style resolveStyle(String selector, List<Element> path, HTML.Tag tag) { int count = path.size(); String[] tags = new String[count]; - Map[] attributes = new Map[count]; + List<Map<String,String>> attributes = + new ArrayList<Map<String,String>>(count); for (int i = 0; i < count; i++) { - Element el = (Element) path.get(i); + Element el = path.get(i); AttributeSet atts = el.getAttributes(); if (i == 0 && el.isLeaf()) { @@ -413,12 +414,11 @@ public class StyleSheet extends StyleContext tags[i] = t.toString(); else tags[i] = null; - attributes[i] = attributeSetToMap(atts); + attributes.set(i, attributeSetToMap(atts)); } else { tags[i] = null; - attributes[i] = null; } } tags[0] = tag.toString(); @@ -434,7 +434,8 @@ public class StyleSheet extends StyleContext * * @return the resolved style */ - private Style resolveStyle(String selector, String[] tags, Map[] attributes) + private Style resolveStyle(String selector, String[] tags, + List<Map<String,String>> attributes) { // FIXME: This style resolver is not correct. But it works good enough for // the default.css. @@ -462,10 +463,8 @@ public class StyleSheet extends StyleContext // Sort selectors. Collections.sort(styles); - Style[] styleArray = new Style[styles.size()]; - styleArray = (Style[]) styles.toArray(styleArray); - Style resolved = new MultiStyle(selector, - (Style[]) styles.toArray(styleArray)); + Style[] styleArray = styles.toArray(new Style[styles.size()]); + Style resolved = new MultiStyle(selector, styleArray); resolvedStyles.put(selector, resolved); return resolved; } @@ -481,9 +480,9 @@ public class StyleSheet extends StyleContext public Style getRule(String selector) { CSSStyle best = null; - for (Iterator i = css.iterator(); i.hasNext();) + for (Iterator<CSSStyle> i = css.iterator(); i.hasNext();) { - CSSStyle style = (CSSStyle) i.next(); + CSSStyle style = i.next(); if (style.compareTo(best) < 0) best = style; } @@ -584,7 +583,7 @@ public class StyleSheet extends StyleContext public void addStyleSheet(StyleSheet ss) { if (linked == null) - linked = new ArrayList(); + linked = new ArrayList<StyleSheet>(); linked.add(ss); } @@ -1441,7 +1440,7 @@ public class StyleSheet extends StyleContext * * @return the converted map */ - private Map attributeSetToMap(AttributeSet atts) + private Map<String,String> attributeSetToMap(AttributeSet atts) { HashMap<String,String> map = new HashMap<String,String>(); Enumeration<?> keys = atts.getAttributeNames(); diff --git a/libjava/classpath/javax/swing/text/html/TableView.java b/libjava/classpath/javax/swing/text/html/TableView.java index f87d7b35fc5..912240c28c4 100644 --- a/libjava/classpath/javax/swing/text/html/TableView.java +++ b/libjava/classpath/javax/swing/text/html/TableView.java @@ -181,7 +181,6 @@ class TableView int spans[]) { updateGrid(); - int numCols = offsets.length; int realColumn = 0; int colCount = getViewCount(); for (int i = 0; i < numColumns;) diff --git a/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java index 34a70c19b59..e4cc97838a9 100644 --- a/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java +++ b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java @@ -293,6 +293,7 @@ public class DefaultMutableTreeNode * * @return an enumeration of tree nodes */ + @SuppressWarnings("unchecked") // Required for API compatibility public Enumeration children() { if (children.size() == 0) @@ -320,7 +321,7 @@ public class DefaultMutableTreeNode */ public TreeNode getChildAt(int index) { - return (TreeNode) children.elementAt(index); + return children.elementAt(index); } /** @@ -717,6 +718,7 @@ public class DefaultMutableTreeNode * * @return Enumeration */ + @SuppressWarnings("unchecked") // Required for API compatibility public Enumeration preorderEnumeration() { return new PreorderEnumeration(this); @@ -727,6 +729,7 @@ public class DefaultMutableTreeNode * * @return Enumeration */ + @SuppressWarnings("unchecked") // Required for API compatibility public Enumeration postorderEnumeration() { return new PostorderEnumeration(this); @@ -737,6 +740,7 @@ public class DefaultMutableTreeNode * * @return Enumeration */ + @SuppressWarnings("unchecked") // Required for API compatibility public Enumeration breadthFirstEnumeration() { return new BreadthFirstEnumeration(this); @@ -747,6 +751,7 @@ public class DefaultMutableTreeNode * * @return Enumeration */ + @SuppressWarnings("unchecked") // Required for API compatibility public Enumeration depthFirstEnumeration() { return postorderEnumeration(); @@ -759,6 +764,7 @@ public class DefaultMutableTreeNode * * @return Enumeration */ + @SuppressWarnings("unchecked") // Required for API compatibility public Enumeration pathFromAncestorEnumeration(TreeNode node) { if (node == null) @@ -806,7 +812,7 @@ public class DefaultMutableTreeNode */ public TreeNode getFirstChild() { - return (TreeNode) children.firstElement(); + return children.firstElement(); } /** @@ -818,7 +824,7 @@ public class DefaultMutableTreeNode */ public TreeNode getLastChild() { - return (TreeNode) children.lastElement(); + return children.lastElement(); } /** @@ -1036,7 +1042,7 @@ public class DefaultMutableTreeNode public int getLeafCount() { int count = 0; - Enumeration e = depthFirstEnumeration(); + Enumeration<?> e = depthFirstEnumeration(); while (e.hasMoreElements()) { diff --git a/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java b/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java index 488809e0232..89f05d31c01 100644 --- a/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java +++ b/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java @@ -484,7 +484,7 @@ public class FixedHeightLayoutCache { if (dirty) update(); - Vector p = new Vector(parentPath.getPathCount()); + Vector<TreePath> p = new Vector<TreePath>(parentPath.getPathCount()); Object node; NodeRecord nr; @@ -493,7 +493,7 @@ public class FixedHeightLayoutCache node = parentPath.getPathComponent(i); nr = nodes.get(node); if (nr.row >= 0) - p.add(node); + p.add((TreePath) node); } return p.elements(); } diff --git a/libjava/classpath/javax/swing/tree/TreeNode.java b/libjava/classpath/javax/swing/tree/TreeNode.java index ae7380c703b..53d52f0a7cb 100644 --- a/libjava/classpath/javax/swing/tree/TreeNode.java +++ b/libjava/classpath/javax/swing/tree/TreeNode.java @@ -107,6 +107,7 @@ public interface TreeNode * * @return An enumeration of the children of this node. */ + @SuppressWarnings("unchecked") // Required for API compatibility Enumeration children(); } diff --git a/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java b/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java index 50e8e5ce92e..aac68692edc 100644 --- a/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java +++ b/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java @@ -381,10 +381,10 @@ public class VariableHeightLayoutCache TreePath path = null; // Search row in the nodes map. TODO: This is inefficient, optimize this. - Enumeration nodesEnum = nodes.elements(); + Enumeration<NodeRecord> nodesEnum = nodes.elements(); while (nodesEnum.hasMoreElements() && path == null) { - NodeRecord record = (NodeRecord) nodesEnum.nextElement(); + NodeRecord record = nodesEnum.nextElement(); if (record.row == row) path = record.getPath(); } @@ -498,7 +498,7 @@ public class VariableHeightLayoutCache { if (dirty) update(); - Vector p = new Vector(parentPath.getPathCount()); + Vector<TreePath> p = new Vector<TreePath>(parentPath.getPathCount()); Object node; NodeRecord nr; @@ -507,7 +507,7 @@ public class VariableHeightLayoutCache node = parentPath.getPathComponent(i); nr = nodes.get(node); if (nr != null && nr.row >= 0) - p.add(node); + p.add((TreePath) node); } return p.elements(); } diff --git a/libjava/classpath/javax/swing/undo/StateEdit.java b/libjava/classpath/javax/swing/undo/StateEdit.java index 55282ab37c8..a032d02cdb8 100644 --- a/libjava/classpath/javax/swing/undo/StateEdit.java +++ b/libjava/classpath/javax/swing/undo/StateEdit.java @@ -248,7 +248,7 @@ public class StateEdit */ protected void removeRedundantState() { - Iterator i = preState.keySet().iterator(); + Iterator<Object> i = preState.keySet().iterator(); while (i.hasNext()) { Object key = i.next(); diff --git a/libjava/classpath/javax/swing/undo/UndoableEditSupport.java b/libjava/classpath/javax/swing/undo/UndoableEditSupport.java index b5a93341954..2e5d909543a 100644 --- a/libjava/classpath/javax/swing/undo/UndoableEditSupport.java +++ b/libjava/classpath/javax/swing/undo/UndoableEditSupport.java @@ -167,7 +167,7 @@ public class UndoableEditSupport protected void _postEdit(UndoableEdit edit) { UndoableEditEvent event; - Iterator iter; + Iterator<UndoableEditListener> iter; // Do nothing if we have no listeners. if (listeners.isEmpty()) @@ -181,9 +181,9 @@ public class UndoableEditSupport // Iterator, a java.util.ConcurrentModificationException; in the // case of a direct loop over the Vector elements, some // index-out-of-bounds exception). - iter = ((Vector) listeners.clone()).iterator(); + iter = new Vector<UndoableEditListener>(listeners).iterator(); while (iter.hasNext()) - ((UndoableEditListener) iter.next()).undoableEditHappened(event); + iter.next().undoableEditHappened(event); } |