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


Java BeanUtils.getSimpleProperty方法代码示例

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


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

示例1: prepareInsert

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
@Override
public PreparedPartitionSqlEntity prepareInsert(Object entity) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    String id = BeanUtils.getSimpleProperty(entity, this.idField.getName());
    if (null == id || "".equals(id.trim())) {
        throw new IllegalArgumentException("Entity id cannot be null!");
    }
    String table = this.translatePartitionTable(id);
    if (null == table) {
        throw new IllegalArgumentException("Cannot determine which table to insert into according entity id : " + id + ".");
    }
    PreparedPartitionSqlEntity pe = new PreparedPartitionSqlEntity();
    StringBuilder insertSql = new StringBuilder("insert into ").append(table).append("\n(");
    StringBuilder valueAppender = new StringBuilder();
    Field[] fs = this.getEntityClass().getDeclaredFields();
    for (int i = 0; i < fs.length; i++) {
        Field field = fs[i];
        boolean isAccessable = field.isAccessible();
        if (!isAccessable)
            field.setAccessible(true);
        Object value = field.get(entity);
        field.setAccessible(isAccessable);
        if (null != value) {
            insertSql.append(null == field.getAnnotation(Column.class) ?
                    field.getName().toLowerCase() : field.getAnnotation(Column.class).name());
            valueAppender.append("?");
            pe.addArg(value);
            if (i != fs.length - 1) {
                insertSql.append(", ");
                valueAppender.append(", ");
            }
        }
    }
    insertSql.append(") values\n(").append(valueAppender.toString()).append(")");
    pe.setSql(insertSql.toString());
    return pe;
}
 
开发者ID:hetianyi,项目名称:baseframe-partition,代码行数:37,代码来源:MysqlPartitionEntity.java

示例2: prepareUpdate

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
@Override
public PreparedPartitionSqlEntity prepareUpdate(Object entity) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    String id = BeanUtils.getSimpleProperty(entity, this.idField.getName());
    if (null == id || "".equals(id.trim())) {
        throw new IllegalArgumentException("Entity id cannot be null!");
    }
    String table = this.translatePartitionTable(id);
    if (null == table) {
        throw new IllegalArgumentException("Cannot determine which table to insert into according entity id : " + id + ".");
    }
    PreparedPartitionSqlEntity pe = new PreparedPartitionSqlEntity();
    StringBuilder updateSql = new StringBuilder("update ").append(table).append(" set\n");
    Field[] fs = this.getEntityClass().getDeclaredFields();
    for (int i = 0; i < fs.length; i++) {
        Field field = fs[i];
        if (field == this.idField) {
            continue;
        }
        boolean isAccessable = field.isAccessible();
        if (!isAccessable)
            field.setAccessible(true);
        Object value = field.get(entity);
        field.setAccessible(isAccessable);
        updateSql.append(null == field.getAnnotation(Column.class) ?
                field.getName().toLowerCase() : field.getAnnotation(Column.class).name()).append(" = ?");
        pe.addArg(value);
        if (i != fs.length - 1) {
            updateSql.append(", ");
        }
    }
    updateSql.append("\n where ").append(null == this.idField.getAnnotation(Column.class) ?
            this.idField.getName().toLowerCase() : this.idField.getAnnotation(Column.class).name())
            .append(" = ?");
    pe.setSql(updateSql.toString());
    pe.addArg(id);
    return pe;
}
 
开发者ID:hetianyi,项目名称:baseframe-partition,代码行数:38,代码来源:MysqlPartitionEntity.java

示例3: getText

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
@Override public String getText(Object element) {
  	try {
	return BeanUtils.getSimpleProperty(element, colName);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
	return "i am error";
}
  }
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:8,代码来源:TableColumnBeanLabelProvider.java

示例4: processPasswordProperty

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
private void processPasswordProperty(ApplicationConfiguration source, ApplicationConfiguration current, String property) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, EncryptionException {
	String currentValue = BeanUtils.getProperty(current, property);
	if (StringHelper.equals(currentValue, HIDDEN_PASSWORD_TEXT)) {
		String sourceValue = BeanUtils.getSimpleProperty(source, property);
		BeanUtils.setProperty(current, property, sourceValue);
	} else {
		String currentValueEncrypted = StringEncrypter.defaultInstance().encrypt(currentValue, cryptoConfigurationSalt);
		BeanUtils.setProperty(current, property, currentValueEncrypted);
	}
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:11,代码来源:JsonConfigurationAction.java

示例5: initFilter

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
void initFilter() {
		viewerFilter = new ViewerFilter() {
			@Override public boolean select(Viewer viewer, Object parentElement, Object element) {
				if (SWTUtil.isDisposed(filter)) {
					return true;
				}
				
				logger.debug("filter, select: "+element);

				String ft = filter.getText();
				logger.debug("ft = "+ft);
				if (StringUtils.isEmpty(ft))
					return true;
				
				ft = Pattern.quote(ft);
				
				String reg = "(?i)(.*"+ft+".*)";
				logger.debug("reg = "+reg);
				
				for (String property : filterProperties) {
					try {
						String propValue = BeanUtils.getSimpleProperty(element, property);
						logger.debug("property: "+property+" value: "+propValue);
						
						if (propValue.matches(reg)) {
							return true;
						}
					} catch (Exception e) {
						logger.error("Error getting filter property '"+property+"': "+e.getMessage());
					}
				}

				return false;
				
//				boolean matches = element.toString().matches(reg);
//				logger.debug("matches = "+matches);
//				return matches;
			}
		};
		
		filterModifyListener = new ModifyListener() {
			DelayedTask dt = new DelayedTask(() -> { 
				refreshList(tags);
			}, true);
			@Override public void modifyText(ModifyEvent e) {
				dt.start();
			}
		};
		filter.addModifyListener(filterModifyListener);
		
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:52,代码来源:TagTableWidgetPagination.java

示例6: DocTableWidgetPagination

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
public DocTableWidgetPagination(Composite parent, int style, int initialPageSize, IPageLoadMethods<TrpDocMetadata> methods) {
		super(parent, style, initialPageSize, methods, true);
		
		viewerFilter = new ViewerFilter() {
			@Override public boolean select(Viewer viewer, Object parentElement, Object element) {
				if (SWTUtil.isDisposed(filter)) {
					return true;
				}
				
				logger.trace("filter, select: "+element);

				String ft = filter.getText();
				logger.trace("ft = "+ft);
				if (StringUtils.isEmpty(ft))
					return true;
				
				ft = Pattern.quote(ft);
				
				String reg = "(?i)(.*"+ft+".*)";
				logger.trace("reg = "+reg);
				
//				TrpDocMetadata d = (TrpDocMetadata) element;
				
				for (String property : filterProperties) {
					try {
						String propValue = BeanUtils.getSimpleProperty(element, property);
						logger.trace("property: "+property+" value: "+propValue);
						
						if (propValue.matches(reg)) {
							return true;
						}
					} catch (Exception e) {
						logger.error("Error getting filter property '"+property+"': "+e.getMessage());
					}
				}

				return false;
				
//				boolean matches = element.toString().matches(reg);
//				logger.debug("matches = "+matches);
//				return matches;
			}
		};
		
		filterModifyListener = new ModifyListener() {
			DelayedTask dt = new DelayedTask(() -> { 
				reloadDocs(true, false); 
			}, true);
			@Override public void modifyText(ModifyEvent e) {
				dt.start();
			}
		};
		filter.addModifyListener(filterModifyListener);
//		pageableTable.getViewer().addFilter(viewerFilter); // does not work with pagination -> using viewerFilter explicitly when setting input to listLoader
		
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:57,代码来源:DocTableWidgetPagination.java

示例7: initFilter

import org.apache.commons.beanutils.BeanUtils; //导入方法依赖的package包/类
void initFilter() {
		viewerFilter = new ViewerFilter() {
			@Override public boolean select(Viewer viewer, Object parentElement, Object element) {
				if (SWTUtil.isDisposed(filter)) {
					return true;
				}
				
				logger.trace("filter, select: "+element);

				String ft = filter.getText();
				logger.trace("ft = "+ft);
				if (StringUtils.isEmpty(ft))
					return true;
				
				ft = Pattern.quote(ft);
				
				String reg = "(?i)(.*"+ft+".*)";
				logger.trace("reg = "+reg);
				
//				TrpDocMetadata d = (TrpDocMetadata) element;
				
				for (String property : filterProperties) {
					try {
						String propValue = BeanUtils.getSimpleProperty(element, property);
						logger.trace("property: "+property+" value: "+propValue);
						
						if (propValue.matches(reg)) {
							return true;
						}
					} catch (Exception e) {
						logger.error("Error getting filter property '"+property+"': "+e.getMessage());
					}
				}

				return false;
				
//				boolean matches = element.toString().matches(reg);
//				logger.debug("matches = "+matches);
//				return matches;
			}
		};
		
		filterModifyListener = new ModifyListener() {
			DelayedTask dt = new DelayedTask(() -> { 
				refreshList(collections);
				//this way the first collection found by the filter is preselected
				if (!tv.getTable().isDisposed()){
					tv.getTable().select(0);
				}
			}, true);
			@Override public void modifyText(ModifyEvent e) {
				dt.start();
			}
		};
		filter.addModifyListener(filterModifyListener);
//		pageableTable.getViewer().addFilter(viewerFilter); // does not work with pagination -> using viewerFilter explicitly when setting input to listLoader

		
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:60,代码来源:CollectionsTableWidgetPagination.java


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