本文整理汇总了Java中org.apache.commons.beanutils.BasicDynaClass类的典型用法代码示例。如果您正苦于以下问题:Java BasicDynaClass类的具体用法?Java BasicDynaClass怎么用?Java BasicDynaClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicDynaClass类属于org.apache.commons.beanutils包,在下文中一共展示了BasicDynaClass类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: objectArrayToBean
import org.apache.commons.beanutils.BasicDynaClass; //导入依赖的package包/类
/**
* 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;
}
示例2: setUp
import org.apache.commons.beanutils.BasicDynaClass; //导入依赖的package包/类
@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);
}
示例3: addValue
import org.apache.commons.beanutils.BasicDynaClass; //导入依赖的package包/类
/**
* Creates a {@link org.apache.commons.beanutils.DynaBean} with a
* {@link org.apache.commons.beanutils.DynaProperty} named
* <code>propertyName,</code> sets the value of the property to <code>v</code>
* and adds the DynaBean to the underlying list.
*
*/
public void addValue(double v) {
DynaProperty[] props = new DynaProperty[] {
new DynaProperty(propertyName, Double.class)
};
BasicDynaClass dynaClass = new BasicDynaClass(null, null, props);
DynaBean dynaBean = null;
try {
dynaBean = dynaClass.newInstance();
} catch (Exception ex) { // InstantiationException, IllegalAccessException
throw new RuntimeException(ex); // should never happen
}
dynaBean.set(propertyName, Double.valueOf(v));
addObject(dynaBean);
}
示例4: addValue
import org.apache.commons.beanutils.BasicDynaClass; //导入依赖的package包/类
/**
* Creates a {@link org.apache.commons.beanutils.DynaBean} with a
* {@link org.apache.commons.beanutils.DynaProperty} named
* <code>propertyName,</code> sets the value of the property to <code>v</code>
* and adds the DynaBean to the underlying list.
*
*/
public void addValue(double v) {
DynaProperty[] props = new DynaProperty[] {
new DynaProperty(propertyName, Double.class)
};
BasicDynaClass dynaClass = new BasicDynaClass(null, null, props);
DynaBean dynaBean = null;
try {
dynaBean = dynaClass.newInstance();
} catch (Exception ex) { // InstantiationException, IllegalAccessException
throw new RuntimeException(ex); // should never happen
}
dynaBean.set(propertyName, new Double(v));
addObject(dynaBean);
}
示例5: createDynaClass
import org.apache.commons.beanutils.BasicDynaClass; //导入依赖的package包/类
protected DynaClass createDynaClass()
{
DynaClass dynaClass = new BasicDynaClass
("TestDynaClass", null,
new DynaProperty[]{
new DynaProperty("name", String.class),
});
return (dynaClass);
}