List of usage examples for org.dom4j DocumentHelper createElement
public static Element createElement(String name)
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);//from w w w . j a va 2s .c om } } 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 ww . j ava 2s . c o 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 Element getSubModuleElement(SubModuleDescriptor smd) { Element subModule = DocumentHelper.createElement("sub-module"); subModule.addAttribute("descriptor", smd.getDescriptor().getPath()); return subModule; }
From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private Element getInstanceBuilderElement(InstanceBuilder ib) { Element instanceBuilder;/* w ww . j av a 2s . c o m*/ if (ib instanceof CreateInstanceDescriptor) { CreateInstanceDescriptor cid = (CreateInstanceDescriptor) ib; instanceBuilder = DocumentHelper.createElement("create-instance"); instanceBuilder.addAttribute("class", cid.getInstanceClassName()); if (!cid.getServiceModel().equals("singleton")) instanceBuilder.addAttribute("model", cid.getServiceModel()); } else { InvokeFactoryDescriptor ifd = (InvokeFactoryDescriptor) ib; instanceBuilder = DocumentHelper.createElement("invoke-factory"); if (!ifd.getFactoryServiceId().equals("hivemind.BuilderFactory")) instanceBuilder.addAttribute("service-id", qualify(ifd.getFactoryServiceId())); if (ifd.getServiceModel() != null) instanceBuilder.addAttribute("model", ifd.getServiceModel()); List parameters = ifd.getParameters(); 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); instanceBuilder.add(element); } } } return instanceBuilder; }
From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private Element getInterceptorElement(InterceptorDescriptor icd) { Element interceptor = DocumentHelper.createElement("interceptor"); interceptor.addAttribute("service-id", qualify(icd.getFactoryServiceId())); if (icd.getBefore() != null) interceptor.addAttribute("before", icd.getBefore()); if (icd.getAfter() != null) interceptor.addAttribute("after", icd.getAfter()); return interceptor; }
From source file:com.anite.maven.plugin.hivedoc.Dom4JRegistrySerializer.java
License:Apache License
private Element getParamterElement(org.apache.hivemind.Element parameter) { Element element = DocumentHelper.createElement(parameter.getElementName()); List attributes = parameter.getAttributes(); for (Iterator i = attributes.iterator(); i.hasNext();) { Attribute attribute = (Attribute) i.next(); element.addAttribute(attribute.getName(), attribute.getValue()); }/*from www. ja va2 s . c o m*/ List elements = parameter.getElements(); for (Iterator i = elements.iterator(); i.hasNext();) { org.apache.hivemind.Element nestedParameter = (org.apache.hivemind.Element) i.next(); element.add(getParamterElement(nestedParameter)); } return element; }
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;/*from ww w.j a v a 2 s . co m*/ 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 getRulesElement(ElementModel em) { Element rules = DocumentHelper.createElement("rules"); for (Iterator i = em.getRules().iterator(); i.hasNext();) { Rule r = (Rule) i.next();/*from ww w.j av a2 s. co m*/ Element rule = null; if (r instanceof CreateObjectRule) { CreateObjectRule cor = (CreateObjectRule) r; rule = DocumentHelper.createElement("create-object"); rule.addAttribute("class", cor.getClassName()); } else if (r instanceof InvokeParentRule) { InvokeParentRule ipr = (InvokeParentRule) r; rule = DocumentHelper.createElement("invoke-parent"); rule.addAttribute("method", ipr.getMethodName()); if (ipr.getDepth() != 1) rule.addAttribute("depth", Integer.toString(ipr.getDepth())); } else if (r instanceof PushAttributeRule) { PushAttributeRule par = (PushAttributeRule) r; rule = DocumentHelper.createElement("push-attribute"); rule.addAttribute("attribute", par.getAttributeName()); } else if (r instanceof PushContentRule) { rule = DocumentHelper.createElement("push-content"); } else if (r instanceof ReadAttributeRule) { ReadAttributeRule rar = (ReadAttributeRule) r; rule = DocumentHelper.createElement("read-attribute"); rule.addAttribute("property", rar.getPropertyName()); rule.addAttribute("attribute", rar.getAttributeName()); if (!rar.getSkipIfNull()) rule.addAttribute("skip-if-null", "false"); if (rar.getTranslator() != null) rule.addAttribute("translator", rar.getTranslator()); } else if (r instanceof ReadContentRule) { ReadContentRule rcr = (ReadContentRule) r; rule = DocumentHelper.createElement("read-content"); rule.addAttribute("property", rcr.getPropertyName()); } else if (r instanceof SetModuleRule) { SetModuleRule smr = (SetModuleRule) r; rule = DocumentHelper.createElement("set-module"); rule.addAttribute("property", smr.getPropertyName()); } else if (r instanceof SetParentRule) { SetParentRule spr = (SetParentRule) r; rule = DocumentHelper.createElement("set-parent"); rule.addAttribute("property", spr.getPropertyName()); } else if (r instanceof SetPropertyRule) { SetPropertyRule spr = (SetPropertyRule) r; rule = DocumentHelper.createElement("set-property"); rule.addAttribute("property", spr.getPropertyName()); rule.addAttribute("value", spr.getValue()); } else if (r instanceof ConversionDescriptor) { ConversionDescriptor cd = (ConversionDescriptor) r; rule = DocumentHelper.createElement("conversion"); rule.addAttribute("class", cd.getClassName()); if (!cd.getParentMethodName().equals("addElement")) rule.addAttribute("parent-method", cd.getParentMethodName()); for (Iterator j = cd.getAttributeMappings().iterator(); j.hasNext();) { AttributeMappingDescriptor amd = (AttributeMappingDescriptor) j.next(); Element map = DocumentHelper.createElement("map"); map.addAttribute("attribute", amd.getAttributeName()); map.addAttribute("property", amd.getPropertyName()); rule.add(map); } } else { rule = DocumentHelper.createElement("custom"); rule.addAttribute("class", r.getClass().getName()); } if (rule != null) rules.add(rule); } return rules; }
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()); }/* www. j ava 2 s . c o m*/ 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()); }//from w ww .j av a 2s.c om return attribute; }