List of usage examples for java.beans PropertyDescriptor getWriteMethod
public synchronized Method getWriteMethod()
From source file:org.jdal.ui.bind.AbstractBinder.java
/** * @return Property for property binder// w ww .j ava 2 s . c o m */ protected Property getProperty() { PropertyDescriptor pd = getPropertyDescriptor(); return new Property(getModel().getClass(), pd.getReadMethod(), pd.getWriteMethod()); }
From source file:org.mypsycho.beans.DescriptorExtension.java
/** * Constructor./*from w ww. jav a 2 s . c o m*/ * * @param applicable type applicable * @param propName property name * @param parent the delegating * @throws IntrospectionException */ public DescriptorExtension(Class<?> applicable, String propName, PropertyDescriptor parent) throws IntrospectionException { super(propName, (parent != null) ? parent.getReadMethod() : null, (parent != null) ? parent.getWriteMethod() : null); type = applicable; delegate = parent; }
From source file:org.pentaho.reporting.engine.classic.core.modules.parser.ext.factory.base.BeanObjectDescription.java
/** * Finds a set method in the bean./*from w w w. java2s . com*/ * * @param parameterName * the parameter name. * @return The method. */ private Method findSetMethod(final String parameterName) { final PropertyDescriptor descriptor = (PropertyDescriptor) this.properties.get(parameterName); return descriptor.getWriteMethod(); }
From source file:org.okj.commons.annotations.ServiceReferenceInjectionBeanPostProcessor.java
protected ServiceReference hasServiceProperty(PropertyDescriptor propertyDescriptor) { Method setter = propertyDescriptor.getWriteMethod(); return setter != null ? AnnotationUtils.getAnnotation(setter, ServiceReference.class) : null; }
From source file:gov.nih.nci.caarray.external.v1_0.AbstractCaArrayEntityTest.java
private void setSomeProperty(AbstractCaArrayEntity a) throws Exception { PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(a); for (PropertyDescriptor p : pds) { if (p.getName().equals("id")) continue; if (p.getPropertyType() == String.class) { p.getWriteMethod().invoke(a, "some String"); return; }/* w ww . j av a 2s. c o m*/ if (p.getPropertyType() == Person.class) { p.getWriteMethod().invoke(a, new Person()); return; } if (p.getPropertyType() == FileMetadata.class) { p.getWriteMethod().invoke(a, new FileMetadata()); return; } } throw new UnsupportedOperationException("did know how to set a property on " + a.getClass()); }
From source file:org.mule.module.netsuite.api.model.expression.filter.FilterExpressionBuilder.java
public void setTarget(SearchRecordType targetRecordType) { target = targetRecordType.newSearchInstance(); try {/* www .ja v a2s . c o m*/ PropertyDescriptor descriptor = newDescriptor("basic", target); basic = (SearchRecord) descriptor.getPropertyType().newInstance(); descriptor.getWriteMethod().invoke(target, basic); } catch (Exception e) { throw soften(e); } }
From source file:org.mule.module.netsuite.api.model.expression.filter.FilterExpressionBuilder.java
private Object addAttribute(String attributeName, SearchRecord attributeGroup) throws Exception { PropertyDescriptor descriptor = newDescriptor(attributeName, attributeGroup); Object attributeObject = descriptor.getPropertyType().newInstance(); descriptor.getWriteMethod().invoke(attributeGroup, attributeObject); return attributeObject; }
From source file:pt.ist.vaadinframework.data.metamodel.RolePropertyDescriptor.java
private void calc() throws IntrospectionException, SecurityException, NoSuchMethodException, ClassNotFoundException { if (role.getMultiplicityUpper() == 1) { java.beans.PropertyDescriptor property = new java.beans.PropertyDescriptor(role.getName(), type); reader = property.getReadMethod(); writer = property.getWriteMethod(); } else {/*from www. j ava 2s .co m*/ reader = type.getMethod("get" + WordUtils.capitalize(role.getName()) + "Set"); elementType = (Class<? extends AbstractDomainObject>) Class.forName(role.getType().getFullName()); } }
From source file:org.kordamp.ezmorph.bean.BeanMorpher.java
public Object morph(Object sourceBean) { if (sourceBean == null) { return null; }//from w w w . jav a 2 s.co m if (!supports(sourceBean.getClass())) { throw new MorphException("unsupported class: " + sourceBean.getClass().getName()); } Object targetBean = null; try { targetBean = beanClass.newInstance(); PropertyDescriptor[] targetPds = PropertyUtils.getPropertyDescriptors(beanClass); for (int i = 0; i < targetPds.length; i++) { PropertyDescriptor targetPd = targetPds[i]; String name = targetPd.getName(); if (targetPd.getWriteMethod() == null) { log.info("Property '" + beanClass.getName() + "." + name + "' has no write method. SKIPPED."); continue; } Class sourceType = null; if (sourceBean instanceof DynaBean) { DynaBean dynaBean = (DynaBean) sourceBean; DynaProperty dynaProperty = dynaBean.getDynaClass().getDynaProperty(name); if (dynaProperty == null) { log.warn("DynaProperty '" + name + "' does not exist. SKIPPED."); continue; } sourceType = dynaProperty.getType(); } else { PropertyDescriptor sourcePd = PropertyUtils.getPropertyDescriptor(sourceBean, name); if (sourcePd == null) { log.warn("Property '" + sourceBean.getClass().getName() + "." + name + "' does not exist. SKIPPED."); continue; } else if (sourcePd.getReadMethod() == null) { log.warn("Property '" + sourceBean.getClass().getName() + "." + name + "' has no read method. SKIPPED."); continue; } sourceType = sourcePd.getPropertyType(); } Class targetType = targetPd.getPropertyType(); Object value = PropertyUtils.getProperty(sourceBean, name); setProperty(targetBean, name, sourceType, targetType, value); } } catch (MorphException me) { throw me; } catch (Exception e) { throw new MorphException(e); } return targetBean; }
From source file:org.seasar.struts.bean.SuppressPropertyUtilsBean.java
private boolean isSuppressedProperty(PropertyDescriptor descriptor) { Method readMethod = descriptor.getReadMethod(); if (readMethod != null && isSuppressedMethod(readMethod)) { return true; }/*from w w w .j ava 2s . co m*/ Method writeMethod = descriptor.getWriteMethod(); if (writeMethod != null && isSuppressedMethod(writeMethod)) { return true; } return false; }