/** * Gets the value specified by the BeanProperty * * @param instance Object to get the value from * @param bp the property to get * @return the value of the property if it exists */ protected final Object getBeanValue(Object instance, BeanProperty bp) { String propertyName = bp.getName(); if (bp.isRead()) { try { Object value = bp.get(instance); if (value != null && descriptor != null) { SerializationDescriptor subDescriptor = (SerializationDescriptor) descriptor.get(propertyName); if (subDescriptor != null) { PropertyProxy subProxy = PropertyProxyRegistry.getProxyAndRegister(value); subProxy = (PropertyProxy) subProxy.clone(); subProxy.setDescriptor(subDescriptor); subProxy.setDefaultInstance(value); value = subProxy; } } return value; } catch (Exception e) { SerializationContext context = getSerializationContext(); // Log failed property set errors if (Log.isWarn() && logPropertyErrors(context)) { Logger log = Log.getLogger(LOG_CATEGORY); log.warn( "Failed to get property {0} on type {1}.", new Object[] {propertyName, getAlias(instance)}, e); } if (!ignorePropertyErrors(context)) { // Failed to get property '{propertyName}' on type '{className}'. MessageException ex = new MessageException(); ex.setMessage( FAILED_PROPERTY_READ_ERROR, new Object[] {propertyName, getAlias(instance)}); ex.setRootCause(e); throw ex; } } } else { SerializationContext context = getSerializationContext(); if (!ignorePropertyErrors(context)) { // Property '{propertyName}' not readable from class '{alias}'. MessageException ex = new MessageException(); ex.setMessage(NON_READABLE_PROPERTY_ERROR, new Object[] {propertyName, getAlias(instance)}); throw ex; } } return null; }
@Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { PropertyProxy p = data.get(rowIndex); if (p.getType().getSimpleName().equals(File.class.getSimpleName())) { p.setValue(new File((String) aValue)); } else if (p.getType().getSimpleName().equals(Double.class.getSimpleName())) { p.setValue(Double.valueOf((String) aValue)); } else if (p.getType().getSimpleName().equals(Boolean.class.getSimpleName())) { p.setValue(Boolean.valueOf((String) aValue)); } else if (p.getType().getSimpleName().equals(Long.class.getSimpleName())) { p.setValue(Long.valueOf((String) aValue)); } else { p.setValue(aValue); } fireTableDataChanged(); }