/** * Specify the property path to apply to the target. * @param propertyPath the property path, potentially nested * (e.g. "age" or "spouse.age") */ public void setPropertyPath(String propertyPath) { this.propertyPath = StringUtils.trimAllWhitespace(propertyPath); }
/** * Set a fully qualified static field name to retrieve, * e.g. "example.MyExampleClass.MY_EXAMPLE_FIELD". * Convenient alternative to specifying targetClass and targetField. * @see #setTargetClass * @see #setTargetField */ public void setStaticField(String staticField) { this.staticField = StringUtils.trimAllWhitespace(staticField); }
/** * Specify the name of a target bean to apply the property path to. * Alternatively, specify a target object directly. * @param targetBeanName the bean name to be looked up in the * containing bean factory (e.g. "testBean") * @see #setTargetObject */ public void setTargetBeanName(String targetBeanName) { this.targetBeanName = StringUtils.trimAllWhitespace(targetBeanName); }
/** * Set the name of the field to be retrieved. * Refers to either a static field or a non-static field, * depending on a target object being set. * @see #setTargetClass * @see #setTargetObject */ public void setTargetField(@Nullable String targetField) { this.targetField = (targetField != null ? StringUtils.trimAllWhitespace(targetField) : null); }
/** * Set a fully qualified static field name to retrieve, * e.g. "example.MyExampleClass.MY_EXAMPLE_FIELD". * Convenient alternative to specifying targetClass and targetField. * @see #setTargetClass * @see #setTargetField */ public void setStaticField(String staticField) { this.staticField = StringUtils.trimAllWhitespace(staticField); }
/** * Specify the name of a target bean to apply the property path to. * Alternatively, specify a target object directly. * @param targetBeanName the bean name to be looked up in the * containing bean factory (e.g. "testBean") * @see #setTargetObject */ public void setTargetBeanName(String targetBeanName) { this.targetBeanName = StringUtils.trimAllWhitespace(targetBeanName); }
/** * Specify the property path to apply to the target. * @param propertyPath the property path, potentially nested * (e.g. "age" or "spouse.age") */ public void setPropertyPath(String propertyPath) { this.propertyPath = StringUtils.trimAllWhitespace(propertyPath); }
/** * Set the name of the field to be retrieved. * Refers to either a static field or a non-static field, * depending on a target object being set. * @see #setTargetClass * @see #setTargetObject */ public void setTargetField(@Nullable String targetField) { this.targetField = (targetField != null ? StringUtils.trimAllWhitespace(targetField) : null); }
/** * The bean name of this PropertyPathFactoryBean will be interpreted * as "beanName.property" pattern, if neither "targetObject" nor * "targetBeanName" nor "propertyPath" have been specified. * This allows for concise bean definitions with just an id/name. */ @Override public void setBeanName(String beanName) { this.beanName = StringUtils.trimAllWhitespace(BeanFactoryUtils.originalBeanName(beanName)); }
/** * The bean name of this FieldRetrievingFactoryBean will be interpreted * as "staticField" pattern, if neither "targetClass" nor "targetObject" * nor "targetField" have been specified. * This allows for concise bean definitions with just an id/name. */ @Override public void setBeanName(String beanName) { this.beanName = StringUtils.trimAllWhitespace(BeanFactoryUtils.originalBeanName(beanName)); }
/** * The bean name of this FieldRetrievingFactoryBean will be interpreted * as "staticField" pattern, if neither "targetClass" nor "targetObject" * nor "targetField" have been specified. * This allows for concise bean definitions with just an id/name. */ @Override public void setBeanName(String beanName) { this.beanName = StringUtils.trimAllWhitespace(BeanFactoryUtils.originalBeanName(beanName)); }
/** * Return the set of active profiles as explicitly set through * {@link #setActiveProfiles} or if the current set of active profiles * is empty, check for the presence of the {@value #ACTIVE_PROFILES_PROPERTY_NAME} * property and assign its value to the set of active profiles. * @see #getActiveProfiles() * @see #ACTIVE_PROFILES_PROPERTY_NAME */ protected Set<String> doGetActiveProfiles() { synchronized (this.activeProfiles) { if (this.activeProfiles.isEmpty()) { String profiles = getProperty(ACTIVE_PROFILES_PROPERTY_NAME); if (StringUtils.hasText(profiles)) { setActiveProfiles(StringUtils.commaDelimitedListToStringArray( StringUtils.trimAllWhitespace(profiles))); } } return this.activeProfiles; } }
/** * The bean name of this PropertyPathFactoryBean will be interpreted * as "beanName.property" pattern, if neither "targetObject" nor * "targetBeanName" nor "propertyPath" have been specified. * This allows for concise bean definitions with just an id/name. */ @Override public void setBeanName(String beanName) { this.beanName = StringUtils.trimAllWhitespace(BeanFactoryUtils.originalBeanName(beanName)); }
/** * Return the set of default profiles explicitly set via * {@link #setDefaultProfiles(String...)} or if the current set of default profiles * consists only of {@linkplain #getReservedDefaultProfiles() reserved default * profiles}, then check for the presence of the * {@value #DEFAULT_PROFILES_PROPERTY_NAME} property and assign its value (if any) * to the set of default profiles. * @see #AbstractEnvironment() * @see #getDefaultProfiles() * @see #DEFAULT_PROFILES_PROPERTY_NAME * @see #getReservedDefaultProfiles() */ protected Set<String> doGetDefaultProfiles() { synchronized (this.defaultProfiles) { if (this.defaultProfiles.equals(getReservedDefaultProfiles())) { String profiles = getProperty(DEFAULT_PROFILES_PROPERTY_NAME); if (StringUtils.hasText(profiles)) { setDefaultProfiles(StringUtils.commaDelimitedListToStringArray( StringUtils.trimAllWhitespace(profiles))); } } return this.defaultProfiles; } }
@Override public void setAsText(String text) throws java.lang.IllegalArgumentException { // Trim all whitespace String content = StringUtils.trimAllWhitespace(text); if (!StringUtils.hasText(content)) { // No content , ignore directly return; } // replace "=" to "," content = StringUtils.replace(content, "=", ","); // replace ":" to "," content = StringUtils.replace(content, ":", ","); // String[] to Map Map<String, String> parameters = CollectionUtils.toStringMap(commaDelimitedListToStringArray(content)); setValue(parameters); } });
@Override public void setAsText(String text) throws java.lang.IllegalArgumentException { // Trim all whitespace String content = StringUtils.trimAllWhitespace(text); if (!StringUtils.hasText(content)) { // No content , ignore directly return; } // replace "=" to "," content = StringUtils.replace(content, "=", ","); // replace ":" to "," content = StringUtils.replace(content, ":", ","); // String[] to Map Map<String, String> parameters = CollectionUtils.toStringMap(commaDelimitedListToStringArray(content)); setValue(parameters); } });
@Override public void setAsText(String text) throws java.lang.IllegalArgumentException { // Trim all whitespace String content = StringUtils.trimAllWhitespace(text); if (!StringUtils.hasText(content)) { // No content , ignore directly return; } // replace "=" to "," content = StringUtils.replace(content, "=", ","); // replace ":" to "," content = StringUtils.replace(content, ":", ","); // String[] to Map Map<String, String> parameters = CollectionUtils.toStringMap(commaDelimitedListToStringArray(content)); setValue(parameters); } });
@Override public void setAsText(String text) throws java.lang.IllegalArgumentException { // Trim all whitespace String content = StringUtils.trimAllWhitespace(text); if (!StringUtils.hasText(content)) { // No content , ignore directly return; } // replace "=" to "," content = StringUtils.replace(content, "=", ","); // replace ":" to "," content = StringUtils.replace(content, ":", ","); // String[] to Map Map<String, String> parameters = CollectionUtils.toStringMap(commaDelimitedListToStringArray(content)); setValue(parameters); } });
@Test public void testTrimAllWhitespace() { assertEquals("", StringUtils.trimAllWhitespace("")); assertEquals("", StringUtils.trimAllWhitespace(" ")); assertEquals("", StringUtils.trimAllWhitespace("\t")); assertEquals("a", StringUtils.trimAllWhitespace(" a")); assertEquals("a", StringUtils.trimAllWhitespace("a ")); assertEquals("a", StringUtils.trimAllWhitespace(" a ")); assertEquals("ab", StringUtils.trimAllWhitespace(" a b ")); assertEquals("abc", StringUtils.trimAllWhitespace(" a b c ")); }
Number number = numberFormat.parse(StringUtils.trimAllWhitespace(text)); return convertNumberToTargetClass(number, targetClass);