private String _makeQualifiedMethodName(
MethodDescriptor descriptor
)
{
Method m = descriptor.getMethod();
StringBuffer sb = new StringBuffer();
sb.append(m.getName());
sb.append("=");
Class params[] = m.getParameterTypes();
for (int i = 0; i < params.length; i++)
{
sb.append(":");
sb.append(params[i].getName());
}
return sb.toString();
}
java类java.beans.MethodDescriptor的实例源码
JavaIntrospector.java 文件源码
项目:myfaces-trinidad
阅读 23
收藏 0
点赞 0
评论 0
JavaIntrospector.java 文件源码
项目:myfaces-trinidad
阅读 21
收藏 0
点赞 0
评论 0
private static MethodDescriptor _createMergedMethodDescriptor(
MethodDescriptor secondaryDescriptor,
MethodDescriptor primaryDescriptor
)
{
ParameterDescriptor[] parameterDescriptors =
primaryDescriptor.getParameterDescriptors();
if (parameterDescriptors == null)
{
parameterDescriptors = secondaryDescriptor.getParameterDescriptors();
}
MethodDescriptor mergedDescriptor = new MethodDescriptor(
primaryDescriptor.getMethod(),
parameterDescriptors);
// merge the superclasses
_mergeFeatureDescriptors(secondaryDescriptor,
primaryDescriptor,
mergedDescriptor);
return mergedDescriptor;
}
JavaIntrospector.java 文件源码
项目:myfaces-trinidad
阅读 20
收藏 0
点赞 0
评论 0
static EventSetDescriptor __createMergedEventSetStub(
EventSetDescriptor oldDescriptor,
MethodDescriptor[] listenerDescriptors
)
{
try
{
EventSetDescriptor stubDescriptor = new EventSetDescriptor(
oldDescriptor.getName(),
oldDescriptor.getListenerType(),
listenerDescriptors,
oldDescriptor.getAddListenerMethod(),
oldDescriptor.getRemoveListenerMethod());
// set the unicast attribute
stubDescriptor.setUnicast(oldDescriptor.isUnicast());
return stubDescriptor;
}
catch (Exception e)
{
// _LOG.severe(e);
return null;
}
}
JavaIntrospector.java 文件源码
项目:myfaces-trinidad
阅读 44
收藏 0
点赞 0
评论 0
private static MethodDescriptor _cloneMethodDescriptor(
MethodDescriptor oldDescriptor
)
{
try
{
MethodDescriptor newDescriptor = new MethodDescriptor(
oldDescriptor.getMethod(),
oldDescriptor.getParameterDescriptors());
// copy the rest of the attributes
_copyFeatureDescriptor(oldDescriptor, newDescriptor);
return newDescriptor;
}
catch (Exception e)
{
_LOG.severe(e);
return null;
}
}
ExtendedBeanInfo.java 文件源码
项目:lams
阅读 19
收藏 0
点赞 0
评论 0
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
List<Method> matches = new ArrayList<Method>();
for (MethodDescriptor methodDescriptor : methodDescriptors) {
Method method = methodDescriptor.getMethod();
if (isCandidateWriteMethod(method)) {
matches.add(method);
}
}
// sort non-void returning write methods to guard against the ill effects of
// non-deterministic sorting of methods returned from Class#getDeclaredMethods
// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
Collections.sort(matches, new Comparator<Method>() {
@Override
public int compare(Method m1, Method m2) {
return m2.toString().compareTo(m1.toString());
}
});
return matches;
}
QuartzSchedulerMBeanImpl.java 文件源码
项目:lams
阅读 22
收藏 0
点赞 0
评论 0
private static Method findMethod(Class<?> targetType, String methodName,
Class<?>[] argTypes) throws IntrospectionException {
BeanInfo beanInfo = Introspector.getBeanInfo(targetType);
if (beanInfo != null) {
for(MethodDescriptor methodDesc: beanInfo.getMethodDescriptors()) {
Method method = methodDesc.getMethod();
Class<?>[] parameterTypes = method.getParameterTypes();
if (methodName.equals(method.getName()) && argTypes.length == parameterTypes.length) {
boolean matchedArgTypes = true;
for (int i = 0; i < argTypes.length; i++) {
if (getWrapperIfPrimitive(argTypes[i]) != parameterTypes[i]) {
matchedArgTypes = false;
break;
}
}
if (matchedArgTypes) {
return method;
}
}
}
}
return null;
}
ExtendedBeanInfo.java 文件源码
项目:spring4-understanding
阅读 17
收藏 0
点赞 0
评论 0
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
List<Method> matches = new ArrayList<Method>();
for (MethodDescriptor methodDescriptor : methodDescriptors) {
Method method = methodDescriptor.getMethod();
if (isCandidateWriteMethod(method)) {
matches.add(method);
}
}
// Sort non-void returning write methods to guard against the ill effects of
// non-deterministic sorting of methods returned from Class#getDeclaredMethods
// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
Collections.sort(matches, new Comparator<Method>() {
@Override
public int compare(Method m1, Method m2) {
return m2.toString().compareTo(m1.toString());
}
});
return matches;
}
ExtendedBeanInfo.java 文件源码
项目:spring
阅读 23
收藏 0
点赞 0
评论 0
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
List<Method> matches = new ArrayList<Method>();
for (MethodDescriptor methodDescriptor : methodDescriptors) {
Method method = methodDescriptor.getMethod();
if (isCandidateWriteMethod(method)) {
matches.add(method);
}
}
// Sort non-void returning write methods to guard against the ill effects of
// non-deterministic sorting of methods returned from Class#getDeclaredMethods
// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
Collections.sort(matches, new Comparator<Method>() {
@Override
public int compare(Method m1, Method m2) {
return m2.toString().compareTo(m1.toString());
}
});
return matches;
}
ExplicitBeanInfo.java 文件源码
项目:javify
阅读 21
收藏 0
点赞 0
评论 0
public ExplicitBeanInfo(BeanDescriptor beanDescriptor,
BeanInfo[] additionalBeanInfo,
PropertyDescriptor[] propertyDescriptors,
int defaultPropertyIndex,
EventSetDescriptor[] eventSetDescriptors,
int defaultEventIndex,
MethodDescriptor[] methodDescriptors,
Image[] icons) {
this.beanDescriptor = beanDescriptor;
this.additionalBeanInfo = additionalBeanInfo;
this.propertyDescriptors = propertyDescriptors;
this.defaultPropertyIndex = defaultPropertyIndex;
this.eventSetDescriptors = eventSetDescriptors;
this.defaultEventIndex = defaultEventIndex;
this.methodDescriptors = methodDescriptors;
this.icons = icons;
}
IntrospectionIncubator.java 文件源码
项目:javify
阅读 22
收藏 0
点赞 0
评论 0
public BeanInfoEmbryo getBeanInfoEmbryo() throws IntrospectionException {
BeanInfoEmbryo b = new BeanInfoEmbryo();
findXXX(b,IS);
findXXXInt(b,GET_I);
findXXXInt(b,SET_I);
findXXX(b,GET);
findXXX(b,SET);
findAddRemovePairs(b);
for(int i=0;i<otherMethods.size();i++) {
MethodDescriptor newMethod = new MethodDescriptor((Method)otherMethods.elementAt(i));
if(!b.hasMethod(newMethod)) {
b.addMethod(new MethodDescriptor((Method)otherMethods.elementAt(i)));
}
}
return b;
}
ClusterEvaluation.java 文件源码
项目:repo.kmeanspp.silhouette_score
阅读 17
收藏 0
点赞 0
评论 0
/**
* Return the global info (if it exists) for the supplied clusterer
*
* @param clusterer the clusterer to get the global info for
* @return the global info (synopsis) for the clusterer
* @throws Exception if there is a problem reflecting on the clusterer
*/
protected static String getGlobalInfo(Clusterer clusterer) throws Exception {
BeanInfo bi = Introspector.getBeanInfo(clusterer.getClass());
MethodDescriptor[] methods;
methods = bi.getMethodDescriptors();
Object[] args = {};
String result =
"\nSynopsis for " + clusterer.getClass().getName() + ":\n\n";
for (MethodDescriptor method : methods) {
String name = method.getDisplayName();
Method meth = method.getMethod();
if (name.equals("globalInfo")) {
String globalInfo = (String) (meth.invoke(clusterer, args));
result += globalInfo;
break;
}
}
return result;
}
Evaluation.java 文件源码
项目:repo.kmeanspp.silhouette_score
阅读 22
收藏 0
点赞 0
评论 0
/**
* Return the global info (if it exists) for the supplied classifier.
*
* @param classifier the classifier to get the global info for
* @return the global info (synopsis) for the classifier
* @throws Exception if there is a problem reflecting on the classifier
*/
protected static String getGlobalInfo(Classifier classifier) throws Exception {
BeanInfo bi = Introspector.getBeanInfo(classifier.getClass());
MethodDescriptor[] methods;
methods = bi.getMethodDescriptors();
Object[] args = {};
String result =
"\nSynopsis for " + classifier.getClass().getName() + ":\n\n";
for (MethodDescriptor method : methods) {
String name = method.getDisplayName();
Method meth = method.getMethod();
if (name.equals("globalInfo")) {
String globalInfo = (String) (meth.invoke(classifier, args));
result += globalInfo;
break;
}
}
return result;
}
ExplicitBeanInfo.java 文件源码
项目:jvm-stm
阅读 19
收藏 0
点赞 0
评论 0
public ExplicitBeanInfo(BeanDescriptor beanDescriptor,
BeanInfo[] additionalBeanInfo,
PropertyDescriptor[] propertyDescriptors,
int defaultPropertyIndex,
EventSetDescriptor[] eventSetDescriptors,
int defaultEventIndex,
MethodDescriptor[] methodDescriptors,
Image[] icons) {
this.beanDescriptor = beanDescriptor;
this.additionalBeanInfo = additionalBeanInfo;
this.propertyDescriptors = propertyDescriptors;
this.defaultPropertyIndex = defaultPropertyIndex;
this.eventSetDescriptors = eventSetDescriptors;
this.defaultEventIndex = defaultEventIndex;
this.methodDescriptors = methodDescriptors;
this.icons = icons;
}
IntrospectionIncubator.java 文件源码
项目:jvm-stm
阅读 21
收藏 0
点赞 0
评论 0
public BeanInfoEmbryo getBeanInfoEmbryo() throws IntrospectionException {
BeanInfoEmbryo b = new BeanInfoEmbryo();
findXXX(b,IS);
findXXXInt(b,GET_I);
findXXXInt(b,SET_I);
findXXX(b,GET);
findXXX(b,SET);
findAddRemovePairs(b);
for(int i=0;i<otherMethods.size();i++) {
MethodDescriptor newMethod = new MethodDescriptor((Method)otherMethods.elementAt(i));
if(!b.hasMethod(newMethod)) {
b.addMethod(new MethodDescriptor((Method)otherMethods.elementAt(i)));
}
}
return b;
}
ClusterEvaluation.java 文件源码
项目:autoweka
阅读 21
收藏 0
点赞 0
评论 0
/**
* Return the global info (if it exists) for the supplied clusterer
*
* @param clusterer the clusterer to get the global info for
* @return the global info (synopsis) for the clusterer
* @throws Exception if there is a problem reflecting on the clusterer
*/
protected static String getGlobalInfo(Clusterer clusterer) throws Exception {
BeanInfo bi = Introspector.getBeanInfo(clusterer.getClass());
MethodDescriptor[] methods;
methods = bi.getMethodDescriptors();
Object[] args = {};
String result = "\nSynopsis for " + clusterer.getClass().getName()
+ ":\n\n";
for (int i = 0; i < methods.length; i++) {
String name = methods[i].getDisplayName();
Method meth = methods[i].getMethod();
if (name.equals("globalInfo")) {
String globalInfo = (String)(meth.invoke(clusterer, args));
result += globalInfo;
break;
}
}
return result;
}
Evaluation.java 文件源码
项目:autoweka
阅读 20
收藏 0
点赞 0
评论 0
/**
* Return the global info (if it exists) for the supplied classifier.
*
* @param classifier the classifier to get the global info for
* @return the global info (synopsis) for the classifier
* @throws Exception if there is a problem reflecting on the classifier
*/
protected static String getGlobalInfo(Classifier classifier) throws Exception {
BeanInfo bi = Introspector.getBeanInfo(classifier.getClass());
MethodDescriptor[] methods;
methods = bi.getMethodDescriptors();
Object[] args = {};
String result = "\nSynopsis for " + classifier.getClass().getName()
+ ":\n\n";
for (int i = 0; i < methods.length; i++) {
String name = methods[i].getDisplayName();
Method meth = methods[i].getMethod();
if (name.equals("globalInfo")) {
String globalInfo = (String) (meth.invoke(classifier, args));
result += globalInfo;
break;
}
}
return result;
}
ClusterEvaluation.java 文件源码
项目:umple
阅读 22
收藏 0
点赞 0
评论 0
/**
* Return the global info (if it exists) for the supplied clusterer
*
* @param clusterer the clusterer to get the global info for
* @return the global info (synopsis) for the clusterer
* @throws Exception if there is a problem reflecting on the clusterer
*/
protected static String getGlobalInfo(Clusterer clusterer) throws Exception {
BeanInfo bi = Introspector.getBeanInfo(clusterer.getClass());
MethodDescriptor[] methods;
methods = bi.getMethodDescriptors();
Object[] args = {};
String result = "\nSynopsis for " + clusterer.getClass().getName()
+ ":\n\n";
for (MethodDescriptor method : methods) {
String name = method.getDisplayName();
Method meth = method.getMethod();
if (name.equals("globalInfo")) {
String globalInfo = (String) (meth.invoke(clusterer, args));
result += globalInfo;
break;
}
}
return result;
}
Evaluation.java 文件源码
项目:umple
阅读 19
收藏 0
点赞 0
评论 0
/**
* Return the global info (if it exists) for the supplied classifier.
*
* @param classifier the classifier to get the global info for
* @return the global info (synopsis) for the classifier
* @throws Exception if there is a problem reflecting on the classifier
*/
protected static String getGlobalInfo(Classifier classifier) throws Exception {
BeanInfo bi = Introspector.getBeanInfo(classifier.getClass());
MethodDescriptor[] methods;
methods = bi.getMethodDescriptors();
Object[] args = {};
String result = "\nSynopsis for " + classifier.getClass().getName()
+ ":\n\n";
for (MethodDescriptor method : methods) {
String name = method.getDisplayName();
Method meth = method.getMethod();
if (name.equals("globalInfo")) {
String globalInfo = (String) (meth.invoke(classifier, args));
result += globalInfo;
break;
}
}
return result;
}
ExtendedBeanInfo.java 文件源码
项目:class-guard
阅读 30
收藏 0
点赞 0
评论 0
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
List<Method> matches = new ArrayList<Method>();
for (MethodDescriptor methodDescriptor : methodDescriptors) {
Method method = methodDescriptor.getMethod();
if (isCandidateWriteMethod(method)) {
matches.add(method);
}
}
// sort non-void returning write methods to guard against the ill effects of
// non-deterministic sorting of methods returned from Class#getDeclaredMethods
// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
Collections.sort(matches, new Comparator<Method>() {
public int compare(Method m1, Method m2) {
return m2.toString().compareTo(m1.toString());
}
});
return matches;
}
MethodDescriptorTest.java 文件源码
项目:cn1
阅读 22
收藏 0
点赞 0
评论 0
public void testMethodDescriptorMethod() throws SecurityException,
NoSuchMethodException {
String beanName = "MethodDescriptorTest.bean";
MockJavaBean bean = new MockJavaBean(beanName);
Method method = bean.getClass()
.getMethod("getBeanName", (Class[]) null);
MethodDescriptor md = new MethodDescriptor(method);
assertSame(method, md.getMethod());
assertNull(md.getParameterDescriptors());
assertEquals(method.getName(), md.getDisplayName());
assertEquals(method.getName(), md.getName());
assertEquals(method.getName(), md.getShortDescription());
assertNotNull(md.attributeNames());
assertFalse(md.isExpert());
assertFalse(md.isHidden());
assertFalse(md.isPreferred());
}
MethodDescriptorTest.java 文件源码
项目:cn1
阅读 26
收藏 0
点赞 0
评论 0
public void testMethodDescriptorMethodParameterDescriptorArray()
throws SecurityException, NoSuchMethodException {
String beanName = "MethodDescriptorTest.bean";
MockJavaBean bean = new MockJavaBean(beanName);
Method method = bean.getClass().getMethod("setPropertyOne",
new Class[] { String.class });
ParameterDescriptor[] pds = new ParameterDescriptor[1];
pds[0] = new ParameterDescriptor();
pds[0].setValue(method.getName(), method.getReturnType());
MethodDescriptor md = new MethodDescriptor(method, pds);
assertSame(method, md.getMethod());
assertSame(pds, md.getParameterDescriptors());
assertEquals(pds[0].getValue(method.getName()), md
.getParameterDescriptors()[0].getValue(method.getName()));
assertEquals(method.getName(), md.getDisplayName());
assertEquals(method.getName(), md.getName());
assertEquals(method.getName(), md.getShortDescription());
assertNotNull(md.attributeNames());
assertFalse(md.isExpert());
assertFalse(md.isHidden());
assertFalse(md.isPreferred());
}
MethodDescriptorTest.java 文件源码
项目:cn1
阅读 34
收藏 0
点赞 0
评论 0
public void testMethodDescriptorMethodParameterDescriptorArray_PDNull()
throws SecurityException, NoSuchMethodException {
String beanName = "MethodDescriptorTest.bean";
MockJavaBean bean = new MockJavaBean(beanName);
Method method = bean.getClass().getMethod("setPropertyOne",
new Class[] { String.class });
MethodDescriptor md = new MethodDescriptor(method, null);
assertSame(method, md.getMethod());
assertNull(md.getParameterDescriptors());
assertEquals(method.getName(), md.getDisplayName());
assertEquals(method.getName(), md.getName());
assertEquals(method.getName(), md.getShortDescription());
assertNotNull(md.attributeNames());
assertFalse(md.isExpert());
assertFalse(md.isHidden());
assertFalse(md.isPreferred());
}
EmployeeBeanInfo.java 文件源码
项目:protobuf-el
阅读 20
收藏 0
点赞 0
评论 0
private static MethodDescriptor[] getMdescriptor() {
final MethodDescriptor[] methods = new MethodDescriptor[4];
try {
methods[METHOD_equals0] =
new MethodDescriptor(com.github.protobufel.el.Employee.class.getMethod("equals",
new Class[] {java.lang.Object.class})); // NOI18N
methods[METHOD_equals0].setDisplayName("");
methods[METHOD_hashCode1] =
new MethodDescriptor(com.github.protobufel.el.Employee.class.getMethod("hashCode",
new Class[] {})); // NOI18N
methods[METHOD_hashCode1].setDisplayName("");
methods[METHOD_overloaded12] =
new MethodDescriptor(com.github.protobufel.el.Employee.class.getMethod("overloaded1",
new Class[] {java.lang.String.class, int.class})); // NOI18N
methods[METHOD_overloaded12].setDisplayName("");
methods[METHOD_toString3] =
new MethodDescriptor(com.github.protobufel.el.Employee.class.getMethod("toString",
new Class[] {})); // NOI18N
methods[METHOD_toString3].setDisplayName("");
} catch (final Exception e) {
}// GEN-HEADEREND:Methods
// Here you can add code for customizing the methods array.
return methods;
}
IntrospectorTest.java 文件源码
项目:cn1
阅读 15
收藏 0
点赞 0
评论 0
public void testGetBeanInfo_StaticMethods() throws Exception {
BeanInfo beanInfo = Introspector.getBeanInfo(StaticClazz.class);
PropertyDescriptor[] propertyDescriptors = beanInfo
.getPropertyDescriptors();
assertEquals(1, propertyDescriptors.length);
assertTrue(contains("class", Class.class, propertyDescriptors));
MethodDescriptor[] methodDescriptors = beanInfo.getMethodDescriptors();
assertTrue(contains("getStaticMethod", methodDescriptors));
assertTrue(contains("setStaticMethod", methodDescriptors));
beanInfo = Introspector.getBeanInfo(StaticClazzWithProperty.class);
propertyDescriptors = beanInfo.getPropertyDescriptors();
assertEquals(1, propertyDescriptors.length);
methodDescriptors = beanInfo.getMethodDescriptors();
assertTrue(contains("getStaticName", methodDescriptors));
assertTrue(contains("setStaticName", methodDescriptors));
}
IntrospectorTest.java 文件源码
项目:cn1
阅读 16
收藏 0
点赞 0
评论 0
public void testGetBeanInfoClassint_IGNORE_ALL_Method()
throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
Introspector.IGNORE_ALL_BEANINFO);
MethodDescriptor[] mds = info.getMethodDescriptors();
int getMethod = 0;
int setMethod = 0;
for (MethodDescriptor element : mds) {
String name = element.getName();
if (name.startsWith("getText")) {
getMethod++;
assertEquals("getText", name);
}
if (name.startsWith("setText")) {
setMethod++;
assertEquals("setText", name);
}
}
assertEquals(1, getMethod);
assertEquals(1, setMethod);
}
IntrospectorTest.java 文件源码
项目:cn1
阅读 15
收藏 0
点赞 0
评论 0
public void testBeanInfo_1() throws IntrospectionException {
Class<FakeFox011> beanClass = FakeFox011.class;
BeanInfo info = Introspector.getBeanInfo(beanClass);
assertNull(info.getAdditionalBeanInfo());
BeanDescriptor beanDesc = info.getBeanDescriptor();
assertEquals("FakeFox011", beanDesc.getName());
assertEquals(0, info.getEventSetDescriptors().length);
assertEquals(-1, info.getDefaultEventIndex());
assertEquals(0, info.getDefaultPropertyIndex());
MethodDescriptor[] methodDesc = info.getMethodDescriptors();
assertEquals(4, methodDesc.length);
PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
assertEquals(2, propertyDesc.length);
for (PropertyDescriptor element : propertyDesc) {
if (element.getName().equals("class")) {
assertNull(element.getWriteMethod());
assertNotNull(element.getReadMethod());
}
}
}
IntrospectorTest.java 文件源码
项目:cn1
阅读 17
收藏 0
点赞 0
评论 0
public void testExplicitBeanInfo() throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(MockFoo23.class);
assertNull(info.getAdditionalBeanInfo());
BeanDescriptor beanDesc = info.getBeanDescriptor();
assertEquals("IntrospectorTest$MockFoo23", beanDesc.getName());
assertEquals(0, info.getEventSetDescriptors().length);
assertEquals(-1, info.getDefaultEventIndex());
assertEquals(-1, info.getDefaultPropertyIndex());
MethodDescriptor[] methodDesc = info.getMethodDescriptors();
assertEquals(10, methodDesc.length);
PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
assertEquals(1, propertyDesc.length);
assertEquals("name.beanInfo", propertyDesc[0].getDisplayName());
assertNotNull(propertyDesc[0].getReadMethod());
assertNull(propertyDesc[0].getWriteMethod());
}
EventSetDescriptorTest.java 文件源码
项目:cn1
阅读 41
收藏 0
点赞 0
评论 0
public void testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDNull()
throws IntrospectionException, NoSuchMethodException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Method addMethod = sourceClass.getMethod(
"addMockPropertyChangeListener", listenerType);
Method removeMethod = sourceClass.getMethod(
"removeMockPropertyChangeListener", listenerType);
EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
listenerType, (MethodDescriptor[]) null, addMethod,
removeMethod);
assertNull(esd.getListenerMethodDescriptors());
assertNull(esd.getListenerMethods());
}
EventSetDescriptorTest.java 文件源码
项目:cn1
阅读 14
收藏 0
点赞 0
评论 0
public void testSetInDefaultEventSet() throws SecurityException,
NoSuchMethodException, IntrospectionException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Method[] listenerMethods = {
listenerType.getMethod("mockPropertyChange",
MockPropertyChangeEvent.class),
listenerType.getMethod("mockPropertyChange2",
MockPropertyChangeEvent.class) };
MethodDescriptor[] listenerMethodDescriptors = {
new MethodDescriptor(listenerMethods[0]),
new MethodDescriptor(listenerMethods[1]), };
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Method addMethod = sourceClass.getMethod(
"addMockPropertyChangeListener", listenerType);
Method removeMethod = sourceClass.getMethod(
"removeMockPropertyChangeListener", listenerType);
EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
listenerType, listenerMethodDescriptors, addMethod,
removeMethod);
esd.setInDefaultEventSet(true);
assertTrue(esd.isInDefaultEventSet());
}
EventSetDescriptorTest.java 文件源码
项目:cn1
阅读 20
收藏 0
点赞 0
评论 0
public void testSetInDefaultEventSet_false() throws SecurityException,
NoSuchMethodException, IntrospectionException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Method[] listenerMethods = {
listenerType.getMethod("mockPropertyChange",
new Class[] { MockPropertyChangeEvent.class }),
listenerType.getMethod("mockPropertyChange2",
new Class[] { MockPropertyChangeEvent.class }), };
MethodDescriptor[] listenerMethodDescriptors = {
new MethodDescriptor(listenerMethods[0]),
new MethodDescriptor(listenerMethods[1]), };
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Method addMethod = sourceClass.getMethod(
"addMockPropertyChangeListener", new Class[] { listenerType });
Method removeMethod = sourceClass.getMethod(
"removeMockPropertyChangeListener",
new Class[] { listenerType });
EventSetDescriptor esd = new EventSetDescriptor(eventSetName,
listenerType, listenerMethodDescriptors, addMethod,
removeMethod);
assertTrue(esd.isInDefaultEventSet());
esd.setInDefaultEventSet(false);
assertFalse(esd.isInDefaultEventSet());
}