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


Java BeanUtil.setPropertyValue方法代码示例

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


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

示例1: execute

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes" })
  @Override
  public boolean execute(BeneratorContext context) {
// invoke constructor
      Object bean = constructionExpression.evaluate(context);
      // post construction steps
      super.execute(context);
      if (!StringUtil.isEmpty(id)) {
      	PropertyDescriptor descriptor = BeanUtil.getPropertyDescriptor(bean.getClass(), "id");
      	if (descriptor != null && descriptor.getWriteMethod() != null)
      		BeanUtil.setPropertyValue(bean, "id", id, false);
      }
      if (bean instanceof ContextAware)
	((ContextAware) bean).setContext(context);
if (bean instanceof DescriptorProvider)
	context.getDataModel().addDescriptorProvider((DescriptorProvider) bean);
if (bean instanceof Closeable && resourceManager != null)
	resourceManager.addResource((Closeable) bean);
if (bean instanceof Generator && constructionExpression instanceof BeanConstruction)
	((Generator) bean).init(context);
context.setGlobal(id, bean);
  	return true;
  }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:24,代码来源:BeanStatement.java

示例2: convertEntity

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
private static Object convertEntity(Entity entity) {
	Object result = BeanUtil.newInstance(entity.type());
       for (Map.Entry<String, Object> entry : entity.getComponents().entrySet()) {
           Object value = convertAny(entry.getValue());
		BeanUtil.setPropertyValue(result, entry.getKey(), value, false);
       }
       return result;
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:9,代码来源:Entity2JavaConverter.java

示例3: parseRestrictionChildren

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
private void parseRestrictionChildren(Element restriction,
		SimpleTypeDescriptor descriptor) {
	Element[] children = XMLUtil.getChildElements(restriction);
       for (Element child : children) {
           String nodeName = localName(child);
           String value = child.getAttribute(VALUE);
           if (ENUMERATION.equals(nodeName)) {
           	if (PrimitiveType.STRING.equals(descriptor.getPrimitiveType()))
           		descriptor.addValue("'" + value + "'");
           	else
           		descriptor.addValue(value);
           } else if (MIN_INCLUSIVE.equals(nodeName)) {
               descriptor.setMin(value);
               descriptor.setMinInclusive(true);
           } else if (MIN_EXCLUSIVE.equals(nodeName)) {
               descriptor.setMin(value);
               descriptor.setMinInclusive(false);
           } else if (MAX_INCLUSIVE.equals(nodeName)) {
               descriptor.setMax(value);
               descriptor.setMaxInclusive(true);
           } else if (MAX_EXCLUSIVE.equals(nodeName)) {
               descriptor.setMax(value);
               descriptor.setMaxInclusive(false);
           } else if (LENGTH.equals(nodeName)) {
               int length = Integer.parseInt(value);
               descriptor.setMinLength(length);
               descriptor.setMaxLength(length);
           } else if (BeanUtil.hasProperty(descriptor.getClass(), nodeName)) {
               BeanUtil.setPropertyValue(descriptor, nodeName, value, false);
           } else
               LOGGER.warn("Ignoring restriction " + nodeName + ": " + value);
       }
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:34,代码来源:XMLSchemaDescriptorProvider.java

示例4: mapAttributesTo

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
protected void mapAttributesTo(BeneratorContext context) {
	for (Entry<String, String> attribute : attributes.entrySet()) {
   		String key = attribute.getKey();
		String value = attribute.getValue();
		Object result;
		if ("generatorFactory".equals(key))
   			result = DatabeneScriptParser.parseBeanSpec(value).evaluate(context);
		else 
			result = value;
		BeanUtil.setPropertyValue(context, key, result, true, true);
   	}
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:13,代码来源:BeneratorRootStatement.java

示例5: createConvertingGenerator

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Generator<?> createConvertingGenerator(TypeDescriptor descriptor,
           Generator<?> generator, BeneratorContext context) {
       Converter<?, ?> converter = DescriptorUtil.getConverter(descriptor.getConverter(), context);
       if (converter != null) {
           if (descriptor.getPattern() != null && BeanUtil.hasProperty(converter.getClass(), PATTERN))
               BeanUtil.setPropertyValue(converter, PATTERN, descriptor.getPattern(), false);
           return WrapperFactory.applyConverter((Generator) generator, converter);
       }
       return generator;
   }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:12,代码来源:DescriptorUtil.java

示例6: createConvertingGenerator

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Generator<?> createConvertingGenerator(TypeDescriptor descriptor, Generator generator, BeneratorContext context) {
    Converter<?,?> converter = DescriptorUtil.getConverter(descriptor.getConverter(), context);
    if (converter != null) {
        if (descriptor.getPattern() != null && BeanUtil.hasProperty(converter.getClass(), PATTERN)) {
            BeanUtil.setPropertyValue(converter, PATTERN, descriptor.getPattern(), false);
        }
        generator = WrapperFactory.applyConverter(generator, converter);
    }
    return generator;
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:12,代码来源:TypeGeneratorFactory.java

示例7: setBeanProperty

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
public static void setBeanProperty(Object bean, String detailName, Object detailValue, Context context) {
    if (detailValue != null && BeanUtil.hasProperty(bean.getClass(), detailName)) {
        try {
            PropertyDescriptor propertyDescriptor = BeanUtil.getPropertyDescriptor(bean.getClass(), detailName);
            Class<?> propertyType = propertyDescriptor.getPropertyType();
            Object propertyValue = detailValue;
            if (detailValue instanceof String && StorageSystem.class.isAssignableFrom(propertyType))
                propertyValue = context.get(propertyValue.toString());
            BeanUtil.setPropertyValue(bean, detailName, propertyValue, false);
        } catch (RuntimeException e) {
            throw new RuntimeException("Error setting '" + detailName + "' of class " + bean.getClass().getName(), e); 
        }
    }
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:15,代码来源:FactoryUtil.java

示例8: createConvertingGenerator

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
public static Generator<?> createConvertingGenerator(TypeDescriptor descriptor, Generator<?> generator, BeneratorContext context) {
    Converter<?,?> converter = DescriptorUtil.getConverter(descriptor.getConverter(), context);
    if (converter != null) {
        if (descriptor.getPattern() != null && BeanUtil.hasProperty(converter.getClass(), PATTERN)) {
            BeanUtil.setPropertyValue(converter, PATTERN, descriptor.getPattern(), false);
        }
        generator = DescriptorUtil.createConvertingGenerator(descriptor, generator, context);
    }
    return generator;
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:11,代码来源:VariableGeneratorFactory.java

示例9: applyProperties

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
private static void applyProperties(Property[] properties, Object bean, BeneratorContext context) {
for (Property property : properties) {
	Object value = resolveProperty(property, bean, context);
	BeanUtil.setPropertyValue(bean, property.name(), value, true, true);
}
  }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:7,代码来源:AnnotationMapper.java

示例10: mapProperty

import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
private void mapProperty(String propertyName, Entity source, State target, boolean required) {
	String propertyValue = String.valueOf(source.get(propertyName));
	if (required)
		Assert.notNull(propertyValue, propertyName);
	BeanUtil.setPropertyValue(target, propertyName, propertyValue);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:7,代码来源:Country.java


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