public class Value extends BindingAppender
<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-items> </order>
Smooks smooks = new Smooks(); Value customerNumberValue = new Value( "customerNumber", "customer/@number") .setDecoder("Integer"); Value customerNameValue = new Value( "customerName", "customer") .setDefault("Unknown"); smooks.addVisitors(customerNumberValue); smooks.addVisitors(customerNameValue);And the execution code:
JavaResult result = new JavaResult(); smooks.filterSource(new StreamSource(orderMessageStream), result); Integer customerNumber = (Integer) result.getBean("customerNumber"); String customerName = (String) result.getBean("customerName");
Bean
Constructor and Description |
---|
Value(String beanId,
String data)
Create a Value binding configuration.
|
Value(String beanId,
String data,
Class<?> type)
Create a Value binding configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
addVisitors(VisitorConfigMap visitorMap)
Used by Smooks to retrieve the visitor configuration of this Value Configuration
|
Value |
setDecoder(DataDecoder dataDecoder)
The
DataDecoder to be used for decoding
the data value. |
Value |
setDefaultValue(String defaultValue)
The default value for if the data is null or empty
|
Value |
setTargetNamespace(String targetNamespace)
The namespace for the data selector for the data value to be bound.
|
Value |
setType(Class<?> type)
Set the binding value data type.
|
getBeanId
public Value(String beanId, String data)
beanId
- The bean id under which the value will be stored.data
- The data selector for the data value to be bound.public Value setTargetNamespace(String targetNamespace)
targetNamespace
- The namespacethis
Value configuration instance.public Value setDefaultValue(String defaultValue)
targetNamespace
- The default valuethis
Value configuration instance.public Value setType(Class<?> type)
type
- The data type.this
Value configuration instance.public Value setDecoder(DataDecoder dataDecoder)
DataDecoder
to be used for decoding
the data value.targetNamespace
- The DataDecoder
this
Value configuration instance.public void addVisitors(VisitorConfigMap visitorMap)
visitorMap
- The visitor map to be added to.Copyright © 2020. All rights reserved.