Class ResourceBundleEditor

  • java.lang.Object
    • java.beans.PropertyEditorSupport
      • org.springframework.beans.propertyeditors.ResourceBundleEditor
  • All Implemented Interfaces:

    public class ResourceBundleEditor
    extends java.beans.PropertyEditorSupport
    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 '' file exists at the root of the CLASSPATH
        <property name="messages" value="DialogMessages"/>
     <bean id="errorDialog" class="...">
            the '' file exists in the 'com/messages' package
        <property name="messages" value="com/messages/DialogMessages"/>

    A 'properly configured' Spring container might contain a CustomEditorConfigurer definition such that the conversion can be effected transparently:

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

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

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

    Rick Evans, Juergen Hoeller
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void setAsText(java.lang.String text) 
      • Methods inherited from class java.beans.PropertyEditorSupport

        addPropertyChangeListener, firePropertyChange, getAsText, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditor
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • ResourceBundleEditor

        public ResourceBundleEditor()
    • Method Detail

      • setAsText

        public void setAsText(java.lang.String text)
                       throws java.lang.IllegalArgumentException
        Specified by:
        setAsText in interface java.beans.PropertyEditor
        setAsText in class java.beans.PropertyEditorSupport