An EventSetDescriptor describes a group of events that a given Java
bean fires.
The given group of events are all delivered as method calls on a single
event listener interface, and an event listener object can be registered
via a call on a registration method supplied by the event source.
Constructor: |
EventSetDescriptor(EventSetDescriptor old) {
super(old);
if (old.listenerMethodDescriptors != null) {
int len = old.listenerMethodDescriptors.length;
listenerMethodDescriptors = new MethodDescriptor[len];
for (int i = 0; i < len; i++) {
listenerMethodDescriptors[i] = new MethodDescriptor(
old.listenerMethodDescriptors[i]);
}
}
listenerTypeRef = old.listenerTypeRef;
addMethodDescriptor = old.addMethodDescriptor;
removeMethodDescriptor = old.removeMethodDescriptor;
getMethodDescriptor = old.getMethodDescriptor;
unicast = old.unicast;
inDefaultEventSet = old.inDefaultEventSet;
}
|
EventSetDescriptor(EventSetDescriptor x,
EventSetDescriptor y) {
super(x,y);
listenerMethodDescriptors = x.listenerMethodDescriptors;
if (y.listenerMethodDescriptors != null) {
listenerMethodDescriptors = y.listenerMethodDescriptors;
}
listenerTypeRef = x.listenerTypeRef;
if (y.listenerTypeRef != null) {
listenerTypeRef = y.listenerTypeRef;
}
addMethodDescriptor = x.addMethodDescriptor;
if (y.addMethodDescriptor != null) {
addMethodDescriptor = y.addMethodDescriptor;
}
removeMethodDescriptor = x.removeMethodDescriptor;
if (y.removeMethodDescriptor != null) {
removeMethodDescriptor = y.removeMethodDescriptor;
}
getMethodDescriptor = x.getMethodDescriptor;
if (y.getMethodDescriptor != null) {
getMethodDescriptor = y.getMethodDescriptor;
}
unicast = y.unicast;
if (!x.inDefaultEventSet || !y.inDefaultEventSet) {
inDefaultEventSet = false;
}
}
|
public EventSetDescriptor(Class<?> sourceClass,
String eventSetName,
Class<?> listenerType,
String listenerMethodName) throws IntrospectionException {
this(sourceClass, eventSetName, listenerType,
new String[] { listenerMethodName },
Introspector.ADD_PREFIX + getListenerClassName(listenerType),
Introspector.REMOVE_PREFIX + getListenerClassName(listenerType),
Introspector.GET_PREFIX + getListenerClassName(listenerType) + "s");
String eventName = NameGenerator.capitalize(eventSetName) + "Event";
Method[] listenerMethods = getListenerMethods();
if (listenerMethods.length > 0) {
Class[] args = getParameterTypes(getClass0(), listenerMethods[0]);
// Check for EventSet compliance. Special case for vetoableChange. See 4529996
if (!"vetoableChange".equals(eventSetName) && !args[0].getName().endsWith(eventName)) {
throw new IntrospectionException("Method \"" + listenerMethodName +
"\" should have argument \"" +
eventName + "\"");
}
}
}
Creates an EventSetDescriptor assuming that you are
following the most simple standard design pattern where a named
event "fred" is (1) delivered as a call on the single method of
interface FredListener, (2) has a single argument of type FredEvent,
and (3) where the FredListener may be registered with a call on an
addFredListener method of the source component and removed with a
call on a removeFredListener method. Parameters:
sourceClass - The class firing the event.
eventSetName - The programmatic name of the event. E.g. "fred".
Note that this should normally start with a lower-case character.
listenerType - The target interface that events
will get delivered to.
listenerMethodName - The method that will get called when the event gets
delivered to its target listener interface.
Throws:
IntrospectionException - if an exception occurs during
introspection.
- exception:
IntrospectionException - if an exception occurs during
introspection.
|
public EventSetDescriptor(String eventSetName,
Class<?> listenerType,
Method[] listenerMethods,
Method addListenerMethod,
Method removeListenerMethod) throws IntrospectionException {
this(eventSetName, listenerType, listenerMethods,
addListenerMethod, removeListenerMethod, null);
}
Creates an EventSetDescriptor from scratch using
java.lang.reflect.Method and java.lang.Class objects. Parameters:
eventSetName - The programmatic name of the event set.
listenerType - The Class for the listener interface.
listenerMethods - An array of Method objects describing each
of the event handling methods in the target listener.
addListenerMethod - The method on the event source
that can be used to register an event listener object.
removeListenerMethod - The method on the event source
that can be used to de-register an event listener object.
Throws:
IntrospectionException - if an exception occurs during
introspection.
- exception:
IntrospectionException - if an exception occurs during
introspection.
|
public EventSetDescriptor(String eventSetName,
Class<?> listenerType,
MethodDescriptor[] listenerMethodDescriptors,
Method addListenerMethod,
Method removeListenerMethod) throws IntrospectionException {
setName(eventSetName);
this.listenerMethodDescriptors = listenerMethodDescriptors;
setAddListenerMethod(addListenerMethod);
setRemoveListenerMethod(removeListenerMethod);
setListenerType(listenerType);
}
Creates an EventSetDescriptor from scratch using
java.lang.reflect.MethodDescriptor and java.lang.Class
objects. Parameters:
eventSetName - The programmatic name of the event set.
listenerType - The Class for the listener interface.
listenerMethodDescriptors - An array of MethodDescriptor objects
describing each of the event handling methods in the
target listener.
addListenerMethod - The method on the event source
that can be used to register an event listener object.
removeListenerMethod - The method on the event source
that can be used to de-register an event listener object.
Throws:
IntrospectionException - if an exception occurs during
introspection.
- exception:
IntrospectionException - if an exception occurs during
introspection.
|
public EventSetDescriptor(Class<?> sourceClass,
String eventSetName,
Class<?> listenerType,
String[] listenerMethodNames,
String addListenerMethodName,
String removeListenerMethodName) throws IntrospectionException {
this(sourceClass, eventSetName, listenerType,
listenerMethodNames, addListenerMethodName,
removeListenerMethodName, null);
}
Creates an EventSetDescriptor from scratch using
string names. Parameters:
sourceClass - The class firing the event.
eventSetName - The programmatic name of the event set.
Note that this should normally start with a lower-case character.
listenerType - The Class of the target interface that events
will get delivered to.
listenerMethodNames - The names of the methods that will get called
when the event gets delivered to its target listener interface.
addListenerMethodName - The name of the method on the event source
that can be used to register an event listener object.
removeListenerMethodName - The name of the method on the event source
that can be used to de-register an event listener object.
Throws:
IntrospectionException - if an exception occurs during
introspection.
- exception:
IntrospectionException - if an exception occurs during
introspection.
|
public EventSetDescriptor(String eventSetName,
Class<?> listenerType,
Method[] listenerMethods,
Method addListenerMethod,
Method removeListenerMethod,
Method getListenerMethod) throws IntrospectionException {
setName(eventSetName);
setListenerMethods(listenerMethods);
setAddListenerMethod(addListenerMethod);
setRemoveListenerMethod( removeListenerMethod);
setGetListenerMethod(getListenerMethod);
setListenerType(listenerType);
}
This constructor creates an EventSetDescriptor from scratch using
java.lang.reflect.Method and java.lang.Class objects. Parameters:
eventSetName - The programmatic name of the event set.
listenerType - The Class for the listener interface.
listenerMethods - An array of Method objects describing each
of the event handling methods in the target listener.
addListenerMethod - The method on the event source
that can be used to register an event listener object.
removeListenerMethod - The method on the event source
that can be used to de-register an event listener object.
getListenerMethod - The method on the event source
that can be used to access the array of event listener objects.
Throws:
IntrospectionException - if an exception occurs during
introspection.
- exception:
IntrospectionException - if an exception occurs during
introspection.
- since:
1.4 -
|
public EventSetDescriptor(Class<?> sourceClass,
String eventSetName,
Class<?> listenerType,
String[] listenerMethodNames,
String addListenerMethodName,
String removeListenerMethodName,
String getListenerMethodName) throws IntrospectionException {
if (sourceClass == null || eventSetName == null || listenerType == null) {
throw new NullPointerException();
}
setName(eventSetName);
setClass0(sourceClass);
setListenerType(listenerType);
Method[] listenerMethods = new Method[listenerMethodNames.length];
for (int i = 0; i < listenerMethodNames.length; i++) {
// Check for null names
if (listenerMethodNames[i] == null) {
throw new NullPointerException();
}
listenerMethods[i] = getMethod(listenerType, listenerMethodNames[i], 1);
}
setListenerMethods(listenerMethods);
setAddListenerMethod(getMethod(sourceClass, addListenerMethodName, 1));
setRemoveListenerMethod(getMethod(sourceClass, removeListenerMethodName, 1));
// Be more forgiving of not finding the getListener method.
Method method = Introspector.findMethod(sourceClass, getListenerMethodName, 0);
if (method != null) {
setGetListenerMethod(method);
}
}
This constructor creates an EventSetDescriptor from scratch using
string names. Parameters:
sourceClass - The class firing the event.
eventSetName - The programmatic name of the event set.
Note that this should normally start with a lower-case character.
listenerType - The Class of the target interface that events
will get delivered to.
listenerMethodNames - The names of the methods that will get called
when the event gets delivered to its target listener interface.
addListenerMethodName - The name of the method on the event source
that can be used to register an event listener object.
removeListenerMethodName - The name of the method on the event source
that can be used to de-register an event listener object.
getListenerMethodName - The method on the event source that
can be used to access the array of event listener objects.
Throws:
IntrospectionException - if an exception occurs during
introspection.
- exception:
IntrospectionException - if an exception occurs during
introspection.
- since:
1.4 -
|
Method from java.beans.EventSetDescriptor Detail: |
void appendTo(StringBuilder sb) {
appendTo(sb, "unicast", this.unicast);
appendTo(sb, "inDefaultEventSet", this.inDefaultEventSet);
appendTo(sb, "listenerType", this.listenerTypeRef);
appendTo(sb, "getListenerMethod", getMethod(this.getMethodDescriptor));
appendTo(sb, "addListenerMethod", getMethod(this.addMethodDescriptor));
appendTo(sb, "removeListenerMethod", getMethod(this.removeMethodDescriptor));
}
|
public synchronized Method getAddListenerMethod() {
return getMethod(this.addMethodDescriptor);
}
Gets the method used to add event listeners. |
public synchronized Method getGetListenerMethod() {
return getMethod(this.getMethodDescriptor);
}
Gets the method used to access the registered event listeners. |
public synchronized MethodDescriptor[] getListenerMethodDescriptors() {
return listenerMethodDescriptors;
}
Gets the MethodDescriptor s of the target listener interface. |
public synchronized Method[] getListenerMethods() {
Method[] methods = getListenerMethods0();
if (methods == null) {
if (listenerMethodDescriptors != null) {
methods = new Method[listenerMethodDescriptors.length];
for (int i = 0; i < methods.length; i++) {
methods[i] = listenerMethodDescriptors[i].getMethod();
}
}
setListenerMethods(methods);
}
return methods;
}
Gets the methods of the target listener interface. |
public Class<?> getListenerType() {
return (this.listenerTypeRef != null)
? this.listenerTypeRef.get()
: null;
}
Gets the Class object for the target interface. |
public synchronized Method getRemoveListenerMethod() {
return getMethod(this.removeMethodDescriptor);
}
Gets the method used to remove event listeners. |
public boolean isInDefaultEventSet() {
return inDefaultEventSet;
}
Reports if an event set is in the "default" set. |
public boolean isUnicast() {
return unicast;
}
Normally event sources are multicast. However there are some
exceptions that are strictly unicast. |
public void setInDefaultEventSet(boolean inDefaultEventSet) {
this.inDefaultEventSet = inDefaultEventSet;
}
Marks an event set as being in the "default" set (or not).
By default this is true. |
public void setUnicast(boolean unicast) {
this.unicast = unicast;
}
Mark an event set as unicast (or not). |