public static void main(String[] args) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Company com = new Company(); com.setName(""); com.getName(); // simple BeanUtils.setProperty(com, "name", "Jack"); BeanUtils.getProperty(com, "name"); // indexed BeanUtils.setProperty(com, "product[1]", "NOTES SERVER"); BeanUtils.getProperty(com, "product[1]"); // mapped HashMap am = new HashMap(); am.put("1", "10010"); am.put("2", "10010"); BeanUtils.setProperty(com, "telephone", am); BeanUtils.getProperty(com, "telephone(2)"); // combined BeanUtils.getProperty(com, "employee[1].name"); // copyProperty Company com2 = new Company(); BeanUtils.copyProperties(com2, com); // converter BeanUtils.setProperty(com, "date", new Date()); BeanUtils.setProperty(com, "date", "2013-10-01"); ConvertUtils.register( new Converter() { public <T> T convert(Class<T> type, Object value) { // TODO Auto-generated method stub return null; } }, Date.class); // DynamicBean LazyDynaMap dynaBean = new LazyDynaMap(); dynaBean.set("foo", "bar"); dynaBean.set("customer", "title", "Rose"); dynaBean.set("address", 0, "address1"); System.out.println(dynaBean.get("address", 0)); Map map = dynaBean.getMap(); System.out.println(map.toString()); // returnNull dynaBean.setReturnNull(true); // Restricted dynaBean.setRestricted(true); }
// Adds to each service template the general requirements for the CSA // (if a part of the CSA does not fulfill the requirement the whole will not fullfill it either) private void generalizeCSARequirements() { ArrayList<ServiceTemplate> comps = new ArrayList<ServiceTemplate>(); ArrayList<Requirement> reqs = new ArrayList<Requirement>(); comps = this.data.getServiceTemplates(); reqs = this.data.getRequirements(); for (ServiceTemplate c : comps) { for (Requirement r : reqs) { Requirement temp = new Requirement(); try { BeanUtils.copyProperties(temp, r); // System.out.println(r.toString()); // System.out.println(temp.toString()); c.addReq(temp); } catch (IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } } } }
public static Element getUIPdfComponent( FormBuilderItemBase item, FormBuilderItemData data, String mode) { String type = item.getFormbuildertype(); PdfFormBuilderItem comp; boolean skipPropertiesCopy = false; switch (type) { case FormBuilderItemFactory.TYPE_LABEL: comp = new PdfFormBuilderLabel(); break; case FormBuilderItemFactory.TYPE_HEADING: comp = new PdfFormBuilderHeading(); break; case FormBuilderItemFactory.TYPE_HR: comp = new PdfFormBuilderHorizontalRule(); break; case FormBuilderItemFactory.TYPE_SPACE: comp = new PdfFormBuilderSpace(); break; case FormBuilderItemFactory.TYPE_DATE: case FormBuilderItemFactory.TYPE_TIME: case FormBuilderItemFactory.TYPE_INPUT: case FormBuilderItemFactory.TYPE_NUMBER: comp = new PdfFormBuilderInput(); break; case FormBuilderItemFactory.TYPE_TEXTAREA: comp = new PdfFormBuilderTextarea(); break; case FormBuilderItemFactory.TYPE_IMAGE: comp = new PdfFormBuilderImage(); break; case FormBuilderItemFactory.TYPE_UPLOAD: comp = new PdfFormBuilderUpload(); break; case FormBuilderItemFactory.TYPE_SELECT: comp = new PdfFormBuilderSelect(); break; case FormBuilderItemFactory.TYPE_LISTBOX: comp = new PdfFormBuilderListbox(); break; case FormBuilderItemFactory.TYPE_CHECKBOX: comp = new PdfFormBuilderCheckbox(); break; case FormBuilderItemFactory.TYPE_RADIO: comp = new PdfFormBuilderRadio(); break; case FormBuilderItemFactory.TYPE_METADATA: comp = new PdfFormBuilderMetaData(); break; default: comp = new PdfFormBuilderLabel(); comp.getProperties().setValues(Messages.getStringJSF("pdf.error")); skipPropertiesCopy = true; break; } if (!skipPropertiesCopy) { BeanUtils.copyProperties(item.getProperties(), comp.getProperties()); } // Set data of html object if (data != null) { comp.setValue(data.getValue()); if (data.getNumberValue() != null) { comp.setValue(data.getNumberValue().toString()); } comp.setFile(data.getFile()); } else { comp.setItemUuid(item.getId()); } if (mode != null) { comp.setMode(mode); } // render html object return comp.render(); }