I'm new to Smooks and I want to achieve the following. May be I'm totally new to this and I don't see the answer yet, but this should be a basic thing.
I'm taking an excerpt from the example shown in official document for beanpopulator.
http://www.milyn.org/javadoc/v1.0/smooks-cartridges/javabean/org/milyn/javabean/BeanPopulator.html
public class Header {
private Date date;
private Long customerNumber;
private String customerName;
}
Corresponding smooks configurations
<-- Create the Header bean instance when we encounter the "header" element.
Call it "header" -->
<resource-config selector="header">
<resource>org.milyn.javabean.BeanPopulator</resource>
<param name="beanId">header</param>
<param name="beanClass">org.milyn.javabean.Header</param>
<param name="bindings">
<-- Header bindings... -->
<binding property="date" type="OrderDateLong" selector="header/date" /> <-- See OrderDateLong decoder definition below... -->
<binding property="customerNumber" type="Long" selector="header/customer/@number" />
<binding property="customerName" selector="header/customer" /> <-- Type defaults to String -->
</param>
</resource-config>
Suppose that the field 'customerName' doesn't need to be retrieved from 'selecter', instead it should be populated with a unique value every time. (Ex: customerName = 'Richard')
How do I achieve this? Thanks!
EDIT: In case if this looks silly. What I want to do is add a value to a map sort of a thing. I read a CSV for this and if the CSV contains a certain header (ex: customerName) I add it to the map with the key as 'customerName'. Reading the header from the CSV is another thing in my mind, but I couldn't find a solution for that as well.
I fixed this by writing a new Decoder class. Not sure whether this is the best way, but looks like its THE way;)
public class NameStringDecoder implements DataDecoder {
@Override
public Object decode(String customerName) throws DataDecodeException {
return "Richard";
}
}