當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。