本文整理汇总了Java中java.beans.MethodDescriptor.getName方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDescriptor.getName方法的具体用法?Java MethodDescriptor.getName怎么用?Java MethodDescriptor.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.MethodDescriptor
的用法示例。
在下文中一共展示了MethodDescriptor.getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetBeanInfoClassint_UseAll_Method
import java.beans.MethodDescriptor; //导入方法依赖的package包/类
public void testGetBeanInfoClassint_UseAll_Method()
throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(MockFooSubSub.class,
Introspector.USE_ALL_BEANINFO);
MethodDescriptor[] mds = info.getMethodDescriptors();
int parentMethodGet = 0;
int parentMethodSet = 0;
for (MethodDescriptor element : mds) {
String name = element.getName();
if (name.startsWith("getText")) {
parentMethodGet++;
assertEquals("getText.MockFooSubBeanInfo", name);
}
if (name.startsWith("setText")) {
parentMethodSet++;
assertEquals("setText.MockFooSubBeanInfo", name);
}
}
assertEquals(1, parentMethodGet);
assertEquals(1, parentMethodSet);
}
示例2: testGetBeanInfoClassint_IGNORE_IMMEDIATE_Method
import java.beans.MethodDescriptor; //导入方法依赖的package包/类
public void testGetBeanInfoClassint_IGNORE_IMMEDIATE_Method()
throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
Introspector.IGNORE_IMMEDIATE_BEANINFO);
MethodDescriptor[] mds = info.getMethodDescriptors();
int parentMethodGet = 0;
int parentMethodSet = 0;
for (MethodDescriptor element : mds) {
String name = element.getName();
if (name.startsWith("getChildName")) {
parentMethodGet++;
assertEquals("getChildName.MockFooChildBeanInfo", name);
}
if (name.startsWith("setChildName")) {
parentMethodSet++;
assertEquals("setChildName.MockFooChildBeanInfo", name);
}
}
assertEquals(1, parentMethodGet);
assertEquals(1, parentMethodSet);
}
示例3: testGetBeanInfoClassint_IGNORE_ALL_Method
import java.beans.MethodDescriptor; //导入方法依赖的package包/类
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);
}
示例4: registerHandler
import java.beans.MethodDescriptor; //导入方法依赖的package包/类
/** Register an AclHandler.
* All methods with the valid signature will be registered.
* <pre>
* public boolean aclXXX(Object, String[])
* </pre>
* or
* <pre>
* public static boolean aclXXX(Object, String[])
* </pre>
* Methods without the "acl" prefix are ignored. If a method begins
* with the "acl" prefix but the method signature is invalid, a
* warning is logged and the method is ignored.
*
* @param aclHandler AclHandler
*/
public void registerHandler(AclHandler aclHandler) {
try {
Class clazz = aclHandler.getClass();
// find all the acl* methods. and store them
BeanInfo info = Introspector.getBeanInfo(clazz);
MethodDescriptor[] methodDescriptors = info.getMethodDescriptors();
for (int i = 0; i < methodDescriptors.length; ++i) {
MethodDescriptor methodDescriptor = methodDescriptors[i];
String methodName = methodDescriptor.getName();
// we only care about methods with signatures:
// public boolean aclXXX(Object obj, String[] params);
if (!methodName.startsWith(ACL_PREFIX)) {
continue;
}
Method method = methodDescriptor.getMethod();
Class[] params = method.getParameterTypes();
if (!method.getReturnType().equals(Boolean.TYPE) ||
method.getExceptionTypes().length > 0 ||
params.length != 2 ||
!params[0].equals(Object.class) ||
!params[1].equals(String[].class)) {
log.warn(LocalizationService.getInstance().getMessage(
"bad-signature", method.toString()));
continue;
}
String aclName = methodNameToAclName(methodName);
handlers.put(aclName,
new InstanceMethodPair(aclHandler, method));
}
}
// from reading the javadocs for IntrospectionException,
// dont' really expect to get this one
catch (IntrospectionException e) {
IllegalArgumentException exc = new IllegalArgumentException();
exc.initCause(e);
throw exc;
}
}