From: Michael Koch Date: Sat, 15 Feb 2003 09:21:55 +0000 (+0000) Subject: 2003-02-15 Michael Koch X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=30df932c23db0f7d3b7353f6fee11c4ec27dd9c2;p=gcc.git 2003-02-15 Michael Koch * java/awt/CheckboxMenuItem.java (CheckBoxMenuItem): Dont implement Serializable. (getListeners): New method, (getItemListeners): New method. * java/awt/Choice.java (getListeners): New method, (getItemListeners): New method. * java/awt/Container.java (getListeners): Added exception documentation. (setFocusTraversalKeys): Throw exceptions, added documentattion. (getFocusTraversalKeys): Added documentation. (areFocusTraversalKeysSet): Added documentation. (applyComponentOrientation): Added documentation. * java/awt/ContainerOrderFocusTraversalPolicy.java (implicitDownCycleTraversal): Renamed from downCycle for serialization. (ContainerOrderFocusTraversalPolicy): Added documentation. (accept): Reformated. * java/awt/Dialog.java (Dialog): Dont implement Serializable. (Dialog): Added documentation. * java/awt/Font.java (Font): Dont use absolute class name. * java/awt/Frame.java (Frame): Font implement Serializable. * java/awt/List.java (getListeners): New method, (getActionListeners): New method. (getItemListeners): New method. * java/awt/Menu.java (countItems): New deprecated method. * java/awt/Scrollbar.java (getListeners): New method, (getAdjustmentListeners): New method, * java/awt/TextComponent.java (getListeners): New method, (getTextListeners): New method, * java/awt/TextField.java (getListeners): New method, (getActionListeners): New method. * java/awt/Window.java (windowFocusListener): New member variable. (windowStateListener): New member variable. (getWindowFocusListeners): New method. (getWindowStateListeners): New method. (addWindowFocusListener): New method. (addWindowStateListener): New method. (removeWindowFocusListener): New method. (removeWindowStateListener): New method. * java/awt/datatransfer/DataFlavor.java (isRepresentationClassByteBuffer): New method. (isRepresentationClassCharBuffer): New method. (isRepresentationClassReader): New method. From-SVN: r62933 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index ef7f16021a8..785c9bbae63 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,59 @@ +2003-02-15 Michael Koch + + * java/awt/CheckboxMenuItem.java + (CheckBoxMenuItem): Dont implement Serializable. + (getListeners): New method, + (getItemListeners): New method. + * java/awt/Choice.java + (getListeners): New method, + (getItemListeners): New method. + * java/awt/Container.java + (getListeners): Added exception documentation. + (setFocusTraversalKeys): Throw exceptions, added documentattion. + (getFocusTraversalKeys): Added documentation. + (areFocusTraversalKeysSet): Added documentation. + (applyComponentOrientation): Added documentation. + * java/awt/ContainerOrderFocusTraversalPolicy.java + (implicitDownCycleTraversal): Renamed from downCycle for + serialization. + (ContainerOrderFocusTraversalPolicy): Added documentation. + (accept): Reformated. + * java/awt/Dialog.java + (Dialog): Dont implement Serializable. + (Dialog): Added documentation. + * java/awt/Font.java + (Font): Dont use absolute class name. + * java/awt/Frame.java + (Frame): Font implement Serializable. + * java/awt/List.java + (getListeners): New method, + (getActionListeners): New method. + (getItemListeners): New method. + * java/awt/Menu.java + (countItems): New deprecated method. + * java/awt/Scrollbar.java + (getListeners): New method, + (getAdjustmentListeners): New method, + * java/awt/TextComponent.java + (getListeners): New method, + (getTextListeners): New method, + * java/awt/TextField.java + (getListeners): New method, + (getActionListeners): New method. + * java/awt/Window.java + (windowFocusListener): New member variable. + (windowStateListener): New member variable. + (getWindowFocusListeners): New method. + (getWindowStateListeners): New method. + (addWindowFocusListener): New method. + (addWindowStateListener): New method. + (removeWindowFocusListener): New method. + (removeWindowStateListener): New method. + * java/awt/datatransfer/DataFlavor.java + (isRepresentationClassByteBuffer): New method. + (isRepresentationClassCharBuffer): New method. + (isRepresentationClassReader): New method. + 2003-02-14 Mark Wielaard * java/math/BigDecimal.java (BigDecimal(String)): Always set scale to diff --git a/libjava/java/awt/CheckboxMenuItem.java b/libjava/java/awt/CheckboxMenuItem.java index 88218397c3c..4f41568218a 100644 --- a/libjava/java/awt/CheckboxMenuItem.java +++ b/libjava/java/awt/CheckboxMenuItem.java @@ -43,6 +43,7 @@ import java.awt.peer.MenuItemPeer; import java.awt.peer.MenuComponentPeer; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.EventListener; /** * This class implements a menu item that has a checkbox on it indicating @@ -51,8 +52,7 @@ import java.awt.event.ItemListener; * @author Aaron M. Renn (arenn@urbanophile.com) * @author Tom Tromey */ -public class CheckboxMenuItem extends MenuItem implements ItemSelectable, - java.io.Serializable +public class CheckboxMenuItem extends MenuItem implements ItemSelectable { /* @@ -296,5 +296,29 @@ paramString() + "," + super.paramString()); } + /** + * Returns an array of all the objects currently registered as FooListeners + * upon this CheckboxMenuItem. FooListeners are registered using + * the addFooListener method. + * + * @exception ClassCastException If listenerType doesn't specify a class or + * interface that implements java.util.EventListener. + */ + public EventListener[] getListeners (Class listenerType) + { + if (listenerType == ItemListener.class) + return AWTEventMulticaster.getListeners (item_listeners, listenerType); + + return super.getListeners (listenerType); + } + + /** + * Returns an aray of all item listeners currently registered to this + * CheckBoxMenuItem. + */ + public ItemListener[] getItemListeners () + { + return (ItemListener[]) getListeners (ItemListener.class); + } } // class CheckboxMenuItem diff --git a/libjava/java/awt/Choice.java b/libjava/java/awt/Choice.java index 4c7b505535c..cb8bb036491 100644 --- a/libjava/java/awt/Choice.java +++ b/libjava/java/awt/Choice.java @@ -44,6 +44,7 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.io.Serializable; import java.util.Vector; +import java.util.EventListener; /** * This class implements a drop down choice list. @@ -474,4 +475,31 @@ paramString() return ("selectedIndex=" + selectedIndex + "," + super.paramString()); } + /** + * Returns an array of all the objects currently registered as FooListeners + * upon this Choice. FooListeners are registered using the addFooListener + * method. + * + * @exception ClassCastException If listenerType doesn't specify a class or + * interface that implements java.util.EventListener. + * + * @since 1.3 + */ + public EventListener[] getListeners (Class listenerType) + { + if (listenerType == ItemListener.class) + return AWTEventMulticaster.getListeners (item_listeners, listenerType); + + return super.getListeners (listenerType); + } + + /** + * Returns all registered item listeners. + * + * @since 1.4 + */ + public ItemListener[] getItemListeners () + { + return (ItemListener[]) getListeners (ItemListener.class); + } } // class Choice diff --git a/libjava/java/awt/Container.java b/libjava/java/awt/Container.java index 9494d8c56ac..91804d7f8c9 100644 --- a/libjava/java/awt/Container.java +++ b/libjava/java/awt/Container.java @@ -728,6 +728,9 @@ public class Container extends Component * upon this Container. FooListeners are registered using the addFooListener * method. * + * @exception ClassCastException If listenerType doesn't specify a class or + * interface that implements @see java.util.EventListener. + * * @since 1.3 */ public EventListener[] getListeners(Class listenerType) @@ -994,15 +997,48 @@ public class Container extends Component } } - public void setFocusTraversalKeys(int id, Set keys) + /** + * Sets the focus traversal keys for a given traversal operation for this + * Container. + * + * @exception IllegalArgumentException If id is not one of + * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, + * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, + * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, + * or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS, + * or if keystrokes contains null, or if any Object in keystrokes is not an + * AWTKeyStroke, or if any keystroke represents a KEY_TYPED event, or if any + * keystroke already maps to another focus traversal operation for this + * Container. + * + * @since 1.4 + */ + public void setFocusTraversalKeys(int id, Set keystrokes) { if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS && id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS && id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS && id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS) throw new IllegalArgumentException (); + + if (keystrokes == null) + throw new IllegalArgumentException (); + + throw new Error ("not implemented"); } + /** + * Returns the Set of focus traversal keys for a given traversal operation for + * this Container. + * + * @exception IllegalArgumentException If id is not one of + * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, + * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, + * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, + * or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS. + * + * @since 1.4 + */ public Set getFocusTraversalKeys(int id) { if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS && @@ -1014,6 +1050,20 @@ public class Container extends Component return null; } + /** + * Returns whether the Set of focus traversal keys for the given focus + * traversal operation has been explicitly defined for this Container. + * If this method returns false, this Container is inheriting the Set from + * an ancestor, or from the current KeyboardFocusManager. + * + * @exception IllegalArgumentException If id is not one of + * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, + * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, + * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, + * or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS. + * + * @since 1.4 + */ public boolean areFocusTraversalKeysSet(int id) { if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS && @@ -1060,8 +1110,16 @@ public class Container extends Component public void transferFocusDownCycle() { } - - public void applyComponentOrientation(ComponentOrientation o) + + /** + * Sets the ComponentOrientation property of this container and all components + * contained within it. + * + * @exception NullPointerException If orientation is null + * + * @since 1.4 + */ + public void applyComponentOrientation (ComponentOrientation orientation) { if (orientation == null) throw new NullPointerException (); diff --git a/libjava/java/awt/ContainerOrderFocusTraversalPolicy.java b/libjava/java/awt/ContainerOrderFocusTraversalPolicy.java index e3cf31cb111..71267a579f0 100644 --- a/libjava/java/awt/ContainerOrderFocusTraversalPolicy.java +++ b/libjava/java/awt/ContainerOrderFocusTraversalPolicy.java @@ -48,8 +48,11 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy { static final long serialVersionUID = 486933713763926351L; - private boolean downCycle = true; + private boolean implicitDownCycleTraversal = true; + /** + * Creates the ContainerOrderFocusTraversalPolicy object. + */ public ContainerOrderFocusTraversalPolicy() { throw new Error("not implemented"); @@ -82,17 +85,19 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy public void setImplicitDownCycleTraversal(boolean value) { - downCycle = value; + boolean implicitDownCycleTraversal = value; } public boolean getImplicitDownCycleTraversal() { - return downCycle; + return implicitDownCycleTraversal; } protected boolean accept(Component current) { - return current.visible && current.isDisplayable() && current.enabled - && current.focusable; + return (current.visible + && current.isDisplayable() + && current.enabled + && current.focusable); } } // class ContainerOrderFocusTraversalPolicy diff --git a/libjava/java/awt/Dialog.java b/libjava/java/awt/Dialog.java index 471826c4b1b..9aa2ea6f346 100644 --- a/libjava/java/awt/Dialog.java +++ b/libjava/java/awt/Dialog.java @@ -49,7 +49,7 @@ import java.awt.peer.ComponentPeer; * @author Aaron M. Renn (arenn@urbanophile.com) * @author Tom Tromey */ -public class Dialog extends Window implements java.io.Serializable +public class Dialog extends Window { /* @@ -92,6 +92,10 @@ private String title; * parent, that is not resizable and not modal, and which has no title. * * @param parent The parent frame of this dialog box. + * + * @exception IllegalArgumentException If the owner's GraphicsConfiguration + * is not from a screen device, or if owner is null. This exception is always + * thrown when GraphicsEnvironment.isHeadless() returns true. */ public Dialog(Frame parent) @@ -108,6 +112,10 @@ Dialog(Frame parent) * @param parent The parent frame of this dialog box. * @param modal if this dialog box is modal, false * otherwise. + * + * @exception IllegalArgumentException If the owner's GraphicsConfiguration + * is not from a screen device, or if owner is null. This exception is always + * thrown when GraphicsEnvironment.isHeadless() returns true. */ public Dialog(Frame parent, boolean modal) @@ -124,6 +132,10 @@ Dialog(Frame parent, boolean modal) * * @param parent The parent frame of this dialog box. * @param title The title string for this dialog box. + * + * @exception IllegalArgumentException If the owner's GraphicsConfiguration + * is not from a screen device, or if owner is null. This exception is always + * thrown when GraphicsEnvironment.isHeadless() returns true. */ public Dialog(Frame parent, String title) @@ -160,12 +172,30 @@ Dialog (Dialog owner) this (owner, "", false); } +/** + * Initializes a new instance of Dialog with the specified, + * parent and title, that is not resizable. + * + * @exception IllegalArgumentException If parent is null. This exception is + * always thrown when GraphicsEnvironment.isHeadless() returns true. + * + * @since 1.2 + */ public Dialog (Dialog owner, String title) { this (owner, title, false); } +/** + * Initializes a new instance of Dialog with the specified, + * parent, title and modality, that is not resizable. + * + * @exception IllegalArgumentException If parent is null. This exception is + * always thrown when GraphicsEnvironment.isHeadless() returns true. + * + * @since 1.2 + */ public Dialog (Dialog owner, String title, boolean modal) { diff --git a/libjava/java/awt/Font.java b/libjava/java/awt/Font.java index 730a7003e59..3723a4528ed 100644 --- a/libjava/java/awt/Font.java +++ b/libjava/java/awt/Font.java @@ -39,6 +39,7 @@ exception statement from your version. */ package java.awt; import java.awt.peer.FontPeer; +import java.io.Serializable; import java.util.StringTokenizer; /** @@ -47,7 +48,7 @@ import java.util.StringTokenizer; * @author Aaron M. Renn (arenn@urbanophile.com) * @author Warren Levy */ -public class Font implements java.io.Serializable +public class Font implements Serializable { /* diff --git a/libjava/java/awt/Frame.java b/libjava/java/awt/Frame.java index a25af9c5546..8c08a2e9b7b 100644 --- a/libjava/java/awt/Frame.java +++ b/libjava/java/awt/Frame.java @@ -42,7 +42,6 @@ import java.awt.peer.FramePeer; import java.awt.peer.WindowPeer; import java.awt.peer.ContainerPeer; import java.awt.peer.ComponentPeer; -import java.io.Serializable; import java.util.Enumeration; import java.util.Vector; @@ -52,7 +51,7 @@ import java.util.Vector; * * @author Aaron M. Renn (arenn@urbanophile.com) */ -public class Frame extends Window implements MenuContainer, Serializable +public class Frame extends Window implements MenuContainer { /* diff --git a/libjava/java/awt/List.java b/libjava/java/awt/List.java index d182e560014..9e59041f781 100644 --- a/libjava/java/awt/List.java +++ b/libjava/java/awt/List.java @@ -45,6 +45,7 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.peer.ListPeer; import java.awt.peer.ComponentPeer; +import java.util.EventListener; import java.util.Vector; import javax.accessibility.Accessible; @@ -1030,4 +1031,38 @@ paramString() return "multiple=" + multipleMode + ",rows=" + rows + super.paramString(); } + /** + * Returns an array of all the objects currently registered as FooListeners + * upon this List. FooListeners are registered using the + * addFooListener method. + * + * @exception ClassCastException If listenerType doesn't specify a class or + * interface that implements java.util.EventListener. + */ + public EventListener[] getListeners (Class listenerType) + { + if (listenerType == ActionListener.class) + return AWTEventMulticaster.getListeners (action_listeners, listenerType); + + if (listenerType == ItemListener.class) + return AWTEventMulticaster.getListeners (item_listeners, listenerType); + + return super.getListeners (listenerType); + } + + /** + * Returns all action listeners registered to this object. + */ + public ActionListener[] getActionListeners () + { + return (ActionListener[]) getListeners (ActionListener.class); + } + + /** + * Returns all action listeners registered to this object. + */ + public ItemListener[] getItemListeners () + { + return (ItemListener[]) getListeners (ItemListener.class); + } } // class List diff --git a/libjava/java/awt/Menu.java b/libjava/java/awt/Menu.java index 326101b76e5..2ca9467e2b1 100644 --- a/libjava/java/awt/Menu.java +++ b/libjava/java/awt/Menu.java @@ -175,6 +175,18 @@ getItemCount() { return(items.size()); } + +/** + * Returns the number of items in this menu. + * + * @return The number of items in this menu. + * + * @deprecated As of JDK 1.1, replaced by getItemCount(). + */ +public int countItems () +{ + return getItemCount (); +} /*************************************************************************/ diff --git a/libjava/java/awt/Scrollbar.java b/libjava/java/awt/Scrollbar.java index 76daee3f8bf..f78f402d3c9 100644 --- a/libjava/java/awt/Scrollbar.java +++ b/libjava/java/awt/Scrollbar.java @@ -42,6 +42,7 @@ import java.awt.peer.ScrollbarPeer; import java.awt.peer.ComponentPeer; import java.awt.event.AdjustmentListener; import java.awt.event.AdjustmentEvent; +import java.util.EventListener; import javax.accessibility.Accessible; /** @@ -699,5 +700,29 @@ paramString() + super.paramString()); } + /** + * Returns an array of all the objects currently registered as FooListeners + * upon this Scrollbar. FooListeners are registered using the + * addFooListener method. + * + * @exception ClassCastException If listenerType doesn't specify a class or + * interface that implements java.util.EventListener. + */ + public EventListener[] getListeners (Class listenerType) + { + if (listenerType == AdjustmentListener.class) + return AWTEventMulticaster.getListeners (adjustment_listeners, + listenerType); + + return super.getListeners (listenerType); + } + + /** + * Returns an array of all registered adjustment listeners. + */ + public AdjustmentListener[] getAdjustmentListeners () + { + return (AdjustmentListener[]) getListeners (AdjustmentListener.class); + } } // class Scrollbar diff --git a/libjava/java/awt/TextComponent.java b/libjava/java/awt/TextComponent.java index 6dc904cc8b1..cbe7dc9169d 100644 --- a/libjava/java/awt/TextComponent.java +++ b/libjava/java/awt/TextComponent.java @@ -42,6 +42,7 @@ import java.awt.event.TextEvent; import java.awt.event.TextListener; import java.awt.peer.TextComponentPeer; import java.awt.peer.ComponentPeer; +import java.util.EventListener; /** * This class provides common functionality for widgets than @@ -442,5 +443,28 @@ paramString() return(getClass().getName() + "(text=" + getText() + ")"); } + /** + * Returns an array of all the objects currently registered as FooListeners + * upon this TextComponent. FooListeners are registered using + * the addFooListener method. + * + * @exception ClassCastException If listenerType doesn't specify a class or + * interface that implements java.util.EventListener. + */ + public EventListener[] getListeners (Class listenerType) + { + if (listenerType == TextListener.class) + return AWTEventMulticaster.getListeners (textListener, listenerType); + + return super.getListeners (listenerType); + } + + /** + * Returns all text listeners registered to this object. + */ + public TextListener[] getTextListeners () + { + return (TextListener[]) getListeners (TextListener.class); + } } // class TextComponent diff --git a/libjava/java/awt/TextField.java b/libjava/java/awt/TextField.java index 335edc6d220..c2c2be7215e 100644 --- a/libjava/java/awt/TextField.java +++ b/libjava/java/awt/TextField.java @@ -43,6 +43,7 @@ import java.awt.event.ActionListener; import java.awt.peer.TextFieldPeer; import java.awt.peer.TextComponentPeer; import java.awt.peer.ComponentPeer; +import java.util.EventListener; /** * This class implements a single line text entry field widget @@ -489,4 +490,32 @@ paramString() getEchoChar()); } + /** + * Returns an array of all the objects currently registered as FooListeners + * upon this TextField. FooListeners are registered using the + * addFooListener method. + * + * @exception ClassCastException If listenerType doesn't specify a class or + * interface that implements java.util.EventListener. + * + * @since 1.3 + */ + public EventListener[] getListeners (Class listenerType) + { + if (listenerType == ActionListener.class) + return AWTEventMulticaster.getListeners (action_listeners, listenerType); + + return super.getListeners (listenerType); + } + + /** + * Return all ActionListeners register to this TextField object + * as an array. + * + * @since 1.4 + */ + public ActionListener[] getActionListeners () + { + return (ActionListener[]) getListeners (ActionListener.class); + } } // class TextField diff --git a/libjava/java/awt/Window.java b/libjava/java/awt/Window.java index dbfe92c71b8..805152e5405 100644 --- a/libjava/java/awt/Window.java +++ b/libjava/java/awt/Window.java @@ -39,7 +39,9 @@ exception statement from your version. */ package java.awt; import java.awt.event.WindowEvent; +import java.awt.event.WindowFocusListener; import java.awt.event.WindowListener; +import java.awt.event.WindowStateListener; import java.awt.peer.WindowPeer; import java.awt.peer.ComponentPeer; import java.util.EventListener; @@ -61,6 +63,8 @@ public class Window extends Container private int windowSerializedDataVersion = 0; // FIXME private transient WindowListener windowListener; + private transient WindowFocusListener windowFocusListener; + private transient WindowStateListener windowStateListener; private transient GraphicsConfiguration graphicsConfiguration; /** @@ -380,6 +384,68 @@ public class Window extends Container WindowListener.class); } + /** + * Returns an array of all the window focus listeners registered on this + * window. + * + * @since 1.4 + */ + public synchronized WindowFocusListener[] getWindowFocusListeners() + { + return (WindowFocusListener[]) + AWTEventMulticaster.getListeners(windowFocusListener, + WindowFocusListener.class); + } + + /** + * Returns an array of all the window state listeners registered on this + * window. + * + * @since 1.4 + */ + public synchronized WindowStateListener[] getWindowStateListeners() + { + return (WindowStateListener[]) + AWTEventMulticaster.getListeners(windowStateListener, + WindowStateListener.class); + } + + /** + * Adds the specified listener to this window. + */ + public void addWindowFocusListener (WindowFocusListener wfl) + { + AWTEventMulticaster.add (windowFocusListener, wfl); + } + + /** + * Adds the specified listener to this window. + * + * @since 1.4 + */ + public void addWindowStateListener (WindowStateListener wsl) + { + AWTEventMulticaster.add (windowStateListener, wsl); + } + + /** + * Removes the specified listener from this window. + */ + public void removeWindowFocusListener (WindowFocusListener wfl) + { + AWTEventMulticaster.remove (windowFocusListener, wfl); + } + + /** + * Removes the specified listener from this window. + * + * @since 1.4 + */ + public void removeWindowStateListener (WindowStateListener wsl) + { + AWTEventMulticaster.remove (windowStateListener, wsl); + } + /** * Returns an array of all the objects currently registered as FooListeners * upon this Window. FooListeners are registered using the addFooListener diff --git a/libjava/java/awt/datatransfer/DataFlavor.java b/libjava/java/awt/datatransfer/DataFlavor.java index 86d1f53c1d9..f542bd89286 100644 --- a/libjava/java/awt/datatransfer/DataFlavor.java +++ b/libjava/java/awt/datatransfer/DataFlavor.java @@ -47,6 +47,8 @@ import java.io.ObjectInput; import java.io.Reader; import java.io.StringReader; import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; /** * This class represents a particular data format used for transferring @@ -999,5 +1001,59 @@ public Reader getReaderForText(Transferable transferable) throw new UnsupportedFlavorException(this); } + /** + * Returns whether the representation class for this DataFlavor is + * @see java.nio.ByteBuffer or a subclass thereof. + * + * @since 1.4 + */ + public boolean isRepresentationClassByteBuffer () + { + try + { + return ByteBuffer.class.isAssignableFrom (representationClass); + } + catch (ClassNotFoundException e) + { + return false; + } + } + + /** + * Returns whether the representation class for this DataFlavor is + * @see java.nio.CharBuffer or a subclass thereof. + * + * @since 1.4 + */ + public boolean isRepresentationClassCharBuffer () + { + try + { + return CharBuffer.class.isAssignableFrom (representationClass); + } + catch (ClassNotFoundException e) + { + return false; + } + } + + /** + * Returns whether the representation class for this DataFlavor is + * @see java.io.Reader or a subclass thereof. + * + * @since 1.4 + */ + public boolean isRepresentationClassReader () + { + try + { + return Reader.class.isAssignableFrom (representationClass); + } + catch (ClassNotFoundException e) + { + return false; + } + } + } // class DataFlavor