2002-05-02 David S. Miller <davem@redhat.com>
[official-gcc.git] / libjava / javax / naming / event / NamingEvent.java
blob3151dd84024a5f4e0cb1b4db2470e034dfa6a339
1 /* Copyright (C) 2001 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7 details. */
9 package javax.naming.event;
10 import javax.naming.*;
11 import java.util.EventObject;
13 /**
14 * @author Warren Levy <warrenl@redhat.com>
15 * @date June 5, 2001
18 public class NamingEvent extends EventObject
20 public static final int OBJECT_ADDED = 0;
21 public static final int OBJECT_REMOVED = 1;
22 public static final int OBJECT_RENAMED = 2;
23 public static final int OBJECT_CHANGED = 3;
25 // Serialized fields.
26 protected Object changeInfo;
27 protected int type;
28 protected Binding oldBinding;
29 protected Binding newBinding;
31 public NamingEvent(EventContext source, int type, Binding newBd,
32 Binding oldBd, Object changeInfo)
34 super(source);
35 this.type = type;
36 this.oldBinding = oldBd;
37 this.newBinding = newBd;
38 this.changeInfo = changeInfo;
39 // FIXME: for OBJECT_ADDED, newBd must not be null;
40 // FIXME: for OBJECT_CHANGED, newBd and oldBd must not be null;
41 // FIXME: for OBJECT_RENAMED, one of newBd or oldBd may be null if newBd or
42 // FIXME: oldBd is outside of the scope for which listener has registered.
43 // FIXME: namingExceptionThrown() is called for the listener in question.
46 public int getType()
48 return type;
51 public EventContext getEventContext()
53 return (EventContext) getSource();
56 public Binding getOldBinding()
58 return oldBinding;
61 public Binding getNewBinding()
63 return newBinding;
66 public Object getChangeInfo()
68 return changeInfo;
71 public void dispatch(NamingListener listener)
73 switch (type)
75 case OBJECT_ADDED:
76 ((NamespaceChangeListener) listener).objectAdded(this);
77 break;
78 case OBJECT_REMOVED:
79 ((NamespaceChangeListener) listener).objectRemoved(this);
80 break;
81 case OBJECT_RENAMED:
82 ((NamespaceChangeListener) listener).objectRenamed(this);
83 break;
84 case OBJECT_CHANGED:
85 ((ObjectChangeListener) listener).objectChanged(this);
86 break;