List of usage examples for org.dom4j Element addText
Element addText(String text);
Text
node with the given text to this element. From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private Element getServicePointElement(ServicePointDescriptor spd) { Element servicePoint = DocumentHelper.createElement("service-point"); servicePoint.addAttribute("id", qualify(spd.getId())); servicePoint.addAttribute("interface", spd.getInterfaceClassName()); if (spd.getVisibility() == Visibility.PRIVATE) servicePoint.addAttribute("visibility", "private"); if (spd.getParametersCount() != Occurances.REQUIRED) servicePoint.addAttribute("parameters-occurs", spd.getParametersCount().getName().toLowerCase()); if (spd.getAnnotation() != null) { servicePoint.addText(spd.getAnnotation()); }//from w w w .j a v a 2 s . c om if (spd.getParametersSchema() != null) addSchema(servicePoint, (SchemaImpl) spd.getParametersSchema(), "parameters-schema"); else if (spd.getParametersSchemaId() != null) servicePoint.addAttribute("parameters-schema-id", qualify(spd.getParametersSchemaId())); InstanceBuilder ib = spd.getInstanceBuilder(); if (ib != null) { Element instanceBuilder = getInstanceBuilderElement(ib); servicePoint.add(instanceBuilder); } List interceptors = spd.getInterceptors(); if (interceptors != null) { for (Iterator i = interceptors.iterator(); i.hasNext();) { InterceptorDescriptor icd = (InterceptorDescriptor) i.next(); Element interceptor = getInterceptorElement(icd); servicePoint.add(interceptor); } } return servicePoint; }
From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private Element getConfigurationPointElement(ConfigurationPointDescriptor cpd) { Element configurationPoint = DocumentHelper.createElement("configuration-point"); configurationPoint.addAttribute("id", qualify(cpd.getId())); if (cpd.getVisibility() == Visibility.PRIVATE) configurationPoint.addAttribute("visibility", "private"); if (cpd.getAnnotation() != null) { configurationPoint.addText(cpd.getAnnotation()); }//from w ww .ja v a 2 s . com if (cpd.getContributionsSchema() != null) addSchema(configurationPoint, (SchemaImpl) cpd.getContributionsSchema(), "schema"); else if (cpd.getContributionsSchemaId() != null) configurationPoint.addAttribute("schema-id", qualify(cpd.getContributionsSchemaId())); return configurationPoint; }
From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private Element getContributionElement(ContributionDescriptor cd) { Element contribution = DocumentHelper.createElement("contribution"); contribution.addAttribute("configuration-id", qualify(cd.getConfigurationId())); if (cd.getConditionalExpression() != null) contribution.addAttribute("if", cd.getConditionalExpression()); List parameters = cd.getElements(); if (parameters != null) { for (Iterator i = parameters.iterator(); i.hasNext();) { org.apache.hivemind.Element parameter = (org.apache.hivemind.Element) i.next(); Element element = getParamterElement(parameter); contribution.add(element);// w w w.j a va 2s. c o m } } if (cd.getAnnotation() != null) { contribution.addText(cd.getAnnotation()); } return contribution; }
From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private Element getImplementationElement(ImplementationDescriptor id) { Element implementation = DocumentHelper.createElement("implementation"); implementation.addAttribute("service-id", qualify(id.getServiceId())); if (id.getConditionalExpression() != null) implementation.addAttribute("if", id.getConditionalExpression()); if (id.getAnnotation() != null) { implementation.addText(id.getAnnotation()); }//from w w w. ja v a 2s . co m InstanceBuilder ib = id.getInstanceBuilder(); if (ib != null) { Element instanceBuilder = getInstanceBuilderElement(ib); implementation.add(instanceBuilder); } List interceptors = id.getInterceptors(); if (interceptors != null) { for (Iterator i = interceptors.iterator(); i.hasNext();) { InterceptorDescriptor icd = (InterceptorDescriptor) i.next(); Element interceptor = getInterceptorElement(icd); implementation.add(interceptor); } } return implementation; }
From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private void addSchema(Element container, SchemaImpl s, String elementName) { if (_processedSchemas.contains(s)) return;/* w w w . j a v a2 s . com*/ Element schema = DocumentHelper.createElement(elementName); if (s.getId() != null) schema.addAttribute("id", qualify(s.getId())); if (s.getVisibility() == Visibility.PRIVATE) schema.addAttribute("visibility", "private"); if (s.getAnnotation() != null) { schema.addText(s.getAnnotation()); } for (Iterator j = s.getElementModel().iterator(); j.hasNext();) { ElementModel em = (ElementModel) j.next(); Element element = getElementElement(em); schema.add(element); } container.add(schema); _processedSchemas.add(s); }
From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private Element getElementElement(ElementModel em) { Element element = DocumentHelper.createElement("element"); element.addAttribute("name", em.getElementName()); if (em.getAnnotation() != null) { element.addText(em.getAnnotation()); }//from w w w . ja va 2s. com for (Iterator i = em.getAttributeModels().iterator(); i.hasNext();) { AttributeModel am = (AttributeModel) i.next(); Element attribute = getAttributeElement(am); element.add(attribute); } for (Iterator i = em.getElementModel().iterator(); i.hasNext();) { ElementModel nestedEm = (ElementModel) i.next(); Element nestedElement = getElementElement(nestedEm); element.add(nestedElement); } if (!em.getRules().isEmpty()) { Element rules = getRulesElement(em); element.add(rules); } return element; }
From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private Element getAttributeElement(AttributeModel am) { Element attribute = DocumentHelper.createElement("attribute"); attribute.addAttribute("name", am.getName()); if (am.isRequired()) attribute.addAttribute("required", "true"); if (am.isUnique()) attribute.addAttribute("unique", "true"); if (!am.getTranslator().equals("smart")) attribute.addAttribute("translator", am.getTranslator()); if (am.getAnnotation() != null) { attribute.addText(am.getAnnotation()); }//w w w. jav a2s . c o m return attribute; }
From source file:com.blocks.framework.utils.date.XMLDom4jUtils.java
License:Open Source License
/** * ElementString//from ww w .j av a 2 s .c o m * * @param parent * * @param name * * * * * @param value * * @return element * @throws XMLDocException */ public static Element appendChild(Element parent, String name, String value) { Element element = parent.addElement(new QName(name, parent.getNamespace())); if (value != null) { element.addText(value); } return element; }
From source file:com.bsoft.baseframe.baseframe_utils.beanUtils.CreateXMLFile.java
License:Open Source License
/** * xml??/* w w w . j ava 2s . com*/ * @return ?? */ public boolean createXMLFile() { String clsName = FileUtils.getClassName(tbName); String fileName = path + clsName + ".xml"; String beanName = beanPkg + "." + clsName; List<GenaBean> list = GenaBeanDBUtils.getFields(tbName); if (list.size() == 0) { return false; } StringBuffer fields = new StringBuffer(); StringBuffer values = new StringBuffer(); GenaBean gb = null; String fn = null; for (int i = 0; i < list.size(); i++) { gb = list.get(i); fn = gb.getColumnName(); fields.append(fn); if ("delflag".equals(fn)) { values.append("'0'"); } else if ("ctb1".equals(fn)) { values.append("getdate()"); } else { values.append("#").append(fn).append("#"); } if (i != list.size() - 1) { fields.append(", "); values.append(", "); } } System.out.println(fields.toString()); System.out.println(values.toString()); //Document Document document = DocumentHelper.createDocument(); // document.addDocType("sqlMap", "-//ibatis.apache.org//DTD SQL Map 2.0//EN", "http://ibatis.apache.org/dtd/sql-map-2.dtd"); // document Element rootElement = document.addElement("sqlMap"); //?? rootElement.addAttribute("namespace", clsName.toUpperCase()); //insert Element insertNode = rootElement.addElement("insert"); insertNode.addAttribute("id", "add" + clsName); insertNode.addAttribute("parameterClass", beanName); insertNode.setText("insert into " + tbName + "(" + fields + ") values (" + values + ")"); //? Element removeNode = rootElement.addElement("delete"); removeNode.addAttribute("id", "remove" + clsName); removeNode.addAttribute("parameterClass", beanName); removeNode.setText("delete from " + tbName + " where id = #id#"); // Element deleteNode = rootElement.addElement("update"); deleteNode.addAttribute("id", "del" + clsName); deleteNode.addAttribute("parameterClass", beanName); deleteNode.setText("update " + tbName + " set delflag=#delflag# where id = #id#"); //selectOne Element selectOneNode = rootElement.addElement("select"); selectOneNode.addAttribute("id", "getOne" + clsName); selectOneNode.addAttribute("parameterClass", beanName); selectOneNode.addAttribute("resultClass", beanName); selectOneNode.setText("select * from " + tbName + " where id = #id# "); //select Element selectNode = rootElement.addElement("select"); selectNode.addAttribute("id", "queryCount"); selectNode.addAttribute("resultClass", "int"); selectNode.setText("select count(*) as countnum from " + tbName + " where 1=1"); //select Element selectNode2 = rootElement.addElement("select"); selectNode2.addAttribute("id", "list" + clsName); selectNode2.addAttribute("resultClass", beanName); selectNode2.addAttribute("parameterClass", "java.util.Map"); selectNode2.setText("select * from (select top $endNum$ row_number()over(order by TT.id) as RN,* from" + "(SELECT * FROM " + tbName + " where 1=1) as TT)as H where RN > #startNum#"); //update Element updateNode = rootElement.addElement("update"); updateNode.addAttribute("id", "upSap" + clsName); updateNode.addAttribute("parameterClass", beanName); updateNode.setText("UPDATE " + tbName + " "); Element erElement = updateNode.addElement("dynamic"); erElement.addAttribute("prepend", "set"); for (int i = 0; i < list.size(); i++) { gb = list.get(i); fn = gb.getColumnName(); if (!"id".equals(fn)) { Element saElement = erElement.addElement("isNotNull"); saElement.addAttribute("property", fn); saElement.addAttribute("removeFirstPrepend", "true"); saElement.addAttribute("prepend", ","); saElement.setText(fn + "=#" + fn + "#"); } } updateNode.addText(" where "); Element terElement = updateNode.addElement("isNotNull"); terElement.addAttribute("property", "id"); terElement.setText(" id = #id# "); //update Element updateSimpleNode = rootElement.addElement("update"); updateSimpleNode.addAttribute("id", "update" + clsName); updateSimpleNode.addAttribute("parameterClass", beanName); StringBuffer sb = new StringBuffer(); sb.append("update ").append(tbName).append(" set "); for (int i = 0; i < list.size(); i++) { gb = list.get(i); fn = gb.getColumnName(); if (!"id".equals(fn)) { if ("ctb3".equals(fn)) { sb.append(fn).append("=").append("getdate()"); } else { sb.append(fn).append("=#").append(fn).append("#"); } if (i != list.size() - 1) { sb.append(", "); } } } sb.append(" where id = #id# "); updateSimpleNode.setText(sb.toString()); return FileUtils.wrieteXML2Doc(document, new File(fileName)); }
From source file:com.cosmosource.common.service.UserMgrManager.java
/** * @??: ?xml?//from w w w . j a v a2s . c om * @param nodeId * @param orgid * @return */ public String getOrgTreeData(String orgid, String ctx, String type) { if ("init".equals(type)) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("tree"); root.addAttribute("id", "0"); TAcOrg org = (TAcOrg) dao.findById(TAcOrg.class, new Long(orgid)); Element el = root.addElement("item"); el.addAttribute("text", org.getOrgname()); el.addAttribute("id", org.getOrgid() + ""); // el.addAttribute("open", "1"); el.addAttribute("child", "1"); Element elx = el.addElement("userdata"); elx.addAttribute("name", "url"); elx.addText(ctx + "/common/userMgr/list.act?nodeId=" + org.getOrgid() + "&orgtype=" + org.getOrgtype()); // getOrgTreeDoc(new Long(orgid), el, ctx, org.getOrgtype()); return doc.asXML(); } else { Element root = DocumentHelper.createElement("tree"); root.addAttribute("id", orgid); List<TAcOrg> list = dao .findByHQL("select t from TAcOrg t where t.parentid=" + orgid + " order by orgcode "); if (list.size() <= 500) { for (TAcOrg org : list) { Element el = root.addElement("item"); el.addAttribute("text", org.getOrgname()); el.addAttribute("id", org.getOrgid() + ""); if ("1".equals(org.getIsbottom())) { el.addAttribute("child", "1"); } else { el.addAttribute("child", "0"); } // if(org.getParentid()==0){ // el.addAttribute("open", "1"); // } Element elx = el.addElement("userdata"); elx.addAttribute("name", "url"); if (!org.getOrgtype().equals("3")) { elx.addText(ctx + "/common/userMgr/list.act?nodeId=" + org.getOrgid() + "&orgtype=" + org.getOrgtype()); } else { elx.addText(ctx + "/common/userMgr/orgFrame.act?nodeId=" + org.getOrgid()); } } } return root.asXML(); } }