X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libjava%2Fclasspath%2Fjavax%2Fswing%2Fevent%2FEventListenerList.java;h=1568039f0ff479c02426cc15490b1e53248c12de;hb=65bf3316cf384588453604be6b4f0ed3751a8b0f;hp=bde8b3c7e4fd9ec73620da9852bcd36850d77ad2;hpb=8fc56618a84446beccd45b80381cdfe0e94050df;p=pf3gnuchains%2Fgcc-fork.git
diff --git a/libjava/classpath/javax/swing/event/EventListenerList.java b/libjava/classpath/javax/swing/event/EventListenerList.java
index bde8b3c7e4f..1568039f0ff 100644
--- a/libjava/classpath/javax/swing/event/EventListenerList.java
+++ b/libjava/classpath/javax/swing/event/EventListenerList.java
@@ -37,6 +37,9 @@ exception statement from your version. */
package javax.swing.event;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.EventListener;
@@ -136,7 +139,7 @@ public class EventListenerList
*
* @throws NullPointerException if t
is null
.
*/
- public void add(Class t, EventListener listener)
+ public void add(Class t, T listener)
{
int oldLength;
Object[] newList;
@@ -175,7 +178,7 @@ public class EventListenerList
* t
. Thus, subclasses of t
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)
@@ -224,7 +227,7 @@ public class EventListenerList
*
* @since 1.3
*/
- public EventListener[] getListeners(Class c)
+ public T[] getListeners(Class c)
{
int count, f;
EventListener[] result;
@@ -236,7 +239,7 @@ public class EventListenerList
if (listenerList[i] == c)
result[f++] = (EventListener) listenerList[i + 1];
- return result;
+ return (T[]) result;
}
@@ -253,7 +256,7 @@ public class EventListenerList
*
* @throws NullPointerException if t
is null
.
*/
- public void remove(Class t, EventListener listener)
+ public void remove(Class t, T listener)
{
Object[] oldList, newList;
int oldLength;
@@ -304,4 +307,51 @@ public class EventListenerList
}
return buf.toString();
}
+
+ /**
+ * Serializes an instance to an ObjectOutputStream.
+ *
+ * @param out the stream to serialize to
+ *
+ * @throws IOException if something goes wrong
+ */
+ private void writeObject(ObjectOutputStream out)
+ throws IOException
+ {
+ out.defaultWriteObject();
+ for (int i = 0; i < listenerList.length; i += 2)
+ {
+ Class cl = (Class) listenerList[i];
+ EventListener l = (EventListener) listenerList[i + 1];
+ if (l != null && l instanceof Serializable)
+ {
+ out.writeObject(cl.getName());
+ out.writeObject(l);
+ }
+ }
+ // Write end marker.
+ out.writeObject(null);
+ }
+
+ /**
+ * Deserializes an instance from an ObjectInputStream.
+ *
+ * @param in the input stream
+ *
+ * @throws ClassNotFoundException if a serialized class can't be found
+ * @throws IOException if something goes wrong
+ */
+ private void readObject(ObjectInputStream in)
+ throws ClassNotFoundException, IOException
+ {
+ listenerList = NO_LISTENERS;
+ in.defaultReadObject();
+ Object type;
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ while ((type = in.readObject()) != null)
+ {
+ EventListener l = (EventListener) in.readObject();
+ add(((Class) Class.forName((String) type, true, cl)), (T) l);
+ }
+ }
}