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
Modifier and Type | Field and Description |
---|---|
protected String |
dataSelector |
protected String |
defaultValue |
protected org.smooks.api.Registry |
registry |
protected static Set<org.smooks.api.converter.TypeConverterFactory<?,?>> |
TYPE_CONVERTER_FACTORIES |
protected org.smooks.api.converter.TypeConverter<? super String,?> |
typeConverter |
beanId
Constructor and Description |
---|
Value(String beanId,
String data,
Class<?> type,
org.smooks.api.Registry registry)
Create a Value binding configuration.
|
Value(String beanId,
String data,
org.smooks.api.Registry registry)
Create a Value binding configuration.
|
Modifier and Type | Method and Description |
---|---|
List<org.smooks.api.delivery.ContentHandlerBinding<org.smooks.api.resource.visitor.Visitor>> |
addVisitors()
Used by Smooks to retrieve the visitor configuration of this Value Configuration
|
Value |
setDefaultValue(String defaultValue)
The default value for if the data is null or empty
|
Value |
setType(Class<?> type)
Set the binding value data type.
|
Value |
setTypeConverter(org.smooks.api.converter.TypeConverter<String,?> typeConverter)
The
org.smooks.cartridges.javabean.DataDecoder to be used for decoding
the data value. |
getBeanId
protected static volatile Set<org.smooks.api.converter.TypeConverterFactory<?,?>> TYPE_CONVERTER_FACTORIES
protected final org.smooks.api.Registry registry
protected final String dataSelector
protected String defaultValue
protected org.smooks.api.converter.TypeConverter<? super String,?> typeConverter
public Value(String beanId, String data, org.smooks.api.Registry registry)
beanId
- The bean id under which the value will be stored.data
- The data selector for the data value to be bound.public Value setDefaultValue(String defaultValue)
defaultValue
- The default valuethis
Value configuration instance.public Value setType(Class<?> type)
type
- The data type.this
Value configuration instance.public Value setTypeConverter(org.smooks.api.converter.TypeConverter<String,?> typeConverter)
org.smooks.cartridges.javabean.DataDecoder
to be used for decoding
the data value.targetNamespace
- The org.smooks.cartridges.javabean.DataDecoder
this
Value configuration instance.public List<org.smooks.api.delivery.ContentHandlerBinding<org.smooks.api.resource.visitor.Visitor>> addVisitors()
Copyright © 2024. All rights reserved.