本文整理匯總了Java中org.apache.commons.beanutils.BeanUtils.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanUtils.getProperty方法的具體用法?Java BeanUtils.getProperty怎麽用?Java BeanUtils.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.beanutils.BeanUtils
的用法示例。
在下文中一共展示了BeanUtils.getProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkPropertiesOfAttachement
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
* Check properties of Attachement objects.
*
* @param attachements
* @throws AirtableException
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*/
private void checkPropertiesOfAttachement(List<Attachment> attachements) throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (attachements != null) {
for (int i = 0; i < attachements.size(); i++) {
if (propertyExists(attachements.get(i), FIELD_ID) || propertyExists(attachements.get(i), "size")
|| propertyExists(attachements.get(i), "type") || propertyExists(attachements.get(i), "filename")) {
final Field[] attributesPhotos = attachements.getClass().getDeclaredFields();
for (Field attributePhoto : attributesPhotos) {
final String namePhotoAttribute = attributePhoto.getName();
if (FIELD_ID.equals(namePhotoAttribute) || "size".equals(namePhotoAttribute)
|| "type".equals(namePhotoAttribute) || "filename".equals(namePhotoAttribute)) {
if (BeanUtils.getProperty(attachements.get(i), namePhotoAttribute) != null) {
throw new AirtableException("Property " + namePhotoAttribute + " should be null!");
}
}
}
}
}
}
}
示例2: checkProperties
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
* Checks if the Property Values of the item are valid for the Request.
*
* @param item
* @throws AirtableException
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*/
private void checkProperties(T item) throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (propertyExists(item, FIELD_ID) || propertyExists(item, FIELD_CREATED_TIME)) {
Field[] attributes = item.getClass().getDeclaredFields();
for (Field attribute : attributes) {
String attrName = attribute.getName();
if (FIELD_ID.equals(attrName) || FIELD_CREATED_TIME.equals(attrName)) {
if (BeanUtils.getProperty(item, attribute.getName()) != null) {
throw new AirtableException("Property " + attrName + " should be null!");
}
} else if ("photos".equals(attrName)) {
List<Attachment> obj = (List<Attachment>) BeanUtilsBean.getInstance().getPropertyUtils().getProperty(item, "photos");
checkPropertiesOfAttachement(obj);
}
}
}
}
示例3: getOrderedKeyset
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
protected List getOrderedKeyset(Set keys, Object param) throws Exception {
List orderedKeyset = new ArrayList();
if (keys.size() > 0) {
String firstitems = BeanUtils.getProperty(param,
"_firstitems");
String firstitemname = null;
if (firstitems != null) {
for (StringTokenizer st = new StringTokenizer(firstitems, ","); st
.hasMoreTokens(); ) {
firstitemname = st.nextToken();
if (keys.contains(firstitemname)) {
orderedKeyset.add(firstitemname);
}
}
}
for (Iterator it = keys.iterator(); it.hasNext(); ) {
String key = (String) it.next();
if (!orderedKeyset.contains(key))
orderedKeyset.add(key);
}
}
return orderedKeyset;
}
示例4: isValid
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@Override
public boolean isValid(Object value, ConstraintValidatorContext context) {
if (value == null) {
return true;
}
try {
final String fieldValue = BeanUtils.getProperty(value, fieldName);
final String notNullFieldValue = BeanUtils.getProperty(value, notNullFieldName);
if (StringUtils.equals(fieldValue, fieldSetValue) && StringUtils.isEmpty(notNullFieldValue)) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate(context.getDefaultConstraintMessageTemplate())
.addPropertyNode(notNullFieldName).addConstraintViolation();
return false;
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
return true;
}
示例5: doRoute
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@Before("aopPoint()")
public Object doRoute(JoinPoint jp) throws Throwable {
boolean result = true;
Method method = this.getMethod(jp);
DbRoute dbRoute = method.getAnnotation(DbRoute.class);
String routeField = dbRoute.field(); // userId
Object[] args = jp.getArgs();
if(args != null && args.length > 0) {
for(int i = 0; i < args.length; ++i) {
String routeFieldValue = BeanUtils.getProperty(args[i], routeField);
if(StringUtils.isNotEmpty(routeFieldValue)) {
if("userId".equals(routeField)) {
this.dbRouter.route(routeField);
}
break;
}
}
}
return Boolean.valueOf(result);
}
示例6: extractRecordId
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
private String extractRecordId(MobileBean record)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
{
String id = "";
Class recordClazz = record.getClass();
Field[] declaredFields = recordClazz.getDeclaredFields();
for(Field field: declaredFields)
{
Annotation[] annotations = field.getAnnotations();
for(Annotation annotation: annotations)
{
if(annotation instanceof MobileBeanId)
{
return BeanUtils.getProperty(record, field.getName());
}
}
}
return id;
}
示例7: isValid
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@Override
public boolean isValid(Object value, ConstraintValidatorContext context) {
try {
final Idtp idtp = (Idtp) PropertyUtils.getProperty(value, typeFieldName);
final String idno = BeanUtils.getProperty(value, codeFieldName);
if (idtp.equals(Idtp.IDCARD)) {
return IdentifierValidation.isIdCardNo(idno);
}
if (idtp.equals(Idtp.OCC)) {
return IdentifierValidation.isOcc(idno);
}
if (idtp.equals(Idtp.USCIC)) {
return IdentifierValidation.isUscic(idno);
}
} catch (Exception e) {
throw new BaseException("E-BASE-000001", e.getMessage()).initCause(e);
}
return true;
}
示例8: newBeansSource
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
* Create a new ReplaceSource that handles bean references
*
* @param properties
* the properties to use for replacing
* @return the new ReplaceSource instance
*/
public static ReplaceSource newBeansSource ( final Map<?, ?> properties )
{
return new ReplaceSource () {
@Override
public String replace ( final String context, final String key )
{
String result = null;
try
{
result = BeanUtils.getProperty ( properties, key );
}
catch ( final Exception e )
{
}
if ( result != null )
{
return result;
}
else
{
return context;
}
}
};
}
示例9: getIdOfItem
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
* Get the String Id from the item.
*
* @param item
* @return
* @throws AirtableException
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*/
private String getIdOfItem(T item) throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (propertyExists(item, FIELD_ID)) {
final String id = BeanUtils.getProperty(item, FIELD_ID);
if (id != null) {
return id;
}
}
throw new AirtableException("Id of " + item + " not Found!");
}
示例10: filterFields
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
*
* Filter the Fields of the PostRecord Object. Id and created Time are set
* to null so Object Mapper doesent convert them to JSON.
*
* @param item
* @return
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*/
private T filterFields(T item) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
final Field[] attributes = item.getClass().getDeclaredFields();
for (Field attribute : attributes) {
String attrName = attribute.getName();
if ((FIELD_ID.equals(attrName) || FIELD_CREATED_TIME.equals(attrName))
&& (BeanUtils.getProperty(item, attrName) != null)) {
BeanUtilsBean.getInstance().getPropertyUtils().setProperty(item, attrName, null);
}
}
return item;
}
示例11: fetchData
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
protected Object fetchData(Object object,String property){
try {
return BeanUtils.getProperty(object, property);
} catch (Exception e) {
throw new RuleException(e);
}
}
示例12: getValueProperty
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/** Renvoie la valeur de la propriété du bean
* @param property
* @return la valeur de la propriété
*/
public String getValueProperty(String property){
try {
String valueProperty = BeanUtils.getProperty(this, property);
if (valueProperty!=null){
return valueProperty.toString();
}else{
return "";
}
} catch (Exception e) {
return "";
}
}
示例13: getIdValue
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
public String getIdValue() {
try {
return BeanUtils.getProperty(this, id());
} catch (Exception e) {
log.catching(e);
}
return null;
}
示例14: getOid
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
public static String getOid(MobileBean record)
{
try
{
String id = "";
Class recordClazz = record.getClass();
Field[] declaredFields = recordClazz.getDeclaredFields();
for(Field field: declaredFields)
{
Annotation[] annotations = field.getAnnotations();
for(Annotation annotation: annotations)
{
if(annotation instanceof MobileBeanId)
{
return BeanUtils.getProperty(record, field.getName());
}
}
}
return id;
}
catch(Exception e)
{
throw new RuntimeException(e);
}
}
示例15: getString
import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
* Get virtual column string value
*/
public static String getString(DatabaseMetadataValue value, String column) throws DatabaseException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException {
List<DatabaseMetadataType> types = DatabaseMetadataDAO.findAllTypes(value.getTable());
for (DatabaseMetadataType emt : types) {
if (emt.getVirtualColumn().equals(column)) {
return BeanUtils.getProperty(value, emt.getRealColumn());
}
}
return null;
}