/** * Create a Bean binding configuration. * * @param beanClass The bean runtime class. * @param beanId The bean ID. * @param createOnElement The element selector used to create the bean instance. * @param createOnElementNS The namespace for the element selector used to create the bean instance. */ public static Bean newBean(Class<?> beanClass, String beanId, String createOnElement, String createOnElementNS) { return new Bean(beanClass, beanId, createOnElement, createOnElementNS); }
/** * Create a Bean binding configuration. * * @param beanClass The bean runtime class. * @param beanId The bean ID. * @param createOnElement The element selector used to create the bean instance. * @param createOnElementNS The namespace for the element selector used to create the bean instance. * @param factory The factory that will create the runtime object */ public static <T> Bean newBean(Class<T> beanClass, String beanId, String createOnElement, String createOnElementNS, Factory<T> factory) { return new Bean(beanClass, beanId, createOnElement, createOnElementNS, factory); }
/** * Create a Bean binding configuration. * <p/> * This method binds the configuration to the same {@link Smooks} instance * supplied in the constructor. * * @param beanClass The bean runtime class. * @param beanId The beanId. * @param createOnElement The element selector used to create the bean instance. * @return <code>this</code> Bean configuration instance. */ public Bean newBean(Class<?> beanClass, String beanId, String createOnElement) { return new Bean(beanClass, beanId, createOnElement); }
/** * Create a Bean binding configuration. * <p/> * This method binds the configuration to the same {@link Smooks} instance * supplied in the constructor. * * @param beanClass The bean runtime class. * @param beanId The beanId. * @param createOnElement The element selector used to create the bean instance. * @param factory The factory that will create the runtime object * @return <code>this</code> Bean configuration instance. */ public <T> Bean newBean(Class<T> beanClass, String beanId, String createOnElement, Factory<T> factory) { return new Bean(beanClass, beanId, createOnElement, factory); }
/** * Create a Bean binding configuration. * <p/> * This method binds the configuration to the same {@link Smooks} instance * supplied in the constructor. The beanId is generated. * * @param beanClass The bean runtime class. * @param createOnElement The element selector used to create the bean instance. * @return <code>this</code> Bean configuration instance. * @param factory The factory that will create the runtime object */ public <T> Bean newBean(Class<T> beanClass, String createOnElement, Factory<T> factory) { String randomBeanId = UUID.randomUUID().toString(); return new Bean(beanClass, randomBeanId, createOnElement, factory); }
/** * Create a Bean binding configuration. * <p/> * This method binds the configuration to the same {@link Smooks} instance * supplied in the constructor. The beanId is generated. * * @param beanClass The bean runtime class. * @param createOnElement The element selector used to create the bean instance. * @return <code>this</code> Bean configuration instance. */ public Bean newBean(Class<?> beanClass, String createOnElement) { String randomBeanId = UUID.randomUUID().toString(); return new Bean(beanClass, randomBeanId, createOnElement); }
public void addVisitors(VisitorConfigMap visitorMap) { if(bindBeanId != null && bindBeanClass != null) { Bean bean; if(bindingType == CSVBindingType.LIST) { Bean listBean = new Bean(ArrayList.class, bindBeanId, "$document"); bean = listBean.newBean(bindBeanClass, recordElementName); listBean.bindTo(bean); addFieldBindings(bean); listBean.addVisitors(visitorMap); } else if(bindingType == CSVBindingType.MAP) { if(bindMapKeyField == null) { throw new SmooksConfigurationException("CSV 'MAP' Binding must specify a 'keyField' property on the binding configuration."); } assertValidFieldName(bindMapKeyField); Bean mapBean = new Bean(LinkedHashMap.class, bindBeanId, "$document"); Bean recordBean = new Bean(bindBeanClass, RECORD_BEAN, recordElementName); MapBindingWiringVisitor wiringVisitor = new MapBindingWiringVisitor(bindMapKeyField, bindBeanId); addFieldBindings(recordBean); mapBean.addVisitors(visitorMap); recordBean.addVisitors(visitorMap); visitorMap.addVisitor(wiringVisitor, recordElementName, null, false); } else { bean = new Bean(bindBeanClass, bindBeanId, recordElementName); addFieldBindings(bean); bean.addVisitors(visitorMap); } } }
public void addVisitors(VisitorConfigMap visitorMap) { initialize(); if(bindBeanId != null && bindBeanClass != null) { Bean bean; if(bindingType == FixedLengthBindingType.LIST) { Bean listBean = new Bean(ArrayList.class, bindBeanId, "$document"); bean = listBean.newBean(bindBeanClass, recordElementName); listBean.bindTo(bean); addFieldBindings(bean); listBean.addVisitors(visitorMap); } else if(bindingType == FixedLengthBindingType.MAP) { if(bindMapKeyField == null) { throw new SmooksConfigurationException("FixedLenght 'MAP' Binding must specify a 'keyField' property on the binding configuration."); } assertValidFieldName(bindMapKeyField); Bean mapBean = new Bean(LinkedHashMap.class, bindBeanId, "$document"); Bean recordBean = new Bean(bindBeanClass, RECORD_BEAN, recordElementName); MapBindingWiringVisitor wiringVisitor = new MapBindingWiringVisitor(bindMapKeyField, bindBeanId); addFieldBindings(recordBean); mapBean.addVisitors(visitorMap); recordBean.addVisitors(visitorMap); visitorMap.addVisitor(wiringVisitor, recordElementName, null, false); } else { bean = new Bean(bindBeanClass, bindBeanId, recordElementName); addFieldBindings(bean); bean.addVisitors(visitorMap); } } }
Bean listBean = new Bean(ArrayList.class, bindBeanId, SmooksResourceConfiguration.DOCUMENT_FRAGMENT_SELECTOR); Bean mapBean = new Bean(LinkedHashMap.class, bindBeanId, SmooksResourceConfiguration.DOCUMENT_FRAGMENT_SELECTOR); Bean recordBean = new Bean(bindBeanClass, RECORD_BEAN, recordElementName); MapBindingWiringVisitor wiringVisitor = new MapBindingWiringVisitor(bindMapKeyField, bindBeanId); visitorMap.addVisitor(wiringVisitor, recordElementName, null, false); } else { bean = new Bean(bindBeanClass, bindBeanId, recordElementName); addFieldBindings(bean);