/** * Returns the canonical property name. * @see org.springframework.beans.PropertyAccessorUtils#canonicalPropertyName */ @Override protected String canonicalFieldName(String field) { return PropertyAccessorUtils.canonicalPropertyName(field); }
/** * Returns the canonical property name. * @see org.springframework.beans.PropertyAccessorUtils#canonicalPropertyName */ @Override protected String canonicalFieldName(String field) { return PropertyAccessorUtils.canonicalPropertyName(field); }
/** * Determine the canonical names for the given property paths. * @param propertyNames the bean property paths (as array) * @return the canonical representation of the property paths * (as array of the same size) * @see #canonicalPropertyName(String) */ @Nullable public static String[] canonicalPropertyNames(@Nullable String[] propertyNames) { if (propertyNames == null) { return null; } String[] result = new String[propertyNames.length]; for (int i = 0; i < propertyNames.length; i++) { result[i] = canonicalPropertyName(propertyNames[i]); } return result; }
/** * Determine the canonical names for the given property paths. * @param propertyNames the bean property paths (as array) * @return the canonical representation of the property paths * (as array of the same size) * @see #canonicalPropertyName(String) */ @Nullable public static String[] canonicalPropertyNames(@Nullable String[] propertyNames) { if (propertyNames == null) { return null; } String[] result = new String[propertyNames.length]; for (int i = 0; i < propertyNames.length; i++) { result[i] = canonicalPropertyName(propertyNames[i]); } return result; }
@Test public void testCanonicalPropertyName() { assertEquals("map", PropertyAccessorUtils.canonicalPropertyName("map")); assertEquals("map[key1]", PropertyAccessorUtils.canonicalPropertyName("map[key1]")); assertEquals("map[key1]", PropertyAccessorUtils.canonicalPropertyName("map['key1']")); assertEquals("map[key1]", PropertyAccessorUtils.canonicalPropertyName("map[\"key1\"]")); assertEquals("map[key1][key2]", PropertyAccessorUtils.canonicalPropertyName("map[key1][key2]")); assertEquals("map[key1][key2]", PropertyAccessorUtils.canonicalPropertyName("map['key1'][\"key2\"]")); assertEquals("map[key1].name", PropertyAccessorUtils.canonicalPropertyName("map[key1].name")); assertEquals("map[key1].name", PropertyAccessorUtils.canonicalPropertyName("map['key1'].name")); assertEquals("map[key1].name", PropertyAccessorUtils.canonicalPropertyName("map[\"key1\"].name")); }
/** * Check the given property values against the allowed fields, * removing values for fields that are not allowed. * @param mpvs the property values to be bound (can be modified) * @see #getAllowedFields * @see #isAllowed(String) */ protected void checkAllowedFields(MutablePropertyValues mpvs) { PropertyValue[] pvs = mpvs.getPropertyValues(); for (PropertyValue pv : pvs) { String field = PropertyAccessorUtils.canonicalPropertyName(pv.getName()); if (!isAllowed(field)) { mpvs.removePropertyValue(pv); getBindingResult().recordSuppressedField(field); if (logger.isDebugEnabled()) { logger.debug("Field [" + field + "] has been removed from PropertyValues " + "and will not be bound, because it has not been found in the list of allowed fields"); } } } }
PropertyValue[] pvs = mpvs.getPropertyValues(); for (PropertyValue pv : pvs) { String canonicalName = PropertyAccessorUtils.canonicalPropertyName(pv.getName()); propertyValues.put(canonicalName, pv);
/** * Check the given property values against the allowed fields, * removing values for fields that are not allowed. * @param mpvs the property values to be bound (can be modified) * @see #getAllowedFields * @see #isAllowed(String) */ protected void checkAllowedFields(MutablePropertyValues mpvs) { PropertyValue[] pvs = mpvs.getPropertyValues(); for (PropertyValue pv : pvs) { String field = PropertyAccessorUtils.canonicalPropertyName(pv.getName()); if (!isAllowed(field)) { mpvs.removePropertyValue(pv); getBindingResult().recordSuppressedField(field); if (logger.isDebugEnabled()) { logger.debug("Field [" + field + "] has been removed from PropertyValues " + "and will not be bound, because it has not been found in the list of allowed fields"); } } } }
PropertyValue[] pvs = mpvs.getPropertyValues(); for (PropertyValue pv : pvs) { String canonicalName = PropertyAccessorUtils.canonicalPropertyName(pv.getName()); propertyValues.put(canonicalName, pv);
/** * Determine the canonical names for the given property paths. * @param propertyNames the bean property paths (as array) * @return the canonical representation of the property paths * (as array of the same size) * @see #canonicalPropertyName(String) */ public static String[] canonicalPropertyNames(String[] propertyNames) { if (propertyNames == null) { return null; } String[] result = new String[propertyNames.length]; for (int i = 0; i < propertyNames.length; i++) { result[i] = canonicalPropertyName(propertyNames[i]); } return result; }
/** * Returns the canonical property name. * @see org.springframework.beans.PropertyAccessorUtils#canonicalPropertyName */ @Override protected String canonicalFieldName(String field) { return PropertyAccessorUtils.canonicalPropertyName(field); }
/** * Determine the canonical names for the given property paths. * @param propertyNames the bean property paths (as array) * @return the canonical representation of the property paths * (as array of the same size) * @see #canonicalPropertyName(String) */ public static String[] canonicalPropertyNames(String[] propertyNames) { if (propertyNames == null) { return null; } String[] result = new String[propertyNames.length]; for (int i = 0; i < propertyNames.length; i++) { result[i] = canonicalPropertyName(propertyNames[i]); } return result; }
/** * <p>Constructor for PropertyPath.</p> * * @param nestedPath a {@link java.lang.String} object. */ public PropertyPath(String nestedPath) { String canonicalPath = PropertyAccessorUtils.canonicalPropertyName(nestedPath); int lastIndex = PropertyAccessorUtils.getLastNestedPropertySeparatorIndex(canonicalPath); if (lastIndex < 0) { propertyName = PropertyAccessorUtils.getPropertyName(canonicalPath); key = computeKey(canonicalPath); } else { parent = new PropertyPath(canonicalPath.substring(0, lastIndex)); String lastProperty = canonicalPath.substring(lastIndex+1); propertyName = PropertyAccessorUtils.getPropertyName(lastProperty); key = computeKey(lastProperty); } }
PropertyValue[] pvs = mpvs.getPropertyValues(); for (PropertyValue pv : pvs) { String canonicalName = PropertyAccessorUtils.canonicalPropertyName(pv.getName()); propertyValues.put(canonicalName, pv);
String propertyName = PropertyAccessorUtils.canonicalPropertyName(property.getName()); Object propertyValue = target.getPropertyValue(propertyName);