當前位置: 首頁>>代碼示例>>Java>>正文


Java DomUtils.getChildElementsByTagName方法代碼示例

本文整理匯總了Java中org.springframework.util.xml.DomUtils.getChildElementsByTagName方法的典型用法代碼示例。如果您正苦於以下問題:Java DomUtils.getChildElementsByTagName方法的具體用法?Java DomUtils.getChildElementsByTagName怎麽用?Java DomUtils.getChildElementsByTagName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.util.xml.DomUtils的用法示例。


在下文中一共展示了DomUtils.getChildElementsByTagName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parsePropsElement

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
	ManagedProperties props = new OrderedManagedProperties();
	props.setSource(extractSource(propsEle));
	props.setMergeEnabled(parseMergeAttribute(propsEle));

	List propEles = DomUtils.getChildElementsByTagName(propsEle, BeanDefinitionParserDelegate.PROP_ELEMENT);
	for (Iterator it = propEles.iterator(); it.hasNext();) {
		Element propEle = (Element) it.next();
		String key = propEle.getAttribute(BeanDefinitionParserDelegate.KEY_ATTRIBUTE);
		// Trim the text value to avoid unwanted whitespace
		// caused by typical XML formatting.
		String value = DomUtils.getTextValue(propEle).trim();

		TypedStringValue keyHolder = new TypedStringValue(key);
		keyHolder.setSource(extractSource(propEle));
		TypedStringValue valueHolder = new TypedStringValue(value);
		valueHolder.setSource(extractSource(propEle));
		props.put(keyHolder, valueHolder);
	}

	return props;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:26,代碼來源:BlueprintParser.java

示例2: doParse

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	builder.addPropertyReference("transactionManager", TxNamespaceHandler.getTransactionManagerName(element));

	List<Element> txAttributes = DomUtils.getChildElementsByTagName(element, ATTRIBUTES_ELEMENT);
	if (txAttributes.size() > 1) {
		parserContext.getReaderContext().error(
				"Element <attributes> is allowed at most once inside element <advice>", element);
	}
	else if (txAttributes.size() == 1) {
		// Using attributes source.
		Element attributeSourceElement = txAttributes.get(0);
		RootBeanDefinition attributeSourceDefinition = parseAttributeSource(attributeSourceElement, parserContext);
		builder.addPropertyValue("transactionAttributeSource", attributeSourceDefinition);
	}
	else {
		// Assume annotations source.
		builder.addPropertyValue("transactionAttributeSource",
				new RootBeanDefinition("org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"));
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:TxAdviceBeanDefinitionParser.java

示例3: resolveScriptSource

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
 * Resolves the script source from either the '{@code script-source}' attribute or
 * the '{@code inline-script}' element. Logs and {@link XmlReaderContext#error} and
 * returns {@code null} if neither or both of these values are specified.
 */
private String resolveScriptSource(Element element, XmlReaderContext readerContext) {
	boolean hasScriptSource = element.hasAttribute(SCRIPT_SOURCE_ATTRIBUTE);
	List<Element> elements = DomUtils.getChildElementsByTagName(element, INLINE_SCRIPT_ELEMENT);
	if (hasScriptSource && !elements.isEmpty()) {
		readerContext.error("Only one of 'script-source' and 'inline-script' should be specified.", element);
		return null;
	}
	else if (hasScriptSource) {
		return element.getAttribute(SCRIPT_SOURCE_ATTRIBUTE);
	}
	else if (!elements.isEmpty()) {
		Element inlineElement = elements.get(0);
		return "inline:" + DomUtils.getTextValue(inlineElement);
	}
	else {
		readerContext.error("Must specify either 'script-source' or 'inline-script'.", element);
		return null;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:ScriptBeanDefinitionParser.java

示例4: parseReplacedMethodSubElements

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
 * Parse replaced-method sub-elements of the given bean element.
 */
public void parseReplacedMethodSubElements(Element beanEle, MethodOverrides overrides) {
	NodeList nl = beanEle.getChildNodes();
	for (int i = 0; i < nl.getLength(); i++) {
		Node node = nl.item(i);
		if (isCandidateElement(node) && nodeNameEquals(node, REPLACED_METHOD_ELEMENT)) {
			Element replacedMethodEle = (Element) node;
			String name = replacedMethodEle.getAttribute(NAME_ATTRIBUTE);
			String callback = replacedMethodEle.getAttribute(REPLACER_ATTRIBUTE);
			ReplaceOverride replaceOverride = new ReplaceOverride(name, callback);
			// Look for arg-type match elements.
			List<Element> argTypeEles = DomUtils.getChildElementsByTagName(replacedMethodEle, ARG_TYPE_ELEMENT);
			for (Element argTypeEle : argTypeEles) {
				String match = argTypeEle.getAttribute(ARG_TYPE_MATCH_ATTRIBUTE);
				match = (StringUtils.hasText(match) ? match : DomUtils.getTextValue(argTypeEle));
				if (StringUtils.hasText(match)) {
					replaceOverride.addTypeIdentifier(match);
				}
			}
			replaceOverride.setSource(extractSource(replacedMethodEle));
			overrides.addOverride(replaceOverride);
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:BeanDefinitionParserDelegate.java

示例5: parsePropsElement

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
	ManagedProperties props = new ManagedProperties();
	props.setSource(extractSource(propsEle));
	props.setMergeEnabled(parseMergeAttribute(propsEle));

	List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT);
	for (Element propEle : propEles) {
		String key = propEle.getAttribute(KEY_ATTRIBUTE);
		// Trim the text value to avoid unwanted whitespace
		// caused by typical XML formatting.
		String value = DomUtils.getTextValue(propEle).trim();
		TypedStringValue keyHolder = new TypedStringValue(key);
		keyHolder.setSource(extractSource(propEle));
		TypedStringValue valueHolder = new TypedStringValue(value);
		valueHolder.setSource(extractSource(propEle));
		props.put(keyHolder, valueHolder);
	}

	return props;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:BeanDefinitionParserDelegate.java

示例6: doParse

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	builder.addPropertyReference("cacheManager", CacheNamespaceHandler.extractCacheManager(element));
	CacheNamespaceHandler.parseKeyGenerator(element, builder.getBeanDefinition());

	List<Element> cacheDefs = DomUtils.getChildElementsByTagName(element, DEFS_ELEMENT);
	if (cacheDefs.size() >= 1) {
		// Using attributes source.
		List<RootBeanDefinition> attributeSourceDefinitions = parseDefinitionsSources(cacheDefs, parserContext);
		builder.addPropertyValue("cacheOperationSources", attributeSourceDefinitions);
	} else {
		// Assume annotations source.
		builder.addPropertyValue("cacheOperationSources", new RootBeanDefinition(
				AnnotationCacheOperationSource.class));
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:CacheAdviceParser.java

示例7: getCallableInterceptors

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
private ManagedList<?> getCallableInterceptors(Element element, Object source, ParserContext parserContext) {
	ManagedList<? super Object> interceptors = new ManagedList<Object>();
	Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
	if (asyncElement != null) {
		Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "callable-interceptors");
		if (interceptorsElement != null) {
			interceptors.setSource(source);
			for (Element converter : DomUtils.getChildElementsByTagName(interceptorsElement, "bean")) {
				BeanDefinitionHolder beanDef = parserContext.getDelegate().parseBeanDefinitionElement(converter);
				beanDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(converter, beanDef);
				interceptors.add(beanDef);
			}
		}
	}
	return interceptors;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:17,代碼來源:AnnotationDrivenBeanDefinitionParser.java

示例8: getDeferredResultInterceptors

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
private ManagedList<?> getDeferredResultInterceptors(Element element, Object source, ParserContext parserContext) {
	ManagedList<? super Object> interceptors = new ManagedList<Object>();
	Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
	if (asyncElement != null) {
		Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "deferred-result-interceptors");
		if (interceptorsElement != null) {
			interceptors.setSource(source);
			for (Element converter : DomUtils.getChildElementsByTagName(interceptorsElement, "bean")) {
				BeanDefinitionHolder beanDef = parserContext.getDelegate().parseBeanDefinitionElement(converter);
				beanDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(converter, beanDef);
				interceptors.add(beanDef);
			}
		}
	}
	return interceptors;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:17,代碼來源:AnnotationDrivenBeanDefinitionParser.java

示例9: createContentNegotiatingViewResolver

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
private BeanDefinition createContentNegotiatingViewResolver(Element resolverElement, ParserContext context) {
	RootBeanDefinition beanDef = new RootBeanDefinition(ContentNegotiatingViewResolver.class);
	beanDef.setSource(context.extractSource(resolverElement));
	beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	MutablePropertyValues values = beanDef.getPropertyValues();

	List<Element> elements = DomUtils.getChildElementsByTagName(resolverElement, new String[] {"default-views"});
	if (!elements.isEmpty()) {
		ManagedList<Object> list = new ManagedList<Object>();
		for (Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) {
			list.add(context.getDelegate().parsePropertySubElement(element, null));
		}
		values.add("defaultViews", list);
	}
	if (resolverElement.hasAttribute("use-not-acceptable")) {
		values.add("useNotAcceptableStatusCode", resolverElement.getAttribute("use-not-acceptable"));
	}
	Object manager = getContentNegotiationManager(context);
	if (manager != null) {
		values.add("contentNegotiationManager", manager);
	}
	return beanDef;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:24,代碼來源:ViewResolversBeanDefinitionParser.java

示例10: doParse

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    super.doParse(element, parserContext, builder);
    List<Element> opeationCodesElements = DomUtils.getChildElementsByTagName(element, "operation");
    ArrayList<Integer> operationCodes = new ArrayList<Integer>();
    ArrayList<String> operationCodesNames = new ArrayList<String>();
    for (int i = 0; i < opeationCodesElements.size(); i++) {
        String operationCode = opeationCodesElements.get(i).getAttribute("code");
        if (StringUtils.hasText(operationCode)) {
            operationCodes.add(Integer.valueOf(operationCode));
        }
        operationCode = opeationCodesElements.get(i).getAttribute("code-name");
        if (StringUtils.hasText(operationCode)) {
            operationCodesNames.add(operationCode);
        }
    }
    int[] numberOperationCodes = new int[operationCodes.size()];
    for (int i = 0; i < numberOperationCodes.length; i++) {
        numberOperationCodes[i] = operationCodes.get(i);
    }
    builder.addPropertyValue("operationCodes", numberOperationCodes);

    builder.addPropertyValue("operationCodesNames", operationCodesNames.toArray(new String[operationCodesNames.size()]));
}
 
開發者ID:Gigaspaces,項目名稱:xap-openspaces,代碼行數:24,代碼來源:SpaceFilterBeanDefinitionParser.java

示例11: handleModifierElements

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked","rawtypes"})
private void handleModifierElements(Element element, ParserContext parserContext,
        BeanDefinitionBuilder builder, ModifierElement modifierElementEnum) {
    List<Element> modifiers = DomUtils.getChildElementsByTagName(element, 
                                                                 modifierElementEnum.name().toLowerCase() + "-modifier");
    if (modifiers.isEmpty()) {
        return;
    }
    
    ManagedList managedModifiers = new ManagedList();
    for (Element modifierElement : modifiers) {
        managedModifiers.add(parserContext.getDelegate().parsePropertySubElement(
                                      modifierElement, 
                                      builder.getRawBeanDefinition(), 
                                      null));
    }
    
    builder.addPropertyValue("default" + modifierElementEnum.name() + "Modifiers", 
                             managedModifiers);
}
 
開發者ID:Gigaspaces,項目名稱:xap-openspaces,代碼行數:21,代碼來源:GigaSpaceBeanDefinitionParser.java

示例12: parseCachingModels

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
 * Parses the given XML element which sub-elements containing the properties
 * of the caching models to create.
 * 
 * @param element
 *          the XML element to parse
 * @return a map containing the parsed caching models.The key of each element
 *         is the value of the XML attribute <code>target</code> (a String)
 *         and the value is the caching model (an instance of
 *         <code>CachingModel</code>)
 */
private Map parseCachingModels(Element element) {
  List modelElements = DomUtils.getChildElementsByTagName(element, "caching");
  if (CollectionUtils.isEmpty(modelElements)) {
    return null;
  }

  String cacheModelKey = getCacheModelKey();
  Map models = new HashMap();
  int modelElementCount = modelElements.size();

  for (int i = 0; i < modelElementCount; i++) {
    Element modelElement = (Element) modelElements.get(i);
    String key = modelElement.getAttribute(cacheModelKey);

    CachingModel model = cacheModelParser.parseCachingModel(modelElement);
    models.put(key, model);
  }

  return models;
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:32,代碼來源:AbstractCacheSetupStrategyParser.java

示例13: parseFlushingModels

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
 * Parses the given XML element which sub-elements containing the properties
 * of the flushing models to create.
 * 
 * @param element
 *          the XML element to parse
 * @return a map containing the parsed flushing models.The key of each element
 *         is the value of the XML attribute <code>target</code> (a String) *
 *         and the value is the flushing model (an instance of
 *         <code>FlushingModel</code>)
 */
private Map parseFlushingModels(Element element) {
  List modelElements = DomUtils.getChildElementsByTagName(element,
      "flushing");
  if (CollectionUtils.isEmpty(modelElements)) {
    return null;
  }

  String cacheModelKey = getCacheModelKey();
  Map models = new HashMap();
  int modelElementCount = modelElements.size();

  for (int i = 0; i < modelElementCount; i++) {
    Element modelElement = (Element) modelElements.get(i);
    String key = modelElement.getAttribute(cacheModelKey);

    FlushingModel model = cacheModelParser.parseFlushingModel(modelElement);
    models.put(key, model);
  }

  return models;
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:33,代碼來源:AbstractCacheSetupStrategyParser.java

示例14: doParseFlushingModel

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
 * Creates a <code>{@link JcsFlushingModel}</code> from the given XML
 * element.
 * 
 * @param element
 *          the XML element to parse
 * @param flushBeforeMethodExecution
 *          indicates if the cache should be flushed before or after the
 *          execution of the intercepted method
 * @return the created flushing model
 * 
 * @see AbstractCacheModelParser#doParseFlushingModel(Element, boolean)
 */
protected FlushingModel doParseFlushingModel(Element element,
    boolean flushBeforeMethodExecution) {

  JcsFlushingModel model = new JcsFlushingModel();

  List cacheElements = DomUtils.getChildElementsByTagName(element, "cache");
  if (!CollectionUtils.isEmpty(cacheElements)) {
    int count = cacheElements.size();
    CacheStruct[] cacheStructs = new CacheStruct[count];

    for (int i = 0; i < count; i++) {
      Element cacheElement = (Element) cacheElements.get(i);
      String cacheName = cacheElement.getAttribute("name");
      String groups = cacheElement.getAttribute("groups");

      CacheStruct cache = new CacheStruct(cacheName, groups);
      cacheStructs[i] = cache;
    }

    model.setCacheStructs(cacheStructs);
  }

  model.setFlushBeforeMethodExecution(flushBeforeMethodExecution);
  return model;
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:39,代碼來源:JcsModelParser.java

示例15: doParse

import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
 * JAVADOC Method Level Comments
 *
 * @param element JAVADOC.
 * @param builder JAVADOC.
 */
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    List<Element> resources = DomUtils.getChildElementsByTagName(element,
            SingletonBeanFactory.INSTANCE_FACTORY_ID);

    List<Object> resnames = new ManagedList<Object>();

    for (Element relement : resources) {
        String pack = relement.getAttribute(PACKAGE);

        if (StringUtils.isNotEmpty(pack)) {
            resnames.add(new PackageBasedInstanceFactory(pack));
        } else {
            resnames.add(new RuntimeBeanReference(relement.getAttribute(REF)));
        }
    }

    builder.addPropertyValue(INSTANCE_FACTORIES, resnames);
}
 
開發者ID:cucina,項目名稱:opencucina,代碼行數:26,代碼來源:CompositeIFDefinitionParser.java


注:本文中的org.springframework.util.xml.DomUtils.getChildElementsByTagName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。