本文整理匯總了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;
}
}
示例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;
}
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
}
示例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));
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}