List of usage examples for org.w3c.dom Element getTextContent
public String getTextContent() throws DOMException;
From source file:eu.elf.license.LicenseParser.java
/** * Creates List of LicenseModelGroup objects * * @param productGroupElementList - List of <ns:productGroup> elements * @return list of LicenseModelGroup objects */// w w w . j a v a 2s . c o m private static List<LicenseModelGroup> createLicenseModelGroupList(NodeList productGroupElementList) { List<LicenseModelGroup> lmgList = new ArrayList<LicenseModelGroup>(); for (int i = 0; i < productGroupElementList.getLength(); i++) { LicenseModelGroup tempLMG = new LicenseModelGroup(); Boolean isAccountGroup = false; Element productGroupElement = (Element) productGroupElementList.item(i); NamedNodeMap productGroupElementAttributeMap = productGroupElement.getAttributes(); for (int j = 0; j < productGroupElementAttributeMap.getLength(); j++) { Attr attrs = (Attr) productGroupElementAttributeMap.item(j); if (attrs.getNodeName().equals("id")) { if (attrs.getNodeValue().equals("ACCOUNTING_SUMMARY_GROUP")) { // Skip element with id="ACCOUNTING_SUMMARY_GROUP" - do not add to the list isAccountGroup = true; } if (attrs.getNodeName() != null) { tempLMG.setId(attrs.getNodeValue()); } } if (attrs.getNodeName().equals("name")) { if (attrs.getNodeName() != null) { tempLMG.setUrl(attrs.getNodeValue()); } } } if (isAccountGroup == true) { continue; // Skip element with id="ACCOUNTING_SUMMARY_GROUP" - do not add to the list } Element abstractElement = (Element) productGroupElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "abstract").item(0); if (abstractElement != null) { tempLMG.setDescription(abstractElement.getTextContent()); } Element titleElement = (Element) productGroupElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "title").item(0); if (titleElement != null) { tempLMG.setName(titleElement.getTextContent()); } NodeList productElementList = productGroupElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "product"); tempLMG.setLicenseModels(createLicenseModelList(productElementList)); lmgList.add(tempLMG); } return lmgList; }
From source file:eu.elf.license.LicenseParser.java
/** * Creates list of LicenseModel elements * * @param productElementList - NodeList of <ns:product> elements: * @return List of LicenseModel objects/*from w w w . j ava 2s.c o m*/ */ private static List<LicenseModel> createLicenseModelList(NodeList productElementList) { List<LicenseModel> lmList = new ArrayList<LicenseModel>(); for (int i = 0; i < productElementList.getLength(); i++) { LicenseModel tempLM = new LicenseModel(); Boolean isRestricted = true; Element productElement = (Element) productElementList.item(i); NamedNodeMap productElementAttributeMap = productElement.getAttributes(); for (int j = 0; j < productElementAttributeMap.getLength(); j++) { Attr attrs = (Attr) productElementAttributeMap.item(j); if (attrs.getNodeName().equals("id")) { if (attrs.getNodeName() != null) { tempLM.setId(attrs.getNodeValue()); } } } Element titleElement = (Element) productElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "title").item(0); if (titleElement != null) { tempLM.setName(titleElement.getTextContent()); } Element abstractElement = (Element) productElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "abstract").item(0); if (abstractElement != null) { tempLM.setDescription(abstractElement.getTextContent()); } Element calculationElement = (Element) productElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "calculation").item(0); Element declarationListElement = (Element) calculationElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "declarationList").item(0); Element predefinedParametersElement = (Element) declarationListElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "predefinedParameters").item(0); NodeList predefinedParametersParameterElementList = predefinedParametersElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "parameter"); for (int k = 0; k < predefinedParametersParameterElementList.getLength(); k++) { Element parameterElement = (Element) predefinedParametersParameterElementList.item(k); NamedNodeMap parameterElementAttributeMap = parameterElement.getAttributes(); for (int l = 0; l < parameterElementAttributeMap.getLength(); l++) { Attr attrs = (Attr) parameterElementAttributeMap.item(l); if (attrs.getNodeName().equals("name")) { if (attrs.getNodeName() != null) { if (attrs.getNodeValue().equals("ALL_ROLES")) { Element valueElement = (Element) parameterElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "value").item(0); if (valueElement.getTextContent().equals("true")) { isRestricted = false; } } } } if (attrs.getNodeName().equals("name")) { if (attrs.getNodeName() != null) { if (attrs.getNodeValue().equals("ALLOWED_ROLES")) { NodeList valueElementList = parameterElement .getElementsByTagNameNS("http://www.conterra.de/xcpf/1.1", "value"); for (int m = 0; m < valueElementList.getLength(); m++) { tempLM.addRole(valueElementList.item(m).getTextContent()); } } } } } } tempLM.setRestricted(isRestricted); tempLM.setParams(createLicenseModelParamList(declarationListElement)); lmList.add(tempLM); } return lmList; }
From source file:fm.last.lastfmlive.service.MapNodeMapper.java
public Map<String, String> mapNode(Node arg0, int arg1) throws DOMException { Map<String, String> result = new HashMap<String, String>(); for (String xpath : xpaths) { List<Node> nodes = xpathTemplate.evaluateAsNodeList(xpath, new DOMSource(arg0)); if (nodes.size() != 0) { Element e = (Element) nodes.get(0); result.put(e.getNodeName(), e.getTextContent()); }//from w w w. j av a 2 s . c o m } return result; }
From source file:edu.internet2.middleware.shibboleth.idp.config.profile.authn.IPAddressLoginHandlerBeanDefinitionParser.java
/** * Gets the list of IP ranges given in the configuration. * /* w ww .ja va 2s.co m*/ * @param config current configuration * * @return list of IP ranges */ protected List<IPRange> getIPRanges(Element config) { List<Element> ipEntries = XMLHelper.getChildElementsByTagNameNS(config, ProfileHandlerNamespaceHandler.NAMESPACE, "IPEntry"); if (ipEntries == null || ipEntries.isEmpty()) { String msg = "At least one IPEntry must be specified."; log.error(msg); throw new BeanCreationException(msg); } List<IPRange> ranges = new LazyList<IPRange>(); for (Element ipEntry : ipEntries) { ranges.add(IPRange.parseCIDRBlock(ipEntry.getTextContent())); } return ranges; }
From source file:com.mtgi.analytics.aop.config.v11.BtJdbcPersisterBeanDefinitionParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { //configure ID generator settings NodeList children = element.getElementsByTagNameNS("*", ELT_ID_SQL); if (children.getLength() == 1) { BeanDefinition def = builder.getRawBeanDefinition(); MutablePropertyValues props = def.getPropertyValues(); Element child = (Element) children.item(0); String sql = child.getTextContent(); if (StringUtils.hasText(sql)) props.addPropertyValue("idSql", sql); if (child.hasAttribute(ATT_INCREMENT)) props.addPropertyValue("idIncrement", child.getAttribute(ATT_INCREMENT)); }// w ww . j a v a2 s. co m //configure nested dataSource NodeList nodes = element.getElementsByTagNameNS("*", "data-source"); if (nodes.getLength() == 1) { Element ds = (Element) nodes.item(0); ds.setAttribute("name", "dataSource"); parserContext.getDelegate().parsePropertyElement(ds, builder.getRawBeanDefinition()); } //push persister into parent manager bean, if applicable if (parserContext.isNested()) { AbstractBeanDefinition def = builder.getBeanDefinition(); String id = element.hasAttribute("id") ? element.getAttribute("id") : BeanDefinitionReaderUtils.generateBeanName(def, parserContext.getReaderContext().getRegistry(), true); BeanDefinitionHolder holder = new BeanDefinitionHolder(def, id); BtManagerBeanDefinitionParser.registerNestedBean(holder, "persister", parserContext); } }
From source file:de.codesourcery.eve.skills.calendar.impl.PlaintextPayloadType.java
@Override public ICalendarEntryPayload parsePayload(Element element) throws ParseException { final PlaintextPayload result = new PlaintextPayload(); final Element child = XmlHelper.getElement(element, "plaintext", true); final String notes = child.getTextContent(); final String summary = child.getAttribute("summary"); result.setSummary(summary);/*from w w w . java2s . co m*/ result.setNotes(notes); return result; }
From source file:edu.internet2.middleware.shibboleth.common.config.profile.AbstractRequestURIMappedProfileHandlerBeanDefinitionParser.java
/** * Gets the list of request paths the profile handler handles. * //w ww . j av a2 s . c o m * @param config profile handler configuration element * * @return list of request paths the profile handler handles */ protected List<String> getRequestPaths(Element config) { ArrayList<String> requestPaths = new ArrayList<String>(); List<Element> requestPathElems = XMLHelper.getChildElementsByTagName(config, "RequestPath"); if (requestPathElems != null) { for (Element requestPathElem : requestPathElems) { requestPaths.add(DatatypeHelper.safeTrimOrNullString(requestPathElem.getTextContent())); } } return requestPaths; }
From source file:nats.client.spring.config.NatsBeanDefinitionParser.java
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(NatsFactoryBean.class); // Parse list of hosts final List<String> uris = new ManagedList<>(); final List<Element> hosts = DomUtils.getChildElementsByTagName(element, ELEMENT_URL); for (Element host : hosts) { uris.add(host.getTextContent()); }//from ww w .ja v a 2s.c om builder.addPropertyValue("hostUris", uris); // Parse list of subscriptions final List<BeanDefinition> subscriptions = new ManagedList<>(); final List<Element> subscriptionElements = DomUtils.getChildElementsByTagName(element, ELEMENT_SUBSCRIPTION); for (Element subscriptionElement : subscriptionElements) { final BeanDefinitionBuilder subscriptionBuilder = BeanDefinitionBuilder .genericBeanDefinition(SubscriptionConfig.class); subscriptionBuilder.addConstructorArgValue(subscriptionElement.getAttribute(ATTRIBUTE_SUBJECT)); subscriptionBuilder.addConstructorArgReference(subscriptionElement.getAttribute(ATTRIBUTE_REF)); subscriptionBuilder.addConstructorArgValue(subscriptionElement.getAttribute(ATTRIBUTE_METHOD)); subscriptionBuilder.addConstructorArgValue(subscriptionElement.getAttribute(ATTRIBUTE_QUEUE_GROUP)); subscriptions.add(subscriptionBuilder.getBeanDefinition()); } builder.addPropertyValue("subscriptions", subscriptions); // Parse attributes builder.addPropertyValue("autoReconnect", element.getAttribute(ATTRIBUTE_AUTO_RECONNECT)); builder.addPropertyValue("reconnectWaitTime", element.getAttribute(ATTRIBUTE_RECONNECT_WAIT_TIME)); final String eventLoopGroupRef = element.getAttribute(ATTRIBUTE_EVENT_LOOP_GROUP_REF); if (StringUtils.hasText(eventLoopGroupRef)) { builder.addPropertyReference("eventLoopGroup", eventLoopGroupRef); } final String callbackExecutorRef = element.getAttribute(ATTRIBUTE_CALLBACK_EXECUTOR_REF); if (StringUtils.hasText(callbackExecutorRef)) { builder.addPropertyReference("callbackExecutor", callbackExecutorRef); } final String connectionStateListenerRef = element.getAttribute(ATTRIBUTE_CONNECTION_STATE_LISTENER_REF); if (StringUtils.hasText(connectionStateListenerRef)) { builder.addPropertyReference("connectionStateListener", connectionStateListenerRef); } // Register bean final String id = element.getAttribute(ATTRIBUTE_ID); final AbstractBeanDefinition beanDefinition = builder.getBeanDefinition(); parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); return beanDefinition; }
From source file:eu.europa.ec.markt.dss.validation.xades.XAdESOCSPSource.java
@Override public List<BasicOCSPResp> getOCSPResponsesFromSignature() { List<BasicOCSPResp> list = new ArrayList<BasicOCSPResp>(); try {/*from w ww . j av a 2 s. c o m*/ NodeList nodeList = (NodeList) XMLUtils.getNodeList(signatureElement, "ds:Object/xades:QualifyingProperties/xades:UnsignedProperties/xades:UnsignedSignatureProperties/xades:RevocationValues/xades:OCSPValues/xades:EncapsulatedOCSPValue"); for (int i = 0; i < nodeList.getLength(); i++) { Element certEl = (Element) nodeList.item(i); byte[] derEncoded = Base64.decodeBase64(certEl.getTextContent()); list.add((BasicOCSPResp) new OCSPResp(derEncoded).getResponseObject()); } } catch (OCSPException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } return list; }
From source file:edu.internet2.middleware.shibboleth.common.config.security.StaticPKIXSignatureTrustEngineBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { log.info("Parsing configuration for {} trust engine with id: {}", XMLHelper.getXSIType(element).getLocalPart(), element.getAttributeNS(null, "id")); List<Element> childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE, "ValidationInfo"); builder.addPropertyValue("PKIXInfo", SpringConfigurationUtils.parseInnerCustomElements(childElems, parserContext)); childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE, "TrustedName"); HashSet<String> trustedNames = new HashSet<String>(childElems.size()); for (Element nameElem : childElems) { trustedNames.add(DatatypeHelper.safeTrimOrNullString(nameElem.getTextContent())); }/*from w ww .j a va2 s . com*/ builder.addPropertyValue("trustedNames", trustedNames); childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE, "ValidationOptions"); if (childElems.size() > 0) { builder.addPropertyValue("PKIXValidationOptions", SpringConfigurationUtils.parseInnerCustomElement((Element) childElems.get(0), parserContext)); } }