Java 类org.apache.commons.beanutils.WrapDynaBean 实例源码

项目:imcms    文件:DublinCoreItem.java   
public Map<NameSpace, DynaBean> getNameSpaceBeans() {
    WrapDynaBean dublinCoreDynaBean = new WrapDynaBean(dublinCoreTerms);
    return ArrayUtils.toMap(new Object[][]{
            {DublinCoreTerms.DUBLIN_CORE_ELEMENTS_NAME_SPACE, dublinCoreDynaBean},
            {DublinCoreTerms.DUBLIN_CORE_TERMS_NAME_SPACE, dublinCoreDynaBean},
    });
}
项目:clobaframe    文件:Utils.java   
/**
 * Wrap an object info ObjectMap.
 * 
 * @param object
 * @return 
 */
public static ObjectMap Wrap(Object object){
    Assert.notNull(object);

    ObjectMap viewModel = new DefaultObjectMap();

    // check object type
    if (object instanceof Map){
        Map m = (Map)object;
        for(Object name : m.keySet()){
            viewModel.add(name.toString(), m.get(name));
        }
        return viewModel;
    }

    // copy all properties (except 'class') to map
    DynaBean dynaBean = new WrapDynaBean(object);
    DynaClass dynaClass = dynaBean.getDynaClass();
    for(DynaProperty property : dynaClass.getDynaProperties()){
        String key = property.getName();
        if (key.equals("class")){
            continue;
        }

        viewModel.add(key, dynaBean.get(key));
    }

    return viewModel;
}
项目:clobaframe    文件:Utils.java   
/**
 * Wrap an object into ObjectMap with the specify properties.
 * 
 * @param object
 * @param names
 * @return 
 */
public static ObjectMap Wrap(Object object, Collection<String> names){
    Assert.notNull(object);
    Assert.notNull(names);

    ObjectMap viewModel = new DefaultObjectMap();

    // check object type
    if (object instanceof Map){
        Map m = (Map)object;
        for(Object name : m.keySet()){
            String s = name.toString();
            if (names.contains(s)){
                viewModel.add(s, m.get(name));
            }
        }
        return viewModel;
    }

    // copy all properties (except 'class') to map
    DynaBean dynaBean = new WrapDynaBean(object);
    DynaClass dynaClass = dynaBean.getDynaClass();
    for(DynaProperty property : dynaClass.getDynaProperties()){
        String key = property.getName();
        if (names.contains(key)){
            viewModel.add(key, dynaBean.get(key));
        }
    }

    return viewModel;
}
项目:lams    文件:BeanValidatorForm.java   
/**
* <p>Return the <code>Bean</code> that this <code>ActionForm</code> is backed by.</p>
*
* <p>If the <code>DynaBean</code> is a <code>WrapDynaBean</code> type then this method
* returns the 'Wrapped' POJO bean associated with it. If you require the actual <code>WrapDynaBean</code>
* then use the <code>getDynaBean()</code> method.</p>
*/
public Object getInstance() {

    if (dynaBean instanceof WrapDynaBean) {
        return ((WrapDynaBean)dynaBean).getInstance();
    }

    return dynaBean;

}
项目:sonar-scanner-maven    文件:BeanValidatorForm.java   
/**
 * <p>Return the <code>Bean</code> that this <code>ActionForm</code> is
 * backed by.</p>
 *
 * <p>If the <code>DynaBean</code> is a <code>WrapDynaBean</code> type
 * then this method returns the 'Wrapped' POJO bean associated with it. If
 * you require the actual <code>WrapDynaBean</code> then use the
 * <code>getDynaBean()</code> method.</p>
 */
public Object getInstance() {
    if (dynaBean instanceof WrapDynaBean) {
        return ((WrapDynaBean) dynaBean).getInstance();
    }

    return dynaBean;
}