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


Java DomUtils.getTextValue方法代码示例

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


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

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

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

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

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

示例5: 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 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 = (Element) elements.get(0);
		return "inline:" + DomUtils.getTextValue(inlineElement);
	}
	else {
		readerContext.error("Must specify either 'script-source' or 'inline-script'.", element);
		return null;
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:ScriptBeanDefinitionParser.java

示例6: parseRef

import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
public void parseRef(Element element, RootBeanDefinition beandef) {
	List<Element> refs = DomUtils.getChildElementsByTagName(element, REF);
	if (refs == null) {
		return;
	}
	String name = null;
	String value = null;
	for (Element ele : refs) {
		name = ele.getAttribute(NAME);
		value = DomUtils.getTextValue(ele);
		if(name == null) {
			System.out.println("Tag 'ref' must have a 'name' attribute");
			return;
		}
		beandef.getPropertyValues().add(name, new RuntimeBeanReference(value));
	}
}
 
开发者ID:yaneri,项目名称:se,代码行数:18,代码来源:ActionBeanDefinitionParser.java

示例7: getModules

import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
 * Get the Citrus modules for this project based on the build dependencies.
 * @return
 */
public List<Module> getModules() {
    List<Module> modules = new ArrayList<>();
    Collection<String> allModules = new SpringBeanNamespacePrefixMapper().getNamespaceMappings().values();

    if (project.isMavenProject()) {
        try {
            String pomXml = FileUtils.readToString(new FileSystemResource(project.getMavenPomFile()));
            SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
            nsContext.bindNamespaceUri("mvn", "http://maven.apache.org/POM/4.0.0");

            Document pomDoc = XMLUtils.parseMessagePayload(pomXml);

            NodeList dependencies = XPathUtils.evaluateAsNodeList(pomDoc, "/mvn:project/mvn:dependencies/mvn:dependency/mvn:artifactId[starts-with(., 'citrus-')]", nsContext);

            for (int i = 0; i < dependencies.getLength(); i++) {
                String moduleName = DomUtils.getTextValue((Element) dependencies.item(i));

                if (moduleName.equals("citrus-core")) {
                    allModules.remove("citrus");
                } else {
                    allModules.remove(moduleName);
                }

                modules.add(new Module(moduleName.substring("citrus-".length()), getActiveProject().getVersion(), true));
            }
        } catch (IOException e) {
            throw new ApplicationRuntimeException("Unable to open Maven pom.xml file", e);
        }
    }

    allModules.stream()
            .filter(name -> !name.equals("citrus-test"))
            .map(name -> name.equals("citrus") ? "citrus-core" : name)
            .map(name -> new Module(name.substring("citrus-".length()), getActiveProject().getVersion(), false))
            .forEach(modules::add);

    return modules;
}
 
开发者ID:christophd,项目名称:citrus-admin,代码行数:43,代码来源:ProjectService.java

示例8: postProcess

import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
@Override
protected void postProcess(BeanDefinitionBuilder definitionBuilder, Element element) {
    List<Element> eventTypes = DomUtils.getChildElementsByTagName(element, EVENT_TYPE);
    if (eventTypes != null && eventTypes.size() > 0) {
        // compute event type
        int eventType = 0;
        Constants types = new Constants(Event.class);
        for (Iterator<Element> iter = eventTypes.iterator(); iter.hasNext();) {
            Element evenTypeElement = iter.next();
            eventType |= types.asNumber(DomUtils.getTextValue(evenTypeElement)).intValue();
        }
        definitionBuilder.addPropertyValue("eventTypes", Integer.valueOf(eventType));
    }

    List<Element> nodeTypeNames = DomUtils.getChildElementsByTagName(element, NODE_TYPE_NAME);
    String[] nodeTypeValues = new String[nodeTypeNames.size()];

    for (int i = 0; i < nodeTypeValues.length; i++) {
        nodeTypeValues[i] = DomUtils.getTextValue(nodeTypeNames.get(i));
    }
    definitionBuilder.addPropertyValue(NODE_TYPE_NAME, nodeTypeValues);
    List<Element> uuids = DomUtils.getChildElementsByTagName(element, UUID);

    String[] uuidsValues = new String[uuids.size()];

    for (int i = 0; i < uuidsValues.length; i++) {
        uuidsValues[i] = DomUtils.getTextValue(uuids.get(i));
    }

    definitionBuilder.addPropertyValue(UUID, uuidsValues);
    //TODO, reference a listenerBean, it is not a propertyReference
    Element eventListner = DomUtils.getChildElementByTagName(element, "listener");
    String listenerBeanRefName = DomUtils.getTextValue(eventListner);

    definitionBuilder.addPropertyReference("listener", listenerBeanRefName);
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:37,代码来源:JcrNamespaceHandler.java

示例9: getChildElementText

import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
 * Get the text context of first child element matching the local name and
 * namespace
 * 
 * @param parent
 *            The element for which to locate the child
 * @param ns
 *            The namespace to match, or null for any namespace
 * @param localName
 *            The local name to match, or null for any local name
 * @return The text content of the first child matching the criteria or null
 *         if element not found
 */
public static String getChildElementText(final Element parent,
        final String ns, final String localName) {
    List<Element> elements = getChildElements(parent);

    for (Element element : elements) {
        if ((ns == null || ns.equals(element.getNamespaceURI())
                && (localName == null || localName.equals(element
                        .getLocalName())))) {
            return DomUtils.getTextValue(element);
        }
    }

    return null;
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:28,代码来源:SpringUtil.java

示例10: parsePersistenceUnitInfo

import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
 * Parse the unit info DOM element.
 */
protected SpringPersistenceUnitInfo parsePersistenceUnitInfo(Element persistenceUnit, String version, URL rootUrl)
		throws IOException {

	SpringPersistenceUnitInfo unitInfo = new SpringPersistenceUnitInfo();

	// set JPA version (1.0 or 2.0)
	unitInfo.setPersistenceXMLSchemaVersion(version);

	// set persistence unit root URL
	unitInfo.setPersistenceUnitRootUrl(rootUrl);

	// set unit name
	unitInfo.setPersistenceUnitName(persistenceUnit.getAttribute(UNIT_NAME).trim());

	// set transaction type
	String txType = persistenceUnit.getAttribute(TRANSACTION_TYPE).trim();
	if (StringUtils.hasText(txType)) {
		unitInfo.setTransactionType(PersistenceUnitTransactionType.valueOf(txType));
	}

	// evaluate data sources
	String jtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, JTA_DATA_SOURCE);
	if (StringUtils.hasText(jtaDataSource)) {
		unitInfo.setJtaDataSource(this.dataSourceLookup.getDataSource(jtaDataSource.trim()));
	}

	String nonJtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, NON_JTA_DATA_SOURCE);
	if (StringUtils.hasText(nonJtaDataSource)) {
		unitInfo.setNonJtaDataSource(this.dataSourceLookup.getDataSource(nonJtaDataSource.trim()));
	}

	// provider
	String provider = DomUtils.getChildElementValueByTagName(persistenceUnit, PROVIDER);
	if (StringUtils.hasText(provider)) {
		unitInfo.setPersistenceProviderClassName(provider.trim());
	}

	// exclude unlisted classes
	Element excludeUnlistedClasses = DomUtils.getChildElementByTagName(persistenceUnit, EXCLUDE_UNLISTED_CLASSES);
	if (excludeUnlistedClasses != null) {
		String excludeText = DomUtils.getTextValue(excludeUnlistedClasses);
		unitInfo.setExcludeUnlistedClasses(!StringUtils.hasText(excludeText) || Boolean.valueOf(excludeText));
	}

	// set JPA 2.0 shared cache mode
	String cacheMode = DomUtils.getChildElementValueByTagName(persistenceUnit, SHARED_CACHE_MODE);
	if (StringUtils.hasText(cacheMode)) {
		unitInfo.setSharedCacheMode(SharedCacheMode.valueOf(cacheMode));
	}

	// set JPA 2.0 validation mode
	String validationMode = DomUtils.getChildElementValueByTagName(persistenceUnit, VALIDATION_MODE);
	if (StringUtils.hasText(validationMode)) {
		unitInfo.setValidationMode(ValidationMode.valueOf(validationMode));
	}

	parseProperties(persistenceUnit, unitInfo);
	parseManagedClasses(persistenceUnit, unitInfo);
	parseMappingFiles(persistenceUnit, unitInfo);
	parseJarFiles(persistenceUnit, unitInfo);

	return unitInfo;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:67,代码来源:PersistenceUnitReader.java

示例11: parsePersistenceUnitInfo

import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
/**
 * Parse the unit info DOM element.
 */
protected SpringPersistenceUnitInfo parsePersistenceUnitInfo(Element persistenceUnit, String version, URL rootUrl)
		throws IOException {

	SpringPersistenceUnitInfo unitInfo = new SpringPersistenceUnitInfo();

	// set JPA version (1.0 or 2.0)
	unitInfo.setPersistenceXMLSchemaVersion(version);

	// set persistence unit root URL
	unitInfo.setPersistenceUnitRootUrl(rootUrl);

	// set unit name
	unitInfo.setPersistenceUnitName(persistenceUnit.getAttribute(UNIT_NAME).trim());

	// set transaction type
	String txType = persistenceUnit.getAttribute(TRANSACTION_TYPE).trim();
	if (StringUtils.hasText(txType)) {
		unitInfo.setTransactionType(PersistenceUnitTransactionType.valueOf(txType));
	}

	// evaluate data sources
	String jtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, JTA_DATA_SOURCE);
	if (StringUtils.hasText(jtaDataSource)) {
		unitInfo.setJtaDataSource(this.dataSourceLookup.getDataSource(jtaDataSource.trim()));
	}

	String nonJtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, NON_JTA_DATA_SOURCE);
	if (StringUtils.hasText(nonJtaDataSource)) {
		unitInfo.setNonJtaDataSource(this.dataSourceLookup.getDataSource(nonJtaDataSource.trim()));
	}

	// provider
	String provider = DomUtils.getChildElementValueByTagName(persistenceUnit, PROVIDER);
	if (StringUtils.hasText(provider)) {
		unitInfo.setPersistenceProviderClassName(provider.trim());
	}

	// exclude unlisted classes
	Element excludeUnlistedClasses = DomUtils.getChildElementByTagName(persistenceUnit, EXCLUDE_UNLISTED_CLASSES);
	if (excludeUnlistedClasses != null) {
		String excludeText = DomUtils.getTextValue(excludeUnlistedClasses);
		unitInfo.setExcludeUnlistedClasses(!StringUtils.hasText(excludeText) || Boolean.valueOf(excludeText));
	}

	// set JPA 2.0 shared cache mode
	String cacheMode = DomUtils.getChildElementValueByTagName(persistenceUnit, SHARED_CACHE_MODE);
	if (StringUtils.hasText(cacheMode)) {
		unitInfo.setSharedCacheModeName(cacheMode);
	}

	// set JPA 2.0 validation mode
	String validationMode = DomUtils.getChildElementValueByTagName(persistenceUnit, VALIDATION_MODE);
	if (StringUtils.hasText(validationMode)) {
		unitInfo.setValidationModeName(validationMode);
	}

	parseProperties(persistenceUnit, unitInfo);
	parseManagedClasses(persistenceUnit, unitInfo);
	parseMappingFiles(persistenceUnit, unitInfo);
	parseJarFiles(persistenceUnit, unitInfo);

	return unitInfo;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:67,代码来源:PersistenceUnitReader.java

示例12: parseChannel

import org.springframework.util.xml.DomUtils; //导入方法依赖的package包/类
public void parseChannel(Element element, RootBeanDefinition beandef) {
	List<Element> channels = DomUtils.getChildElementsByTagName(element, CHANNEL);
	Map<String, Map<String, String>> channel = new HashMap<String, Map<String, String>>();
	Map<String, String> path = null;
	List<Element> paraele = null;
	String type = null;
	String name = null;
	String value = null;
	if(channels == null || channels.size() == 0) {
		path = new HashMap<String, String>();
		path.put(SUCCESS, JSON);
		channel.put(HTTP, path);
	} else {
		for (Element ch : channels) {
			type = ch.getAttribute(TYPE);
			if(type == null)
				type = HTTP;
			paraele = DomUtils.getChildElementsByTagName(ch, PATH);
			if(paraele.size() == 0) {
				System.out.println("Tag 'channel' must have a 'para' element");
				return;
			}
			path = new HashMap<String, String>();
			for (Element pa : paraele) {
				name = pa.getAttribute(NAME);
				value = DomUtils.getTextValue(pa);
				if (!(StringUtils.hasLength(name))) {
					System.out.println("Tag 'para' must have a 'name' attribute");
					return;
				}
				if (!(StringUtils.hasLength(value))) {
					System.out.println("Tag 'para' must have a node value");
					return;
				}
				path.put(name, value);
			}
			channel.put(type, path);
		}
	}
	beandef.getPropertyValues().addPropertyValue(CHANNEL, channel);
}
 
开发者ID:yaneri,项目名称:se,代码行数:42,代码来源:TransactionBeanDefinitionParser.java


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