當前位置: 首頁>>代碼示例>>Java>>正文


Java IndexedPropertyDescriptor類代碼示例

本文整理匯總了Java中java.beans.IndexedPropertyDescriptor的典型用法代碼示例。如果您正苦於以下問題:Java IndexedPropertyDescriptor類的具體用法?Java IndexedPropertyDescriptor怎麽用?Java IndexedPropertyDescriptor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IndexedPropertyDescriptor類屬於java.beans包,在下文中一共展示了IndexedPropertyDescriptor類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
public static void main(String[] args)throws Exception {

         
        BeanInfo bi = Introspector.getBeanInfo( BadBeanHidden.class );
        PropertyDescriptor[] ps = bi.getPropertyDescriptors();
        
        for ( int i = 0; i < ps.length; i++ ) {
            System.out.println( i + " : " + ps[i]);
            System.out.println("  Read : " + ps[i].getReadMethod() );
            System.out.println("  Write : " + ps[i].getWriteMethod() );
            System.out.println(" TYPE " + ps[i].getPropertyType() );
            if ( ps[i] instanceof IndexedPropertyDescriptor ) {
                System.out.println("  I Read : " + ((IndexedPropertyDescriptor)ps[i]).getIndexedReadMethod() );
                System.out.println("  I Write : " +((IndexedPropertyDescriptor)ps[i]).getIndexedWriteMethod() );
                System.out.println(" TYPE " + ((IndexedPropertyDescriptor)ps[i]).getIndexedPropertyType() );
            }
            
            
        }
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:BeanNodeBug21285.java

示例2: _cloneIndexedPropertyDescriptor

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
private static IndexedPropertyDescriptor _cloneIndexedPropertyDescriptor(
  IndexedPropertyDescriptor oldDescriptor
  )
{
  try
  {
    IndexedPropertyDescriptor newDescriptor = new IndexedPropertyDescriptor(
                                    oldDescriptor.getName(),
                                    oldDescriptor.getReadMethod(),
                                    oldDescriptor.getWriteMethod(),
                                    oldDescriptor.getIndexedReadMethod(),
                                    oldDescriptor.getIndexedWriteMethod());

    // copy the rest of the attributes
    _copyPropertyDescriptor(oldDescriptor, newDescriptor);

    return newDescriptor;
  }
  catch (Exception e)
  {
    _LOG.severe(e);
    return null;
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:25,代碼來源:JavaIntrospector.java

示例3: findExistingPropertyDescriptor

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, Class<?> propertyType) {
	for (PropertyDescriptor pd : this.propertyDescriptors) {
		final Class<?> candidateType;
		final String candidateName = pd.getName();
		if (pd instanceof IndexedPropertyDescriptor) {
			IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
			candidateType = ipd.getIndexedPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
				return pd;
			}
		}
		else {
			candidateType = pd.getPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
				return pd;
			}
		}
	}
	return null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:ExtendedBeanInfo.java

示例4: equals

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
@Override
public boolean equals(Object obj) {
	if (this == obj) {
		return true;
	}
	if (obj != null && obj instanceof IndexedPropertyDescriptor) {
		IndexedPropertyDescriptor other = (IndexedPropertyDescriptor) obj;
		if (!compareMethods(getIndexedReadMethod(), other.getIndexedReadMethod())) {
			return false;
		}
		if (!compareMethods(getIndexedWriteMethod(), other.getIndexedWriteMethod())) {
			return false;
		}
		if (getIndexedPropertyType() != other.getIndexedPropertyType()) {
			return false;
		}
		return PropertyDescriptorUtils.equals(this, obj);
	}
	return false;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:ExtendedBeanInfo.java

示例5: makeProperty

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
private static Property makeProperty(Object o, PropertyDescriptor propertyDescriptor) {
    Class propertyType = propertyDescriptor.getPropertyType();
    if (propertyType != null && Vector.class.isAssignableFrom(propertyType)) {
        return new VectorProperty(o, propertyDescriptor);
    }
    if (propertyType != null && IAtomList.class.isAssignableFrom(propertyType)) {
        return new AtomListProperty(o, propertyDescriptor);
    }
    if (propertyType != null && IMoleculeList.class.isAssignableFrom(propertyType)) {
        return new MoleculeListProperty(o, propertyDescriptor);
    }
    if (!(propertyDescriptor instanceof IndexedPropertyDescriptor) && propertyType.isArray() &&
            !(propertyType.getComponentType().isPrimitive() || propertyType.getComponentType().equals(String.class))) {
        return new ArrayProperty(o, propertyDescriptor);
    }
    return new InstanceProperty(o, propertyDescriptor);
}
 
開發者ID:etomica,項目名稱:etomica,代碼行數:18,代碼來源:ObjectWrapper.java

示例6: create

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
private static PropertyDescriptor create(PropertyDescriptor pd) {
    try {
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            return new IndexedPropertyDescriptor(
                    ipd.getName(),
                    ipd.getReadMethod(),
                    ipd.getWriteMethod(),
                    ipd.getIndexedReadMethod(),
                    ipd.getIndexedWriteMethod());
        } else {
            return new PropertyDescriptor(
                    pd.getName(),
                    pd.getReadMethod(),
                    pd.getWriteMethod());
        }
    }
    catch (IntrospectionException exception) {
        exception.printStackTrace();
        return null;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:Test4634390.java

示例7: test

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
private static void test(Class<?> type, boolean read, boolean write, boolean readIndexed, boolean writeIndexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, "size");
    if (pd != null) {
        test(type, "read", read, null != pd.getReadMethod());
        test(type, "write", write, null != pd.getWriteMethod());
        if (pd instanceof IndexedPropertyDescriptor) {
            IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
            test(type, "indexed read", readIndexed, null != ipd.getIndexedReadMethod());
            test(type, "indexed write", writeIndexed, null != ipd.getIndexedWriteMethod());
        } else if (readIndexed || writeIndexed) {
            error(type, "indexed property does not exist");
        }
    } else if (read || write || readIndexed || writeIndexed) {
        error(type, "property does not exist");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:Test8034164.java

示例8: main

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    Class<?> bt = Accessor.getBeanType();
    Class<?> lt = Accessor.getListenerType();

    // test PropertyDescriptor
    PropertyDescriptor pd = new PropertyDescriptor("boolean", bt);
    test(pd.getReadMethod());
    test(pd.getWriteMethod());

    // test IndexedPropertyDescriptor
    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt);
    test(ipd.getReadMethod());
    test(ipd.getWriteMethod());
    test(ipd.getIndexedReadMethod());
    test(ipd.getIndexedWriteMethod());

    // test EventSetDescriptor
    EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process");
    test(esd.getAddListenerMethod());
    test(esd.getRemoveListenerMethod());
    test(esd.getGetListenerMethod());
    test(esd.getListenerMethods());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:Test6976577.java

示例9: getPropertyType

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
/**
 * Return the Java Class representing the property type of the specified property, or
 * <code>null</code> if there is no such property for the specified bean.  This method
 * follows the same name resolution rules used by <code>getPropertyDescriptor()</code>,
 * so if the last element of a name reference is indexed, the type of the property itself
 * will be returned.  If the last (or only) element has no property with the specified
 * name, <code>null</code> is returned.
 *
 * @param bean Bean for which a property descriptor is requested
 * @param name Possibly indexed and/or nested name of the property for which a property
 *             descriptor is requested
 * @throws IllegalAccessException    if the caller does not have access to the property
 *                                   accessor method
 * @throws IllegalArgumentException  if <code>bean</code> or <code>name</code> are null
 *                                   or if a nested reference to a property returns null
 * @throws InvocationTargetException if the property accessor method throws an exception
 * @throws NoSuchMethodException     if an accessor method for this property cannot be
 *                                   found
 */
public static Class getPropertyType(Object bean, String name)
   throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
{

   if(bean == null) throw new IllegalArgumentException("No bean specified");
   if(name == null) throw new IllegalArgumentException("No name specified");

   PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
   if(descriptor == null) {
      return null;
   } else if(descriptor instanceof IndexedPropertyDescriptor) {
      return (((IndexedPropertyDescriptor) descriptor).getIndexedPropertyType());
   } else if(descriptor instanceof MappedPropertyDescriptor) {
      return (((MappedPropertyDescriptor) descriptor).getMappedPropertyType());
   } else {
      return descriptor.getPropertyType();
   }

}
 
開發者ID:cfloersch,項目名稱:Stdlib,代碼行數:39,代碼來源:PropertyUtils.java

示例10: test_MixedBooleanSimpleClass7

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
public void test_MixedBooleanSimpleClass7() throws Exception {
    BeanInfo info = Introspector
            .getBeanInfo(MixedBooleanSimpleClass7.class);
    Method getter = MixedBooleanSimpleClass7.class
            .getDeclaredMethod("isList");
    Method setter = MixedBooleanSimpleClass7.class.getDeclaredMethod(
            "setList", boolean.class);

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertFalse(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter, pd.getReadMethod());
            assertEquals(setter, pd.getWriteMethod());
        }
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:IntrospectorTest.java

示例11: testSetIndexedWriteMethod_return

import java.beans.IndexedPropertyDescriptor; //導入依賴的package包/類
public void testSetIndexedWriteMethod_return()
        throws IntrospectionException, NoSuchMethodException,
        NoSuchMethodException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;

    Method readMethod = beanClass.getMethod("get" + propertyName,
            (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { String[].class });
    Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
            new Class[] { Integer.TYPE });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, readMethod, writeMethod, indexedReadMethod, null);
    assertNull(ipd.getIndexedWriteMethod());
    Method badArgType = beanClass.getMethod("setPropertyFourInvalid",
            new Class[] { Integer.TYPE, String.class });
    ipd.setIndexedWriteMethod(badArgType);

    assertEquals(String.class, ipd.getIndexedPropertyType());
    assertEquals(String[].class, ipd.getPropertyType());
    assertEquals(Integer.TYPE, ipd.getIndexedWriteMethod().getReturnType());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:25,代碼來源:IndexedPropertyDescriptorTest.java


注:本文中的java.beans.IndexedPropertyDescriptor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。