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.opensixen.swing.BeanTableModel.java
@Override public void setValueAt(Object value, int rowIndex, int columnIndex) { String name = columnDefinitions[columnIndex].getName(); try {/*from w w w . j a v a 2s . co m*/ PropertyUtils.setProperty(model[rowIndex], name, value); } catch (Exception e) { log.log(Level.SEVERE, "No se encuentra la propiedad: " + name + "[" + columnIndex + "]", e); } }
From source file:org.opentestsystem.delivery.testreg.service.impl.AccommodationServiceImpl.java
private void setDefaultAccommodations(final Accommodation accommodation) { //List<String> headerCodes = templateDownloadMap.get (FormatType.DESIGNATEDSUPPORTSANDACCOMMODATIONS); HashMap<FormatType, List<String>> headerMap = masterResourceService.getAllCodes(); List<String> headerCodes = headerMap.get(FormatType.DESIGNATEDSUPPORTSANDACCOMMODATIONS); HashMap<String, String> defaultOptions = masterResourceService.getAllDefaultOptions(); HashMap<String, String> accResourceTypes = masterResourceService.getAllResourceTypes(); for (String option : headerCodes) { if (defaultOptions.containsKey(option)) { String heaerProperty = getHeaderPropertyName(option); try { Object value = PropertyUtils.getProperty(accommodation, heaerProperty); if (value == null && defaultOptions.get(option) != null) { List<String> defaultList = new ArrayList<String>(); if (accResourceTypes.get(option) .equalsIgnoreCase(AccommodationResourceType.MultiSelectResource.name())) { defaultList.add(defaultOptions.get(option)); PropertyUtils.setProperty(accommodation, heaerProperty, defaultList); } else { PropertyUtils.setProperty(accommodation, heaerProperty, defaultOptions.get(option)); }//from w ww . j a v a 2 s . c o m } } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { e.printStackTrace(); LOGGER.error("Failure in accommodation service can't find field called " + heaerProperty + " in accommodation, invalid rule", e); } } } }
From source file:org.opoo.oqs.core.mapper.BeanPropertyMapper.java
private void setProperty(Object target, String name, Object value) { try {//from w w w . ja v a 2 s . com PropertyUtils.setProperty(target, name, value); } catch (Exception ex) { log.error("set property error", ex); } }
From source file:org.opoo.util.ClassUtils.java
public static void setProperty(final Object entity, String name, Object value) { try {// ww w . j av a 2 s .c o m PropertyUtils.setProperty(entity, name, value); } catch (Exception ex) { log.error(ex); } }
From source file:org.osaf.cosmo.eim.schema.BaseApplicator.java
/** * Handle a missing attribute for a modification by setting * the value to null./*from w w w.j a v a 2 s . c o m*/ * * @param attribute attribute to copy * @param modification object to copy attribute to */ protected void handleMissingAttribute(String attribute, Object modification) { try { PropertyUtils.setProperty(modification, attribute, null); } catch (IllegalAccessException e) { throw new RuntimeException("error copying attribute " + attribute); } catch (InvocationTargetException e) { throw new RuntimeException("error copying attribute " + attribute); } catch (NoSuchMethodException e) { throw new RuntimeException("error copying attribute " + attribute); } }
From source file:org.ovirt.engine.sdk.mapping.Mapper.java
/** * Excludes mapping exceptions//from ww w . j a v a 2s . com * * @param dstobj */ private static <T> void excludeExceptions(T dstobj) { for (String field : MAPPING_EXCEPTIONS) { try { PropertyUtils.setProperty(dstobj, field, null); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { // do nothing (PropertyUtils exceptions treatment #1007266) } } }
From source file:org.pentaho.agilebi.modeler.models.annotations.AnnotationType.java
protected void attemptAutoConvertAndAssign(final Field field, final Object value) throws Exception { if (field == null) { return; // exit early }/*www . j a va 2s.c o m*/ if (value == null) { try { PropertyUtils.setProperty(this, field.getName(), value); } catch (Exception e) { // ignore } return; // exit early } if (value != null && ClassUtils.isAssignable(value.getClass(), field.getType(), true)) { PropertyUtils.setProperty(this, field.getName(), value); } else { try { if (ClassUtils.isAssignable(field.getType(), Boolean.class, true)) { PropertyUtils.setProperty(this, field.getName(), BooleanUtils.toBoolean(value.toString())); return; } if (ClassUtils.isAssignable(field.getType(), AggregationType.class, true)) { AggregationType type = AggregationType.valueOf(value.toString()); if (type != null) { PropertyUtils.setProperty(this, field.getName(), type); } return; } if (ClassUtils.isAssignable(field.getType(), ModelAnnotation.TimeType.class, true)) { ModelAnnotation.TimeType type = ModelAnnotation.TimeType.valueOf(value.toString()); if (type != null) { PropertyUtils.setProperty(this, field.getName(), type); } return; } if (ClassUtils.isAssignable(field.getType(), ModelAnnotation.GeoType.class, true)) { ModelAnnotation.GeoType type = ModelAnnotation.GeoType.valueOf(value.toString()); if (type != null) { PropertyUtils.setProperty(this, field.getName(), type); } return; } if (NumberUtils.isNumber(value.toString())) { Number number = NumberUtils.createNumber(value.toString()); PropertyUtils.setProperty(this, field.getName(), number); } } catch (Exception e) { if (value == null || StringUtils.isBlank(value.toString())) { return; // do not log } // ignore error but log getLogger().warning("Unable to convert " + value.toString() + " in to " + field.getType()); } } }
From source file:org.photovault.image.Test_ImageOp.java
@Test public void testBeanAccess() throws IllegalAccessException, InvocationTargetException, InvocationTargetException, NoSuchMethodException { ImageOpChain chain = new ImageOpChain(); DCRawOp dcrawOp = new DCRawOp(); dcrawOp.setBlack(20);//from ww w . j a v a 2 s.c o m PropertyUtils.setProperty(chain, "operation(dcraw)", dcrawOp); PropertyUtils.setProperty(chain, "operation(dcraw).white", 10000); DCRawMapOp mapOp = new DCRawMapOp(); mapOp.setEvCorr(-1.0); PropertyUtils.setProperty(chain, "operation(raw-map)", mapOp); PropertyUtils.setProperty(chain, "connection(raw-map.in)", "dcraw.out"); assertEquals(10000, dcrawOp.getWhite()); assertEquals(dcrawOp.getOutputPort("out"), mapOp.getInputPort("in").getSource()); }
From source file:org.photovault.imginfo.ProcGraphEditorHelper.java
/** * Set a property of the processing graph * @param name Name of the proeprty// w w w . ja v a 2s . c o m * @param value New value for the property * @throws IllegalAccessException * @throws InvocationTargetException * @throws NoSuchMethodException */ void setProperty(String name, Object value) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { isModified = true; if (createdNode != null) { PropertyUtils.setProperty(createdNode, name, value); } else { String fullname = "processing.operation(" + nodeName + ")." + name; editor.setField(fullname, value); } }
From source file:org.photovault.replication.ValueFieldDesc.java
/** * Change a certain property of the target obejct * @param target Object that will be changed * @param propName Property to change//from w w w . j ava 2s .c o m * @param newValue New value for the property * @throws IllegalAccessException * @throws InvocationTargetException */ void applyPropertyChange(Object target, String propName, Object newValue) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { PropertyUtils.setProperty(target, propName, newValue); }