this.targetProfile = targetProfile;
return this;
}
public List<SmooksResourceConfiguration> toConfig() {
GenericReaderConfigurator configurator = new GenericReaderConfigurator(FlatFileReader.class);
configurator.getParameters().setProperty("parserFactory", CSVRecordParserFactory.class.getName());
configurator.getParameters().setProperty("fields", csvFields);
configurator.getParameters().setProperty("separator", Character.toString(separatorChar));
configurator.getParameters().setProperty("quote-char", Character.toString(quoteChar));
configurator.getParameters().setProperty("escape-char", Character.toString(escapeChar));
configurator.getParameters().setProperty("skip-line-count", Integer.toString(skipLineCount));
configurator.getParameters().setProperty("encoding", encoding.name());
configurator.getParameters().setProperty("rootElementName", rootElementName);
configurator.getParameters().setProperty("recordElementName", recordElementName);
configurator.getParameters().setProperty("indent", Boolean.toString(indent));
configurator.getParameters().setProperty("strict", Boolean.toString(strict));
if (binding != null) {
configurator.getParameters().setProperty("bindBeanId", binding.getBeanId());
configurator.getParameters().setProperty("bindBeanClass", binding.getBeanClass().getName());
configurator.getParameters().setProperty("bindingType", binding.getBindingType().toString());
if (binding.getBindingType() == CSVBindingType.MAP) {
if (binding.getKeyField() == null) {
throw new SmooksConfigurationException(
"CSV 'MAP' Binding must specify a 'keyField' property on the binding configuration.");
}
configurator.getParameters().setProperty("bindMapKeyField", binding.getKeyField());
}
}
configurator.setTargetProfile(targetProfile);
return configurator.toConfig();
}