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

项目:enterprise-app    文件:DefaultHbnContainer.java   
/**
 * Constructs a DynaBean using the values and properties specified. 
 * @param values property values.
 * @param properties properties to add to the bean.
 * @param classes properties types.
 * @return DynBean with the values and properties specified.
 */
protected DynaBean objectArrayToBean(Object[] values, String[] properties, Class<?>[] classes) {
    DynaBean dynaBean = null;

    try {
        DynaProperty[] columnsDynaProperties = getColumnsDynaProperties(properties, classes);
        BasicDynaClass clazz = new BasicDynaClass(this.getClass().getSimpleName(), BasicDynaBean.class, columnsDynaProperties);
        dynaBean = clazz.newInstance();

        for(int i = 0; i < columnsDynaProperties.length; i++) {
            dynaBean.set(columnsDynaProperties[i].getName(), values[i]);
        }

    } catch (Exception e) {
        throw new RuntimeException("Error creating dynamic bean", e);
    }

    return dynaBean;
}
项目:greenpepper    文件:DynaBeanFixtureTest.java   
@Override
     protected void setUp() throws Exception {
         target = new BasicDynaBean(new BasicDynaClass("target", null, new DynaProperty[] {
                 new DynaProperty("string", String.class),
                 new DynaProperty("integer", int.class)
         }));

decorated = context.mock(Fixture.class);
         fixture = new DynaBeanFixture(decorated);
     }
项目:platypus-js    文件:ExcelRowProcessor.java   
public String getCellTemplate(Object aCollectionItem) {
    if (aCollectionItem != null) {
        if (aCollectionItem instanceof BasicDynaBean) {
            Object temp = null;
            try {
                temp = ((BasicDynaBean) aCollectionItem).get(TEMPLATE_CELL);
            } catch (IllegalArgumentException e) {
            }
            if (temp != null) {
                return (String) temp;
            }
        }
    }
    return "";
}
项目:enterprise-app    文件:TableViewReport.java   
@Override
public void updateReport() {
    table.setContainerDataSource(null);

    String[] columnProperties = getColumnProperties();
    Class<?>[] columnClasses = getColumnClasses();
    String[] columnTitles = getColumnTitles();

    for(int i = 0; i < columnProperties.length; i++) {
        table.addContainerProperty(columnProperties[i], columnClasses[i], null, columnTitles[i], null, null);
    }

    for(int i = 0; i < columnProperties.length; i++) {
        if(!columnsCheckBoxes[i].booleanValue()) {
            table.setColumnCollapsed(columnProperties[i], true);
        }
    }

    Collection<?> data = getData();

    if(data != null) {
        for(Object row : data) {
            BasicDynaBean bean = (BasicDynaBean) row;
            Object[] cells = new Object[columnProperties.length];

            for(int i = 0; i < columnProperties.length; i++) {
                cells[i] = bean.get(columnProperties[i]);
            }

            table.addItem(cells, row);
        }
    }
}