当前位置: 首页>>代码示例>>Java>>正文


Java MethodDescriptor.getName方法代码示例

本文整理汇总了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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:IntrospectorTest.java

示例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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:IntrospectorTest.java

示例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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:IntrospectorTest.java

示例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;
    }

}
 
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:62,代码来源:Acl.java


注:本文中的java.beans.MethodDescriptor.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。