src/main/java/org/jboss/util/propertyeditor/PropertyEditors.java
public static void mapJavaBeanProperties(Object bean, Properties beanProps, boolean isStrict)
      throws IntrospectionException
   {

      HashMap<String, PropertyDescriptor> propertyMap = new HashMap<String, PropertyDescriptor>();
      BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass());
      PropertyDescriptor[] props = beanInfo.getPropertyDescriptors();
      for (int p = 0; p < props.length; p++)
      {
         String fieldName = props[p].getName();
         propertyMap.put(fieldName, props[p]);
      }

      boolean trace = log.isTraceEnabled();
      Iterator keys = beanProps.keySet().iterator();
      if( trace )
         log.trace("Mapping properties for bean: "+bean);
      while( keys.hasNext() )
      {
         String name = (String) keys.next();
         String text = beanProps.getProperty(name);
         PropertyDescriptor pd = propertyMap.get(name);
         if (pd == null)
         {
            /* Try the property name with the first char uppercased to handle
            a property name like dLQMaxResent whose expected introspected
            property name would be DLQMaxResent since the JavaBean
            Introspector would view setDLQMaxResent as the setter for a
            DLQMaxResent property whose Introspector.decapitalize() method
            would also return "DLQMaxResent".
            */
            if (name.length() > 1)
            {
               char first = name.charAt(0);
               String exName = Character.toUpperCase(first) + name.substring(1);
               pd = propertyMap.get(exName);
               
               // Be lenient and check the other way around, e.g. ServerName -> serverName
               if (pd == null)
               {
                  exName = Character.toLowerCase(first) + name.substring(1);
                  pd = propertyMap.get(exName);
               }
            }

            if (pd == null)
            {
               if (isStrict)
               {
                  String msg = "No property found for: "+name+" on JavaBean: "+bean;
                  throw new IntrospectionException(msg);
               }
               else
               {
                  // since is not strict, ignore that this property was not found
                  continue;
               }
            }
         }
         Method setter = pd.getWriteMethod();
         if( trace )
            log.trace("Property editor found for: "+name+", editor: "+pd+", setter: "+setter);
         if (setter != null)
         {
            Class<?> ptype = pd.getPropertyType();
            PropertyEditor editor = PropertyEditorManager.findEditor(ptype);
            if (editor == null)
            {
               if( trace )
                  log.trace("Failed to find property editor for: "+name);
            }
            try
            {
               editor.setAsText(text);
               Object args[] = {editor.getValue()};
               setter.invoke(bean, args);
            }
            catch (Exception e)
            {
               if( trace )
                  log.trace("Failed to write property", e);
            }
         }
      }
   }
public static void mapJavaBeanProperties(Object bean, Properties beanProps, boolean isStrict)
      throws IntrospectionException
   {

      HashMap<String, PropertyDescriptor> propertyMap = new HashMap<String, PropertyDescriptor>();
      BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass());
      PropertyDescriptor[] props = beanInfo.getPropertyDescriptors();
      for (int p = 0; p < props.length; p++)
      {
         String fieldName = props[p].getName();
         propertyMap.put(fieldName, props[p]);
      }

      boolean trace = log.isTraceEnabled();
      Iterator keys = beanProps.keySet().iterator();
      if( trace )
         log.trace("Mapping properties for bean: "+bean);
      while( keys.hasNext() )
      {
         String name = (String) keys.next();
         String text = beanProps.getProperty(name);
         PropertyDescriptor pd = propertyMap.get(name);
         if (pd == null)
         {
            /* Try the property name with the first char uppercased to handle
            a property name like dLQMaxResent whose expected introspected
            property name would be DLQMaxResent since the JavaBean
            Introspector would view setDLQMaxResent as the setter for a
            DLQMaxResent property whose Introspector.decapitalize() method
            would also return "DLQMaxResent".
            */
            if (name.length() > 1)
            {
               char first = name.charAt(0);
               String exName = Character.toUpperCase(first) + name.substring(1);
               pd = propertyMap.get(exName);
               
               // Be lenient and check the other way around, e.g. ServerName -> serverName
               if (pd == null)
               {
                  exName = Character.toLowerCase(first) + name.substring(1);
                  pd = propertyMap.get(exName);
               }
            }

            if (pd == null)
            {
               if (isStrict)
               {
                  String msg = "No property found for: "+name+" on JavaBean: "+bean;
                  throw new IntrospectionException(msg);
               }
               else
               {
                  // since is not strict, ignore that this property was not found
                  continue;
               }
            }
         }
         Method setter = pd.getWriteMethod();
         if( trace )
            log.trace("Property editor found for: "+name+", editor: "+pd+", setter: "+setter);
         if (setter != null)
         {
            Class<?> ptype = pd.getPropertyType();
            PropertyEditor editor = PropertyEditorManager.findEditor(ptype);
            if (editor == null)
            {
               if( trace )
                  log.trace("Failed to find property editor for: "+name);
            }
            try
            {
               editor.setAsText(text);
               Object args[] = {editor.getValue()};
               setter.invoke(bean, args);
            }
            catch (Exception e)
            {
               if( trace )
                  log.trace("Failed to write property", e);
            }
         }
      }
   }
public static void mapJavaBeanProperties ( Object bean , Properties beanProps , boolean isStrict ) throws IntrospectionException { HashMap < String , PropertyDescriptor > propertyMap = new HashMap < String , PropertyDescriptor > ( ) ; BeanInfo beanInfo = Introspector . getBeanInfo ( bean . getClass ( ) ) ; PropertyDescriptor [ ] props = beanInfo . getPropertyDescriptors ( ) ; for ( int p = 0 ; p < props . length ; p ++ ) { String fieldName = props [ p ] . getName ( ) ; propertyMap . put ( fieldName , props [ p ] ) ; } boolean trace = log . isTraceEnabled ( ) ; Iterator keys = beanProps . keySet ( ) . iterator ( ) ; if ( trace ) log . trace ( "Mapping properties for bean: " + bean ) ; while ( keys . hasNext ( ) ) { String name = ( String ) keys . next ( ) ; String text = beanProps . getProperty ( name ) ; PropertyDescriptor pd = propertyMap . get ( name ) ; if ( pd == null ) { /* Try the property name with the first char uppercased to handle
            a property name like dLQMaxResent whose expected introspected
            property name would be DLQMaxResent since the JavaBean
            Introspector would view setDLQMaxResent as the setter for a
            DLQMaxResent property whose Introspector.decapitalize() method
            would also return "DLQMaxResent".
            */ if ( name . length ( ) > 1 ) { char first = name . charAt ( 0 ) ; String exName = Character . toUpperCase ( first ) + name . substring ( 1 ) ; pd = propertyMap . get ( exName ) ; // Be lenient and check the other way around, e.g. ServerName -> serverName if ( pd == null ) { exName = Character . toLowerCase ( first ) + name . substring ( 1 ) ; pd = propertyMap . get ( exName ) ; } } if ( pd == null ) { if ( isStrict ) { String msg = "No property found for: " + name + " on JavaBean: " + bean ; throw new IntrospectionException ( msg ) ; } else { // since is not strict, ignore that this property was not found continue ; } } } Method setter = pd . getWriteMethod ( ) ; if ( trace ) log . trace ( "Property editor found for: " + name + ", editor: " + pd + ", setter: " + setter ) ; if ( setter != null ) { Class < ? > ptype = pd . getPropertyType ( ) ; PropertyEditor editor = PropertyEditorManager . findEditor ( ptype ) ; if ( editor == null ) { if ( trace ) log . trace ( "Failed to find property editor for: " + name ) ; } try { editor . setAsText ( text ) ; Object args [ ] = { editor . getValue ( ) } ; setter . invoke ( bean , args ) ; } catch ( Exception e ) { if ( trace ) log . trace ( "Failed to write property" , e ) ; } } } }
This method takes the properties found in the given beanProps
to the bean using the property editor registered for the property.
Any property in beanProps that does not have an associated java bean
property will result in an IntrospectionException. The string property
values are converted to the true java bean property type using the
java bean PropertyEditor framework. If a property in beanProps does not
have a PropertyEditor registered it will be ignored.

@param bean - the java bean instance to apply the properties to
@param beanProps - map of java bean property name to property value.
@param isStrict - indicates if should throw exception if bean property can not
be matched.  True for yes, false for no.
@throws IntrospectionException thrown on introspection of bean and if
a property in beanProps does not map to a property of bean.
This method takes the properties found in the given beanProps to the bean using the property editor registered for the property . Any property in beanProps that does not have an associated java bean property will result in an IntrospectionException . The string property values are converted to the true java bean property type using the java bean PropertyEditor framework . If a property in beanProps does not have a PropertyEditor registered it will be ignored .