List of usage examples for org.apache.commons.beanutils PropertyUtils setProperty
public static void setProperty(Object bean, String name, Object value) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Set the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.
For more details see PropertyUtilsBean
.
From source file:org.thiesen.helenaorm.HelenaDAO.java
private void applySuperColumnName(final T object, final byte[] value) { final Class<?> returnType = _superColumnPropertyDescriptor.getReadMethod().getReturnType(); try {/*w ww . ja v a2 s .c o m*/ PropertyUtils.setProperty(object, _superColumnPropertyDescriptor.getName(), _typeConverter.convertByteArrayToValueObject(returnType, value)); } catch (final IllegalAccessException e) { throw new HelenaRuntimeException(e); } catch (final InvocationTargetException e) { throw new HelenaRuntimeException(e); } catch (final NoSuchMethodException e) { throw new HelenaRuntimeException(e); } }
From source file:org.tinygroup.flow.impl.FlowExecutorImpl.java
/** * ??/*from w w w .ja v a 2 s. c o m*/ * * @param node * @param componentInstance */ private void setProperties(Node node, ComponentInterface componentInstance, Context context) { Map<String, FlowProperty> properties = node.getComponent().getPropertyMap(); if (properties != null) { for (String name : properties.keySet()) { FlowProperty property = properties.get(name); String value = property.getValue(); Object object = null; // el?el?? if (FlowProperty.EL_TYPE.equals(property.getType())) { object = FlowElUtil.execute(value, context, this.getClass().getClassLoader()); } else {// ??? object = getObject(property.getType(), value, context); } try { PropertyUtils.setProperty(componentInstance, name, object); } catch (Exception e) { throw new FlowRuntimeException(e); } } } }
From source file:org.tohu.domain.DomainModelSupportTest.java
private void setTextProperty(String property, String value) { try {//from w w w .j a va2 s. c om logger.debug("Setting " + property); Class<?> propertyClass = PropertyUtils.getPropertyType(data, property); Object v = DomainModelSupport.answerToObject(Question.TYPE_TEXT, value, propertyClass); PropertyUtils.setProperty(data, property, v); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.tohu.domain.DomainModelSupportTest.java
private void setNumberProperty(String property, Long value) { try {/*from w w w . j a v a2 s.co m*/ logger.debug("Setting " + property); Class<?> propertyClass = PropertyUtils.getPropertyType(data, property); Object v = DomainModelSupport.answerToObject(Question.TYPE_NUMBER, value, propertyClass); PropertyUtils.setProperty(data, property, v); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.tohu.domain.DomainModelSupportTest.java
private void setDecimalProperty(String property, BigDecimal value) { try {/*from ww w. jav a 2 s. co m*/ logger.debug("Setting " + property); Class<?> propertyClass = PropertyUtils.getPropertyType(data, property); Object v = DomainModelSupport.answerToObject(Question.TYPE_DECIMAL, value, propertyClass); PropertyUtils.setProperty(data, property, v); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.tohu.domain.DomainModelSupportTest.java
private void setBooleanProperty(String property, Boolean value) { try {// www.j a v a 2 s.c om logger.debug("Setting " + property); Class<?> propertyClass = PropertyUtils.getPropertyType(data, property); Object v = DomainModelSupport.answerToObject(Question.TYPE_BOOLEAN, value, propertyClass); PropertyUtils.setProperty(data, property, v); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.tohu.domain.DomainModelSupportTest.java
private void setDateProperty(String property, Date value) { try {/* ww w. j a v a 2 s .c om*/ logger.debug("Setting " + property); Class<?> propertyClass = PropertyUtils.getPropertyType(data, property); Object v = DomainModelSupport.answerToObject(Question.TYPE_DATE, value, propertyClass); PropertyUtils.setProperty(data, property, v); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.tohu.domain.DomainModelSupportTest.java
private void setListProperty(String property, String value) { try {/*from ww w .j av a2s. co m*/ logger.debug("Setting " + property); Class<?> propertyClass = PropertyUtils.getPropertyType(data, property); Object v = DomainModelSupport.answerToObject(Question.TYPE_LIST, value, propertyClass); PropertyUtils.setProperty(data, property, v); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.trpr.dataaccess.hbase.persistence.HBaseHandlerDelegate.java
/** * Sets value for an entity's attribute//ww w .j a v a2 s . c o m * * @param entity * HBase entity that is being updated * @param attribute * Attribute whose value is to be updated * @param value * Value for the attribute * @throws ConfigurationException */ private void setAttribute(PersistentEntity entity, String attribute, Object value) throws ConfigurationException { try { if (StringUtils.isNotBlank(attribute)) { PropertyUtils.setProperty(entity, attribute, value); } } catch (Exception e) { logger.error("Error setting attribute " + attribute, e); } }
From source file:org.vulpe.commons.util.VulpeReflectUtil.java
/** * Copy attributes from <code>origin</code> to <code>destination</code>. * * @param destination// www . j a va2s .c om * @param origin * @param ignoreTransient */ public static void copy(final Object destination, final Object origin, boolean ignoreTransient) { final List<Field> fields = getFields(origin.getClass()); for (final Field field : fields) { if (ignoreTransient && Modifier.isTransient(field.getModifiers())) { continue; } try { final Object value = PropertyUtils.getProperty(origin, field.getName()); if (Collection.class.isAssignableFrom(field.getType())) { final Collection valueDes = (Collection) PropertyUtils.getProperty(destination, field.getName()); if (value == null) { if (valueDes != null) { valueDes.clear(); } } else { if (valueDes == null) { PropertyUtils.setProperty(destination, field.getName(), value); } else { valueDes.clear(); valueDes.addAll((Collection) value); } } } else { PropertyUtils.setProperty(destination, field.getName(), value); } } catch (NoSuchMethodException e) { LOG.debug("Method not found.", e); } catch (Exception e) { throw new VulpeSystemException(e); } } }