@Override public void setAsText(String text) throws IllegalArgumentException { Assert.hasText(text, "'text' must not be empty"); String name = text.trim(); int separator = name.indexOf(BASE_NAME_SEPARATOR); if (separator == -1) { setValue(ResourceBundle.getBundle(name)); } else { // The name potentially contains locale information String baseName = name.substring(0, separator); if (!StringUtils.hasText(baseName)) { throw new IllegalArgumentException("Invalid ResourceBundle name: '" + text + "'"); } String localeString = name.substring(separator + 1); Locale locale = StringUtils.parseLocaleString(localeString); setValue(locale != null ? ResourceBundle.getBundle(baseName, locale) : ResourceBundle.getBundle(baseName)); } }
@Override public void setAsText(String text) throws IllegalArgumentException { Assert.hasText(text, "'text' must not be empty"); String name = text.trim(); int separator = name.indexOf(BASE_NAME_SEPARATOR); if (separator == -1) { setValue(ResourceBundle.getBundle(name)); } else { // The name potentially contains locale information String baseName = name.substring(0, separator); if (!StringUtils.hasText(baseName)) { throw new IllegalArgumentException("Invalid ResourceBundle name: '" + text + "'"); } String localeString = name.substring(separator + 1); Locale locale = StringUtils.parseLocaleString(localeString); setValue(locale != null ? ResourceBundle.getBundle(baseName, locale) : ResourceBundle.getBundle(baseName)); } }
@Override public void setAsText(String text) throws IllegalArgumentException { Assert.hasText(text, "'text' must not be empty"); ResourceBundle bundle; String rawBaseName = text.trim(); int indexOfBaseNameSeparator = rawBaseName.indexOf(BASE_NAME_SEPARATOR); if (indexOfBaseNameSeparator == -1) { bundle = ResourceBundle.getBundle(rawBaseName); } else { // it potentially has locale information String baseName = rawBaseName.substring(0, indexOfBaseNameSeparator); if (!StringUtils.hasText(baseName)) { throw new IllegalArgumentException("Bad ResourceBundle name : received '" + text + "' as argument to 'setAsText(String value)'."); } String localeString = rawBaseName.substring(indexOfBaseNameSeparator + 1); Locale locale = StringUtils.parseLocaleString(localeString); bundle = (StringUtils.hasText(localeString)) ? ResourceBundle.getBundle(baseName, locale) : ResourceBundle.getBundle(baseName); } setValue(bundle); }
@Override public void setAsText(String text) throws IllegalArgumentException { Assert.hasText(text, "'text' must not be empty"); String name = text.trim(); int separator = name.indexOf(BASE_NAME_SEPARATOR); if (separator == -1) { setValue(ResourceBundle.getBundle(name)); } else { // The name potentially contains locale information String baseName = name.substring(0, separator); if (!StringUtils.hasText(baseName)) { throw new IllegalArgumentException("Invalid ResourceBundle name: '" + text + "'"); } String localeString = name.substring(separator + 1); Locale locale = StringUtils.parseLocaleString(localeString); setValue(locale != null ? ResourceBundle.getBundle(baseName, locale) : ResourceBundle.getBundle(baseName)); } }