当前位置: 首页>>代码示例>>Java>>正文


Java DomUtils类代码示例

本文整理汇总了Java中org.springframework.util.xml.DomUtils的典型用法代码示例。如果您正苦于以下问题:Java DomUtils类的具体用法?Java DomUtils怎么用?Java DomUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DomUtils类属于org.springframework.util.xml包,在下文中一共展示了DomUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseChildElements

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
private void parseChildElements(Element element, String parentId, String redissonRef, BeanDefinitionBuilder redissonDef, ParserContext parserContext) {
    if (element.hasChildNodes()) {
        CompositeComponentDefinition compositeDef
                = new CompositeComponentDefinition(parentId,
                        parserContext.extractSource(element));
        parserContext.pushContainingComponent(compositeDef);
        List<Element> childElts = DomUtils.getChildElements(element);
        for (Element elt : childElts) {
            if(BeanDefinitionParserDelegate
                    .QUALIFIER_ELEMENT.equals(elt.getLocalName())) {
                continue;//parsed elsewhere
            }
            String localName = parserContext.getDelegate().getLocalName(elt);
            localName = Conventions.attributeNameToPropertyName(localName);
            if (ConfigType.contains(localName)) {
                parseConfigTypes(elt, localName, redissonDef, parserContext);
            } else if (AddressType.contains(localName)) {
                parseAddressTypes(elt, localName, redissonDef, parserContext);
            } else if (helper.isRedissonNS(elt)) {
                elt.setAttribute(REDISSON_REF, redissonRef);
                parserContext.getDelegate().parseCustomElement(elt);
            }
        }
        parserContext.popContainingComponent();
    }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:27,代码来源:RedissonDefinitionParser.java

示例2: parserBranch

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
private void parserBranch(Map<String, Field[]> mixInfo, Element ele)
{
	List<Element> childElts = DomUtils.getChildElements(ele);
	// 解析fields
	if (CollectionUtils.isEmpty(childElts)) {
		//throw new IllegalArgumentException("cjava:branch node must contain child fields");
		mixInfo.put(ele.getAttribute("keyValue"), new Field[]{});
	}else{
		Field[] values = new Field[childElts.size()];
		for (int i = 0; i < childElts.size(); i++) {
			Element node = childElts.get(i);
			// 解析field
			values[i] = parserField(node,true);
		}

		mixInfo.put(ele.getAttribute("keyValue"), values);
	}
	

}
 
开发者ID:yanghao0518,项目名称:cstruct-parser,代码行数:21,代码来源:CjavaFcTemplateBeanDefinitionParser.java

示例3: parserFieldMixBranchs

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
private void parserFieldMixBranchs(BeanDefinitionBuilder builder, Element ele)
{
	List<Element> childElts = DomUtils.getChildElements(ele);

	checkChildBranchs(childElts);

	Map<String, Field[]> mixInfo = new HashMap<String, Field[]>();

	for (int i = 0; i < childElts.size(); i++) {
		Element node = childElts.get(i);
		// 解析branch
		parserBranch(mixInfo, node);
	}

	builder.addPropertyValue("isMix", true);

	builder.addPropertyValue("mixInfo", mixInfo);
}
 
开发者ID:yanghao0518,项目名称:cstruct-parser,代码行数:19,代码来源:CjavaTcTemplateBeanDefinitionParser.java

示例4: parserBranch

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
private void parserBranch(Map<String, Field[]> mixInfo, Element ele)
{
	List<Element> childElts = DomUtils.getChildElements(ele);
	// 解析fields
	if (CollectionUtils.isEmpty(childElts)) {
		throw new IllegalArgumentException("cjava:branch node must contain child fields");
	}
	Field[] values = new Field[childElts.size()];
	for (int i = 0; i < childElts.size(); i++) {
		Element node = childElts.get(i);
		// 解析field
		values[i] = parserField(node,false);
	}

	mixInfo.put(ele.getAttribute("keyValue"), values);

}
 
开发者ID:yanghao0518,项目名称:cstruct-parser,代码行数:18,代码来源:CjavaTcTemplateBeanDefinitionParser.java

示例5: parseServiceProperties

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
public static boolean parseServiceProperties(Element parent, Element element, ParserContext parserContext,
		BeanDefinitionBuilder builder) {
	String name = element.getLocalName();

	if (PROPS_ID.equals(name)) {
		if (DomUtils.getChildElementsByTagName(element, BeanDefinitionParserDelegate.ENTRY_ELEMENT).size() > 0) {
			Object props = parserContext.getDelegate().parseMapElement(element, builder.getRawBeanDefinition());
			builder.addPropertyValue(Conventions.attributeNameToPropertyName(PROPS_ID), props);
		}
		else {
			parserContext.getReaderContext().error("Invalid service property type", element);
		}
		return true;
	}
	return false;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:17,代码来源:ServiceParsingUtils.java

示例6: parseTopLevelElement

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
/**
 * Parses the top elements belonging to the RFC 124 namespace. Namely these are &lt;component&gt;,
 * &lt;description&gt; and &lt;type-converters&gt;
 * 
 * @param ele
 * @param parserContext
 */
protected void parseTopLevelElement(Element ele, ParserContext parserContext) {
	// description
	if (DomUtils.nodeNameEquals(ele, DESCRIPTION)) {
		// ignore description for now
	} else if (DomUtils.nodeNameEquals(ele, BEAN)) {
		parseComponentElement(ele, parserContext);
	} else if (DomUtils.nodeNameEquals(ele, REFERENCE)) {
		parseReferenceElement(ele, parserContext);
	} else if (DomUtils.nodeNameEquals(ele, SERVICE)) {
		parseServiceElement(ele, parserContext);
	} else if (DomUtils.nodeNameEquals(ele, REFERENCE_LIST)) {
		parseListElement(ele, parserContext);
	} else if (DomUtils.nodeNameEquals(ele, REFERENCE_SET)) {
		parseSetElement(ele, parserContext);
	} else if (DomUtils.nodeNameEquals(ele, TypeConverterBeanDefinitionParser.TYPE_CONVERTERS)) {
		parseConvertersElement(ele, parserContext);
	} else {
		throw new IllegalArgumentException("Unknown element " + ele);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:28,代码来源:BlueprintBeanDefinitionParser.java

示例7: parseValueElement

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
/**
 * Return a typed String value Object for the given value element.
 * 
 * @param ele element
 * @param defaultTypeName type class name
 * @return typed String value Object
 */
private Object parseValueElement(Element ele, String defaultTypeName) {
	// It's a literal value.
	String value = DomUtils.getTextValue(ele);
	String specifiedTypeName = ele.getAttribute(BeanDefinitionParserDelegate.TYPE_ATTRIBUTE);
	String typeName = specifiedTypeName;
	if (!StringUtils.hasText(typeName)) {
		typeName = defaultTypeName;
	}
	try {
		TypedStringValue typedValue = buildTypedStringValue(value, typeName);
		typedValue.setSource(extractSource(ele));
		typedValue.setSpecifiedTypeName(specifiedTypeName);
		return typedValue;
	} catch (ClassNotFoundException ex) {
		error("Type class [" + typeName + "] not found for <value> element", ele, ex);
		return value;
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:26,代码来源:BlueprintParser.java

示例8: 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

示例9: doParse

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	// first check the attributes
	if (element.hasAttribute(AUTOEXPORT) && !DISABLED.equals(element.getAttribute(AUTOEXPORT).trim())) {
		if (element.hasAttribute(INTERFACE)) {
			parserContext.getReaderContext().error(
					"either 'auto-export' or 'interface' attribute has be specified but not both", element);
		}
		if (DomUtils.getChildElementByTagName(element, INTERFACES) != null) {
			parserContext.getReaderContext().error(
					"either 'auto-export' attribute or <intefaces> sub-element has be specified but not both",
					element);

		}

	}

	builder.addPropertyValue(CACHE_TARGET, true);
	super.doParse(element, parserContext, builder);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:21,代码来源:BlueprintServiceDefinitionParser.java

示例10: getMavenSettingsLocalRepository

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
/**
 * Returns the <code>localRepository</code> settings as indicated by the
 * <code>settings.xml</code> file.
 * 
 * @return local repository as indicated by a Maven settings.xml file
 */
String getMavenSettingsLocalRepository(Resource m2Settings) {
	// no file found, return null to continue the discovery process
	if (!m2Settings.exists()) {
		return null;
       }

	try {
		DocumentLoader docLoader = new DefaultDocumentLoader();
		Document document = docLoader.loadDocument(new InputSource(m2Settings.getInputStream()), null, null,
			XmlValidationModeDetector.VALIDATION_NONE, false);

		return (DomUtils.getChildElementValueByTagName(document.getDocumentElement(), LOCAL_REPOSITORY_ELEM));
	} catch (Exception ex) {
		throw new RuntimeException(new ParserConfigurationException("error parsing resource=" + m2Settings).initCause(ex));
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:23,代码来源:LocalFileSystemMavenRepository.java

示例11: 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

示例12: 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

示例13: 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

示例14: parseValueElement

import org.springframework.util.xml.DomUtils; //导入依赖的package包/类
/**
 * Return a typed String value Object for the given value element.
 */
public Object parseValueElement(Element ele, String defaultTypeName) {
	// It's a literal value.
	String value = DomUtils.getTextValue(ele);
	String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE);
	String typeName = specifiedTypeName;
	if (!StringUtils.hasText(typeName)) {
		typeName = defaultTypeName;
	}
	try {
		TypedStringValue typedValue = buildTypedStringValue(value, typeName);
		typedValue.setSource(extractSource(ele));
		typedValue.setSpecifiedTypeName(specifiedTypeName);
		return typedValue;
	}
	catch (ClassNotFoundException ex) {
		error("Type class [" + typeName + "] not found for <value> element", ele, ex);
		return value;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:BeanDefinitionParserDelegate.java

示例15: 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


注:本文中的org.springframework.util.xml.DomUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。