execute_01_test(smooks);
}
public void test_01_factory() {
Smooks smooks = new Smooks();
Bean orderBean = new Bean(Order.class, "order", "/order", new Factory<Order>() {
public Order create(ExecutionContext executionContext) {
return new Order();
}
});
orderBean.bindTo("header",
orderBean.newBean(Header.class, "/order")
.bindTo("order", orderBean)
.bindTo("customerNumber", "header/customer/@number")
.bindTo("customerName", "header/customer")
.bindTo("privatePerson", "header/privatePerson")
).bindTo("orderItems",
orderBean.newBean(Collection.class, "/order", new MVELFactory<Collection>("new java.util.ArrayList()"))
.bindTo(orderBean.newBean(OrderItem.class, "order-item")
.bindTo("productId", "order-item/product")
.bindTo("quantity", "order-item/quantity")
.bindTo("price", "order-item/price"))
).bindTo("orderItems",
orderBean.newBean(OrderItem[].class, "/order")
.bindTo(orderBean.newBean(OrderItem.class, "order-item")
.bindTo("productId", "order-item/product")
.bindTo("quantity", "order-item/quantity")
.bindTo("price", "order-item/price")));
smooks.addVisitor(orderBean);