|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.milyn.javabean.BindingAppender
org.milyn.javabean.Bean
public class Bean
Programmatic Bean Configurator.
This class can be used to programmatically configure a Smooks instance for performing a Java Bindings on a specific class. To populate a graph, you simply create a graph of Bean instances by binding Beans onto Beans. This class uses a Fluent API (all methods return the Bean instance), making it easy to string configurations together to build up a graph of Bean configuration.
<order xmlns="http://x">
<header>
<y:date xmlns:y="http://y">Wed Nov 15 13:45:28 EST 2006</y:date>
<customer number="123123">Joe</customer>
<privatePerson></privatePerson>
</header>
<order-items>
<order-item>
<product>111</product>
<quantity>2</quantity>
<price>8.90</price>
</order-item>
<order-item>
<product>222</product>
<quantity>7</quantity>
<price>5.20</price>
</order-item>
</order-items>
</order>
public class Order {
private Header header;
private List<OrderItem> orderItems;
}
public class Header {
private Long customerNumber;
private String customerName;
}
public class OrderItem {
private long productId;
private Integer quantity;
private double price;
}
Smooks smooks = new Smooks();
Bean orderBean = new Bean(Order.class, "order", "/order");
orderBean.bindTo("header",
orderBean.newBean(Header.class, "/order")
.bindTo("customerNumber", "header/customer/@number")
.bindTo("customerName", "header/customer")
).bindTo("orderItems",
orderBean.newBean(ArrayList.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.addVisitors(orderBean);
And the execution code:
JavaResult result = new JavaResult();
smooks.filterSource(new StreamSource(orderMessageStream), result);
Order order = (Order) result.getBean("order");
Value| Constructor Summary | |
|---|---|
Bean(Class<?> beanClass,
String beanId)
Create a Bean binding configuration. |
|
Bean(Class<?> beanClass,
String beanId,
String createOnElement)
Create a Bean binding configuration. |
|
Bean(Class<?> beanClass,
String beanId,
String createOnElement,
String createOnElementNS)
Create a Bean binding configuration. |
|
Bean(Class<T> beanClass,
String beanId,
Factory<? extends T> factory)
Create a Bean binding configuration. |
|
Bean(Class<T> beanClass,
String beanId,
String createOnElement,
Factory<? extends T> factory)
Create a Bean binding configuration. |
|
Bean(Class<T> beanClass,
String beanId,
String createOnElement,
String createOnElementNS,
Factory<? extends T> factory)
Create a Bean binding configuration. |
|
| Method Summary | ||
|---|---|---|
void |
addVisitors(org.milyn.delivery.VisitorConfigMap visitorMap)
Add the visitors, associated with this Bean instance, to the visitor map. |
|
Bean |
bindTo(Bean bean)
Add a bean binding configuration to this Collection/array bean binding config. |
|
Bean |
bindTo(String dataSelector)
Create a binding configuration to bind the data, selected from the message by the dataSelector, to the target Collection/array Bean beanclass instance. |
|
Bean |
bindTo(String bindingMember,
Bean bean)
Add a bean binding configuration for the specified bindingMember (field/method) to this bean binding config. |
|
Bean |
bindTo(String dataSelector,
org.milyn.javabean.DataDecoder dataDecoder)
Create a binding configuration to bind the data, selected from the message by the dataSelector, to the target Collection/array Bean beanclass instance. |
|
Bean |
bindTo(String bindingMember,
String dataSelector)
Create a binding configuration to bind the data, selected from the message by the dataSelector, to the specified bindingMember (field/method). |
|
Bean |
bindTo(String bindingMember,
String dataSelector,
org.milyn.javabean.DataDecoder dataDecoder)
Create a binding configuration to bind the data, selected from the message by the dataSelector, to the target Bean member specified by the bindingMember param. |
|
static Method |
getBindingMethod(String bindingMember,
Class<?> beanClass)
Get the bean binding class Member (field/method). |
|
Bean |
newBean(Class<?> beanClass,
String createOnElement)
Create a Bean binding configuration. |
|
Bean |
newBean(Class<?> beanClass,
String beanId,
String createOnElement)
Create a Bean binding configuration. |
|
static Bean |
newBean(Class<?> beanClass,
String beanId,
String createOnElement,
String createOnElementNS)
Create a Bean binding configuration. |
|
|
newBean(Class<T> beanClass,
String createOnElement,
Factory<T> factory)
Create a Bean binding configuration. |
|
|
newBean(Class<T> beanClass,
String beanId,
String createOnElement,
Factory<T> factory)
Create a Bean binding configuration. |
|
static
|
newBean(Class<T> beanClass,
String beanId,
String createOnElement,
String createOnElementNS,
Factory<T> factory)
Create a Bean binding configuration. |
|
| Methods inherited from class org.milyn.javabean.BindingAppender |
|---|
getBeanId |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Bean(Class<?> beanClass,
String beanId)
beanClass - The bean runtime class.beanId - The bean ID.
public Bean(Class<T> beanClass,
String beanId,
Factory<? extends T> factory)
beanClass - The bean runtime class.beanId - The bean ID.factory - The factory that will create the runtime object
public Bean(Class<?> beanClass,
String beanId,
String createOnElement)
beanClass - The bean runtime class.beanId - The bean ID.createOnElement - The element selector used to create the bean instance.
public Bean(Class<T> beanClass,
String beanId,
String createOnElement,
Factory<? extends T> factory)
beanClass - The bean runtime class.beanId - The bean ID.createOnElement - The element selector used to create the bean instance.factory - The factory that will create the runtime object
public Bean(Class<?> beanClass,
String beanId,
String createOnElement,
String createOnElementNS)
beanClass - The bean runtime class.beanId - The bean ID.createOnElement - The element selector used to create the bean instance.createOnElementNS - The namespace for the element selector used to create the bean instance.
public Bean(Class<T> beanClass,
String beanId,
String createOnElement,
String createOnElementNS,
Factory<? extends T> factory)
beanClass - The bean runtime class.beanId - The bean ID.createOnElement - The element selector used to create the bean instance.createOnElementNS - The namespace for the element selector used to create the bean instance.factory - The factory that will create the runtime object| Method Detail |
|---|
public static Bean newBean(Class<?> beanClass,
String beanId,
String createOnElement,
String createOnElementNS)
beanClass - The bean runtime class.beanId - The bean ID.createOnElement - The element selector used to create the bean instance.createOnElementNS - The namespace for the element selector used to create the bean instance.
public static <T> Bean newBean(Class<T> beanClass,
String beanId,
String createOnElement,
String createOnElementNS,
Factory<T> factory)
beanClass - The bean runtime class.beanId - The bean ID.createOnElement - The element selector used to create the bean instance.createOnElementNS - The namespace for the element selector used to create the bean instance.factory - The factory that will create the runtime object
public Bean newBean(Class<?> beanClass,
String createOnElement)
Smooks instance
supplied in the constructor. The beanId is generated.
beanClass - The bean runtime class.createOnElement - The element selector used to create the bean instance.
this Bean configuration instance.
public <T> Bean newBean(Class<T> beanClass,
String createOnElement,
Factory<T> factory)
Smooks instance
supplied in the constructor. The beanId is generated.
beanClass - The bean runtime class.createOnElement - The element selector used to create the bean instance.factory - The factory that will create the runtime object
this Bean configuration instance.
public Bean newBean(Class<?> beanClass,
String beanId,
String createOnElement)
Smooks instance
supplied in the constructor.
beanClass - The bean runtime class.beanId - The beanId.createOnElement - The element selector used to create the bean instance.
this Bean configuration instance.
public <T> Bean newBean(Class<T> beanClass,
String beanId,
String createOnElement,
Factory<T> factory)
Smooks instance
supplied in the constructor.
beanClass - The bean runtime class.beanId - The beanId.createOnElement - The element selector used to create the bean instance.factory - The factory that will create the runtime object
this Bean configuration instance.
public Bean bindTo(String bindingMember,
String dataSelector)
DataDecoder through the specified
bindingMember.
bindingMember - The name of the binding member. This is a bean property (field)
or method name.dataSelector - The data selector for the data value to be bound.
public Bean bindTo(String bindingMember,
String dataSelector,
org.milyn.javabean.DataDecoder dataDecoder)
bindingMember - The name of the binding member. This is a bean property (field)
or method name.dataSelector - The data selector for the data value to be bound.dataDecoder - The DataDecoder to be used for decoding
the data value.
this Bean configuration instance.
public Bean bindTo(String bindingMember,
Bean bean)
bindingMember - The name of the binding member. This is a bean property (field)
or method name. The bean runtime class should match thebean - The Bean instance to be bound
this Bean configuration instance.
public Bean bindTo(Bean bean)
throws IllegalArgumentException
IllegalArgumentException if the check fails.
bean - The Bean instance to be bound
this Bean configuration instance.
IllegalArgumentException - this Bean's beanClass (not the supplied bean!) is
not a Collection/array. You cannot call this method on Bean configurations whose beanClass is not a
Collection/array. For non Collection/array types, you must use one of the bindTo meths that specify a
'bindingMember'.public Bean bindTo(String dataSelector)
dataSelector - The data selector for the data value to be bound.
this Bean configuration instance.
public Bean bindTo(String dataSelector,
org.milyn.javabean.DataDecoder dataDecoder)
dataSelector - The data selector for the data value to be bound.dataDecoder - The DataDecoder to be used for decoding
the data value.
this Bean configuration instance.public void addVisitors(org.milyn.delivery.VisitorConfigMap visitorMap)
visitorMap - The visitor Map.
public static Method getBindingMethod(String bindingMember,
Class<?> beanClass)
bindingMember - Binding member name.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||