diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-12-10 20:25:39 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-12-10 20:25:39 +0000 |
commit | da66af5951b18b6f5e8752cbbe11f5f842332a33 (patch) | |
tree | a28e126d1415e3689be6c7b2c2d061ae51194195 /javax/swing | |
parent | ab90923ee693a17e2e0e37b6ba5a84794c9236de (diff) | |
download | classpath-da66af5951b18b6f5e8752cbbe11f5f842332a33.tar.gz |
2006-12-10 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of generics-branch to HEAD (woohoo!)
Diffstat (limited to 'javax/swing')
60 files changed, 806 insertions, 149 deletions
diff --git a/javax/swing/AbstractListModel.java b/javax/swing/AbstractListModel.java index 4b89689dd..7d4b2bb2a 100644 --- a/javax/swing/AbstractListModel.java +++ b/javax/swing/AbstractListModel.java @@ -164,7 +164,7 @@ public abstract class AbstractListModel implements ListModel, Serializable * * @return The set of listeners of the specified type */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/AbstractSpinnerModel.java b/javax/swing/AbstractSpinnerModel.java index 1d9476635..d247a3313 100644 --- a/javax/swing/AbstractSpinnerModel.java +++ b/javax/swing/AbstractSpinnerModel.java @@ -84,7 +84,7 @@ public abstract class AbstractSpinnerModel implements SpinnerModel * @param c the type of listener * @return the listeners that are of the specific type */ - public EventListener[] getListeners(Class c) + public <T extends EventListener> T[] getListeners(Class<T> c) { return listenerList.getListeners(c); } diff --git a/javax/swing/ButtonGroup.java b/javax/swing/ButtonGroup.java index 19ce65949..6a474f98d 100644 --- a/javax/swing/ButtonGroup.java +++ b/javax/swing/ButtonGroup.java @@ -68,7 +68,7 @@ public class ButtonGroup implements Serializable private static final long serialVersionUID = 4259076101881721375L; /** Stores references to the buttons added to this button group. */ - protected Vector buttons = new Vector(); + protected Vector<AbstractButton> buttons = new Vector<AbstractButton>(); /** The currently selected button model. */ ButtonModel sel; @@ -129,7 +129,7 @@ public class ButtonGroup implements Serializable * * @return <code>Enumeration</code> over all added buttons */ - public Enumeration getElements() + public Enumeration<AbstractButton> getElements() { return buttons.elements(); } diff --git a/javax/swing/DefaultBoundedRangeModel.java b/javax/swing/DefaultBoundedRangeModel.java index efca148f4..786e4ee92 100644 --- a/javax/swing/DefaultBoundedRangeModel.java +++ b/javax/swing/DefaultBoundedRangeModel.java @@ -424,7 +424,7 @@ public class DefaultBoundedRangeModel * * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/DefaultButtonModel.java b/javax/swing/DefaultButtonModel.java index f408bffdf..c0eaea239 100644 --- a/javax/swing/DefaultButtonModel.java +++ b/javax/swing/DefaultButtonModel.java @@ -166,7 +166,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable * * @return array of listeners */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/DefaultComboBoxModel.java b/javax/swing/DefaultComboBoxModel.java index 71ab11fe3..9b5bdb60d 100644 --- a/javax/swing/DefaultComboBoxModel.java +++ b/javax/swing/DefaultComboBoxModel.java @@ -104,7 +104,7 @@ public class DefaultComboBoxModel extends AbstractListModel * * @throws NullPointerException if <code>vector</code> is <code>null</code>. */ - public DefaultComboBoxModel(Vector vector) + public DefaultComboBoxModel(Vector<?> vector) { this.list = vector; if (getSize() > 0) diff --git a/javax/swing/DefaultListModel.java b/javax/swing/DefaultListModel.java index 2d02874a7..674864cce 100644 --- a/javax/swing/DefaultListModel.java +++ b/javax/swing/DefaultListModel.java @@ -309,7 +309,7 @@ public class DefaultListModel extends AbstractListModel * * @return A new enumeration which iterates over the list */ - public Enumeration elements() + public Enumeration<?> elements() { return elements.elements(); } diff --git a/javax/swing/DefaultListSelectionModel.java b/javax/swing/DefaultListSelectionModel.java index 482ce2cc2..d1e2da85f 100644 --- a/javax/swing/DefaultListSelectionModel.java +++ b/javax/swing/DefaultListSelectionModel.java @@ -815,7 +815,7 @@ public class DefaultListSelectionModel implements Cloneable, * @see #getListSelectionListeners * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/DefaultSingleSelectionModel.java b/javax/swing/DefaultSingleSelectionModel.java index 1c6f473fd..3f79f0dee 100644 --- a/javax/swing/DefaultSingleSelectionModel.java +++ b/javax/swing/DefaultSingleSelectionModel.java @@ -174,7 +174,7 @@ public class DefaultSingleSelectionModel * * @since 1.3 */ - public EventListener[] getListeners(Class listenerClass) + public <T extends EventListener> T[] getListeners(Class<T> listenerClass) { return listenerList.getListeners(listenerClass); } diff --git a/javax/swing/JComboBox.java b/javax/swing/JComboBox.java index c75a94bdc..fa6941cf9 100644 --- a/javax/swing/JComboBox.java +++ b/javax/swing/JComboBox.java @@ -196,7 +196,7 @@ public class JComboBox extends JComponent implements ItemSelectable, * * @param itemVector vector containing list of items for this JComboBox. */ - public JComboBox(Vector itemVector) + public JComboBox(Vector<?> itemVector) { this(new DefaultComboBoxModel(itemVector)); diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java index cc317492c..5ec507922 100644 --- a/javax/swing/JComponent.java +++ b/javax/swing/JComponent.java @@ -927,12 +927,12 @@ public abstract class JComponent extends Container implements Serializable * * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { if (listenerType == PropertyChangeListener.class) - return getPropertyChangeListeners(); + return (T[]) getPropertyChangeListeners(); else if (listenerType == VetoableChangeListener.class) - return getVetoableChangeListeners(); + return (T[]) getVetoableChangeListeners(); else return listenerList.getListeners(listenerType); } diff --git a/javax/swing/JLayeredPane.java b/javax/swing/JLayeredPane.java index ca913e97f..d981788ec 100644 --- a/javax/swing/JLayeredPane.java +++ b/javax/swing/JLayeredPane.java @@ -406,7 +406,7 @@ public class JLayeredPane extends JComponent implements Accessible * Return a hashtable mapping child components of this container to * Integer objects representing the component's layer assignments. */ - protected Hashtable getComponentToLayer() + protected Hashtable<Component, Integer> getComponentToLayer() { return componentToLayer; } diff --git a/javax/swing/JList.java b/javax/swing/JList.java index 98b299044..ff1b23921 100644 --- a/javax/swing/JList.java +++ b/javax/swing/JList.java @@ -1041,7 +1041,7 @@ public class JList extends JComponent implements Accessible, Scrollable * * @param items the initial list items. */ - public JList(Vector items) + public JList(Vector<?> items) { init(createListModel(items)); } @@ -1643,9 +1643,20 @@ public class JList extends JComponent implements Accessible, Scrollable * @param listData The object array to build a new list model on * @see #setModel */ - public void setListData(Vector listData) + public void setListData(final Vector<?> listData) { - setModel(createListModel(listData)); + setModel(new AbstractListModel() + { + public int getSize() + { + return listData.size(); + } + + public Object getElementAt(int i) + { + return listData.elementAt(i); + } + }); } /** diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java index 33f5947c1..42563e6a2 100644 --- a/javax/swing/JTable.java +++ b/javax/swing/JTable.java @@ -3429,7 +3429,7 @@ public class JTable * * @return the editor, suitable for editing this data type */ - public TableCellEditor getDefaultEditor(Class columnClass) + public TableCellEditor getDefaultEditor(Class<?> columnClass) { if (defaultEditorsByColumnClass.containsKey(columnClass)) return (TableCellEditor) defaultEditorsByColumnClass.get(columnClass); @@ -3441,7 +3441,7 @@ public class JTable return r; } } - + /** * Get the cell renderer for rendering the given cell. * @@ -3461,7 +3461,7 @@ public class JTable } return renderer; } - + /** * Set default renderer for rendering the given data type. * @@ -3469,11 +3469,11 @@ public class JTable * rendered. * @param rend the renderer that will rend this data type */ - public void setDefaultRenderer(Class columnClass, TableCellRenderer rend) + public void setDefaultRenderer(Class<?> columnClass, TableCellRenderer rend) { defaultRenderersByColumnClass.put(columnClass, rend); } - + /** * Get the default renderer for rendering the given data type. * @@ -3481,7 +3481,7 @@ public class JTable * * @return the appropriate defauld renderer for rendering that data type. */ - public TableCellRenderer getDefaultRenderer(Class columnClass) + public TableCellRenderer getDefaultRenderer(Class<?> columnClass) { if (defaultRenderersByColumnClass.containsKey(columnClass)) return (TableCellRenderer) defaultRenderersByColumnClass.get(columnClass); @@ -4624,7 +4624,7 @@ public class JTable { setUI((TableUI) UIManager.getUI(this)); } - + /** * Get the class (datatype) of the column. The cells are rendered and edited * differently, depending from they data type. @@ -4634,7 +4634,7 @@ public class JTable * @return the class, defining data type of that column (String.class for * String, Boolean.class for boolean and so on). */ - public Class getColumnClass(int column) + public Class<?> getColumnClass(int column) { return getModel().getColumnClass(convertColumnIndexToModel(column)); } @@ -4655,7 +4655,7 @@ public class JTable int modelColumn = columnModel.getColumn(column).getModelIndex(); return dataModel.getColumnName(modelColumn); } - + /** * Get the column, currently being edited * @@ -4665,7 +4665,7 @@ public class JTable { return editingColumn; } - + /** * Set the column, currently being edited * @@ -4685,7 +4685,7 @@ public class JTable { return editingRow; } - + /** * Set the row currently being edited. * @@ -4716,7 +4716,7 @@ public class JTable { return editorComp != null; } - + /** * Set the default editor for the given column class (column data type). * By default, String is handled by text field and Boolean is handled by @@ -4727,7 +4727,7 @@ public class JTable * * @see TableModel#getColumnClass(int) */ - public void setDefaultEditor(Class columnClass, TableCellEditor editor) + public void setDefaultEditor(Class<?> columnClass, TableCellEditor editor) { if (editor != null) defaultEditorsByColumnClass.put(columnClass, editor); diff --git a/javax/swing/JTree.java b/javax/swing/JTree.java index f1add1293..332ec7424 100644 --- a/javax/swing/JTree.java +++ b/javax/swing/JTree.java @@ -1534,7 +1534,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * * @param value the initial nodes in the tree */ - public JTree(Hashtable value) + public JTree(Hashtable<?, ?> value) { this(createTreeModel(value)); } @@ -1601,7 +1601,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * * @param value the initial nodes in the tree */ - public JTree(Vector value) + public JTree(Vector<?> value) { this(createTreeModel(value)); } @@ -2824,7 +2824,7 @@ public class JTree extends JComponent implements Scrollable, Accessible nodeStates.clear(); } - protected Enumeration getDescendantToggledPaths(TreePath parent) + protected Enumeration<TreePath> getDescendantToggledPaths(TreePath parent) { if (parent == null) return null; @@ -2973,7 +2973,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * * @return An Enumeration containing TreePath objects */ - public Enumeration getExpandedDescendants(TreePath path) + public Enumeration<TreePath> getExpandedDescendants(TreePath path) { Enumeration paths = nodeStates.keys(); Vector relevantPaths = new Vector(); @@ -3101,7 +3101,7 @@ public class JTree extends JComponent implements Scrollable, Accessible * @param toRemove - Enumeration of TreePaths that need to be removed from * cache of toggled tree paths. */ - protected void removeDescendantToggledPaths(Enumeration toRemove) + protected void removeDescendantToggledPaths(Enumeration<TreePath> toRemove) { while (toRemove.hasMoreElements()) { diff --git a/javax/swing/LookAndFeel.java b/javax/swing/LookAndFeel.java index be5434396..d995bc9e9 100644 --- a/javax/swing/LookAndFeel.java +++ b/javax/swing/LookAndFeel.java @@ -284,7 +284,7 @@ public abstract class LookAndFeel * @return A {@link UIDefaults.LazyValue} that serves up an * {@link IconUIResource}. */ - public static Object makeIcon(Class baseClass, String gifFile) + public static Object makeIcon(Class<?> baseClass, String gifFile) { final URL file = baseClass.getResource(gifFile); return new UIDefaults.LazyValue() diff --git a/javax/swing/RepaintManager.java b/javax/swing/RepaintManager.java index d6a00ec43..773371489 100644 --- a/javax/swing/RepaintManager.java +++ b/javax/swing/RepaintManager.java @@ -568,7 +568,7 @@ public class RepaintManager */ public void paintDirtyRegions() { - // Short cicuit if there is nothing to paint. + // Short circuit if there is nothing to paint. if (dirtyComponents.size() == 0) return; diff --git a/javax/swing/SortingFocusTraversalPolicy.java b/javax/swing/SortingFocusTraversalPolicy.java index 96ef38329..d14ee1d30 100644 --- a/javax/swing/SortingFocusTraversalPolicy.java +++ b/javax/swing/SortingFocusTraversalPolicy.java @@ -91,7 +91,7 @@ public class SortingFocusTraversalPolicy * * @param comparator the comparator to set */ - public SortingFocusTraversalPolicy(Comparator comparator) + public SortingFocusTraversalPolicy(Comparator<? super Component> comparator) { this.comparator = comparator; } @@ -119,7 +119,7 @@ public class SortingFocusTraversalPolicy * * @see #setComparator */ - protected Comparator getComparator() + protected Comparator<? super Component> getComparator() { return comparator; } @@ -131,7 +131,7 @@ public class SortingFocusTraversalPolicy * * @see #getComparator */ - protected void setComparator(Comparator comparator) + protected void setComparator(Comparator<? super Component> comparator) { this.comparator = comparator; } diff --git a/javax/swing/SpinnerListModel.java b/javax/swing/SpinnerListModel.java index d8e2f22d5..52ac360e9 100644 --- a/javax/swing/SpinnerListModel.java +++ b/javax/swing/SpinnerListModel.java @@ -118,7 +118,7 @@ public class SpinnerListModel extends AbstractSpinnerModel * @see SpinnerListModel#getNextValue() * @see SpinnerListModel#getValue() */ - public SpinnerListModel(List list) + public SpinnerListModel(List<?> list) { // Retain a reference to the valid list. setList(list); @@ -163,7 +163,7 @@ public class SpinnerListModel extends AbstractSpinnerModel * * @return The backing list. */ - public List getList() + public List<?> getList() { return list; } @@ -239,7 +239,7 @@ public class SpinnerListModel extends AbstractSpinnerModel * * @see ChangeEvent */ - public void setList(List list) + public void setList(List<?> list) { // Check for null or zero size list. if (list == null || list.size() == 0) diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java index c6e50fba5..6ff0b3346 100644 --- a/javax/swing/SwingUtilities.java +++ b/javax/swing/SwingUtilities.java @@ -325,7 +325,7 @@ public class SwingUtilities * @see #getAncestorOfClass * @see #windowForComponent */ - public static Container getAncestorOfClass(Class c, Component comp) + public static Container getAncestorOfClass(Class<?> c, Component comp) { while (comp != null && (! c.isInstance(comp))) comp = comp.getParent(); diff --git a/javax/swing/Timer.java b/javax/swing/Timer.java index acd226249..acd1eb493 100644 --- a/javax/swing/Timer.java +++ b/javax/swing/Timer.java @@ -228,7 +228,7 @@ public class Timer * fired by this timer * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/UIDefaults.java b/javax/swing/UIDefaults.java index bf5242f65..9766cb05c 100644 --- a/javax/swing/UIDefaults.java +++ b/javax/swing/UIDefaults.java @@ -63,7 +63,7 @@ import javax.swing.plaf.InputMapUIResource; * * @author Ronald Veldema (rveldema@cs.vu.nl) */ -public class UIDefaults extends Hashtable +public class UIDefaults extends Hashtable<Object, Object> { /** Our ResourceBundles. */ @@ -672,7 +672,7 @@ public class UIDefaults extends Hashtable * * @return the UI class for <code>id</code> */ - public Class getUIClass(String id, ClassLoader loader) + public Class<? extends ComponentUI> getUIClass(String id, ClassLoader loader) { String className = (String) get(id); if (className == null) @@ -681,7 +681,7 @@ public class UIDefaults extends Hashtable { if (loader == null) loader = ClassLoader.getSystemClassLoader(); - return loader.loadClass (className); + return (Class<? extends ComponentUI>) loader.loadClass (className); } catch (Exception e) { @@ -698,7 +698,7 @@ public class UIDefaults extends Hashtable * * @return the UI class for <code>id</code> */ - public Class getUIClass(String id) + public Class<? extends ComponentUI> getUIClass(String id) { return getUIClass (id, null); } diff --git a/javax/swing/event/EventListenerList.java b/javax/swing/event/EventListenerList.java index ab9d46d8c..1568039f0 100644 --- a/javax/swing/event/EventListenerList.java +++ b/javax/swing/event/EventListenerList.java @@ -139,7 +139,7 @@ public class EventListenerList * * @throws NullPointerException if <code>t</code> is <code>null</code>. */ - public void add(Class t, EventListener listener) + public <T extends EventListener> void add(Class<T> t, T listener) { int oldLength; Object[] newList; @@ -178,7 +178,7 @@ public class EventListenerList * <code>t</code>. Thus, subclasses of <code>t</code> will not be * counted. */ - public int getListenerCount(Class t) + public int getListenerCount(Class<?> t) { int result = 0; for (int i = 0; i < listenerList.length; i += 2) @@ -227,7 +227,7 @@ public class EventListenerList * * @since 1.3 */ - public EventListener[] getListeners(Class c) + public <T extends EventListener> T[] getListeners(Class<T> c) { int count, f; EventListener[] result; @@ -239,7 +239,7 @@ public class EventListenerList if (listenerList[i] == c) result[f++] = (EventListener) listenerList[i + 1]; - return result; + return (T[]) result; } @@ -256,7 +256,7 @@ public class EventListenerList * * @throws NullPointerException if <code>t</code> is <code>null</code>. */ - public void remove(Class t, EventListener listener) + public <T extends EventListener> void remove(Class<T> t, T listener) { Object[] oldList, newList; int oldLength; @@ -341,7 +341,7 @@ public class EventListenerList * @throws ClassNotFoundException if a serialized class can't be found * @throws IOException if something goes wrong */ - private void readObject(ObjectInputStream in) + private <T extends EventListener> void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException { listenerList = NO_LISTENERS; @@ -351,7 +351,7 @@ public class EventListenerList while ((type = in.readObject()) != null) { EventListener l = (EventListener) in.readObject(); - add(Class.forName((String) type, true, cl), l); + add(((Class<T>) Class.forName((String) type, true, cl)), (T) l); } } } diff --git a/javax/swing/plaf/basic/BasicDirectoryModel.java b/javax/swing/plaf/basic/BasicDirectoryModel.java index ed916cb5f..de82bd47b 100644 --- a/javax/swing/plaf/basic/BasicDirectoryModel.java +++ b/javax/swing/plaf/basic/BasicDirectoryModel.java @@ -381,7 +381,7 @@ public class BasicDirectoryModel extends AbstractListModel * * @return a Vector */ - public Vector getDirectories() + public Vector<File> getDirectories() { // Synchronize this with the UpdateSwingRequest for the case when // contents is modified. @@ -418,7 +418,7 @@ public class BasicDirectoryModel extends AbstractListModel * * @return a Vector */ - public Vector getFiles() + public Vector<File> getFiles() { synchronized (contents) { @@ -562,7 +562,7 @@ public class BasicDirectoryModel extends AbstractListModel * * @param v The Vector to sort. */ - protected void sort(Vector v) + protected void sort(Vector<? extends File> v) { Collections.sort(v, comparator); } diff --git a/javax/swing/plaf/basic/BasicFileChooserUI.java b/javax/swing/plaf/basic/BasicFileChooserUI.java index dfe76ba0c..e1f8e4b28 100644 --- a/javax/swing/plaf/basic/BasicFileChooserUI.java +++ b/javax/swing/plaf/basic/BasicFileChooserUI.java @@ -183,7 +183,7 @@ public class BasicFileChooserUI extends FileChooserUI protected class BasicFileView extends FileView { /** Storage for cached icons. */ - protected Hashtable iconCache = new Hashtable(); + protected Hashtable<File, Icon> iconCache = new Hashtable<File, Icon>(); /** * Creates a new instance. diff --git a/javax/swing/plaf/basic/BasicListUI.java b/javax/swing/plaf/basic/BasicListUI.java index 493fc0578..befc22736 100644 --- a/javax/swing/plaf/basic/BasicListUI.java +++ b/javax/swing/plaf/basic/BasicListUI.java @@ -921,7 +921,7 @@ public class BasicListUI extends ListUI */ protected void maybeUpdateLayoutState() { - if (updateLayoutStateNeeded != 0) + if (updateLayoutStateNeeded != 0 || !list.isValid()) { updateLayoutState(); updateLayoutStateNeeded = 0; diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java index 2c8c1e0b7..5b0ffce09 100644 --- a/javax/swing/plaf/basic/BasicTreeUI.java +++ b/javax/swing/plaf/basic/BasicTreeUI.java @@ -195,7 +195,7 @@ public class BasicTreeUI protected AbstractLayoutCache treeState; /** Used for minimizing the drawing of vertical lines. */ - protected Hashtable drawingCache; + protected Hashtable<TreePath, Boolean> drawingCache; /** * True if doing optimizations for a largeModel. Subclasses that don't support diff --git a/javax/swing/plaf/metal/MetalButtonListener.java b/javax/swing/plaf/metal/MetalButtonListener.java new file mode 100644 index 000000000..f2f778f95 --- /dev/null +++ b/javax/swing/plaf/metal/MetalButtonListener.java @@ -0,0 +1,74 @@ +/* MetalButtonListener.java + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.swing.plaf.metal; + +import java.beans.PropertyChangeEvent; + +import javax.swing.AbstractButton; +import javax.swing.plaf.basic.BasicButtonListener; + +/** + * A listener for buttons under the {@link MetalLookAndFeel}. + * + * @see MetalButtonUI#createButtonListener + */ +class MetalButtonListener extends BasicButtonListener +{ + + /** + * Creates a new instance. + * + * @param button the button. + */ + public MetalButtonListener(AbstractButton button) + { + super(button); + } + + /** + * Handles property change events. + * + * @param e the event. + */ + public void propertyChange(PropertyChangeEvent e) + { + super.propertyChange(e); + // TODO: What should be done here? + } +} diff --git a/javax/swing/plaf/metal/MetalLookAndFeel.java b/javax/swing/plaf/metal/MetalLookAndFeel.java index 651fcdfaa..a9a679093 100644 --- a/javax/swing/plaf/metal/MetalLookAndFeel.java +++ b/javax/swing/plaf/metal/MetalLookAndFeel.java @@ -1203,7 +1203,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel "TabbedPane.tabAreaBackground", getControl(), // overridden in OceanTheme "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6), // dito "TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9), - + // new properties in OceanTheme: // TabbedPane.contentAreaColor // TabbedPane.unselectedBackground diff --git a/javax/swing/plaf/synth/SynthLookAndFeel.java b/javax/swing/plaf/synth/SynthLookAndFeel.java index 1a2489e7e..46a95f098 100644 --- a/javax/swing/plaf/synth/SynthLookAndFeel.java +++ b/javax/swing/plaf/synth/SynthLookAndFeel.java @@ -216,9 +216,7 @@ public class SynthLookAndFeel * @throws IllegalArgumentException if one of the parameters is * <code>null</code> */ - // FIXME: The signature in the JDK has a Class<?> here. Should be fixed as - // soon as we switch to the generics branch. - public void load(InputStream in, Class resourceBase) + public void load(InputStream in, Class<?> resourceBase) throws ParseException, IllegalArgumentException, NotImplementedException { // FIXME: Implement this correctly. diff --git a/javax/swing/table/AbstractTableModel.java b/javax/swing/table/AbstractTableModel.java index 7914e0b3f..66b6a0743 100644 --- a/javax/swing/table/AbstractTableModel.java +++ b/javax/swing/table/AbstractTableModel.java @@ -125,7 +125,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable * * @return The class. */ - public Class getColumnClass(int columnIndex) + public Class<?> getColumnClass(int columnIndex) { return Object.class; } @@ -294,7 +294,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable * * @return An array of listeners (possibly empty). */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/table/DefaultTableColumnModel.java b/javax/swing/table/DefaultTableColumnModel.java index 33e68ea9f..e4e7201b1 100644 --- a/javax/swing/table/DefaultTableColumnModel.java +++ b/javax/swing/table/DefaultTableColumnModel.java @@ -71,7 +71,7 @@ public class DefaultTableColumnModel /** * Storage for the table columns. */ - protected Vector tableColumns; + protected Vector<TableColumn> tableColumns; /** * A selection model that keeps track of column selections. @@ -187,7 +187,7 @@ public class DefaultTableColumnModel throw new IllegalArgumentException("Index 'i' out of range."); if (j < 0 || j >= columnCount) throw new IllegalArgumentException("Index 'j' out of range."); - Object column = tableColumns.remove(i); + TableColumn column = tableColumns.remove(i); tableColumns.add(j, column); fireColumnMoved(new TableColumnModelEvent(this, i, j)); } @@ -221,7 +221,7 @@ public class DefaultTableColumnModel * * @return An enumeration of the columns in the model. */ - public Enumeration getColumns() + public Enumeration<TableColumn> getColumns() { return tableColumns.elements(); } @@ -597,7 +597,7 @@ public class DefaultTableColumnModel * @return An array containing the listeners (of the specified type) that * are registered with this model. */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/table/TableColumnModel.java b/javax/swing/table/TableColumnModel.java index 986c02533..7e8a70c3a 100644 --- a/javax/swing/table/TableColumnModel.java +++ b/javax/swing/table/TableColumnModel.java @@ -102,7 +102,7 @@ public interface TableColumnModel * * @return An enumeration of the columns in the model. */ - Enumeration getColumns(); + Enumeration<TableColumn> getColumns(); /** * Returns the index of the {@link TableColumn} with the given identifier. diff --git a/javax/swing/table/TableModel.java b/javax/swing/table/TableModel.java index 016ae171d..7629fa4e4 100644 --- a/javax/swing/table/TableModel.java +++ b/javax/swing/table/TableModel.java @@ -84,7 +84,7 @@ public interface TableModel * * @return The class. */ - Class getColumnClass(int columnIndex); + Class<?> getColumnClass(int columnIndex); /** * Returns <code>true</code> if the cell is editable, and <code>false</code> diff --git a/javax/swing/text/AbstractDocument.java b/javax/swing/text/AbstractDocument.java index b52c76363..eead8de52 100644 --- a/javax/swing/text/AbstractDocument.java +++ b/javax/swing/text/AbstractDocument.java @@ -467,7 +467,7 @@ public abstract class AbstractDocument implements Document, Serializable * * @return the properties of this <code>Document</code> */ - public Dictionary getDocumentProperties() + public Dictionary<Object, Object> getDocumentProperties() { // FIXME: make me thread-safe if (properties == null) @@ -518,7 +518,7 @@ public abstract class AbstractDocument implements Document, Serializable * * @return all registered listeners of the specified type */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } @@ -1347,7 +1347,7 @@ public abstract class AbstractDocument implements Document, Serializable * * @param p the document properties to set */ - public void setDocumentProperties(Dictionary p) + public void setDocumentProperties(Dictionary<Object, Object> p) { // FIXME: make me thread-safe properties = p; @@ -1521,7 +1521,7 @@ public abstract class AbstractDocument implements Document, Serializable * @return the attributes of <code>old</code> minus the attributes in * <code>attributes</code> */ - AttributeSet removeAttributes(AttributeSet old, Enumeration names); + AttributeSet removeAttributes(AttributeSet old, Enumeration<?> names); } /** @@ -1777,7 +1777,7 @@ public abstract class AbstractDocument implements Document, Serializable * * @param names the names of the attributes to be removed */ - public void removeAttributes(Enumeration names) + public void removeAttributes(Enumeration<?> names) { attributes = getAttributeContext().removeAttributes(attributes, names); } @@ -1872,7 +1872,7 @@ public abstract class AbstractDocument implements Document, Serializable * * @return the names of the attributes of this element */ - public Enumeration getAttributeNames() + public Enumeration<?> getAttributeNames() { return attributes.getAttributeNames(); } diff --git a/javax/swing/text/AttributeSet.java b/javax/swing/text/AttributeSet.java index 01d148c06..2d39881c2 100644 --- a/javax/swing/text/AttributeSet.java +++ b/javax/swing/text/AttributeSet.java @@ -158,7 +158,7 @@ public interface AttributeSet * @return the names of the attributes that are stored in this * <code>AttributeSet</code> */ - Enumeration getAttributeNames(); + Enumeration<?> getAttributeNames(); /** * Returns the resolving parent of this <code>AttributeSet</code>. diff --git a/javax/swing/text/DefaultCaret.java b/javax/swing/text/DefaultCaret.java index d3d96ba60..c4c2580c3 100644 --- a/javax/swing/text/DefaultCaret.java +++ b/javax/swing/text/DefaultCaret.java @@ -804,7 +804,7 @@ public class DefaultCaret extends Rectangle } } } - + private void handleHighlight() { Highlighter highlighter = textComponent.getHighlighter(); @@ -946,7 +946,7 @@ public class DefaultCaret extends Rectangle * * @return all registered event listeners of the specified type */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/text/DefaultFormatter.java b/javax/swing/text/DefaultFormatter.java index ce3686586..bf7c02a00 100644 --- a/javax/swing/text/DefaultFormatter.java +++ b/javax/swing/text/DefaultFormatter.java @@ -330,7 +330,7 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter * * @return the class that is used for values */ - public Class getValueClass() + public Class<?> getValueClass() { return valueClass; } @@ -342,7 +342,7 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter * * @see #getValueClass() */ - public void setValueClass(Class valueClass) + public void setValueClass(Class<?> valueClass) { this.valueClass = valueClass; } diff --git a/javax/swing/text/DefaultStyledDocument.java b/javax/swing/text/DefaultStyledDocument.java index 015b09ca0..3156ca67f 100644 --- a/javax/swing/text/DefaultStyledDocument.java +++ b/javax/swing/text/DefaultStyledDocument.java @@ -2377,7 +2377,7 @@ public class DefaultStyledDocument extends AbstractDocument implements * * @return an enumeration of all style names */ - public Enumeration getStyleNames() + public Enumeration<?> getStyleNames() { StyleContext context = (StyleContext) getAttributeContext(); return context.getStyleNames(); diff --git a/javax/swing/text/MutableAttributeSet.java b/javax/swing/text/MutableAttributeSet.java index 3728b9ce1..5dd2406a3 100644 --- a/javax/swing/text/MutableAttributeSet.java +++ b/javax/swing/text/MutableAttributeSet.java @@ -90,7 +90,7 @@ public interface MutableAttributeSet extends AttributeSet * @throws NullPointerException if <code>names</code> is <code>null</code> * or contains any <code>null</code> values. */ - void removeAttributes(Enumeration names); + void removeAttributes(Enumeration<?> names); /** * Removes attributes from this set if they are found in the diff --git a/javax/swing/text/SimpleAttributeSet.java b/javax/swing/text/SimpleAttributeSet.java index cdd3a7ee7..701fa8a7c 100644 --- a/javax/swing/text/SimpleAttributeSet.java +++ b/javax/swing/text/SimpleAttributeSet.java @@ -261,7 +261,7 @@ public class SimpleAttributeSet * * @return An enumeration of the attribute names. */ - public Enumeration getAttributeNames() + public Enumeration<?> getAttributeNames() { return tab.keys(); } @@ -375,7 +375,7 @@ public class SimpleAttributeSet * @throws NullPointerException if <code>names</code> is <code>null</code> * or contains any <code>null</code> values. */ - public void removeAttributes(Enumeration names) + public void removeAttributes(Enumeration<?> names) { while (names.hasMoreElements()) { diff --git a/javax/swing/text/StyleContext.java b/javax/swing/text/StyleContext.java index 238fabb9d..4dded0d04 100644 --- a/javax/swing/text/StyleContext.java +++ b/javax/swing/text/StyleContext.java @@ -121,7 +121,7 @@ public class StyleContext listenerList.remove(ChangeListener.class, l); } - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } @@ -183,7 +183,7 @@ public class StyleContext return attributes.getAttributeCount(); } - public Enumeration getAttributeNames() + public Enumeration<?> getAttributeNames() { return attributes.getAttributeNames(); } @@ -210,7 +210,7 @@ public class StyleContext fireStateChanged(); } - public void removeAttributes(Enumeration names) + public void removeAttributes(Enumeration<?> names) { attributes = StyleContext.this.removeAttributes(attributes, names); fireStateChanged(); @@ -351,7 +351,7 @@ public class StyleContext return attrs.length / 2; } - public Enumeration getAttributeNames() + public Enumeration<?> getAttributeNames() { return new Enumeration() { @@ -539,7 +539,7 @@ public class StyleContext * Get the names of the style. The returned enumeration always * contains at least one member, the default style. */ - public Enumeration getStyleNames() + public Enumeration<?> getStyleNames() { return styles.getAttributeNames(); } @@ -749,7 +749,7 @@ public class StyleContext } public synchronized AttributeSet removeAttributes(AttributeSet old, - Enumeration names) + Enumeration<?> names) { AttributeSet ret; if (old.getAttributeCount() <= getCompressionThreshold()) diff --git a/javax/swing/text/TextAction.java b/javax/swing/text/TextAction.java index 7a27f21f6..49c49cb9d 100644 --- a/javax/swing/text/TextAction.java +++ b/javax/swing/text/TextAction.java @@ -96,7 +96,7 @@ public abstract class TextAction extends AbstractAction */ public static final Action[] augmentList(Action[] list1, Action[] list2) { - HashMap actions = new HashMap(); + HashMap<Object,Action> actions = new HashMap<Object,Action>(); for (int i = 0; i < list1.length; ++i) { @@ -104,6 +104,7 @@ public abstract class TextAction extends AbstractAction Object name = a.getValue(Action.NAME); actions.put(name != null ? name : "", a); } + for (int i = 0; i < list2.length; ++i) { Action a = list2[i]; @@ -113,9 +114,10 @@ public abstract class TextAction extends AbstractAction Action[] augmented = new Action[actions.size()]; int i = 0; - for (Iterator it = actions.values().iterator(); it.hasNext(); i++) - augmented[i] = (Action) it.next(); + for (Iterator<Action> it = actions.values().iterator(); it.hasNext(); i++) + augmented[i] = it.next(); return augmented; + } /** diff --git a/javax/swing/text/html/CSSParser.java b/javax/swing/text/html/CSSParser.java new file mode 100644 index 000000000..0bf76eb80 --- /dev/null +++ b/javax/swing/text/html/CSSParser.java @@ -0,0 +1,568 @@ +/* CSSParser.java -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.swing.text.html; + +import java.io.*; + +/** + * Parses a CSS document. This works by way of a delegate that implements the + * CSSParserCallback interface. The delegate is notified of the following + * events: + * - Import statement: handleImport + * - Selectors handleSelector. This is invoked for each string. For example if + * the Reader contained p, bar , a {}, the delegate would be notified 4 times, + * for 'p,' 'bar' ',' and 'a'. + * - When a rule starts, startRule + * - Properties in the rule via the handleProperty. This + * is invoked one per property/value key, eg font size: foo;, would cause the + * delegate to be notified once with a value of 'font size'. + * - Values in the rule via the handleValue, this is notified for the total value. + * - When a rule ends, endRule + * + * @author Lillian Angel (langel@redhat.com) + */ +class CSSParser +{ + + /** + * Receives all information about the CSS document structure while parsing it. + * The methods are invoked by parser. + */ + static interface CSSParserCallback + { + /** + * Handles the import statment in the document. + * + * @param imp - the import string + */ + public abstract void handleImport(String imp); + + /** + * Called when the start of a rule is encountered. + */ + public abstract void startRule(); + + /** + * Called when the end of a rule is encountered. + */ + public abstract void endRule(); + + /** + * Handles the selector of a rule. + * + * @param selector - the selector in the rule + */ + public abstract void handleSelector(String selector); + + /** + * Handles the properties in the document. + * + * @param property - the property in the document. + */ + public abstract void handleProperty(String property); + + /** + * Handles the values in the document. + * + * @param value - the value to handle. + */ + public abstract void handleValue(String value); + + } + + /** + * The identifier of the rule. + */ + private static final int IDENTIFIER = 1; + + /** + * The open bracket. + */ + private static final int BRACKET_OPEN = 2; + + /** + * The close bracket. + */ + private static final int BRACKET_CLOSE = 3; + + /** + * The open brace. + */ + private static final int BRACE_OPEN = 4; + + /** + * The close brace. + */ + private static final int BRACE_CLOSE = 5; + + /** + * The open parentheses. + */ + private static final int PAREN_OPEN = 6; + + /** + * The close parentheses. + */ + private static final int PAREN_CLOSE = 7; + + /** + * The end of the document. + */ + private static final int END = -1; + + /** + * The character mapping in the document. + */ + // FIXME: What is this used for? + private static final char[] charMapping = null; + + /** + * Set to true if one character has been read ahead. + */ + private boolean didPushChar; + + /** + * The read ahead character. + */ + private int pushedChar; + + /** + * Temporary place to hold identifiers. + */ + private StringBuffer unitBuffer; + + /** + * Used to indicate blocks. + */ + private int[] unitStack; + + /** + * Number of valid blocks. + */ + private int stackCount; + + /** + * Holds the incoming CSS rules. + */ + private Reader reader; + + /** + * Set to true when the first non @ rule is encountered. + */ + private boolean encounteredRuleSet; + + /** + * The call back used to parse. + */ + private CSSParser.CSSParserCallback callback; + + /** + * nextToken() inserts the string here. + */ + private char[] tokenBuffer; + + /** + * Current number of chars in tokenBufferLength. + */ + private int tokenBufferLength; + + /** + * Set to true if any whitespace is read. + */ + private boolean readWS; + + /** + * Constructor + */ + CSSParser() + { + unitBuffer = new StringBuffer(); + tokenBuffer = new char[10]; + } + + /** + * Appends a character to the token buffer. + * + * @param c - the character to append + */ + private void append(char c) + { + if (tokenBuffer.length >= tokenBufferLength) + { + char[] temp = new char[tokenBufferLength * 2]; + if (tokenBuffer != null) + System.arraycopy(tokenBuffer, 0, temp, 0, tokenBufferLength); + + temp[tokenBufferLength] = c; + tokenBuffer = temp; + } + else + tokenBuffer[tokenBufferLength] = c; + tokenBufferLength++; + } + + /** + * Fetches the next token. + * + * @param c - the character to fetch. + * @return the location + * @throws IOException - any i/o error encountered while reading + */ + private int nextToken(char c) throws IOException + { + readWS = false; + int next = readWS(); + + switch (next) + { + case '\"': + if (tokenBufferLength > 0) + tokenBufferLength--; + return IDENTIFIER; + case '\'': + if (tokenBufferLength > 0) + tokenBufferLength--; + return IDENTIFIER; + case '(': + return PAREN_OPEN; + case ')': + return PAREN_CLOSE; + case '{': + return BRACE_OPEN; + case '}': + return BRACE_CLOSE; + case '[': + return BRACKET_OPEN; + case ']': + return BRACKET_CLOSE; + case -1: + return END; + default: + pushChar(next); + getIdentifier(c); + return IDENTIFIER; + } + } + + /** + * Reads a character from the stream. + * + * @return the number of characters read or -1 if end of stream is reached. + * @throws IOException - any i/o encountered while reading + */ + private int readChar() throws IOException + { + if (didPushChar) + { + didPushChar = false; + return pushedChar; + } + return reader.read(); + } + + /** + * Parses the the contents of the reader using the + * callback. + * + * @param reader - the reader to read from + * @param callback - the callback instance + * @param parsingDeclaration - true if parsing a declaration + * @throws IOException - any i/o error from the reader + */ + void parse(Reader reader, CSSParser.CSSParserCallback callback, + boolean parsingDeclaration) + throws IOException + { + this.reader = reader; + this.callback = callback; + + try + { + if (!parsingDeclaration) + while(getNextStatement()); + else + parseDeclarationBlock(); + } + catch (IOException ioe) + { + // Nothing to do here. + } + } + + /** + * Skips any white space, returning the character after the white space. + * + * @return the character after the whitespace + * @throws IOException - any i/o error from the reader + */ + private int readWS() throws IOException + { + int next = readChar(); + while (Character.isWhitespace((char) next)) + { + readWS = true; + int tempNext = readChar(); + if (tempNext == END) + return next; + next = tempNext; + } + + // Its all whitespace + return END; + } + + /** + * Gets the next statement, returning false if the end is reached. + * A statement is either an At-rule, or a ruleset. + * + * @return false if the end is reached + * @throws IOException - any i/o error from the reader + */ + private boolean getNextStatement() throws IOException + { + int c = nextToken((char) 0); + switch (c) + { + case PAREN_OPEN: + case BRACE_OPEN: + case BRACKET_OPEN: + parseTillClosed(c); + break; + case BRACKET_CLOSE: + case BRACE_CLOSE: + case PAREN_CLOSE: + throw new IOException("Not a proper statement."); + case IDENTIFIER: + if (tokenBuffer[0] == ('@')) + parseAtRule(); + else + parseRuleSet(); + break; + case END: + return false; + } + return true; + } + + /** + * Parses an @ rule, stopping at a matching brace pair, or ;. + * + * @throws IOException - any i/o error from the reader + */ + private void parseAtRule() throws IOException + { + // An At-Rule begins with the "@" character followed immediately by a keyword. + // Following the keyword separated by a space is an At-rule statement appropriate + // to the At-keyword used. If the At-Rule is a simple declarative statement + // (charset, import, fontdef), it is terminated by a semi-colon (";".) + // If the At-Rule is a conditional or informative statement (media, page, font-face), + // it is followed by optional arguments and then a style declaration block inside matching + // curly braces ("{", "}".) At-Rules are sometimes nestable, depending on the context. + // If any part of an At-Rule is not understood, it should be ignored. + + // FIXME: Not Implemented + // call handleimport + } + + /** + * Parses the next rule set, which is a selector followed by a declaration + * block. + * + * @throws IOException - any i/o error from the reader + */ + private void parseRuleSet() throws IOException + { + // call parseDeclarationBlock + // call parse selectors + // call parse identifiers + // call startrule/endrule + // FIXME: Not Implemented + } + + /** + * Parses a set of selectors, returning false if the end of the stream is + * reached. + * + * @return false if the end of stream is reached + * @throws IOException - any i/o error from the reader + */ + private boolean parseSelectors() throws IOException + { + // FIXME: Not Implemented + // call handleselector + return false; + } + + /** + * Parses a declaration block. Which a number of declarations followed by a + * })]. + * + * @throws IOException - any i/o error from the reader + */ + private void parseDeclarationBlock() throws IOException + { + // call parseDeclaration + // FIXME: Not Implemented + } + + /** + * Parses a single declaration, which is an identifier a : and another identifier. + * This returns the last token seen. + * + * @returns the last token + * @throws IOException - any i/o error from the reader + */ + private int parseDeclaration() throws IOException + { + // call handleValue + // FIXME: Not Implemented + return 0; + } + + /** + * Parses identifiers until c is encountered, returning the ending token, + * which will be IDENTIFIER if c is found. + * + * @param c - the stop character + * @param wantsBlocks - true if blocks are wanted + * @return the ending token + * @throws IOException - any i/o error from the reader + */ + private int parseIdentifiers(char c, boolean wantsBlocks) throws IOException + { + // FIXME: Not implemented + // call handleproperty? + return 0; + } + + /** + * Parses till a matching block close is encountered. This is only appropriate + * to be called at the top level (no nesting). + * + * @param i - FIXME + * @throws IOException - any i/o error from the reader + */ + private void parseTillClosed(int i) throws IOException + { + // FIXME: Not Implemented + } + + /** + * Gets an identifier, returning true if the length of the string is greater + * than 0, stopping when c, whitespace, or one of {}()[] is hit. + * + * @param c - the stop character + * @return returns true if the length of the string > 0 + * @throws IOException - any i/o error from the reader + */ + private boolean getIdentifier(char c) throws IOException + { + // FIXME: Not Implemented + return false; + } + + /** + * Reads till c is encountered, escaping characters as necessary. + * + * @param c - the stop character + * @throws IOException - any i/o error from the reader + */ + private void readTill(char c) throws IOException + { + // FIXME: Not Implemented + } + + /** + * Parses a comment block. + * + * @throws IOException - any i/o error from the reader + */ + private void readComment() throws IOException + { + // Should ignore comments. Read until end of comment. + // FIXME: Not implemented + } + + /** + * Called when a block start is encountered ({[. + * + * @param start of block + */ + private void startBlock(int start) + { + // FIXME: Not Implemented + } + + /** + * Called when an end block is encountered )]} + * + * @param end of block + */ + private void endBlock(int end) + { + // FIXME: Not Implemented + } + + /** + * Checks if currently in a block. + * + * @return true if currently in a block. + */ + private boolean inBlock() + { + // FIXME: Not Implemented + return false; + } + + /** + * Supports one character look ahead, this will throw if called twice in a row. + * + * @param c - the character to push. + * @throws IOException - if called twice in a row + */ + private void pushChar(int c) throws IOException + { + if (didPushChar) + throw new IOException("pushChar called twice."); + didPushChar = true; + pushedChar = c; + } +} + +
\ No newline at end of file diff --git a/javax/swing/text/html/HTML.java b/javax/swing/text/html/HTML.java index 29e6335a0..93c05daa2 100644 --- a/javax/swing/text/html/HTML.java +++ b/javax/swing/text/html/HTML.java @@ -1129,8 +1129,8 @@ public class HTML static final int BLOCK = 2; static final int PREFORMATTED = 4; static final int SYNTHETIC = 8; - private static Map tagMap; - private static Map attrMap; + private static Map<String,Tag> tagMap; + private static Map<String,Attribute> attrMap; /** * The public constructor (does nothing). It it seldom required to have @@ -1169,7 +1169,7 @@ public class HTML if (attrMap == null) { // Create the map on demand. - attrMap = new TreeMap(); + attrMap = new TreeMap<String,Attribute>(); Attribute[] attrs = getAllAttributeKeys(); @@ -1179,7 +1179,7 @@ public class HTML } } - return (Attribute) attrMap.get(attName.toLowerCase()); + return attrMap.get(attName.toLowerCase()); } /** @@ -1238,7 +1238,7 @@ public class HTML if (tagMap == null) { // Create the mao on demand. - tagMap = new TreeMap(); + tagMap = new TreeMap<String,Tag>(); Tag[] tags = getAllTags(); @@ -1248,6 +1248,6 @@ public class HTML } } - return (Tag) tagMap.get(tagName.toLowerCase()); + return tagMap.get(tagName.toLowerCase()); } } diff --git a/javax/swing/text/html/HTMLDocument.java b/javax/swing/text/html/HTMLDocument.java index 05a250da3..f3d3ce3fa 100644 --- a/javax/swing/text/html/HTMLDocument.java +++ b/javax/swing/text/html/HTMLDocument.java @@ -649,12 +649,12 @@ public class HTMLDocument extends DefaultStyledDocument */ protected MutableAttributeSet charAttr = new SimpleAttributeSet(); - protected Vector parseBuffer = new Vector(); + protected Vector<ElementSpec> parseBuffer = new Vector<ElementSpec>(); /** * The parse stack. It holds the current element tree path. */ - private Stack parseStack = new Stack(); + private Stack<HTML.Tag> parseStack = new Stack<HTML.Tag>(); /** * A stack for character attribute sets * @@ -1791,7 +1791,7 @@ public class HTMLDocument extends DefaultStyledDocument boolean inParagraph = false; if (! parseStack.isEmpty()) { - HTML.Tag top = (HTML.Tag) parseStack.peek(); + HTML.Tag top = parseStack.peek(); inParagraph = top == HTML.Tag.P || top == HTML.Tag.IMPLIED; } return inParagraph; @@ -1802,7 +1802,7 @@ public class HTMLDocument extends DefaultStyledDocument boolean inParagraph = false; if (! parseStack.isEmpty()) { - HTML.Tag top = (HTML.Tag) parseStack.peek(); + HTML.Tag top = parseStack.peek(); inParagraph = top == HTML.Tag.IMPLIED; } return inParagraph; diff --git a/javax/swing/text/html/StyleSheet.java b/javax/swing/text/html/StyleSheet.java index cb10ac1c5..01f19fd7b 100644 --- a/javax/swing/text/html/StyleSheet.java +++ b/javax/swing/text/html/StyleSheet.java @@ -870,10 +870,10 @@ public class StyleSheet extends StyleContext * @param names - the attribute names * @return the update attribute set */ - public AttributeSet removeAttributes(AttributeSet old, Enumeration names) + public AttributeSet removeAttributes(AttributeSet old, Enumeration<?> names) { // FIXME: Not implemented. - return super.removeAttributes(old, names); + return super.removeAttributes(old, names); } /** diff --git a/javax/swing/text/html/parser/AttributeList.java b/javax/swing/text/html/parser/AttributeList.java index 5bca0bfa7..d48266d47 100644 --- a/javax/swing/text/html/parser/AttributeList.java +++ b/javax/swing/text/html/parser/AttributeList.java @@ -122,7 +122,7 @@ public final class AttributeList * null, if this parameter was not specified. * Values, defined in DTD, are case insensitive. */ - public Vector values; + public Vector<?> values; /** * The modifier of this attribute. This field contains one of the @@ -176,7 +176,7 @@ public final class AttributeList * Equals to null for the last attribute definition. */ public AttributeList(String a_name, int a_type, int a_modifier, - String a_default, Vector allowed_values, + String a_default, Vector<?> allowed_values, AttributeList a_next ) { @@ -251,7 +251,7 @@ public final class AttributeList /** * Get the allowed values of this attribute. */ - public Enumeration getValues() + public Enumeration<?> getValues() { return values.elements(); } diff --git a/javax/swing/text/html/parser/ContentModel.java b/javax/swing/text/html/parser/ContentModel.java index 70e9c2acb..d5c4418de 100644 --- a/javax/swing/text/html/parser/ContentModel.java +++ b/javax/swing/text/html/parser/ContentModel.java @@ -151,13 +151,15 @@ public final class ContentModel * discarded. * @param elements - a vector to add the values to. */ - public void getElements(Vector elements) + public void getElements(Vector<Element> elements) { ContentModel c = this; while (c != null) { - elements.add(c.content); + // FIXME: correct? + if (c.content instanceof Element) + elements.add((Element) c.content); c = c.next; } } diff --git a/javax/swing/text/html/parser/DTD.java b/javax/swing/text/html/parser/DTD.java index 16bc5b0d6..ae3c184f1 100644 --- a/javax/swing/text/html/parser/DTD.java +++ b/javax/swing/text/html/parser/DTD.java @@ -88,7 +88,7 @@ public class DTD /** * The table of existing available DTDs. */ - static Hashtable dtdHash = new Hashtable(); + static Hashtable<String,DTD> dtdHash = new Hashtable<String,DTD>(); /** * The applet element for this DTD. @@ -148,12 +148,13 @@ public class DTD /** * The element for accessing all DTD elements by name. */ - public Hashtable elementHash = new Hashtable(); + public Hashtable<String,Element> elementHash = + new Hashtable<String,Element>(); /** * The entity table for accessing all DTD entities by name. */ - public Hashtable entityHash = new Hashtable(); + public Hashtable<Object, Entity> entityHash = new Hashtable<Object, Entity>(); /** * The name of this DTD. @@ -165,7 +166,7 @@ public class DTD * javax.swing.text.html.parser.Element#index field of all elements * in this vector is set to the element position in this vector. */ - public Vector elements = new Vector(); + public Vector<Element> elements = new Vector<Element>(); /** Create a new DTD with the specified name. */ protected DTD(String a_name) @@ -224,7 +225,7 @@ public class DTD String name = Entity.mapper.get(id); if (name != null) - return (Entity) entityHash.get(name); + return entityHash.get(name); else return null; } @@ -269,7 +270,7 @@ public class DTD */ public void defineAttributes(String forElement, AttributeList attributes) { - Element e = (Element) elementHash.get(forElement.toLowerCase()); + Element e = elementHash.get(forElement.toLowerCase()); if (e == null) e = newElement(forElement); @@ -420,7 +421,7 @@ public class DTD if (allowed_values != null) { StringTokenizer st = new StringTokenizer(allowed_values, " \t|"); - Vector v = new Vector(st.countTokens()); + Vector<String> v = new Vector<String>(st.countTokens()); while (st.hasMoreTokens()) v.add(st.nextToken()); @@ -571,7 +572,7 @@ public class DTD */ private Element newElement(String name) { - Element e = (Element) elementHash.get(name.toLowerCase()); + Element e = elementHash.get(name.toLowerCase()); if (e == null) { diff --git a/javax/swing/tree/AbstractLayoutCache.java b/javax/swing/tree/AbstractLayoutCache.java index d674a8a05..4a6899fbe 100644 --- a/javax/swing/tree/AbstractLayoutCache.java +++ b/javax/swing/tree/AbstractLayoutCache.java @@ -344,7 +344,7 @@ public abstract class AbstractLayoutCache * * @return Enumeration */ - public abstract Enumeration getVisiblePathsFrom(TreePath path); + public abstract Enumeration<TreePath> getVisiblePathsFrom(TreePath path); /** * getVisibleChildCount diff --git a/javax/swing/tree/DefaultMutableTreeNode.java b/javax/swing/tree/DefaultMutableTreeNode.java index 6951b9600..9f587946f 100644 --- a/javax/swing/tree/DefaultMutableTreeNode.java +++ b/javax/swing/tree/DefaultMutableTreeNode.java @@ -67,7 +67,7 @@ public class DefaultMutableTreeNode * An empty enumeration, returned by {@link #children()} if a node has no * children. */ - public static final Enumeration EMPTY_ENUMERATION = + public static final Enumeration<TreeNode> EMPTY_ENUMERATION = EmptyEnumeration.getInstance(); /** @@ -78,7 +78,7 @@ public class DefaultMutableTreeNode /** * The child nodes for this node (may be empty). */ - protected Vector children = new Vector(); + protected Vector<MutableTreeNode> children = new Vector<MutableTreeNode>(); /** * userObject @@ -480,7 +480,7 @@ public class DefaultMutableTreeNode public TreeNode getSharedAncestor(DefaultMutableTreeNode node) { TreeNode current = this; - ArrayList list = new ArrayList(); + ArrayList<TreeNode> list = new ArrayList<TreeNode>(); while (current != null) { @@ -527,7 +527,7 @@ public class DefaultMutableTreeNode || children.size() == 0) return 0; - Stack stack = new Stack(); + Stack<Integer> stack = new Stack<Integer>(); stack.push(new Integer(0)); TreeNode node = getChildAt(0); int depth = 0; @@ -765,7 +765,7 @@ public class DefaultMutableTreeNode throw new IllegalArgumentException(); TreeNode parent = this; - Vector nodes = new Vector(); + Vector<TreeNode> nodes = new Vector<TreeNode>(); nodes.add(this); while (parent != node && parent != null) @@ -1148,7 +1148,7 @@ public class DefaultMutableTreeNode static class PostorderEnumeration implements Enumeration { - Stack nodes = new Stack(); + Stack<TreeNode> nodes = new Stack<TreeNode>(); Stack childrenEnums = new Stack(); PostorderEnumeration(TreeNode node) diff --git a/javax/swing/tree/DefaultTreeModel.java b/javax/swing/tree/DefaultTreeModel.java index 639d861fb..afee7ea22 100644 --- a/javax/swing/tree/DefaultTreeModel.java +++ b/javax/swing/tree/DefaultTreeModel.java @@ -615,7 +615,7 @@ public class DefaultTreeModel * * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/tree/DefaultTreeSelectionModel.java b/javax/swing/tree/DefaultTreeSelectionModel.java index 734d899bb..3d9c67728 100644 --- a/javax/swing/tree/DefaultTreeSelectionModel.java +++ b/javax/swing/tree/DefaultTreeSelectionModel.java @@ -776,7 +776,7 @@ public class DefaultTreeSelectionModel * @return an array of listeners * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } diff --git a/javax/swing/tree/FixedHeightLayoutCache.java b/javax/swing/tree/FixedHeightLayoutCache.java index a699a6c9f..dff9298e8 100644 --- a/javax/swing/tree/FixedHeightLayoutCache.java +++ b/javax/swing/tree/FixedHeightLayoutCache.java @@ -480,7 +480,7 @@ public class FixedHeightLayoutCache * @param parentPath the parent path * @return the enumeration over pathes */ - public Enumeration getVisiblePathsFrom(TreePath parentPath) + public Enumeration<TreePath> getVisiblePathsFrom(TreePath parentPath) { if (dirty) update(); diff --git a/javax/swing/tree/VariableHeightLayoutCache.java b/javax/swing/tree/VariableHeightLayoutCache.java index 408c220a7..8c70c13af 100644 --- a/javax/swing/tree/VariableHeightLayoutCache.java +++ b/javax/swing/tree/VariableHeightLayoutCache.java @@ -494,7 +494,7 @@ public class VariableHeightLayoutCache * @param parentPath the parent path * @return the enumeration over pathes */ - public Enumeration getVisiblePathsFrom(TreePath parentPath) + public Enumeration<TreePath> getVisiblePathsFrom(TreePath parentPath) { if (dirty) update(); diff --git a/javax/swing/undo/CompoundEdit.java b/javax/swing/undo/CompoundEdit.java index e1cfbb619..fbff2a264 100644 --- a/javax/swing/undo/CompoundEdit.java +++ b/javax/swing/undo/CompoundEdit.java @@ -1,5 +1,5 @@ /* CompoundEdit.java -- Combines multiple UndoableEdits. - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -75,7 +75,7 @@ public class CompoundEdit * The <code>UndoableEdit</code>s being combined into a compound * editing action. */ - protected Vector edits; + protected Vector<UndoableEdit> edits; /** @@ -92,7 +92,7 @@ public class CompoundEdit */ public CompoundEdit() { - edits = new Vector(); + edits = new Vector<UndoableEdit>(); inProgress = true; } @@ -118,7 +118,7 @@ public class CompoundEdit super.undo(); for (int i = edits.size() - 1; i >= 0; i--) - ((UndoableEdit) edits.elementAt(i)).undo(); + edits.elementAt(i).undo(); } @@ -143,7 +143,7 @@ public class CompoundEdit super.redo(); for (int i = 0; i < edits.size(); i++) - ((UndoableEdit) edits.elementAt(i)).redo(); + edits.elementAt(i).redo(); } @@ -156,7 +156,7 @@ public class CompoundEdit if (edits.size() == 0) return null; else - return (UndoableEdit) edits.elementAt(edits.size() - 1); + return edits.elementAt(edits.size() - 1); } @@ -172,7 +172,7 @@ public class CompoundEdit public void die() { for (int i = edits.size() - 1; i >= 0; i--) - ((UndoableEdit) edits.elementAt(i)).die(); + edits.elementAt(i).die(); super.die(); } @@ -316,7 +316,7 @@ public class CompoundEdit public boolean isSignificant() { for (int i = edits.size() - 1; i >= 0; i--) - if (((UndoableEdit) edits.elementAt(i)).isSignificant()) + if (edits.elementAt(i).isSignificant()) return true; return false; diff --git a/javax/swing/undo/StateEdit.java b/javax/swing/undo/StateEdit.java index 326abea1f..91fc88faa 100644 --- a/javax/swing/undo/StateEdit.java +++ b/javax/swing/undo/StateEdit.java @@ -121,14 +121,14 @@ public class StateEdit * The state of <code>object</code> at the time of constructing * this <code>StateEdit</code>. */ - protected Hashtable preState; + protected Hashtable<Object, Object> preState; /** * The state of <code>object</code> at the time when {@link #end()} * was called. */ - protected Hashtable postState; + protected Hashtable<Object, Object> postState; /** diff --git a/javax/swing/undo/StateEditable.java b/javax/swing/undo/StateEditable.java index 459025be7..7e6cc9785 100644 --- a/javax/swing/undo/StateEditable.java +++ b/javax/swing/undo/StateEditable.java @@ -100,7 +100,7 @@ public interface StateEditable * @param state a hash table containing the relevant state * information. */ - void restoreState(Hashtable state); + void restoreState(Hashtable<?, ?> state); /** @@ -110,5 +110,5 @@ public interface StateEditable * @param state a hash table for storing relevant state * information. */ - void storeState(Hashtable state); + void storeState(Hashtable<Object, Object> state); } diff --git a/javax/swing/undo/UndoableEditSupport.java b/javax/swing/undo/UndoableEditSupport.java index 6d7bbea07..b5a933419 100644 --- a/javax/swing/undo/UndoableEditSupport.java +++ b/javax/swing/undo/UndoableEditSupport.java @@ -69,7 +69,8 @@ public class UndoableEditSupport /** * The currently registered listeners. */ - protected Vector listeners = new Vector(); + protected Vector<UndoableEditListener> listeners = + new Vector<UndoableEditListener>(); /** @@ -148,7 +149,7 @@ public class UndoableEditSupport public synchronized UndoableEditListener[] getUndoableEditListeners() { UndoableEditListener[] result = new UndoableEditListener[listeners.size()]; - return (UndoableEditListener[]) listeners.toArray(result); + return listeners.toArray(result); } |