Java Code Examples for org.w3c.dom.Element#getChildNodes()
The following examples show how to use
org.w3c.dom.Element#getChildNodes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessDiagramLayoutFactory.java From flowable-engine with Apache License 2.0 | 6 votes |
protected Map<String, DiagramNode> getElementBoundsFromBpmnDi(Document bpmnModel) { Map<String, DiagramNode> listOfBounds = new HashMap<>(); // iterate over all DI shapes NodeList shapes = bpmnModel.getElementsByTagNameNS(BpmnParser.BPMN_DI_NS, "BPMNShape"); for (int i = 0; i < shapes.getLength(); i++) { Element shape = (Element) shapes.item(i); String bpmnElementId = shape.getAttribute("bpmnElement"); // get bounds of shape NodeList childNodes = shape.getChildNodes(); for (int j = 0; j < childNodes.getLength(); j++) { Node childNode = childNodes.item(j); if (childNode instanceof Element && BpmnParser.BPMN_DC_NS.equals(childNode.getNamespaceURI()) && "Bounds".equals(childNode.getLocalName())) { DiagramNode bounds = parseBounds((Element) childNode); bounds.setId(bpmnElementId); listOfBounds.put(bpmnElementId, bounds); break; } } } return listOfBounds; }
Example 2
Source File: XmlConfigurationParser.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static Element getChild(Element parent, String name) { NodeList list = parent.getChildNodes(); for (int i=0; i<list.getLength(); i++) { Node n = list.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { if (n.getNodeName().equals(name)) { return (Element)n; } } } return null; }
Example 3
Source File: XmlUtil.java From chipster with MIT License | 6 votes |
/** * Gets the child elements of a parent element. Unlike DOM's getElementsByTagName, this does no recursion, * uses local name (namespace free) instead of tag name, result is a proper Java data structure and result * needs no casting. In other words, this method does not suck unlike DOM. * * @param parent the XML parent element * @param name name of the child elements, if null then all are returned */ public static List<Element> getChildElements(Element parent, String name) { List<Element> childElements = new ArrayList<Element>(); NodeList childNodes = parent.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { // get elements if (childNodes.item(i).getNodeType() == Node.ELEMENT_NODE) { // match element name Element childElement = (Element) childNodes.item(i); if (name == null || childElement.getLocalName().equals(name)) { childElements.add(childElement); } } } return childElements; }
Example 4
Source File: M2AuxilaryConfigImpl.java From netbeans with Apache License 2.0 | 6 votes |
static void findDuplicateElements(@NonNull Element parent, @NonNull ProblemProvider pp, FileObject config) { NodeList l = parent.getChildNodes(); int nodeCount = l.getLength(); Set<String> known = new HashSet<String>(); for (int i = 0; i < nodeCount; i++) { if (l.item(i).getNodeType() == Node.ELEMENT_NODE) { Node node = l.item(i); String localName = node.getLocalName(); localName = localName == null ? node.getNodeName() : localName; String id = localName + "|" + node.getNamespaceURI(); if (!known.add(id)) { //we have a duplicate; pp.setProblem(ProjectProblem.createWarning( TXT_Problem_Broken_Config2(), DESC_Problem_Broken_Config2(), new ProblemReporterImpl.MavenProblemResolver(ProblemReporterImpl.createOpenFileAction(config), BROKEN_NBCONFIG))); } } } }
Example 5
Source File: DOMUtil.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static List<Element> getChildElements(Element e,String localName) { List<Element> r = new ArrayList<Element>(); NodeList l = e.getChildNodes(); for(int i=0;i<l.getLength();i++) { Node n = l.item(i); if(n.getNodeType()==Node.ELEMENT_NODE) { Element c = (Element)n; if(c.getLocalName().equals(localName)) r.add(c); } } return r; }
Example 6
Source File: DOMSignatureProperties.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Creates a <code>DOMSignatureProperties</code> from an element. * * @param propsElem a SignatureProperties element * @throws MarshalException if a marshalling error occurs */ public DOMSignatureProperties(Element propsElem, XMLCryptoContext context) throws MarshalException { // unmarshal attributes Attr attr = propsElem.getAttributeNodeNS(null, "Id"); if (attr != null) { id = attr.getValue(); propsElem.setIdAttributeNode(attr, true); } else { id = null; } NodeList nodes = propsElem.getChildNodes(); int length = nodes.getLength(); List<SignatureProperty> properties = new ArrayList<SignatureProperty>(length); for (int i = 0; i < length; i++) { Node child = nodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { String name = child.getLocalName(); if (!name.equals("SignatureProperty")) { throw new MarshalException("Invalid element name: " + name + ", expected SignatureProperty"); } properties.add(new DOMSignatureProperty((Element)child, context)); } } if (properties.isEmpty()) { throw new MarshalException("properties cannot be empty"); } else { this.properties = Collections.unmodifiableList(properties); } }
Example 7
Source File: DecisionNodeValidator.java From uflo with Apache License 2.0 | 5 votes |
@Override public void validate(Element element, List<String> errors,List<String> nodeNames) { super.validate(element, errors,nodeNames); String type=element.getAttribute("decision-type"); if(StringUtils.isEmpty(type)){ errors.add("路由决策节点必须要指定决策条件判断方式"); }else{ DecisionType decisionType=DecisionType.valueOf(type); if(decisionType.equals(DecisionType.Expression)){ if(StringUtils.isEmpty(element.getAttribute("expression"))){ NodeList nodeList=element.getChildNodes(); boolean hasExpr=false; for(int i=0;i<nodeList.getLength();i++){ Node node=nodeList.item(i); if(!(node instanceof Element)){ continue; } Element childElement=(Element)node; if(childElement.getNodeName().equals("expression")){ hasExpr=true; break; } } if(!hasExpr){ errors.add("路由决策节点条件判断方式表达式时,必须要指定一个具体表达式"); } } } if(decisionType.equals(DecisionType.Handler) && StringUtils.isEmpty(element.getAttribute("handler-bean"))){ errors.add("路由决策节点条件判断方式实现类Bean时,必须要指定一个具体实现类Bean"); } } }
Example 8
Source File: DomWriter.java From cosmo with Apache License 2.0 | 5 votes |
private static void writeElement(Element e, XMLStreamWriter writer) throws XMLStreamException { String local = e.getLocalName(); if (local == null) { local = e.getNodeName(); } String ns = e.getNamespaceURI(); if (ns != null) { String prefix = e.getPrefix(); if (prefix != null) { writer.writeStartElement(prefix, local, ns); writer.writeNamespace(prefix, ns); } else { writer.setDefaultNamespace(ns); writer.writeStartElement(ns, local); writer.writeDefaultNamespace(ns); } } else { writer.writeStartElement(local); } NamedNodeMap attributes = e.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { writeAttribute((Attr) attributes.item(i), writer); } NodeList children = e.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { writeNode(children.item(i), writer); } writer.writeEndElement(); }
Example 9
Source File: DOMPolicyIssuer.java From XACML with MIT License | 5 votes |
/** * Creates a new <code>DOMPolicyIssuer</code> by parsing the given <code>Node</code> representing a XACML PolicyIssuer element. * * @param nodePolicyIssuer the <code>Node</code> representing the PolicyIssuer element * @return the new <code>DOMPolicyIssuer</code> parsed from the given <code>Node</code> * @throws DOMStructureException if the conversion is not possible */ public static PolicyIssuer newInstance(Node nodePolicyIssuer) throws DOMStructureException { Element elementPolicyIssuer = DOMUtil.getElement(nodePolicyIssuer); boolean bLenient = DOMProperties.isLenient(); DOMPolicyIssuer domPolicyIssuer = new DOMPolicyIssuer(); try { NodeList children = elementPolicyIssuer.getChildNodes(); int numChildren; if (children != null && (numChildren = children.getLength()) > 0) { for (int i = 0 ; i < numChildren ; i++) { Node child = children.item(i); if (DOMUtil.isElement(child)) { if (DOMUtil.isInNamespace(child, XACML3.XMLNS)) { String childName = child.getLocalName(); if (XACML3.ELEMENT_CONTENT.equals(childName)) { if (domPolicyIssuer.getContent() != null && !bLenient) { throw DOMUtil.newUnexpectedElementException(child, nodePolicyIssuer); } domPolicyIssuer.setContent(child); } else if (XACML3.ELEMENT_ATTRIBUTE.equals(childName)) { domPolicyIssuer.add(DOMAttribute.newInstance(identifierCategoryPolicyIssuer, child)); } else if (!bLenient) { throw DOMUtil.newUnexpectedElementException(child, nodePolicyIssuer); } } } } } } catch (DOMStructureException ex) { domPolicyIssuer.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage()); if (DOMProperties.throwsExceptions()) { throw ex; } } return domPolicyIssuer; }
Example 10
Source File: SourceDataTagQuality.java From c2mon with GNU Lesser General Public License v3.0 | 5 votes |
/** * Create a SourceDataQuality object from its XML representation. The format * of the XML required is determined by the output of the toXML() method. * * @deprecated Should be removed once XML serialization is not anymore supported */ @Deprecated public static SourceDataTagQuality fromXML(Element domElement) { NodeList fields = domElement.getChildNodes(); int fieldsCount = fields.getLength(); String fieldName; String fieldValueString; Node fieldNode; // Create result object SourceDataTagQuality result = new SourceDataTagQuality(); // Extract information from DOM elements for (int i = 0; i != fieldsCount; i++) { fieldNode = fields.item(i); if (fieldNode.getNodeType() == Node.ELEMENT_NODE) { fieldName = fieldNode.getNodeName(); Node fieldValueNode = fieldNode.getFirstChild(); if (fieldValueNode != null) { fieldValueString = fieldValueNode.getNodeValue(); } else { fieldValueString = ""; } if (fieldName.equals(XML_ELEMENT_QUALITY_CODE)) { short code = Short.parseShort(fieldValueString); result.qualityCode = SourceDataTagQualityCode.getEnum(code); } else if (fieldName.equals(XML_ELEMENT_QUALITY_DESC)) { result.description = fieldValueString; } } } return result; }
Example 11
Source File: DOMUtils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** Gets the fist child of the given name, or null. */ public static Element getFirstChildElement( Element parent, String nsUri, String localPart ) { NodeList children = parent.getChildNodes(); for( int i=0; i<children.getLength(); i++ ) { Node item = children.item(i); if(!(item instanceof Element )) continue; if(nsUri.equals(item.getNamespaceURI()) && localPart.equals(item.getLocalName()) ) return (Element)item; } return null; }
Example 12
Source File: ServiceProvisioningServiceWSTest.java From development with Apache License 2.0 | 5 votes |
/** * parse the XML content and verify the ModificationType has been exported * as expected * * @param xmlString * @throws Exception */ private void verifyXmlForModificationType(String srvId, String xmlString, ParameterModificationType currentModificationType) throws Exception { // parse the XML content DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(new InputSource(new StringReader( xmlString))); Element root = (Element) XMLConverter.getNodeByXPath(document, "//*[local-name(.)=\'TechnicalService\'][@id=\'" + srvId + "\']"); NodeList serviceNode = root.getChildNodes(); for (int index = 0; index < serviceNode.getLength(); index++) { if (serviceNode.item(index).getNodeName() .equals("ParameterDefinition")) { // verify parameter definition attribute NamedNodeMap parameterDefinitionAttrs = serviceNode.item(index) .getAttributes(); // if the currentModificationType is not OneTime, the // modificationType attribute should not be exported if (parameterDefinitionAttrs.getNamedItem("id").equals("TEST")) { if (currentModificationType == null || currentModificationType .equals(ParameterModificationType.STANDARD)) { assertNull(parameterDefinitionAttrs .getNamedItem("modificationType")); } else { // if the currentModificationType is OneTime, verify the // value is correct assertEquals( currentModificationType.name(), parameterDefinitionAttrs.getNamedItem( "modificationType").getTextContent()); } } } } }
Example 13
Source File: ExtractorModelParser_v1.java From link-move with Apache License 2.0 | 5 votes |
protected void doParse(Element rootElement, MutableExtractorModelContainer container, MutableExtractorModel extractor) throws DOMException { NodeList nodes = rootElement.getChildNodes(); int len = nodes.getLength(); for (int i = 0; i < len; i++) { Node c = nodes.item(i); if (Node.ELEMENT_NODE == c.getNodeType()) { Element e = (Element) c; switch (e.getNodeName()) { case "type": // enough to set this at the container level.. extractor // will inherit the type container.setType(e.getTextContent()); break; case "connectorId": // enough to set this at the container level.. extractor // will inherit the connectorId container.addConnectorId(e.getTextContent()); break; case "attributes": processAttributes(e, extractor); break; case "properties": processProperties(e, extractor); break; } } } }
Example 14
Source File: BPELPlanHandler.java From container with Apache License 2.0 | 5 votes |
/** * Returns a List of Strings which represent all Links declared in the given BuildPlan * * @param buildPlan the BuildPlan whose declared Links should be returned * @return a List of Strings containing all Links of the given BuildPlan */ public List<String> getAllLinks(final BPELPlan buildPlan) { final Element flowLinks = buildPlan.getBpelMainFlowLinksElement(); final List<String> linkNames = new ArrayList<>(); final NodeList children = flowLinks.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeName().equals("link")) { linkNames.add(children.item(i).getAttributes().getNamedItem("name").getNodeValue()); } if (children.item(i).getLocalName().equals("link")) { linkNames.add(children.item(i).getAttributes().getNamedItem("name").getNodeValue()); } } return linkNames; }
Example 15
Source File: BootableJar.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void updateConfig(Path configFile, String name, boolean isExploded) throws Exception { FileInputStream fileInputStream = new FileInputStream(configFile.toFile()); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(fileInputStream); Element root = document.getDocumentElement(); NodeList lst = root.getChildNodes(); for (int i = 0; i < lst.getLength(); i++) { Node n = lst.item(i); if (n instanceof Element) { if (DEPLOYMENTS.equals(n.getNodeName())) { throw BootableJarLogger.ROOT_LOGGER.deploymentAlreadyExist(); } } } Element deployments = document.createElement(DEPLOYMENTS); Element deployment = document.createElement(DEPLOYMENT); Element content = document.createElement(CONTENT); content.setAttribute(SHA1, DEP_1 + DEP_2); if (isExploded) { content.setAttribute(ARCHIVE, "false"); } deployment.appendChild(content); deployment.setAttribute(NAME, name); deployment.setAttribute(RUNTIME_NAME, name); deployments.appendChild(deployment); root.appendChild(deployments); Transformer transformer = TransformerFactory.newInstance().newTransformer(); StreamResult output = new StreamResult(configFile.toFile()); DOMSource input = new DOMSource(document); transformer.transform(input, output); }
Example 16
Source File: ToolsInstructionsCleaner.java From buck with Apache License 2.0 | 4 votes |
@NonNull private static MergingReport.Result cleanToolsReferences( @NonNull ManifestMerger2.MergeType mergeType, @NonNull Element element, @NonNull ILogger logger) { NamedNodeMap namedNodeMap = element.getAttributes(); if (namedNodeMap != null) { // make a copy of the original list of attributes as we will remove some during this // process. List<Node> attributes = new ArrayList<Node>(); for (int i = 0; i < namedNodeMap.getLength(); i++) { attributes.add(namedNodeMap.item(i)); } for (Node attribute : attributes) { if (SdkConstants.TOOLS_URI.equals(attribute.getNamespaceURI())) { // we need to special case when the element contained tools:node="remove" // since it also needs to be deleted unless it had a selector. // if this is tools:node="removeAll", we always delete the element whether or // not there is a tools:selector. boolean hasSelector = namedNodeMap.getNamedItemNS( SdkConstants.TOOLS_URI, "selector") != null; if (attribute.getLocalName().equals(NodeOperationType.NODE_LOCAL_NAME) && (attribute.getNodeValue().equals(REMOVE_ALL_OPERATION_XML_MAME) || (attribute.getNodeValue().equals(REMOVE_OPERATION_XML_MAME)) && !hasSelector)) { if (element.getParentNode().getNodeType() == Node.DOCUMENT_NODE) { logger.error(null /* Throwable */, String.format( "tools:node=\"%1$s\" not allowed on top level %2$s element", attribute.getNodeValue(), XmlNode.unwrapName(element))); return ERROR; } else { element.getParentNode().removeChild(element); } } else { // anything else, we just clean the attribute unless we are merging for // libraries. if (mergeType != ManifestMerger2.MergeType.LIBRARY) { element.removeAttributeNS( attribute.getNamespaceURI(), attribute.getLocalName()); } } } // this could also be the xmlns:tools declaration. if (attribute.getNodeName().startsWith(SdkConstants.XMLNS_PREFIX) && SdkConstants.TOOLS_URI.equals(attribute.getNodeValue()) && mergeType != ManifestMerger2.MergeType.LIBRARY) { element.removeAttribute(attribute.getNodeName()); } } } // make a copy of the element children since we will be removing some during // this process, we don't want side effects. NodeList childNodes = element.getChildNodes(); ImmutableList.Builder<Element> childElements = ImmutableList.builder(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { childElements.add((Element) node); } } for (Element childElement : childElements.build()) { if (cleanToolsReferences(mergeType, childElement, logger) == ERROR) { return ERROR; } } return MergingReport.Result.SUCCESS; }
Example 17
Source File: JupiterBeanDefinitionParser.java From Jupiter with Apache License 2.0 | 4 votes |
private BeanDefinition parseJupiterClient(Element element, ParserContext parserContext) { RootBeanDefinition def = new RootBeanDefinition(); def.setBeanClass(beanClass); addProperty(def, element, "appName", false); addProperty(def, element, "registryType", false); addPropertyReference(def, element, "connector", false); List<Pair<JOption<Object>, String>> childOptions = Lists.newArrayList(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); if (item instanceof Element) { String localName = item.getLocalName(); if ("property".equals(localName)) { addProperty(def, (Element) item, "registryServerAddresses", false); addProperty(def, (Element) item, "providerServerAddresses", false); addPropertyReferenceArray( def, (Element) item, ConsumerInterceptor.class.getName(), "globalConsumerInterceptors", false); } else if ("netOptions".equals(localName)) { NodeList configList = item.getChildNodes(); for (int j = 0; j < configList.getLength(); j++) { Node configItem = configList.item(j); if (configItem instanceof Element) { parseNetOption(configItem, null, childOptions); } } } } } if (!childOptions.isEmpty()) { def.getPropertyValues().addPropertyValue("childNetOptions", childOptions); } return registerBean(def, element, parserContext); }
Example 18
Source File: RWikiEntityImpl.java From sakai with Educational Community License v2.0 | 4 votes |
/** * {@inheritDoc} */ public void fromXml(Element el, String defaultRealm) throws Exception { if (rwo == null) throw new RuntimeException( " Cant deserialise containers at the moment "); NodeList nl = el.getElementsByTagName("properties"); // this is hard coded in BaseResourceProperties the element name // properties if (nl == null || nl.getLength() != 1) throw new Exception("Cant find a properties element in " + el.getNodeName() + " id: " + el.getAttribute(SchemaNames.ATTR_ID) + " pagename: " + el.getAttribute(SchemaNames.ATTR_PAGE_NAME)); // only take the first properties Element properties = (Element) nl.item(0); ResourceProperties rp = new BaseResourceProperties(properties); nl = el.getElementsByTagName(SchemaNames.EL_WIKICONTENT); if (nl == null || nl.getLength() != 1) throw new Exception("Cant find a wikiproperties element in " + el.getNodeName() + " id: " + el.getAttribute(SchemaNames.ATTR_ID) + " pagename: " + el.getAttribute(SchemaNames.ATTR_PAGE_NAME)); // only accpet the first Element wikiContents = (Element) nl.item(0); nl = wikiContents.getChildNodes(); StringBuffer content = new StringBuffer(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i); if (n instanceof CharacterData) { CharacterData cdnode = (CharacterData) n; try { content.append(new String(Base64.decode(cdnode.getData()), "UTF-8")); } catch (Throwable t) { log.warn("Cant decode node content for " + cdnode); } } } String realm = rp.getProperty(RWikiEntity.RP_REALM); rwo.setId(rp.getProperty(RWikiEntity.RP_ID)); rwo.setName(NameHelper.globaliseName(NameHelper.localizeName(rp .getProperty(RWikiEntity.RP_NAME), realm), defaultRealm)); rwo.setOwner(rp.getProperty(RWikiEntity.RP_OWNER)); rwo.setRealm(defaultRealm); rwo.setReferenced(rp.getProperty(RWikiEntity.RP_REFERENCED)); // rwo.setRwikiobjectid(rp.getProperty("rwid")); rwo.setContent(content.toString()); if (!rwo.getSha1().equals(rp.getProperty(RWikiEntity.RP_SHA1))) throw new Exception("Sha Checksum Missmatch on content " + rp.getProperty(RWikiEntity.RP_SHA1) + " != " + rwo.getSha1()); rwo.setUser(rp.getProperty(RWikiEntity.RP_USER)); rwo.setGroupAdmin(rp.getBooleanProperty(RWikiEntity.RP_GROUP_ADMIN)); rwo.setGroupRead(rp.getBooleanProperty(RWikiEntity.RP_GROUP_READ)); rwo.setGroupWrite(rp.getBooleanProperty(RWikiEntity.RP_GROUP_WRITE)); rwo.setOwnerAdmin(rp.getBooleanProperty(RWikiEntity.RP_OWNER_ADMIN)); rwo.setOwnerRead(rp.getBooleanProperty(RWikiEntity.RP_OWNER_READ)); rwo.setOwnerWrite(rp.getBooleanProperty(RWikiEntity.RP_OWNER_WRITE)); rwo.setPublicRead(rp.getBooleanProperty(RWikiEntity.RP_PUBLIC_READ)); rwo.setPublicWrite(rp.getBooleanProperty(RWikiEntity.RP_PUBLIC_WRITE)); rwo.setRevision(Integer.valueOf(rp.getProperty(RWikiEntity.RP_REVISION))); rwo.setVersion(new Date(rp.getLongProperty(RWikiEntity.RP_VERSION))); }
Example 19
Source File: Statistics.java From xcurator with Apache License 2.0 | 4 votes |
private void updateStatsForElement(Element entityElement) { mergedCount += entityElement.getAttribute("type").contains("_or_") ? 1 : 0; NodeList children = entityElement.getChildNodes(); int propertyCount = 0; int linkCount = 0; int relCount = 0; boolean linked = false; for (int i = 0; i < children.getLength(); i++) { Node childNode = children.item(i); if (childNode instanceof Element) { Element entityChild = (Element) childNode; if ("property".equals(entityChild.getNodeName())) { this.propertyCount++; propertyCount++; boolean propertyLinked = false; NodeList propertyChildren = entityChild.getChildNodes(); for (int j = 0; j < propertyChildren.getLength(); j++) { Node propertyChildNode = propertyChildren.item(j); if (propertyChildNode instanceof Element && "ontology-link".equals(propertyChildNode.getNodeName())) { linkCount++; this.linkCount++; propertyLinked = true; } } if (propertyLinked) { linkedCount++; } } else if ("ontology-link".equals(entityChild.getNodeName())) { linkCount++; this.linkCount++; linked = true; } else if ("relation".equals(entityChild.getNodeName())) { relCount++; this.relCount++; } } } this.relMin = Math.min(relCount, this.relMin); this.relMax = Math.max(relCount, this.relMax); this.propertyMax = Math.max(propertyCount, propertyMax); this.propertyMin = Math.min(propertyCount, propertyMin); this.linkMax = Math.max(linkCount, linkMax); this.linkMin = Math.min(linkCount, linkMin); if (relCount == 0 && linkCount > 0 && propertyCount == 1) { promotedCount++; } if (linked) { linkedCount++; } }
Example 20
Source File: FileConfigurationParser.java From activemq-artemis with Apache License 2.0 | 4 votes |
private <T extends FederationStreamConfiguration> T getFederationStream(final T config, final Element upstreamNode, final Configuration mainConfig) throws Exception { String name = upstreamNode.getAttribute("name"); config.setName(name); // parsing federation password String passwordTextFederation = upstreamNode.getAttribute("password"); if (passwordTextFederation != null && !passwordTextFederation.isEmpty()) { String resolvedPassword = PasswordMaskingUtil.resolveMask(mainConfig.isMaskPassword(), passwordTextFederation, mainConfig.getPasswordCodec()); config.getConnectionConfiguration().setPassword(resolvedPassword); } config.getConnectionConfiguration().setUsername(upstreamNode.getAttribute("user")); NamedNodeMap attributes = upstreamNode.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Node item = attributes.item(i); if (item.getNodeName().equals("priority-adjustment")) { int priorityAdjustment = Integer.parseInt(item.getNodeValue()); config.getConnectionConfiguration().setPriorityAdjustment(priorityAdjustment); } } boolean ha = getBoolean(upstreamNode, "ha", false); long circuitBreakerTimeout = getLong(upstreamNode, "circuit-breaker-timeout", config.getConnectionConfiguration().getCircuitBreakerTimeout(), Validators.MINUS_ONE_OR_GE_ZERO); long clientFailureCheckPeriod = getLong(upstreamNode, "check-period", ActiveMQDefaultConfiguration.getDefaultFederationFailureCheckPeriod(), Validators.GT_ZERO); long connectionTTL = getLong(upstreamNode, "connection-ttl", ActiveMQDefaultConfiguration.getDefaultFederationConnectionTtl(), Validators.GT_ZERO); long retryInterval = getLong(upstreamNode, "retry-interval", ActiveMQDefaultConfiguration.getDefaultFederationRetryInterval(), Validators.GT_ZERO); long callTimeout = getLong(upstreamNode, "call-timeout", ActiveMQClient.DEFAULT_CALL_TIMEOUT, Validators.GT_ZERO); long callFailoverTimeout = getLong(upstreamNode, "call-failover-timeout", ActiveMQClient.DEFAULT_CALL_FAILOVER_TIMEOUT, Validators.MINUS_ONE_OR_GT_ZERO); double retryIntervalMultiplier = getDouble(upstreamNode, "retry-interval-multiplier", ActiveMQDefaultConfiguration.getDefaultFederationRetryIntervalMultiplier(), Validators.GT_ZERO); long maxRetryInterval = getLong(upstreamNode, "max-retry-interval", ActiveMQDefaultConfiguration.getDefaultFederationMaxRetryInterval(), Validators.GT_ZERO); int initialConnectAttempts = getInteger(upstreamNode, "initial-connect-attempts", ActiveMQDefaultConfiguration.getDefaultFederationInitialConnectAttempts(), Validators.MINUS_ONE_OR_GE_ZERO); int reconnectAttempts = getInteger(upstreamNode, "reconnect-attempts", ActiveMQDefaultConfiguration.getDefaultFederationReconnectAttempts(), Validators.MINUS_ONE_OR_GE_ZERO); List<String> staticConnectorNames = new ArrayList<>(); String discoveryGroupName = null; NodeList children = upstreamNode.getChildNodes(); List<String> policyRefs = new ArrayList<>(); for (int j = 0; j < children.getLength(); j++) { Node child = children.item(j); if (child.getNodeName().equals("discovery-group-ref")) { discoveryGroupName = child.getAttributes().getNamedItem("discovery-group-name").getNodeValue(); } else if (child.getNodeName().equals("static-connectors")) { getStaticConnectors(staticConnectorNames, child); } else if (child.getNodeName().equals("policy")) { policyRefs.add(((Element)child).getAttribute("ref")); } } config.addPolicyRefs(policyRefs); config.getConnectionConfiguration() .setCircuitBreakerTimeout(circuitBreakerTimeout) .setHA(ha) .setClientFailureCheckPeriod(clientFailureCheckPeriod) .setConnectionTTL(connectionTTL) .setRetryInterval(retryInterval) .setRetryIntervalMultiplier(retryIntervalMultiplier) .setMaxRetryInterval(maxRetryInterval) .setInitialConnectAttempts(initialConnectAttempts) .setReconnectAttempts(reconnectAttempts) .setCallTimeout(callTimeout) .setCallFailoverTimeout(callFailoverTimeout); if (!staticConnectorNames.isEmpty()) { config.getConnectionConfiguration().setStaticConnectors(staticConnectorNames); } else { config.getConnectionConfiguration().setDiscoveryGroupName(discoveryGroupName); } return config; }