本文整理汇总了Java中org.apache.commons.beanutils.BeanUtilsBean2类的典型用法代码示例。如果您正苦于以下问题:Java BeanUtilsBean2类的具体用法?Java BeanUtilsBean2怎么用?Java BeanUtilsBean2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BeanUtilsBean2类属于org.apache.commons.beanutils包,在下文中一共展示了BeanUtilsBean2类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProperties
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
public Dictionary<String, ?> getProperties ()
{
try
{
final Dictionary<String, Object> result = new Hashtable<String, Object> ();
final Map<?, ?> properties = new BeanUtilsBean2 ().describe ( this.targetBean );
for ( final Map.Entry<?, ?> entry : properties.entrySet () )
{
if ( entry.getValue () != null )
{
result.put ( entry.getKey ().toString (), entry.getValue () );
}
}
return result;
}
catch ( final Exception e )
{
logger.warn ( "Failed to get dictionary", e );
return new Hashtable<String, Object> ( 1 );
}
}
示例2: copyProperties
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
/**
* Copy properties.
*
* @param desc 不允许为空
* @param src 不允许为空
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void copyProperties(Object desc, Object src)
{
BeanUtilsBean2 beanUtilsBean2 = new BeanUtilsBean2();
try
{
if (desc instanceof Map)
{
Map<String, Object> map = beanToMap(src);
((Map) desc).putAll(map);
} else
{
beanUtilsBean2.copyProperties(desc, src);
}
} catch (Exception e)
{
log.error(e.getMessage(), e);
}
}
示例3: main
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
BeanUtilsBean utilsBean = BeanUtilsBean2.getInstance();
utilsBean.getConvertUtils().register(false, false, 0);
BeanOne one = new BeanOne();
one.setPropertyOne("One");
one.setPropertyTwo("Two");
one.setPropertyThree(3L);
one.setPropertyFour(4); //this is a string in BeanTwo
BeanTwo two = new BeanTwo();
utilsBean.copyProperties(two, one);
BeanUtilsBean.getInstance().getConvertUtils().register(false, false, 0);
System.out.println(two);
}
示例4: init
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Override
public void init(ServletConfig config) throws ServletException {
this.config = config;
BlockingQueue<Filter> waiters = (BlockingQueue<Filter>) config.getServletContext()
.getAttribute(APPLICATION_CONTEXT_LOCK_KEY);
if (waiters != null) {
waiters.add(this);
} else {
//Servlet 2.5 lazy filter initing
delayedInit();
}
// register the bean utils converter to fail if encounters a type mismatch between the destination
// and the original, see RTFACT-3610
BeanUtilsBean instance = BeanUtilsBean2.getInstance();
instance.getConvertUtils().register(true, false, 0);
}
示例5: GitRiver
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@Inject
protected GitRiver(RiverName riverName, RiverSettings settings, @RiverIndexName String riverIndexName, Client client) throws InvocationTargetException, IllegalAccessException {
super(riverName, settings);
this.client = client;
logger.info("Creating Git river");
if (settings.settings().containsKey("git")) {
Map<String, Object> gitSettings = (Map<String, Object>) settings.settings().get("git");
BeanUtilsBean2.getInstance().populate(context, transformKeys(gitSettings, new Function<String, String>() {
@Override
public String apply(String input) {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input);
}
}));
}
context.setRiverName(riverName.name());
context.setRiverIndexName(riverIndexName);
context.setClient(client);
context.setIssuePattern(compilePattern(context.getIssueRegex()));
}
示例6: getMarkInumMapEntryAsRemoved
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
private GluuInumMap getMarkInumMapEntryAsRemoved(GluuInumMap currentInumMap, String date) {
GluuInumMap clonedInumMap;
try {
clonedInumMap = (GluuInumMap) BeanUtilsBean2.getInstance().cloneBean(currentInumMap);
} catch (Exception ex) {
log.error("Failed to prepare GluuInumMap for removal", ex);
return null;
}
String suffix = "-" + date;
String[] primaryKeyValues = ArrayHelper.arrayClone(clonedInumMap.getPrimaryKeyValues());
String[] secondaryKeyValues = ArrayHelper.arrayClone(clonedInumMap.getSecondaryKeyValues());
String[] tertiaryKeyValues = ArrayHelper.arrayClone(clonedInumMap.getTertiaryKeyValues());
if (ArrayHelper.isNotEmpty(primaryKeyValues)) {
markInumMapEntryKeyValuesAsRemoved(primaryKeyValues, suffix);
}
if (ArrayHelper.isNotEmpty(secondaryKeyValues)) {
markInumMapEntryKeyValuesAsRemoved(secondaryKeyValues, suffix);
}
if (ArrayHelper.isNotEmpty(tertiaryKeyValues)) {
markInumMapEntryKeyValuesAsRemoved(tertiaryKeyValues, suffix);
}
clonedInumMap.setPrimaryKeyValues(primaryKeyValues);
clonedInumMap.setSecondaryKeyValues(secondaryKeyValues);
clonedInumMap.setTertiaryKeyValues(tertiaryKeyValues);
clonedInumMap.setStatus(GluuStatus.INACTIVE);
return clonedInumMap;
}
示例7: onCreate
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@PrePersist
public void onCreate(Object object) {
final String ID = "id";
final String CREATED_AT = "createdAt";
final String LAST_MODIFIED_AT = "lastModifiedAt";
BeanUtilsBean beanUtilsBean = BeanUtilsBean2.getInstance();
try {
if (Objects.equals(beanUtilsBean.getProperty(object, ID), CommonsConstant.ZERO)) {
beanUtilsBean.setProperty(object, CREATED_AT, System.currentTimeMillis());
beanUtilsBean.setProperty(object, LAST_MODIFIED_AT, System.currentTimeMillis());
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignore) {}
}
示例8: onCreate
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@PrePersist
public void onCreate(Object object) {
final String ID = "id";
final String VALID_FLAG = "validFlag";
BeanUtilsBean beanUtilsBean = BeanUtilsBean2.getInstance();
try {
if (Objects.equals(beanUtilsBean.getProperty(object, ID), CommonsConstant.ZERO)) {
beanUtilsBean.setProperty(object, VALID_FLAG, ValidFlag.VALID);
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignore) {}
}
示例9: initialValue
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
@Override
protected ConvertUtilsBean initialValue() {
ConvertUtilsBean ret = BeanUtilsBean2.getInstance().getConvertUtils();
ret.deregister();
ret.register(false, true, 1);
return ret;
}
示例10: update
import org.apache.commons.beanutils.BeanUtilsBean2; //导入依赖的package包/类
public void update ( final Map<String, String> parameters ) throws Exception
{
new BeanUtilsBean2 ().populate ( this.targetBean, parameters );
}