當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。