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


Java PropertyAccessException类代码示例

本文整理汇总了Java中org.springframework.beans.PropertyAccessException的典型用法代码示例。如果您正苦于以下问题:Java PropertyAccessException类的具体用法?Java PropertyAccessException怎么用?Java PropertyAccessException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: processPropertyAccessException

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
/**
 * Adds an entry to the {@link org.kuali.rice.krad.util.GlobalVariables#getMessageMap()} for the given
 * binding processing error
 *
 * @param ex exception that was thrown
 * @param bindingResult binding result containing the results of the binding process
 */
@Override
public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) {
    // Create field error with the exceptions's code, e.g. "typeMismatch".
    super.processPropertyAccessException(ex, bindingResult);

    Object rejectedValue = ex.getValue();
    if (!(rejectedValue == null || rejectedValue.equals(""))) {
        if (ex.getCause() instanceof FormatException) {
            GlobalVariables.getMessageMap().putError(ex.getPropertyName(),
                    ((FormatException) ex.getCause()).getErrorKey(),
                    new String[] {rejectedValue.toString()});
        } else {
            GlobalVariables.getMessageMap().putError(ex.getPropertyName(), RiceKeyConstants.ERROR_CUSTOM,
                    new String[] {"Invalid format"});
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:UifBindingErrorProcessor.java

示例2: setValueSilently

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
public void setValueSilently(Object value, PropertyChangeListener listenerToSkip) {
	try {
		if (logger.isDebugEnabled()) {
			Class valueClass = (value != null ? value.getClass() : null);
			logger.debug("Setting '" + formProperty + "' value to convert/validate '"
					+ (UserMetadata.isFieldProtected(DefaultFormModel.this, formProperty) ? "***" : value)
					+ "', class=" + valueClass);
		}
		super.setValueSilently(value, listenerToSkip);
		clearBindingError(this);
	}
	catch (ConversionException ce) {
		logger.warn("Conversion exception occurred setting value", ce);
		raiseBindingError(this, value, ce);
	}
	catch (PropertyAccessException pae) {
		logger.warn("Type Mismatch Exception occurred setting value", pae);
		raiseBindingError(this, value, pae);
	}
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:21,代码来源:DefaultFormModel.java

示例3: getMessageCodeForException

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
protected String getMessageCodeForException(Exception e) {
    if (e instanceof PropertyAccessException) {
        return ((PropertyAccessException)e).getErrorCode();
    }
    else if (e instanceof NullPointerException) {
        return "required";
    }
    else if (e instanceof InvalidFormatException) {
        return "typeMismatch";
    }
    else if (e instanceof IllegalArgumentException) {
        return "typeMismatch";
    }
    else if (e.getCause() instanceof Exception) {
        return getMessageCodeForException((Exception)e.getCause());
    }
    else {
        return "unknown";
    }
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:21,代码来源:DefaultBindingErrorMessageProvider.java

示例4: processPropertyAccessException

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
@Override
public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) {
	// Create field error with the exceptions's code, e.g. "typeMismatch".
	String field = ex.getPropertyName();
	String[] codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field);
	Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), field);
	Object rejectedValue = ex.getValue();
	if (rejectedValue != null && rejectedValue.getClass().isArray()) {
		rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue));
	}
	bindingResult.addError(new FieldError(
			bindingResult.getObjectName(), field, rejectedValue, true,
			codes, arguments, ex.getLocalizedMessage()));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:DefaultBindingErrorProcessor.java

示例5: applyPropertyValues

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
/**
 * Apply given property values to the target object.
 * <p>Default implementation applies all of the supplied property
 * values as bean property values. By default, unknown fields will
 * be ignored.
 * @param mpvs the property values to be bound (can be modified)
 * @see #getTarget
 * @see #getPropertyAccessor
 * @see #isIgnoreUnknownFields
 * @see #getBindingErrorProcessor
 * @see BindingErrorProcessor#processPropertyAccessException
 */
protected void applyPropertyValues(MutablePropertyValues mpvs) {
	try {
		// Bind request parameters onto target object.
		getPropertyAccessor().setPropertyValues(mpvs, isIgnoreUnknownFields(), isIgnoreInvalidFields());
	}
	catch (PropertyBatchUpdateException ex) {
		// Use bind error processor to create FieldErrors.
		for (PropertyAccessException pae : ex.getPropertyAccessExceptions()) {
			getBindingErrorProcessor().processPropertyAccessException(pae, getInternalBindingResult());
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:DataBinder.java

示例6: main

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
public static void main(final String[] args) {
    final String rootContextDirectoryClassPath = "cool/pandora/modeller/ctx";

    final String startupContextPath =
            rootContextDirectoryClassPath + "/common/richclient-startup-context.xml";

    final String richclientApplicationContextPath =
            rootContextDirectoryClassPath + "/common/richclient-application-context.xml";

    final String businessLayerContextPath =
            rootContextDirectoryClassPath + "/common/business-layer-context.xml";

    try {
        new ApplicationLauncher(startupContextPath,
                new String[]{richclientApplicationContextPath, businessLayerContextPath});
    } catch (final IllegalStateException ex1) {
        log.error("IllegalStateException during startup", ex1);
        JOptionPane.showMessageDialog(new JFrame(), "An illegal state error occured.\n",
                "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (final PropertyAccessException ex) {
        log.error("PropertyAccessException during startup", ex);
        JOptionPane.showMessageDialog(new JFrame(), "An error occured loading properties.\n",
                "Bagger startup " + "error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (final RuntimeException e) {
        log.error("RuntimeException during startup", e);
        final String msg = e.getMessage();
        if (msg.contains("SAXParseException")) {
            JOptionPane.showMessageDialog(new JFrame(),
                    "An error occured parsing application context.  You may " + "have no "
                            + "internet access.\n", "Bagger startup error!",
                    JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(new JFrame(), "An error occured during startup.\n",
                    "Bagger startup " + "error!", JOptionPane.ERROR_MESSAGE);
        }
        System.exit(1);
    }
}
 
开发者ID:pan-dora,项目名称:modeller,代码行数:41,代码来源:ModellerApplication.java

示例7: extract

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
@Override
public Object[] extract(BaseData item) {
	Object[] values = new Object[names.length];
	Term extensionTerm = termFactory.findTerm(extension);
	Map<Term,String> propertyMap = DarwinCorePropertyMap.getPropertyMap(extensionTerm);
	BeanWrapper beanWrapper = new BeanWrapperImpl(item);
	for(int i = 0; i < names.length; i++) {
		String property = names[i];
		Term propertyTerm = termFactory.findTerm(property);
		String propertyName = propertyMap.get(propertyTerm);
		try {
			String value = conversionService.convert(beanWrapper.getPropertyValue(propertyName), String.class);
			if(quoteCharacter == null) {
				values[i] = value;
			} else if(value != null) {
				values[i] = new StringBuilder().append(quoteCharacter).append(value).append(quoteCharacter).toString();
			} else {
				values[i] = new StringBuilder().append(quoteCharacter).append(quoteCharacter).toString();
			}
		} catch(PropertyAccessException pae) {
			if(quoteCharacter != null) {
				values[i] = new StringBuilder().append(quoteCharacter).append(quoteCharacter).toString();
			}
		} catch(NullValueInNestedPathException nvinpe) {
			if(quoteCharacter != null) {
				values[i] = new StringBuilder().append(quoteCharacter).append(quoteCharacter).toString();
			}
		}

	}
	return values;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:33,代码来源:DwcFieldExtractor.java

示例8: serializeEnum

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
public static <T extends Enum<T>> String serializeEnum(ObjectMapper objMapper, Class<T> enumClass) throws BeansException, InvalidPropertyException,
    JsonProcessingException, PropertyAccessException {
    T[] enumItems = enumClass.getEnumConstants();
    Map<String, Map<String, Object>> enumMap = new LinkedHashMap<>(enumItems.length);
    Map<String, Object> enumItemMap;
    Map<String, String> enumItemValueMap;
    String enumItemKey;
    BeanWrapper enumItemWrapper;
    PropertyDescriptor[] enumItemPropDescs;
    Method enumItemPropGetter;
    String enumItemPropName;

    for (T enumItem : enumItems) {
        enumMap.put((enumItemKey = enumItem.name()), (enumItemMap = new LinkedHashMap<>(2)));

        enumItemMap.put(KEY_PROP_NAME, enumItemKey);

        enumItemMap.put(VALUE_PROP_NAME,
            (enumItemValueMap =
                new LinkedHashMap<>((enumItemPropDescs = (enumItemWrapper = new BeanWrapperImpl(enumItem)).getPropertyDescriptors()).length)));

        for (PropertyDescriptor enumItemPropDesc : enumItemPropDescs) {
            if (((enumItemPropGetter = enumItemPropDesc.getReadMethod()) == null) || !enumItemPropGetter.isAnnotationPresent(JsonProperty.class)) {
                continue;
            }

            enumItemValueMap.put((enumItemPropName = enumItemPropDesc.getName()), enumItemWrapper.getPropertyValue(enumItemPropName).toString());
        }
    }

    return objMapper.writeValueAsString(enumMap);
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:33,代码来源:CrigttJsonUtils.java

示例9: processPropertyAccessException

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) {
	// Create field error with the exceptions's code, e.g. "typeMismatch".
	String field = ex.getPropertyName();
	String[] codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field);
	Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), field);
	Object rejectedValue = ex.getValue();
	if (rejectedValue != null && rejectedValue.getClass().isArray()) {
		rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue));
	}
	bindingResult.addError(new FieldError(
			bindingResult.getObjectName(), field, rejectedValue, true,
			codes, arguments, ex.getLocalizedMessage()));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:DefaultBindingErrorProcessor.java

示例10: processPropertyAccessException

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void processPropertyAccessException(PropertyAccessException e, BindingResult bindingResult) {

    TypeOrFormatMismatchException converted = null;
    if (Controllers.exceptionMatch(e.getCause().getClass(), PropertyEditingException.class)) {
        converted = new TypeOrFormatMismatchException(e, bindingResult);
        super.processPropertyAccessException(converted, bindingResult);
    } else {
        super.processPropertyAccessException(e, bindingResult);
    }
}
 
开发者ID:ctc-g,项目名称:sinavi-jfw,代码行数:15,代码来源:JseBindingErrorProcessor.java

示例11: processPropertyAccessException

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) {
	// Create field error with the exceptions's code, e.g. "typeMismatch".
	super.processPropertyAccessException(ex, bindingResult);
	Object rejectedValue = ex.getValue();
	if (!(rejectedValue == null || rejectedValue.equals(""))) {
		if (ex.getCause() instanceof FormatException) {
			GlobalVariables.getMessageMap().putError(ex.getPropertyName(), ((FormatException)ex.getCause()).getErrorKey(),
					new String[] {rejectedValue.toString()});
		}else{
			GlobalVariables.getMessageMap().putError(ex.getPropertyName(), RiceKeyConstants.ERROR_CUSTOM,
					new String[] {"Invalid format"});
		}
	}
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:15,代码来源:UifBindingErrorProcessor.java

示例12: execute

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
public void execute(ControlAccessor controlAccessor, String name) {
	try {
		modelPropertyAccessor.setPropertyValue(name, controlAccessor.getControlValue());
	}
	catch (PropertyAccessException pae) { 
		errorProcessor.processPropertyAccessException(pae, bindingResult);
	}
}
 
开发者ID:chelu,项目名称:jdal,代码行数:9,代码来源:AutoBinder.java

示例13: setValue

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
/**
 * Set value on binded object using the property name.
 * @param value the value to set
 */
protected void setValue(Object value) {
	BeanWrapper wrapper = getBeanWrapper();
	Object convertedValue = convertIfNecessary(value, wrapper.getPropertyType(this.propertyName));
	try {
		wrapper.setPropertyValue(propertyName, convertedValue);
		oldValue = value;
	}
	catch (PropertyAccessException pae) {
		log.error(pae);
		errorProcessor.processPropertyAccessException(component, pae, bindingResult);
	}
}
 
开发者ID:chelu,项目名称:jdal,代码行数:17,代码来源:AbstractBinder.java

示例14: processPropertyAccessException

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
/** 
 * Add a ControlError instead FieldError to hold component that has failed.
 * @param control
 * @param ex
 * @param bindingResult
 */
public void processPropertyAccessException(Object control, PropertyAccessException ex, 
		BindingResult bindingResult ) {
	// Create field error with the exceptions's code, e.g. "typeMismatch".
	String field = ex.getPropertyName();
	String[] codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field);
	Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), field);
	Object rejectedValue = ex.getValue();
	if (rejectedValue != null && rejectedValue.getClass().isArray()) {
		rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue));
	}
	bindingResult.addError(new ControlError(control,
			bindingResult.getObjectName(), field, rejectedValue, true,
			codes, arguments, ex.getLocalizedMessage()));
}
 
开发者ID:chelu,项目名称:jdal,代码行数:21,代码来源:ControlBindingErrorProcessor.java

示例15: setProperty

import org.springframework.beans.PropertyAccessException; //导入依赖的package包/类
/**
 * Set property, without trowing exceptions on errors
 * @param bean bean name
 * @param name name
 * @param value value
 */
public static void setProperty(Object bean, String name, Object value) {
	try  {
		BeanWrapper wrapper = new BeanWrapperImpl(bean);
		wrapper.setPropertyValue(new PropertyValue(name, value));
	} catch (InvalidPropertyException ipe) {
		log.debug("Bean has no property: " + name);
	} catch (PropertyAccessException pae) {
		log.debug("Access Error on property: " + name);
	}
}
 
开发者ID:chelu,项目名称:jdal,代码行数:17,代码来源:BeanUtils.java


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