Java 8 Element - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Element class.

This code example shows how to use the following methods:getAttribute, hasAttribute
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document doc = builder.parse(new InputSource(new StringReader(xml)));
 
        Element rootElement = doc.getDocumentElement();
 
        CardType type      = CardType.class.getEnumConstants()[Integer.parseInt(rootElement.getAttribute("type"))];
        byte[]   id        = Utils.hexStringToByteArray(rootElement.getAttribute("id"));
        Date     scannedAt = rootElement.hasAttribute("scanned_at") ? new Date(Long.valueOf(rootElement.getAttribute("scanned_at"))) : new Date(0);
        switch (type) {
            case MifareDesfire:
                return DesfireCard.fromXml(id, scannedAt, rootElement);
            case CEPAS:
                return CEPASCard.fromXML(id, scannedAt, rootElement);
            case FeliCa:
                return FelicaCard.fromXml(id, scannedAt, rootElement);
            case MifareClassic:
                return ClassicCard.fromXml(id, scannedAt, rootElement);
            default: 
                throw new UnsupportedOperationException("Unsupported card type: " + type);
        } 

8
CodeRank
This code example shows how to use the following methods:getAttribute
This code example shows how to use the following methods:getAttribute, hasAttribute
		return beanDef;
	} 
 
	private RootBeanDefinition getRedirectView(Element element, HttpStatus status, Object source) {
		ConstructorArgumentValues cavs = new ConstructorArgumentValues();
		cavs.addIndexedArgumentValue(0, element.getAttribute("redirect-url"));
		RootBeanDefinition redirectView = new RootBeanDefinition(RedirectView.class, cavs, null);
		redirectView.setSource(source);
		if (status != null) {
			redirectView.getPropertyValues().add("statusCode", status);
		} 
		if (element.hasAttribute("context-relative")) {
			redirectView.getPropertyValues().add("contextRelative", element.getAttribute("context-relative"));
		} 
		if (element.hasAttribute("keep-query-params")) {
			redirectView.getPropertyValues().add("propagateQueryParams", element.getAttribute("keep-query-params"));
		} 
		return redirectView;
	} 
 
} 
8
CodeRank
This code example shows how to use the following methods:getAttribute, hasAttribute
		return true; 
	} 
 
	@Override 
	protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
		if (element.hasAttribute(ADDRESSES) &&
				(element.hasAttribute(HOST_ATTRIBUTE) || element.hasAttribute(PORT_ATTRIBUTE))) {
			parserContext.getReaderContext().error("If the 'addresses' attribute is provided, a connection " +
					"factory can not have 'host' or 'port' attributes.", element);
		} 
		String channelCacheSize = element.getAttribute(CHANNEL_CACHE_SIZE_ATTRIBUTE);
		String connectionCacheSize = element.getAttribute(CONNECTION_CACHE_SIZE_ATTRIBUTE);
		if (StringUtils.hasText(channelCacheSize) && StringUtils.hasText(connectionCacheSize)) {
			parserContext.getReaderContext().error(
					"Cannot have both 'connection-cache-size' and 'channel-cache-size' attributes", element);
		} 
		NamespaceUtils.addConstructorArgParentRefIfAttributeDefined(builder, element, CONNECTION_FACTORY_ATTRIBUTE);
		NamespaceUtils.setValueIfAttributeDefined(builder, element, CHANNEL_CACHE_SIZE_ATTRIBUTE);
		NamespaceUtils.setValueIfAttributeDefined(builder, element, HOST_ATTRIBUTE);
		NamespaceUtils.setValueIfAttributeDefined(builder, element, PORT_ATTRIBUTE);

8
CodeRank
This code example shows how to use the following methods:getAttribute, hasAttribute
	} 
 
	protected MutablePropertyValues parseCommonContainerProperties(Element containerEle, ParserContext parserContext) {
		MutablePropertyValues properties = new MutablePropertyValues();
 
		String destinationType = containerEle.getAttribute(DESTINATION_TYPE_ATTRIBUTE);
		boolean pubSubDomain = false;
		boolean subscriptionDurable = false;
		boolean subscriptionShared = false;
		if (DESTINATION_TYPE_SHARED_DURABLE_TOPIC.equals(destinationType)) {
			pubSubDomain = true;
			subscriptionDurable = true;
			subscriptionShared = true;
		} 
		else if (DESTINATION_TYPE_SHARED_TOPIC.equals(destinationType)) {
			pubSubDomain = true;
			subscriptionShared = true;
		} 
		else if (DESTINATION_TYPE_DURABLE_TOPIC.equals(destinationType)) {
			pubSubDomain = true;

8
CodeRank
This code example shows how to use the following methods:getAttribute
 * @version 1.0 
 */ 
public class SystemParameterNamesBeanDefinitionParser implements BeanDefinitionParser { 
    @Override 
    public BeanDefinition parse(Element element, ParserContext parserContext) {
        String appKey = element.getAttribute("appkey-param-name");
        String sessionId = element.getAttribute("sessionid-param-name");
        String method = element.getAttribute("method-param-name");
        String version = element.getAttribute("version-param-name");
        String format = element.getAttribute("format-param-name");
        String locale = element.getAttribute("locale-param-name");
        String sign = element.getAttribute("sign-param-name");
        String jsonp = element.getAttribute("jsonp-param-name");
 
        if (StringUtils.hasText(appKey)) {
            SystemParameterNames.setAppKey(appKey);
        } 
        if (StringUtils.hasText(sessionId)) {
            SystemParameterNames.setSessionId(sessionId);
        } 
8
CodeRank
This code example shows how to use the following methods:getAttribute
		return true; 
	} 
 
	@Override 
	protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
		String connectionFactoryRef = element.getAttribute(CONNECTION_FACTORY_ATTRIBUTE);
 
		// At least one of 'templateRef' or 'connectionFactoryRef' attribute must be set. 
		if (!StringUtils.hasText(connectionFactoryRef)) {
			parserContext.getReaderContext().error("A '" + CONNECTION_FACTORY_ATTRIBUTE + "' attribute must be set.",
					element);
		} 
 
		if (StringUtils.hasText(connectionFactoryRef)) {
			// Use constructor with connectionFactory parameter 
			builder.addConstructorArgReference(connectionFactoryRef);
		} 
 
		String attributeValue;
		attributeValue = element.getAttribute(AUTO_STARTUP_ATTRIBUTE);

8
CodeRank
This code example shows how to use the following methods:getAttribute, hasAttribute
	 * {@link Element} and add a {@code pointcut} property as appropriate. Generates a 
	 * {@link org.springframework.beans.factory.config.BeanDefinition} for the pointcut if  necessary 
	 * and returns its bean name, otherwise returns the bean name of the referred pointcut. 
	 */ 
	private Object parsePointcutProperty(Element element, ParserContext parserContext) {
		if (element.hasAttribute(POINTCUT) && element.hasAttribute(POINTCUT_REF)) {
			parserContext.getReaderContext().error(
					"Cannot define both 'pointcut' and 'pointcut-ref' on <advisor> tag.", 
					element, this.parseState.snapshot());
			return null; 
		} 
		else if (element.hasAttribute(POINTCUT)) {
			// Create a pointcut for the anonymous pc and register it. 
			String expression = element.getAttribute(POINTCUT);
			AbstractBeanDefinition pointcutDefinition = createPointcutDefinition(expression);
			pointcutDefinition.setSource(parserContext.extractSource(element));
			return pointcutDefinition;
		} 
		else if (element.hasAttribute(POINTCUT_REF)) {
			String pointcutRef = element.getAttribute(POINTCUT_REF);

8
CodeRank
This code example shows how to use the following methods:getElementsByTagName, appendChild
This code example shows how to use the following methods:getAttribute
 */ 
public class RangeFilterBuilder implements FilterBuilder { 
 
  @Override 
  public Filter getFilter(Element e) throws ParserException {
    String fieldName = DOMUtils.getAttributeWithInheritance(e, "fieldName");
 
    String lowerTerm = e.getAttribute("lowerTerm");
    String upperTerm = e.getAttribute("upperTerm");
    boolean includeLower = DOMUtils.getAttribute(e, "includeLower", true);
    boolean includeUpper = DOMUtils.getAttribute(e, "includeUpper", true);
    return TermRangeFilter.newStringRange(fieldName, lowerTerm, upperTerm, includeLower, includeUpper);
  } 
 
} 
7
CodeRank

Related Java 8 Element Questions & Answers:

Other Java 8 Element Examples

56:			for (int i = 0; i < nl.getLength(); i++) {
57:				// creating new HashMap
58:				HashMap<String, String> map = new HashMap<String, String>();
59:				Element e = (Element) nl.item(i);
60:				// adding each child node to HashMap key => value
-
56:			for (int i = 0; i < nl.getLength(); i++) {
57:				// creating new HashMap
58:				HashMapg, String> map = new HashMap<String, String>();
59:				Element e = (Element) nl.item(i);
60:				// adding each child node to HashMap key => value

Read More

44:				HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
45:				Element e = (Element) nl.item(i);
46:				// adding each child node to HashMap key =&gt; value
47:				map.put(KEY_ID, parser.getValue(e, KEY_ID));
48:				map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
-
44:				HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
45:				Element e = (Element) nl.item(i);
46:				// adding each child node to HashMap key =&gt; value
47:				map.put(KEY_ID, parser.getValue(e, KEY_ID));
48:				map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));

Read More

68:						Document doc = this.getDomElement(rss_feed_xml);
69:						NodeList nodeList = doc.getElementsByTagName(TAG_CHANNEL);
70:						Element e = (Element) nodeList.item(0);
71:						
72:						// RSS nodes
-
68:						Document doc = this.getDomElement(rss_feed_xml);
69:						NodeList nodeList = doc.getElementsByTagName(TAG_CHANNEL);
70:						Element e = (Element) nodeList.item(0);
71:						
72:						// RSS nodes
-
219:				DocumentBuilder db = dbf.newDocumentBuilder();
220:	
221:				InputSource is = new InputSource();
222:				is.setCharacterStream(new StringReader(xml));
223:				doc = (Document) db.parse(is);

Read More

See Code Examples for Java 8 Element Methods: