Java Code Examples for org.apache.commons.beanutils.PropertyUtils.isReadable()

The following are Jave code examples for showing how to use isReadable() of the org.apache.commons.beanutils.PropertyUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: helium   File: ExpedientConsultaInformeController.java   View Source Code Vote up 6 votes
private Map<String, Object> processarValorsFiltre(
		Object filtreCommand,
		List<TascaDadaDto> dadesFiltre,
		Map<String, Object> valors) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
	Map<String, Object> valorsPerService = new HashMap<String, Object>();
	for (TascaDadaDto dada: dadesFiltre) {
		String clau = (dada.getDefinicioProcesKey() == null) ? dada.getVarCodi() : dada.getDefinicioProcesKey() + "." + dada.getVarCodi();
		clau = clau.replace(
				ExpedientCamps.EXPEDIENT_PREFIX_JSP,
				ExpedientCamps.EXPEDIENT_PREFIX);
		if (CampTipusDto.BOOLEAN.equals(dada.getCampTipus()) && PropertyUtils.isReadable(filtreCommand, dada.getVarCodi())) {
			Boolean valor = (Boolean) PropertyUtils.getSimpleProperty(
					filtreCommand,
					dada.getVarCodi());
			valors.put(
					dada.getVarCodi(),
					valor);
		}
		valorsPerService.put(
				clau,
				valors.get(dada.getVarCodi()));
	}
	return valorsPerService;
}
 
Example 2
Project: helium   File: ExpedientConsultaLlistatController.java   View Source Code Vote up 6 votes
private Map<String, Object> processarValorsFiltre(
		Object filtreCommand,
		List<TascaDadaDto> dadesFiltre,
		Map<String, Object> valors) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
	Map<String, Object> valorsPerService = new HashMap<String, Object>();
	for (TascaDadaDto dada: dadesFiltre) {
		String clau = (dada.getDefinicioProcesKey() == null) ? dada.getVarCodi() : dada.getDefinicioProcesKey() + "." + dada.getVarCodi();
		clau = clau.replace(
				ExpedientCamps.EXPEDIENT_PREFIX_JSP,
				ExpedientCamps.EXPEDIENT_PREFIX);
		if (CampTipusDto.BOOLEAN.equals(dada.getCampTipus()) && PropertyUtils.isReadable(filtreCommand, dada.getVarCodi())) {
			Boolean valor = (Boolean) PropertyUtils.getSimpleProperty(
					filtreCommand,
					dada.getVarCodi());
			valors.put(
					dada.getVarCodi(),
					valor);
		}
		valorsPerService.put(
				clau,
				valors.get(dada.getVarCodi()));
	}
	return valorsPerService;
}
 
Example 3
Project: abina-common-util   File: ParamsUtils.java   View Source Code Vote up 6 votes
/**
 * 对象拷贝 数据对象空值不拷贝到目标对象
 * 
 * @param databean 待拷贝对象
 * @param tobean 目标对象
 * @throws NoSuchMethodException
 */
public static void copyBeanNotNull2Bean(Object databean, Object tobean) throws Exception {
	PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(databean);
	for (int i = 0; i < origDescriptors.length; i++) {
		String name = origDescriptors[i].getName();
		// String type = origDescriptors[i].getPropertyType().toString();
		if ("class".equals(name)) {
			continue; // No point in trying to set an object's class
		}
		if (PropertyUtils.isReadable(databean, name) && PropertyUtils.isWriteable(tobean, name)) {
			try {
				Object value = PropertyUtils.getSimpleProperty(databean, name);
				if (value != null) {
					getInstance().setSimpleProperty(tobean, name, value);
				}
			} catch (java.lang.IllegalArgumentException ie) {
				; // Should not happen
			} catch (Exception e) {
				; // Should not happen
			}

		}
	}
}
 
Example 4
Project: stallion-core   File: MappedModel.java   View Source Code Vote up 5 votes
public default Object get(Object key) {
    try {
        if (PropertyUtils.isReadable(this, key.toString())) {

            return PropertyUtils.getProperty(this, key.toString());
        }

        return getAttributes().get(key);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
Example 5
Project: tkhoon   File: ObjectUtil.java   View Source Code Vote up 5 votes
public static Object getFieldValue(Object obj, String fieldName) {
    Object propertyValue = null;
    try {
        if (PropertyUtils.isReadable(obj, fieldName)) {
            propertyValue = PropertyUtils.getProperty(obj, fieldName);
        }
    } catch (Exception e) {
        logger.error("获取成员变量出错!", e);
        throw new RuntimeException(e);
    }
    return propertyValue;
}
 
Example 6
Project: helium   File: ExpedientInformeController.java   View Source Code Vote up 5 votes
@SuppressWarnings("static-access")
private Map<String, Object> getValorsPerService(Object filtreCommand, List<TascaDadaDto> camps, Map<String, Object> valors) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
	Map<String, Object> valorsPerService = new HashMap<String, Object>();
	for (TascaDadaDto camp : camps) {
		String clau = (camp.getDefinicioProcesKey() == null) ? camp.getVarCodi() : camp.getDefinicioProcesKey() + "." + camp.getVarCodi();
		clau = camp.getVarCodi().replace(ExpedientCamps.EXPEDIENT_PREFIX_JSP, ExpedientCamps.EXPEDIENT_PREFIX);
		if (camp.getCampTipus().BOOLEAN.equals(camp.getCampTipus()) && PropertyUtils.isReadable(filtreCommand, camp.getVarCodi())) {
			Boolean valor = (Boolean) PropertyUtils.getSimpleProperty(filtreCommand, camp.getVarCodi());
			valors.put(camp.getVarCodi(), valor);
		}
		valorsPerService.put(clau, valors.get(camp.getVarCodi()));
	}
	return valorsPerService;
}
 
Example 7
Project: audible   File: TypeSafeCopy.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
public void copyProperties(Object dest, Object orig) throws IllegalAccessException, InvocationTargetException {
    PropertyDescriptor[] origDescriptors =
            PropertyUtils.getPropertyDescriptors(orig);
    for (PropertyDescriptor origDescriptor : origDescriptors) {
        String name = origDescriptor.getName();
        if ("class".equals(name)) {
            continue; // No point in trying to set an object's class
        }
        if (PropertyUtils.isReadable(orig, name) &&
                PropertyUtils.isWriteable(dest, name)) {


            try {
                Class origPropClass = PropertyUtils.getPropertyType(orig, name);
                Class destPropClass = PropertyUtils.getPropertyType(dest, name);

                if (destPropClass.isAssignableFrom(origPropClass)) {
                    Object value =
                            PropertyUtils.getSimpleProperty(orig, name);
                    BeanUtils.copyProperty(dest, name, value);
                }
            } catch (NoSuchMethodException e) {
                // Should not happen
            }
        }
    }
}
 
Example 8
Project: MMServerEngine   File: ObjectUtil.java   View Source Code Vote up 5 votes
/**
 * 获取成员变量
 */
public static Object getFieldValue(Object obj, String fieldName) {
    Object propertyValue = null;
    try {
        if (PropertyUtils.isReadable(obj, fieldName)) {
            propertyValue = PropertyUtils.getProperty(obj, fieldName);
        }
    } catch (Exception e) {
        logger.error("获取成员变量出错!", e);
        throw new RuntimeException(e);
    }
    return propertyValue;
}
 
Example 9
Project: CriteriaBuilder   File: CriteriaServiceImpl.java   View Source Code Vote up 4 votes
static boolean propertyExists(Object bean, String property) {
    return PropertyUtils.isReadable(bean, property) && 
           PropertyUtils.isWriteable(bean, property); 
}
 
Example 10
Project: stallion-core   File: MappedModel.java   View Source Code Vote up 4 votes
public default boolean containsKey(String key) {
    return getAttributes().containsKey(key) || PropertyUtils.isReadable(this, key);
}
 
Example 11
Project: stallion-core   File: MappedModel.java   View Source Code Vote up 4 votes
public default boolean containsKey(Object key) {
    return getAttributes().containsKey(key) || PropertyUtils.isReadable(this, key.toString());
}
 
Example 12
Project: TranskribusSwtGui   File: Utils.java   View Source Code Vote up 4 votes
public static boolean propertyExists(Object bean, String property) {
	return PropertyUtils.isReadable(bean, property) && PropertyUtils.isWriteable(bean, property);
}
 
Example 13
Project: airtable.java   File: Table.java   View Source Code Vote up 2 votes
/**
 * Check if writable property exists.
 *
 * @param bean bean to inspect
 * @param property name of property
 * @return true if writable property exists.
 */
private static boolean propertyExists(Object bean, String property) {
    return PropertyUtils.isReadable(bean, property)
            && PropertyUtils.isWriteable(bean, property);
}