Top Description Fields Constructors Methods
org.springframework.beans.propertyeditors

public Class ResourceBundleEditor

extends PropertyEditorSupport
Class Inheritance
Imports
java.beans.PropertyEditorSupport, java.util.Locale, .ResourceBundle, org.springframework.util.Assert, .StringUtils

java.beans.PropertyEditor implementation for standard JDK ResourceBundles.

Only supports conversion from a String, but not to a String. Find below some examples of using this class in a (properly configured) Spring container using XML-based metadata:

 <bean id="errorDialog" class="...">
   <!--
       the 'messages' property is of type java.util.ResourceBundle.
       the 'DialogMessages.properties' file exists at the root of the CLASSPATH
   -->
   <property name="messages" value="DialogMessages"/>
</bean>
 <bean id="errorDialog" class="...">
   <!--
       the 'DialogMessages.properties' file exists in the 'com/messages' package
   -->
   <property name="messages" value="com/messages/DialogMessages"/>
</bean>

A 'properly configured' Spring container might contain a org.springframework.beans.factory.config.CustomEditorConfigurer definition such that the conversion can be effected transparently:

 <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
   <property name="customEditors">
       <map>
           <entry key="java.util.ResourceBundle">
               <bean class="org.springframework.beans.propertyeditors.ResourceBundleEditor"/>
           </entry>
       </map>
   </property>
</bean>

Please note that this java.beans.PropertyEditor is not registered by default with any of the Spring infrastructure.

Thanks to David Leal Valmana for the suggestion and initial prototype.

Authors
Rick Evans, Juergen Hoeller
Since
2.0

Field Summary

Modifier and TypeField and Description
public static final String
BASE_NAME_SEPARATOR

The separator used to distinguish between the base name and the locale (if any) when converting from a String.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
setAsText(String
The string to be parsed.
text
)

Overrides java.beans.PropertyEditorSupport.setAsText.

Implements java.beans.PropertyEditor.setAsText.

Sets the property value by parsing a given String.
Inherited from java.beans.PropertyEditorSupport:
addPropertyChangeListenerfirePropertyChangegetAsTextgetCustomEditorgetJavaInitializationStringgetSourcegetTagsgetValueisPaintablepaintValueremovePropertyChangeListenersetSourcesetValuesupportsCustomEditor

Field Detail

BASE_NAME_SEPARATORback to summary
public static final String BASE_NAME_SEPARATOR

The separator used to distinguish between the base name and the locale (if any) when converting from a String.

Constructor Detail

ResourceBundleEditorback to summary
public ResourceBundleEditor()

Method Detail

setAsTextback to summary
public void setAsText(String text) throws IllegalArgumentException

Overrides java.beans.PropertyEditorSupport.setAsText.

Implements java.beans.PropertyEditor.setAsText.

Doc from java.beans.PropertyEditorSupport.setAsText.

Sets the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String is badly formatted or if this kind of property can't be expressed as text.

Parameters
text:String

The string to be parsed.

Annotations
@Override