Bean bean = (Bean) pageContext.getAttribute("bean", PageContext.REQUEST_SCOPE); if (bean == null) { bean = new Bean(); pageContext.setAttribute("bean", bean, PageContext.REQUEST_SCOPE); } // Use bean ...
Bean bean = new Bean(); StringProperty nameProperty() = new JavaBeanStringPropertyBuilder() .bean(bean) .name("name") .build(); nameProperty().addListener((obs, oldName, newName) -> System.out.println("name changed from "+oldName+" to "+newName)); bean.setName("James"); System.out.println(nameProperty().get());
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); } } }
/** * Create a binding configuration to bind the data, selected from the message by the * dataSelector, to the target Collection/array Bean beanclass instance. * * @param dataSelector The data selector for the data value to be bound. * @return <code>this</code> Bean configuration instance. */ public Bean bindTo(String dataSelector) { return bindTo(dataSelector, (DataDecoder) null); }
/** * Add the visitors, associated with this Bean instance, to the visitor map. * @param visitorMap The visitor Map. */ public void addVisitors(VisitorConfigMap visitorMap) { // Need to protect against multiple calls. This can happen where e.g. beans are // wired together in 2-way relationships, or the creating code doesn't use the // fluent interface and calls Smooks.addVisitor to each bean instance. if(processed) { return; } processed = true; // Add the create bean visitor... SmooksResourceConfiguration creatorConfig = visitorMap.addVisitor(beanInstanceCreator, createOnElement, targetNamespace, true); creatorConfig.setParameter("beanId", getBeanId()); creatorConfig.setParameter("beanClass", beanClass.getName()); // Recurse down the wired beans... for(Bean bean : wirings) { bean.addVisitors(visitorMap); } // Add the populate bean visitors... for(Binding binding : bindings) { SmooksResourceConfiguration populatorConfig = visitorMap.addVisitor(binding.beanInstancePopulator, binding.selector, targetNamespace, true); populatorConfig.setParameter("beanId", getBeanId()); if(binding.assertTargetIsCollection) { assertBeanClassIsCollection(); } } }
assertNotProcessed(); AssertArgument.isNotNull(bindingMember, "bindingMember"); AssertArgument.isNotNull(bean, "bean"); beanInstancePopulator.setBeanId(getBeanId()); beanInstancePopulator.setWireBeanId(bean.getBeanId()); Method bindingMethod = getBindingMethod(bindingMember, beanClass);
for (int i = 0; i < rows.size(); i++) { Bean line = new Bean(); ArrayList al=(ArrayList)rows.get(i);//now [FRPP, PE103, , USD] line.setField1((String)al.get(0));//FRPP line.setField2((String)al.get(1));//PE103 line.setField3((String)al.get(2));// line.setField4((String)al.get(3));//USD data.add(line); }
Bean b0 = new Bean(); b0.setK("k0"); b0.setSomething("sth0"); Bean b1 = new Bean(); b1.setK("k1"); b1.setSomething("sth1");
Bean bean = new Bean(); bean.setString1("test"); MySingleton.setBean(bean); Bean bean2 = MySingleton.getBean(); System.out.println(bean2.getString1()); //prints test
@RequestMapping("/performTest.json") public @ResponseBody String performTest(@RequestBody List<Object> jsonData){ List<Bean> beanList=new ArrayList<Bean>(); for(Object obj:jsonData){ LinkedHashMap<String,Object> map=(LinkedHashMap<String,Object>)obj; Bean bean=new Bean(); bean.setName(map.get("name")); bean.setAge(map.get("age")); beanList.add(bean); }
DAO.deleteRows(); // so I'm inserting into an empty table long time = new Date().getTime(); for(int i=0; i<objectsArray.length()*50; i++){ JSONArray entry = (JSONArray) objectsArray.get(i%objectsArray.length()); Bean bean = new Bean(); bean.setStuff(entry.getInt(0)); // and so on... dao.addObject(bean); } long timeFinish = new Date().getTime(); long timeTotal = timeFinish - time;
while(rs.next()) { String supply[] = (rs.getString("location_name")).split(","); for(int i=0; i<supply.length; i++) { Bean Location = new Bean(); Location.setLocation(supply[i]); SupplyLocation.add(Location); } }
Bean b = new Bean(); b.setItemnames(itemnames); Intent i=new Intent(); i.setClass(A.this,B.class); i.putExtra("itemnames", b); startActivity(i);
/** * Add a bean binding configuration to this Collection/array bean binding config. * <p/> * This method checks that this bean's beanClass is a Collection/array, generating an * {@link IllegalArgumentException} if the check fails. * * @param bean The Bean instance to be bound * @return <code>this</code> Bean configuration instance. * @throws IllegalArgumentException <u><code>this</code></u> Bean's beanClass (not the supplied bean!) is * not a Collection/array. You cannot call this method on Bean configurations whose beanClass is not a * Collection/array. For non Collection/array types, you must use one of the bindTo meths that specify a * 'bindingMember'. */ public Bean bindTo(Bean bean) throws IllegalArgumentException { assertNotProcessed(); AssertArgument.isNotNull(bean, "bean"); BeanInstancePopulator beanInstancePopulator = new BeanInstancePopulator(); // Configure the populator visitor... beanInstancePopulator.setBeanId(getBeanId()); beanInstancePopulator.setWireBeanId(bean.getBeanId()); bindings.add(new Binding(createOnElement, beanInstancePopulator, true)); wirings.add(bean); return this; }
private Class<?> resolveBindTypeReflectively() throws DataDecodeException { String bindingMember = (setterMethod != null? setterMethod : property); if(bindingMember != null && beanRuntimeInfo.getClassification() == Classification.NON_COLLECTION) { Method bindingMethod = Bean.getBindingMethod(bindingMember, beanRuntimeInfo.getPopulateType()); if(bindingMethod != null) { return bindingMethod.getParameterTypes()[0]; } } return null; }