本文整理汇总了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;
}
示例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;
}
示例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";
}
}
示例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);
}
}
示例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);
}
示例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
}
示例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
}