當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。