private String updatePropertyValue(String propertyName,
PropertyValues values) {
PropertyValue property = values.getPropertyValue(propertyName);
if (property == null) {
return null;
}
Object value = property.getValue();
if (value == null) {
return null;
} else if (value instanceof String) {
return value.toString();
} else if (value instanceof TypedStringValue) {
return ((TypedStringValue) value).getValue();
} else {
return null;
}
}
java类org.springframework.beans.factory.config.TypedStringValue的实例源码
MapperScannerConfigurer.java 文件源码
项目:MybatisSpring2.5.X
阅读 24
收藏 0
点赞 0
评论 0
BeanPropertyParserTest.java 文件源码
项目:arondor-common-reflection
阅读 17
收藏 0
点赞 0
评论 0
@Test
public void testParsePropertyEnum() throws Exception
{
TypedStringValue enumPropertyValue = mockTypedStringValue("my enum type", "my enum type value");
ElementConfiguration parsedEnumFieldConfiguration = beanPropertyParser.parseProperty(enumPropertyValue);
assertEquals(ElementConfigurationType.Object, parsedEnumFieldConfiguration.getFieldConfigurationType());
assertTrue(parsedEnumFieldConfiguration instanceof ObjectConfiguration);
ObjectConfiguration enumObjectConfiguration = (ObjectConfiguration) parsedEnumFieldConfiguration;
assertEquals(enumPropertyValue.getTargetTypeName(), enumObjectConfiguration.getClassName());
ElementConfiguration actual = enumObjectConfiguration.getConstructorArguments().get(0);
assertEquals(ElementConfigurationType.Primitive, actual.getFieldConfigurationType());
PrimitiveConfiguration primitiveConfiguration = (PrimitiveConfiguration) actual;
assertEquals(enumPropertyValue.getValue(), primitiveConfiguration.getValue());
}
BeanPropertyParserTest.java 文件源码
项目:arondor-common-reflection
阅读 16
收藏 0
点赞 0
评论 0
@Test
public void testParsePropertyClassicList()
{
ManagedList<TypedStringValue> list = new ManagedList<TypedStringValue>();
mock(ManagedList.class);
list.add(mockTypedStringValue(null, "my first value"));
list.add(mockTypedStringValue(null, "my second value"));
ElementConfiguration parsedFieldConfiguration = beanPropertyParser.parseProperty(list);
assertEquals(ElementConfigurationType.List, parsedFieldConfiguration.getFieldConfigurationType());
ListConfiguration listConfiguration = (ListConfiguration) parsedFieldConfiguration;
assertEquals(2, listConfiguration.getListConfiguration().size());
assertEquals(ElementConfigurationType.Primitive, listConfiguration.getListConfiguration().get(0)
.getFieldConfigurationType());
assertEquals(ElementConfigurationType.Primitive, listConfiguration.getListConfiguration().get(1)
.getFieldConfigurationType());
assertEquals(list.get(0).getValue(),
((PrimitiveConfiguration) listConfiguration.getListConfiguration().get(0)).getValue());
assertEquals(list.get(1).getValue(),
((PrimitiveConfiguration) listConfiguration.getListConfiguration().get(1)).getValue());
}
BeanDefinitionWriterServiceImpl.java 文件源码
项目:geomajas-project-server
阅读 27
收藏 0
点赞 0
评论 0
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
ManagedMap<?, ?> map = (ManagedMap<?, ?>) source;
for (Map.Entry<?, ?> entry : map.entrySet()) {
writer.startNode("entry");
writer.startNode("key");
if (entry.getKey().getClass().equals(TypedStringValue.class)) {
writer.startNode("value");
writer.setValue(((TypedStringValue) entry.getKey()).getValue());
writer.endNode();
} else {
writeItem(entry.getKey(), context, writer);
}
writer.endNode();
if (entry.getValue().getClass().equals(TypedStringValue.class)) {
writer.startNode("value");
writer.setValue(((TypedStringValue) entry.getValue()).getValue());
writer.endNode();
} else {
writeItem(entry.getValue(), context, writer);
}
writer.endNode();
}
}
BeanDefinitionWriterServiceImpl.java 文件源码
项目:geomajas-project-server
阅读 25
收藏 0
点赞 0
评论 0
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
BeanDefinitionHolder holder = (BeanDefinitionHolder) source;
BeanDefinition definition = holder.getBeanDefinition();
writer.addAttribute("class", definition.getBeanClassName());
writer.addAttribute("name", holder.getBeanName());
for (PropertyValue property : definition.getPropertyValues().getPropertyValueList()) {
writer.startNode("property");
writer.addAttribute("name", property.getName());
if (property.getValue().getClass().equals(TypedStringValue.class)) {
context.convertAnother(property.getValue());
} else {
writeItem(property.getValue(), context, writer);
}
writer.endNode();
}
}
DaoScannerConfigurer.java 文件源码
项目:winlet
阅读 60
收藏 0
点赞 0
评论 0
private String updatePropertyValue(String propertyName,
PropertyValues values) {
PropertyValue property = values.getPropertyValue(propertyName);
if (property == null) {
return null;
}
Object value = property.getValue();
if (value == null) {
return null;
} else if (value instanceof String) {
return value.toString();
} else if (value instanceof TypedStringValue) {
return ((TypedStringValue) value).getValue();
} else {
return null;
}
}
ViewModelUtils.java 文件源码
项目:kuali_rice
阅读 25
收藏 0
点赞 0
评论 0
/**
* Helper method for getting the string value of a property from a {@link PropertyValues}
*
* @param propertyValues property values instance to pull from
* @param propertyName name of property whose value should be retrieved
* @return String value for property or null if property was not found
*/
public static String getStringValFromPVs(PropertyValues propertyValues, String propertyName) {
String propertyValue = null;
if ((propertyValues != null) && propertyValues.contains(propertyName)) {
Object pvValue = propertyValues.getPropertyValue(propertyName).getValue();
if (pvValue instanceof TypedStringValue) {
TypedStringValue typedStringValue = (TypedStringValue) pvValue;
propertyValue = typedStringValue.getValue();
} else if (pvValue instanceof String) {
propertyValue = (String) pvValue;
}
}
return propertyValue;
}
SpringGraphBuilder.java 文件源码
项目:directed-graph-builder
阅读 29
收藏 0
点赞 0
评论 0
/**
* @param node
* @param v
*/
private void addFieldToNode(Graph.Node node, final PropertyValue v) {
if (v.getValue() instanceof TypedStringValue) {
if (!v.getName().toUpperCase().contains("PASSWORD")) {
node.addField(v.getName() + "=" + ((TypedStringValue) v.getValue()).getValue());
} else {
node.addField(v.getName() + "=********");
}
} else if (v.getValue() instanceof String | v.getValue() instanceof Boolean | v.getValue() instanceof Integer) {
node.addField(v.getName() + "=" + v.getValue());
} else if (v.getValue() instanceof BeanDefinitionHolder) {
node.addField(v.getName() + "=" + ((BeanDefinitionHolder) v.getValue()).getBeanDefinition().getBeanClassName());
} else if (!(v.getValue() instanceof RuntimeBeanReference)) {
node.addField(v.getName() + "=(" + v.getValue().getClass().getSimpleName() + ")");
} else {
//This is a RuntimeBeanReference which is handled as an edge
}
}
DependencyNotFoundFilterParser.java 文件源码
项目:redhat-repository-validator
阅读 19
收藏 0
点赞 0
评论 0
/**
* Parses a list of regular expressions stored inside list bean, defined by the standard <util:list>.
*/
private List<String> parseListOfRegexs(BeanDefinition listBean) {
Object value = listBean.getPropertyValues().getPropertyValue("sourceList").getValue();
List<String> regexs = new ArrayList<String>();
if (value instanceof ManagedList) {
@SuppressWarnings("rawtypes")
ManagedList regexList = (ManagedList) value;
for (int i = 0; i < regexList.size(); i++) {
Object obj = regexList.get(i);
if (obj instanceof TypedStringValue) {
regexs.add(((TypedStringValue) obj).getValue());
} else {
throw new RuntimeException("Can't parse the list of regular expressions from bean " + listBean);
}
}
} else {
throw new RuntimeException("Can't parse the list of regular expressions from bean " + listBean);
}
return regexs;
}
MandatoryImporterDependencyFactory.java 文件源码
项目:gemini.blueprint
阅读 23
收藏 0
点赞 0
评论 0
private String getString(PropertyValue pv) {
if (pv == null)
return "";
Object value = pv.getValue();
if (value == null) {
return "";
}
if (value instanceof TypedStringValue) {
return ((TypedStringValue) value).getValue();
}
return value.toString();
}