Package org.apache.commons.beanutils

Examples of org.apache.commons.beanutils.PropertyUtilsBean


            if (log.isTraceEnabled())
                log.trace(bean.getClass().getName() + ": setting property '" + property + "' to " + String.valueOf(value));
            */
           
            // Get Property Value
            PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
            return pub.getSimpleProperty(bean, property);
           
            // Check result
            /*
             * String res = BeanUtils.getProperty(bean, property); if (res!=value && res.equals(String.valueOf(value))==false) { //
             * Property value cannot be set // (missing setter?) String msg = bean.getClass().getName() + ": unable to set
View Full Code Here


  private void fillBeanFromMap(Object bean, Map<?, ?> map) throws IllegalAccessException,
                                                                  InvocationTargetException,
                                                                  NoSuchMethodException
  {
      PropertyUtilsBean propUtils = _beanUtilsBean.getPropertyUtils();

      for (Map.Entry<?, ?> entry : map.entrySet())
    {
      String keyStr = entry.getKey().toString();
      Object value = entry.getValue();
      if (value instanceof Map<?, ?>)
      {
        Object subBean = propUtils.getProperty(bean, keyStr);
        if (null != subBean) fillBeanFromMap(subBean, (Map<?, ?>)value);
      }
      else if (value instanceof List<?>)
      {
        fillPropertyFromList(bean, keyStr, (List<?>)value);
      }
      else
      {
        propUtils.setProperty(bean, keyStr, value);
      }
    }
  }
View Full Code Here

  private void fillPropertyFromList(Object bean, String propName, List<?> values)
                                    throws IllegalAccessException,
                                             InvocationTargetException,
                                             NoSuchMethodException
  {
      PropertyUtilsBean propUtils = _beanUtilsBean.getPropertyUtils();
      int idx = 0;
      for (Object elem: values)
      {
        if (elem instanceof Map<?,?>)
        {
          Object subBean = propUtils.getIndexedProperty(bean, propName, idx);
          fillBeanFromMap(subBean, (Map<?, ?>)elem);
        }
        else
        {
          propUtils.setIndexedProperty(bean, propName, idx, elem);
        }
        ++idx;
      }
  }
View Full Code Here

            if (log.isTraceEnabled())
                log.trace(bean.getClass().getName() + ": getting property '" + property + "' for column " + column.getName());
            */
           
            // Get Property Value
            PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
            Object value = pub.getSimpleProperty(bean, property);

            // Now, set the record value
            setValue( column, value );

        } catch (IllegalAccessException e)
View Full Code Here

    protected Object getBeanPropertyValue(Object bean, String property)
    {
        try
        { // Get Property Value
            PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
            return pub.getSimpleProperty(bean, property);

        }
        catch (IllegalAccessException e)
        {
            log.error(bean.getClass().getName() + ": unable to get property '" + property + "'");
View Full Code Here

            else if (rec!=null)
            {   // Get Value from a bean
                String property = col.getBeanPropertyName();
                try
                {   // Use Beanutils to get Property
                    PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
                    return pub.getSimpleProperty(rec, property);
                }
                catch (Exception e)
                {   log.error("BeanUtils.getSimpleProperty failed for "+property, e);
                    return null;
                }
View Full Code Here

            throw new InvalidArgumentException("bean", bean);
        if (property==null)
            throw new InvalidArgumentException("property", property);
        try
        {   // Get Property Value
            PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
            return pub.getSimpleProperty(bean, property);

        } catch (IllegalAccessException e)
        {   log.error(bean.getClass().getName() + ": unable to get property '" + property + "'");
            throw new BeanPropertyGetException(bean, property, e);
        } catch (InvocationTargetException e)
View Full Code Here

    @Test
    public void testDigester()
        throws IOException, SAXException
    {
        PropertyUtilsBean propertyUtils = new MyPropertyUtilsBean();
        ConvertUtilsBean convertUtils = new ConvertUtilsBean();
        BeanUtilsBean beanUtils = new BeanUtilsBean( convertUtils, propertyUtils );
        BeanUtilsBean.setInstance( beanUtils );

        final String xml = "<myclass flag='true' />";
View Full Code Here

            if (log.isTraceEnabled())
                log.trace(bean.getClass().getName() + ": getting property '" + property + "' for column " + column.getName());
            */
           
            // Get Property Value
            PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
            Object value = pub.getSimpleProperty(bean, property);

            // Now, set the record value
            return setValue( column, value );

        } catch (IllegalAccessException e)
View Full Code Here

            if (log.isTraceEnabled())
                log.trace(bean.getClass().getName() + ": getting property '" + property + "' for column " + column.getName());
            */
           
            // Get Property Value
            PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
            Object value = pub.getSimpleProperty(bean, property);

            // Now, set the record value
            setValue( column, value );

        } catch (IllegalAccessException e)
View Full Code Here

TOP

Related Classes of org.apache.commons.beanutils.PropertyUtilsBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.