本文整理匯總了Java中org.springframework.util.xml.DomUtils.getChildElements方法的典型用法代碼示例。如果您正苦於以下問題:Java DomUtils.getChildElements方法的具體用法?Java DomUtils.getChildElements怎麽用?Java DomUtils.getChildElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.util.xml.DomUtils
的用法示例。
在下文中一共展示了DomUtils.getChildElements方法的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();
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例5: parse
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
CompositeComponentDefinition compositeDef =
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
parserContext.pushContainingComponent(compositeDef);
configureAutoProxyCreator(parserContext, element);
List<Element> childElts = DomUtils.getChildElements(element);
for (Element elt: childElts) {
String localName = parserContext.getDelegate().getLocalName(elt);
if (POINTCUT.equals(localName)) {
parsePointcut(elt, parserContext);
}
else if (ADVISOR.equals(localName)) {
parseAdvisor(elt, parserContext);
}
else if (ASPECT.equals(localName)) {
parseAspect(elt, parserContext);
}
}
parserContext.popAndRegisterContainingComponent();
return null;
}
示例6: parse
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
public BeanDefinition parse(Element element, ParserContext parserContext) {
CompositeComponentDefinition compositeDef =
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
parserContext.pushContainingComponent(compositeDef);
configureAutoProxyCreator(parserContext, element);
List<Element> childElts = DomUtils.getChildElements(element);
for (Element elt: childElts) {
String localName = parserContext.getDelegate().getLocalName(elt);
if (POINTCUT.equals(localName)) {
parsePointcut(elt, parserContext);
}
else if (ADVISOR.equals(localName)) {
parseAdvisor(elt, parserContext);
}
else if (ASPECT.equals(localName)) {
parseAspect(elt, parserContext);
}
}
parserContext.popAndRegisterContainingComponent();
return null;
}
示例7: createCacheCollection
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
private ManagedList<Object> createCacheCollection(Element element, ParserContext parserContext) {
ManagedList<Object> caches = new ManagedList<>();
List<Element> cacheElements = DomUtils.getChildElements(element);
for (Element cacheElement : cacheElements) {
String elementName = cacheElement.getLocalName();
switch (elementName) {
case CACHE_REF_ELEMENT_NAME:
caches.add(new RuntimeBeanReference(cacheElement.getAttribute("ref")));
break;
case CACHE_CLUSTER_ELEMENT_NAME:
String cacheClusterId = getRequiredAttribute("name", cacheElement, parserContext);
caches.add(createElastiCacheFactoryBean(cacheElement, parserContext, cacheClusterId, createDefaultCacheFactories(cacheElement, parserContext)));
break;
default:
parserContext.getReaderContext().error("Unknown element detected", parserContext.extractSource(cacheElement));
}
}
return caches;
}
示例8: doParse
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder)
{
String key = element.getAttribute("key");
builder.addPropertyValue("key", key);
setDefault(element,builder);
String className = element.getAttribute("class");
if (StringUtils.hasText(className)) {
builder.getBeanDefinition().setBeanClassName(className);
}
List<Element> childElts = DomUtils.getChildElements(element);
// 解析fields
if (CollectionUtils.isEmpty(childElts)) {
throw new IllegalArgumentException("cjava:tc-header node must contain fields");
}
Field[] values = new Field[childElts.size()];
for (int i = 0; i < childElts.size(); i++) {
Element node = childElts.get(i);
// 解析
values[i] = parserField(node,false);
}
builder.addPropertyValue("fields", values);
}
示例9: doParse
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder)
{
String key = element.getAttribute("key");
builder.addPropertyValue("key", key);
setDefault(element,builder);
String className = element.getAttribute("class");
if (StringUtils.hasText(className)) {
builder.getBeanDefinition().setBeanClassName(className);
}
List<Element> childElts = DomUtils.getChildElements(element);
// 解析fields
if (CollectionUtils.isEmpty(childElts)) {
throw new IllegalArgumentException("cjava:header node must contain fields");
}
Field[] values = new Field[childElts.size()];
for (int i = 0; i < childElts.size(); i++) {
Element node = childElts.get(i);
// 解析
values[i] = parserField(node,true);
}
builder.addPropertyValue("fields", values);
}
示例10: parseInternal
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected @Nullable AbstractBeanDefinition parseInternal(
@Nullable Element element, @Nullable ParserContext parserContext) {
// Here we parse the Spring elements such as < property>
if (parserContext == null || element == null)
throw GlobalUtils
.createNotInitializedException("element and parserContext");
// this will never be null since the schema explicitly requires that a
// value be supplied
String testCaseName = element
.getAttribute(XsdElementConstants.ATTR_TESTCASE_TESTCASENAME);
BeanDefinitionBuilder factory = BeanDefinitionBuilder
.rootBeanDefinition(TestCase.class);
if (StringUtils.hasText(testCaseName))
factory.addConstructorArgValue(testCaseName);
List<Element> testStepElements = (List<Element>) DomUtils
.getChildElements(element);
if (testStepElements != null && !testStepElements.isEmpty()) {
if (null == factory)
throw GlobalUtils.createNotInitializedException("factory");
parseTestStepComponents(testStepElements, factory, parserContext);
}
return factory.getBeanDefinition();
}
示例11: doParse
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
if (parserContext.getRegistry().containsBeanDefinition(CredentialsProviderFactoryBean.CREDENTIALS_PROVIDER_BEAN_NAME)) {
parserContext.getReaderContext().error("Multiple <context-credentials/> detected. The <context-credentials/> is only allowed once per application context", element);
}
List<Element> elements = DomUtils.getChildElements(element);
ManagedList<BeanDefinition> credentialsProviders = new ManagedList<>(elements.size());
for (Element credentialsProviderElement : elements) {
if ("simple-credentials".equals(credentialsProviderElement.getLocalName())) {
credentialsProviders.add(getCredentialsProvider(STATIC_CREDENTIALS_PROVIDER_BEAN_CLASS_NAME, getCredentials(credentialsProviderElement, parserContext)));
}
if ("instance-profile-credentials".equals(credentialsProviderElement.getLocalName())) {
credentialsProviders.add(getCredentialsProvider(INSTANCE_CREDENTIALS_PROVIDER_BEAN_CLASS_NAME));
}
if ("profile-credentials".equals(credentialsProviderElement.getLocalName())) {
credentialsProviders.add(getCredentialsProvider(PROFILE_CREDENTIALS_PROVIDER_BEAN_CLASS_NAME, getProfileConfiguration(credentialsProviderElement).toArray()));
}
}
builder.addConstructorArgValue(credentialsProviders);
replaceDefaultCredentialsProvider(parserContext.getRegistry(), CredentialsProviderFactoryBean.CREDENTIALS_PROVIDER_BEAN_NAME);
}
示例12: doParse
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder)
{
// 是否有class
if (element.hasAttribute("class") && StringUtils.hasText(element.getAttribute("class"))) {
// 重新賦值
builder.getRawBeanDefinition().setBeanClassName(element.getAttribute("class"));
} else {
builder.getRawBeanDefinition().setBeanClassName(defaultClass);
}
// 設置子項
List<Element> childElts = DomUtils.getChildElements(element);
// 解析fields
if (!CollectionUtils.isEmpty(childElts)) {
Map<BaseDataType, JFieldOpt> inits = new HashMap<BaseDataType, JFieldOpt>();
Map<String, String> valueRefs = new HashMap<String, String>();
for (Element child : childElts) {
if (child.hasAttribute("key") && StringUtils.hasText(child.getAttribute("key")) && child.hasAttribute("class") && StringUtils.hasText(child.getAttribute("class"))) {
checkKey(child.getAttribute("key"));
// 進行實例化
try {
checkClass(child.getAttribute("class"));
Class<?> targetClass = Class.forName(child.getAttribute("class"));
inits.put(getBaseDataType(child.getAttribute("key")), (JFieldOpt) BeanUtils.instantiate(targetClass));
} catch (ClassNotFoundException e) {
throw new RuntimeException("實例化class:" + child.getAttribute("class") + "失敗!");
}
}
if (child.hasAttribute("key") && StringUtils.hasText(child.getAttribute("key")) && child.hasAttribute("value-ref") && StringUtils.hasText(child.getAttribute("value-ref"))) {
checkKey(child.getAttribute("key"));
valueRefs.put(child.getAttribute("key"), child.getAttribute("value-ref"));
}
}
builder.addConstructorArgValue(inits);
builder.addPropertyValue("valueRefs", valueRefs);
}
dealId(element, builder);
}
示例13: doParse
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder)
{
setDefault(element, builder);
String className = element.getAttribute("class");
if (StringUtils.hasText(className)) {
builder.getBeanDefinition().setBeanClassName(className);
}
List<Element> childElts = DomUtils.getChildElements(element);
// 解析fields
if (CollectionUtils.isEmpty(childElts)) {
throw new IllegalArgumentException("cjava:ftc node must contain fields");
}
// 判斷是否存在混合協議
boolean isMix = isMix(childElts);
if (!isMix) {
parserFieldCommon(builder, childElts);
return;
}
int mixIndex = -1;
List<Element> childFirstElts = new ArrayList<Element>();
List<Element> childEndFields = new ArrayList<Element>();
for (int i = 0; i < childElts.size(); i++) {
Element node = childElts.get(i);
// 解析
if (node.getNodeName().equals("cjava:branchs")) {
mixIndex = i;
parserFieldMixBranchs(builder, node);
} else {
if (mixIndex != -1) {
childEndFields.add(node);
} else {
childFirstElts.add(node);
}
}
}
parserFieldMixCommonFirst(builder, childFirstElts);
parserFieldMixCommonEnd(builder, childEndFields);
}
示例14: parserFieldMixBranchs
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
private void parserFieldMixBranchs(BeanDefinitionBuilder builder, Element ele)
{
List<Element> childElts = DomUtils.getChildElements(ele);
if(!ele.hasAttribute("key") || !StringUtils.hasText(ele.getAttribute("key"))){
throw new IllegalArgumentException("cjava:branchs tag must contain key attr");
}
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("mixKey", ele.getAttribute("key"));
builder.addPropertyValue("mixInfo", mixInfo);
}
示例15: doParse
import org.springframework.util.xml.DomUtils; //導入方法依賴的package包/類
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder)
{
setDefault(element, builder);
String className = element.getAttribute("class");
if (StringUtils.hasText(className)) {
builder.getBeanDefinition().setBeanClassName(className);
}
List<Element> childElts = DomUtils.getChildElements(element);
// 解析fields
if (CollectionUtils.isEmpty(childElts)) {
throw new IllegalArgumentException("cjava:tct node must contain fields");
}
// 判斷是否存在混合協議
boolean isMix = isMix(childElts);
if (!isMix) {
parserFieldCommon(builder, childElts);
return;
}
int mixIndex = -1;
List<Element> childFirstElts = new ArrayList<Element>();
List<Element> childEndFields = new ArrayList<Element>();
for (int i = 0; i < childElts.size(); i++) {
Element node = childElts.get(i);
// 解析
if (node.hasAttribute("cjava:branchs")) {
mixIndex = i;
parserFieldMixBranchs(builder, node);
} else {
if (mixIndex != -1) {
childEndFields.add(node);
} else {
childFirstElts.add(node);
}
}
}
parserFieldMixCommonFirst(builder, childFirstElts);
parserFieldMixCommonEnd(builder, childEndFields);
}