/** * Returns an indexed property from the object we're validating. * * @param bean The bean to extract the indexed values from. * @throws ValidatorException If there's an error looking up the property * or, the property found is not indexed. */ Object[] getIndexedProperty(Object bean) throws ValidatorException { Object indexedProperty = null; try { indexedProperty = PropertyUtils.getProperty(bean, this.getIndexedListProperty()); } catch(IllegalAccessException e) { throw new ValidatorException(e.getMessage()); } catch(InvocationTargetException e) { throw new ValidatorException(e.getMessage()); } catch(NoSuchMethodException e) { throw new ValidatorException(e.getMessage()); } if (indexedProperty instanceof Collection) { return ((Collection<?>) indexedProperty).toArray(); } else if (indexedProperty.getClass().isArray()) { return (Object[]) indexedProperty; } else { throw new ValidatorException(this.getKey() + " is not indexed"); } } /**
/** * Returns the size of an indexed property from the object we're validating. * * @param bean The bean to extract the indexed values from. * @throws ValidatorException If there's an error looking up the property * or, the property found is not indexed. */ private int getIndexedPropertySize(Object bean) throws ValidatorException { Object indexedProperty = null; try { indexedProperty = PropertyUtils.getProperty(bean, this.getIndexedListProperty()); } catch(IllegalAccessException e) { throw new ValidatorException(e.getMessage()); } catch(InvocationTargetException e) { throw new ValidatorException(e.getMessage()); } catch(NoSuchMethodException e) { throw new ValidatorException(e.getMessage()); } if (indexedProperty == null) { return 0; } else if (indexedProperty instanceof Collection) { return ((Collection<?>)indexedProperty).size(); } else if (indexedProperty.getClass().isArray()) { return ((Object[])indexedProperty).length; } else { throw new ValidatorException(this.getKey() + " is not indexed"); } }
protected String getFieldKey(Field field, PropertyDesc propDesc) { String key = getFieldProperty(field, propDesc); if (!StringUtil.isEmpty(field.getIndexedListProperty())) { key = field.getIndexedListProperty() + "[]." + key; } return key; }
/** * Returns the size of an indexed property from the object we're validating. * * @param bean The bean to extract the indexed values from. * @throws ValidatorException If there's an error looking up the property * or, the property found is not indexed. */ private int getIndexedPropertySize(Object bean) throws ValidatorException { Object indexedProperty = null; try { indexedProperty = PropertyUtils.getProperty(bean, this.getIndexedListProperty()); } catch(IllegalAccessException e) { throw new ValidatorException(e.getMessage()); } catch(InvocationTargetException e) { throw new ValidatorException(e.getMessage()); } catch(NoSuchMethodException e) { throw new ValidatorException(e.getMessage()); } if (indexedProperty == null) { return 0; } else if (indexedProperty instanceof Collection) { return ((Collection<?>)indexedProperty).size(); } else if (indexedProperty.getClass().isArray()) { return ((Object[])indexedProperty).length; } else { throw new ValidatorException(this.getKey() + " is not indexed"); } }
/** * Returns an indexed property from the object we're validating. * * @param bean The bean to extract the indexed values from. * @throws ValidatorException If there's an error looking up the property * or, the property found is not indexed. */ Object[] getIndexedProperty(Object bean) throws ValidatorException { Object indexedProperty = null; try { indexedProperty = PropertyUtils.getProperty(bean, this.getIndexedListProperty()); } catch(IllegalAccessException e) { throw new ValidatorException(e.getMessage()); } catch(InvocationTargetException e) { throw new ValidatorException(e.getMessage()); } catch(NoSuchMethodException e) { throw new ValidatorException(e.getMessage()); } if (indexedProperty instanceof Collection) { return ((Collection<?>) indexedProperty).toArray(); } else if (indexedProperty.getClass().isArray()) { return (Object[]) indexedProperty; } else { throw new ValidatorException(this.getKey() + " is not indexed"); } } /**
/** * Returns the size of an indexed property from the object we're validating. * * @param bean The bean to extract the indexed values from. * @throws ValidatorException If there's an error looking up the property * or, the property found is not indexed. */ private int getIndexedPropertySize(Object bean) throws ValidatorException { Object indexedProperty = null; try { indexedProperty = PropertyUtils.getProperty(bean, this.getIndexedListProperty()); } catch(IllegalAccessException e) { throw new ValidatorException(e.getMessage()); } catch(InvocationTargetException e) { throw new ValidatorException(e.getMessage()); } catch(NoSuchMethodException e) { throw new ValidatorException(e.getMessage()); } if (indexedProperty == null) { return 0; } else if (indexedProperty instanceof Collection) { return ((Collection)indexedProperty).size(); } else if (indexedProperty.getClass().isArray()) { return ((Object[])indexedProperty).length; } else { throw new ValidatorException(this.getKey() + " is not indexed"); } }
/** * Returns an indexed property from the object we're validating. * * @param bean The bean to extract the indexed values from. * @throws ValidatorException If there's an error looking up the property * or, the property found is not indexed. */ Object[] getIndexedProperty(Object bean) throws ValidatorException { Object indexedProperty = null; try { indexedProperty = PropertyUtils.getProperty(bean, this.getIndexedListProperty()); } catch(IllegalAccessException e) { throw new ValidatorException(e.getMessage()); } catch(InvocationTargetException e) { throw new ValidatorException(e.getMessage()); } catch(NoSuchMethodException e) { throw new ValidatorException(e.getMessage()); } if (indexedProperty instanceof Collection) { return ((Collection) indexedProperty).toArray(); } else if (indexedProperty.getClass().isArray()) { return (Object[]) indexedProperty; } else { throw new ValidatorException(this.getKey() + " is not indexed"); } } /**
protected Field createField(Field field, PropertyDesc propDesc, String depends) { Field newField = new Field(); newField.setDepends(depends); String property = getFieldProperty(field, propDesc); if (propDesc.getPropertyType().isArray()) { newField.setProperty(""); newField.setIndexedListProperty(property); } else { newField.setProperty(property); newField.setIndexedListProperty(field.getIndexedListProperty()); } return newField; }