Java Code Examples for java.beans.BeanInfo#getMethodDescriptors()
The following examples show how to use
java.beans.BeanInfo#getMethodDescriptors() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntrospectorTest.java From j2objc with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: IntrospectorTest.java From j2objc with Apache License 2.0 | 6 votes |
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()); } } }
Example 3
Source File: DefaultWidgetIntrospector.java From nebula with Eclipse Public License 2.0 | 6 votes |
public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException { Introspector.flushFromCaches(beanClass); BeanInfo bi = Introspector.getBeanInfo(beanClass); BeanDescriptor bd = bi.getBeanDescriptor(); MethodDescriptor mds[] = bi.getMethodDescriptors(); EventSetDescriptor esds[] = bi.getEventSetDescriptors(); PropertyDescriptor pds[] = bi.getPropertyDescriptors(); List<PropertyDescriptor> filteredPDList = new ArrayList<PropertyDescriptor>(); List<String> nonPropList = Arrays.asList(getNonProperties()); for(PropertyDescriptor pd : pds){ if(!nonPropList.contains(pd.getName()) && pd.getWriteMethod() != null && pd.getReadMethod() != null) filteredPDList.add(pd); } int defaultEvent = bi.getDefaultEventIndex(); int defaultProperty = bi.getDefaultPropertyIndex(); return new GenericBeanInfo(bd, esds, defaultEvent, filteredPDList.toArray(new PropertyDescriptor[filteredPDList.size()]), defaultProperty, mds, null); }
Example 4
Source File: Evaluation.java From tsml with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example 5
Source File: ClusterEvaluation.java From tsml with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example 6
Source File: UnloadClassBeanInfo.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(final String[] args) throws Exception { Class cl = getStub(); System.out.println("cl.getClassLoader() = " + cl.getClassLoader()); final BeanInfo beanInfo = Introspector.getBeanInfo(cl, Object.class); MethodDescriptor[] mds = beanInfo.getMethodDescriptors(); System.out.println("mds = " + Arrays.toString(mds)); loader.close(); loader=null; cl=null; Util.generateOOME(); mds = beanInfo.getMethodDescriptors(); System.out.println("mds = " + Arrays.toString(mds)); }
Example 7
Source File: UnloadClassBeanInfo.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(final String[] args) throws Exception { Class cl = getStub(); System.out.println("cl.getClassLoader() = " + cl.getClassLoader()); final BeanInfo beanInfo = Introspector.getBeanInfo(cl, Object.class); MethodDescriptor[] mds = beanInfo.getMethodDescriptors(); System.out.println("mds = " + Arrays.toString(mds)); loader.close(); loader=null; cl=null; Util.generateOOME(); mds = beanInfo.getMethodDescriptors(); System.out.println("mds = " + Arrays.toString(mds)); }
Example 8
Source File: Test6277246.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IntrospectionException { Class type = BASE64Encoder.class; System.setSecurityManager(new SecurityManager()); BeanInfo info = Introspector.getBeanInfo(type); for (MethodDescriptor md : info.getMethodDescriptors()) { Method method = md.getMethod(); System.out.println(method); String name = method.getDeclaringClass().getName(); if (name.startsWith("sun.misc.")) { throw new Error("found inaccessible method"); } } }
Example 9
Source File: ExtendedBeanInfo.java From blog_demos with Apache License 2.0 | 5 votes |
/** * Wrap the given {@link BeanInfo} instance; copy all its existing property descriptors * locally, wrapping each in a custom {@link SimpleIndexedPropertyDescriptor indexed} * or {@link SimplePropertyDescriptor non-indexed} {@code PropertyDescriptor} * variant that bypasses default JDK weak/soft reference management; then search * through its method descriptors to find any non-void returning write methods and * update or create the corresponding {@link PropertyDescriptor} for each one found. * @param delegate the wrapped {@code BeanInfo}, which is never modified * @throws IntrospectionException if any problems occur creating and adding new * property descriptors * @see #getPropertyDescriptors() */ public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException { this.delegate = delegate; for (PropertyDescriptor pd : delegate.getPropertyDescriptors()) { this.propertyDescriptors.add(pd instanceof IndexedPropertyDescriptor ? new SimpleIndexedPropertyDescriptor((IndexedPropertyDescriptor) pd) : new SimplePropertyDescriptor(pd)); } MethodDescriptor[] methodDescriptors = delegate.getMethodDescriptors(); if (methodDescriptors != null) { for (Method method : findCandidateWriteMethods(methodDescriptors)) { handleCandidateWriteMethod(method); } } }
Example 10
Source File: Test6277246.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IntrospectionException { Class type = BASE64Encoder.class; System.setSecurityManager(new SecurityManager()); BeanInfo info = Introspector.getBeanInfo(type); for (MethodDescriptor md : info.getMethodDescriptors()) { Method method = md.getMethod(); System.out.println(method); String name = method.getDeclaringClass().getName(); if (name.startsWith("sun.misc.")) { throw new Error("found inaccessible method"); } } }
Example 11
Source File: Test6277246.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IntrospectionException { Class type = BASE64Encoder.class; System.setSecurityManager(new SecurityManager()); BeanInfo info = Introspector.getBeanInfo(type); for (MethodDescriptor md : info.getMethodDescriptors()) { Method method = md.getMethod(); System.out.println(method); String name = method.getDeclaringClass().getName(); if (name.startsWith("sun.misc.")) { throw new Error("found inaccessible method"); } } }
Example 12
Source File: Test6277246.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IntrospectionException { Class type = BASE64Encoder.class; System.setSecurityManager(new SecurityManager()); BeanInfo info = Introspector.getBeanInfo(type); for (MethodDescriptor md : info.getMethodDescriptors()) { Method method = md.getMethod(); System.out.println(method); String name = method.getDeclaringClass().getName(); if (name.startsWith("sun.misc.")) { throw new Error("found inaccessible method"); } } }
Example 13
Source File: Test6277246.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IntrospectionException { Class type = BASE64Encoder.class; System.setSecurityManager(new SecurityManager()); BeanInfo info = Introspector.getBeanInfo(type); for (MethodDescriptor md : info.getMethodDescriptors()) { Method method = md.getMethod(); System.out.println(method); String name = method.getDeclaringClass().getName(); if (name.startsWith("sun.misc.")) { throw new Error("found inaccessible method"); } } }
Example 14
Source File: Test6277246.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws IntrospectionException { Class type = BASE64Encoder.class; System.setSecurityManager(new SecurityManager()); BeanInfo info = Introspector.getBeanInfo(type); for (MethodDescriptor md : info.getMethodDescriptors()) { Method method = md.getMethod(); System.out.println(method); String name = method.getDeclaringClass().getName(); if (name.startsWith("sun.misc.")) { throw new Error("found inaccessible method"); } } }
Example 15
Source File: BeanInfoFinder.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override protected BeanInfo instantiate(Class<?> type, String prefix, String name) { if (DEFAULT.equals(prefix)) { prefix = DEFAULT_NEW; } // this optimization will only use the BeanInfo search path // if is has changed from the original // or trying to get the ComponentBeanInfo BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name) ? super.instantiate(type, prefix, name) : null; if (info != null) { // make sure that the returned BeanInfo matches the class BeanDescriptor bd = info.getBeanDescriptor(); if (bd != null) { if (type.equals(bd.getBeanClass())) { return info; } } else { PropertyDescriptor[] pds = info.getPropertyDescriptors(); if (pds != null) { for (PropertyDescriptor pd : pds) { Method method = pd.getReadMethod(); if (method == null) { method = pd.getWriteMethod(); } if (isValid(type, method)) { return info; } } } else { MethodDescriptor[] mds = info.getMethodDescriptors(); if (mds != null) { for (MethodDescriptor md : mds) { if (isValid(type, md.getMethod())) { return info; } } } } } } return null; }
Example 16
Source File: BeanInfoFinder.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override protected BeanInfo instantiate(Class<?> type, String prefix, String name) { if (DEFAULT.equals(prefix)) { prefix = DEFAULT_NEW; } // this optimization will only use the BeanInfo search path // if is has changed from the original // or trying to get the ComponentBeanInfo BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name) ? super.instantiate(type, prefix, name) : null; if (info != null) { // make sure that the returned BeanInfo matches the class BeanDescriptor bd = info.getBeanDescriptor(); if (bd != null) { if (type.equals(bd.getBeanClass())) { return info; } } else { PropertyDescriptor[] pds = info.getPropertyDescriptors(); if (pds != null) { for (PropertyDescriptor pd : pds) { Method method = pd.getReadMethod(); if (method == null) { method = pd.getWriteMethod(); } if (isValid(type, method)) { return info; } } } else { MethodDescriptor[] mds = info.getMethodDescriptors(); if (mds != null) { for (MethodDescriptor md : mds) { if (isValid(type, md.getMethod())) { return info; } } } } } } return null; }
Example 17
Source File: BeanInfoFinder.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override protected BeanInfo instantiate(Class<?> type, String prefix, String name) { if (DEFAULT.equals(prefix)) { prefix = DEFAULT_NEW; } // this optimization will only use the BeanInfo search path // if is has changed from the original // or trying to get the ComponentBeanInfo BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name) ? super.instantiate(type, prefix, name) : null; if (info != null) { // make sure that the returned BeanInfo matches the class BeanDescriptor bd = info.getBeanDescriptor(); if (bd != null) { if (type.equals(bd.getBeanClass())) { return info; } } else { PropertyDescriptor[] pds = info.getPropertyDescriptors(); if (pds != null) { for (PropertyDescriptor pd : pds) { Method method = pd.getReadMethod(); if (method == null) { method = pd.getWriteMethod(); } if (isValid(type, method)) { return info; } } } else { MethodDescriptor[] mds = info.getMethodDescriptors(); if (mds != null) { for (MethodDescriptor md : mds) { if (isValid(type, md.getMethod())) { return info; } } } } } } return null; }
Example 18
Source File: BeanInfoFinder.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Override protected BeanInfo instantiate(Class<?> type, String prefix, String name) { if (DEFAULT.equals(prefix)) { prefix = DEFAULT_NEW; } // this optimization will only use the BeanInfo search path // if is has changed from the original // or trying to get the ComponentBeanInfo BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name) ? super.instantiate(type, prefix, name) : null; if (info != null) { // make sure that the returned BeanInfo matches the class BeanDescriptor bd = info.getBeanDescriptor(); if (bd != null) { if (type.equals(bd.getBeanClass())) { return info; } } else { PropertyDescriptor[] pds = info.getPropertyDescriptors(); if (pds != null) { for (PropertyDescriptor pd : pds) { Method method = pd.getReadMethod(); if (method == null) { method = pd.getWriteMethod(); } if (isValid(type, method)) { return info; } } } else { MethodDescriptor[] mds = info.getMethodDescriptors(); if (mds != null) { for (MethodDescriptor md : mds) { if (isValid(type, md.getMethod())) { return info; } } } } } } return null; }
Example 19
Source File: BeanInfoFinder.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override protected BeanInfo instantiate(Class<?> type, String prefix, String name) { if (DEFAULT.equals(prefix)) { prefix = DEFAULT_NEW; } // this optimization will only use the BeanInfo search path // if is has changed from the original // or trying to get the ComponentBeanInfo BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name) ? super.instantiate(type, prefix, name) : null; if (info != null) { // make sure that the returned BeanInfo matches the class BeanDescriptor bd = info.getBeanDescriptor(); if (bd != null) { if (type.equals(bd.getBeanClass())) { return info; } } else { PropertyDescriptor[] pds = info.getPropertyDescriptors(); if (pds != null) { for (PropertyDescriptor pd : pds) { Method method = pd.getReadMethod(); if (method == null) { method = pd.getWriteMethod(); } if (isValid(type, method)) { return info; } } } else { MethodDescriptor[] mds = info.getMethodDescriptors(); if (mds != null) { for (MethodDescriptor md : mds) { if (isValid(type, md.getMethod())) { return info; } } } } } } return null; }
Example 20
Source File: BeanInfoFinder.java From Bytecoder with Apache License 2.0 | 4 votes |
@Override protected BeanInfo instantiate(Class<?> type, String prefix, String name) { if (DEFAULT.equals(prefix)) { prefix = DEFAULT_NEW; } // this optimization will only use the BeanInfo search path // if is has changed from the original // or trying to get the ComponentBeanInfo BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name) ? super.instantiate(type, prefix, name) : null; if (info != null) { // make sure that the returned BeanInfo matches the class BeanDescriptor bd = info.getBeanDescriptor(); if (bd != null) { if (type.equals(bd.getBeanClass())) { return info; } } else { PropertyDescriptor[] pds = info.getPropertyDescriptors(); if (pds != null) { for (PropertyDescriptor pd : pds) { Method method = pd.getReadMethod(); if (method == null) { method = pd.getWriteMethod(); } if (isValid(type, method)) { return info; } } } else { MethodDescriptor[] mds = info.getMethodDescriptors(); if (mds != null) { for (MethodDescriptor md : mds) { if (isValid(type, md.getMethod())) { return info; } } } } } } return null; }