本文整理汇总了Java中org.springframework.beans.factory.support.ManagedArray类的典型用法代码示例。如果您正苦于以下问题:Java ManagedArray类的具体用法?Java ManagedArray怎么用?Java ManagedArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ManagedArray类属于org.springframework.beans.factory.support包,在下文中一共展示了ManagedArray类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseArrayElement
import org.springframework.beans.factory.support.ManagedArray; //导入依赖的package包/类
/**
* Parse an array element.
*/
public Object parseArrayElement(Element arrayEle, BeanDefinition bd) {
String elementType = arrayEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
NodeList nl = arrayEle.getChildNodes();
ManagedArray target = new ManagedArray(elementType, nl.getLength());
target.setSource(extractSource(arrayEle));
target.setElementTypeName(elementType);
target.setMergeEnabled(parseMergeAttribute(arrayEle));
parseCollectionElements(nl, target, bd, elementType);
return target;
}
示例2: createStream
import org.springframework.beans.factory.support.ManagedArray; //导入依赖的package包/类
private XStream createStream() {
XStream stream = new XStream();
stream.registerConverter(new BeanDefinitionConverter(stream.getMapper()));
stream.registerConverter(new BeanDefinitionHolderConverter(stream.getMapper()));
stream.registerConverter(new TypedStringValueConverter());
stream.registerConverter(new ManagedCollectionConverter(stream.getMapper()));
stream.registerConverter(new ManagedMapConverter(stream.getMapper()));
stream.registerConverter(new RuntimeBeanReferenceConverter());
stream.alias("map", ManagedMap.class);
stream.alias("list", ManagedList.class);
stream.alias("set", ManagedSet.class);
stream.alias("array", ManagedArray.class);
stream.aliasType("bean", BeanDefinition.class);
stream.alias("bean", BeanDefinitionHolder.class);
stream.alias("ref", RuntimeBeanReference.class);
return stream;
}
示例3: parseArrayElement
import org.springframework.beans.factory.support.ManagedArray; //导入依赖的package包/类
/**
* Parse an array element.
*/
public Object parseArrayElement(Element arrayEle, BeanDefinition bd) {
String elementType = arrayEle.getAttribute(BeanDefinitionParserDelegate.VALUE_TYPE_ATTRIBUTE);
NodeList nl = arrayEle.getChildNodes();
ManagedArray target = new ManagedArray(elementType, nl.getLength());
target.setSource(extractSource(arrayEle));
target.setElementTypeName(elementType);
target.setMergeEnabled(parseMergeAttribute(arrayEle));
parseCollectionElements(nl, target, bd, elementType);
return target;
}
示例4: visitCollection
import org.springframework.beans.factory.support.ManagedArray; //导入依赖的package包/类
/**
* Determines what kind of collection (or array) the given value is and call handlers based on the determined type
*
* @param value collection value to process
* @param propertyName name of the property which has the collection value
* @param nestedBeanStack stack of bean containers which contains the collection property
*/
protected void visitCollection(Object value, String propertyName, Stack<BeanDefinitionHolder> nestedBeanStack) {
if (value instanceof Object[] || (value instanceof ManagedArray)) {
visitArray(value, propertyName, nestedBeanStack);
} else if (value instanceof List) {
visitList((List<?>) value, propertyName, nestedBeanStack);
} else if (value instanceof Set) {
visitSet((Set<?>) value, propertyName, nestedBeanStack);
} else if (value instanceof Map) {
visitMap((Map<?, ?>) value, propertyName, nestedBeanStack);
}
}
示例5: visitArray
import org.springframework.beans.factory.support.ManagedArray; //导入依赖的package包/类
/**
* Iterates through the array values and calls helpers to process the value
*
* @param array the array to process
* @param propertyName name of the property which has the array value
* @param nestedBeanStack stack of bean containers which contains the array property
*/
protected void visitArray(Object array, String propertyName, Stack<BeanDefinitionHolder> nestedBeanStack) {
Object[] arrayVal = null;
if (array instanceof ManagedArray) {
arrayVal = (Object[]) ((ManagedArray) array).getSource();
} else {
arrayVal = (Object[]) array;
}
Object[] newArray = new Object[arrayVal.length];
for (int i = 0; i < arrayVal.length; i++) {
Object elem = arrayVal[i];
if (isStringValue(elem)) {
elem = processArrayStringPropertyValue(propertyName, arrayVal, getString(elem), i, nestedBeanStack,
beanProcessors);
} else {
elem = visitPropertyValue(propertyName, elem, nestedBeanStack);
}
newArray[i] = elem;
}
if (array instanceof ManagedArray) {
((ManagedArray) array).setSource(newArray);
} else {
array = newArray;
}
}
示例6: isCollectionValue
import org.springframework.beans.factory.support.ManagedArray; //导入依赖的package包/类
/**
* Indicate whether the given value is a collection
*
* @param value value to test
* @return boolean true if the value is a collection, false if not
*/
protected boolean isCollectionValue(Object value) {
boolean isCollection = false;
if (value instanceof Object[] || (value instanceof ManagedArray) || (value instanceof List) ||
(value instanceof Set) || (value instanceof Map)) {
isCollection = true;
}
return isCollection;
}
示例7: canConvert
import org.springframework.beans.factory.support.ManagedArray; //导入依赖的package包/类
public boolean canConvert(Class type) {
return type.equals(ManagedList.class) || type.equals(ManagedArray.class) || type.equals(ManagedSet.class);
}