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


Java NotReadablePropertyException类代码示例

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


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

示例1: processConstraintViolations

import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
@Override
protected void processConstraintViolations(Set<ConstraintViolation<Object>> violations, Errors errors) {
    for (ConstraintViolation<Object> violation : violations) {
        String field = violation.getPropertyPath().toString();
        FieldError fieldError = errors.getFieldError(field);
        if (fieldError == null || !fieldError.isBindingFailure()) {
            try {
                String errorCode = violation.getConstraintDescriptor().getAnnotation().annotationType().getSimpleName();
                Object[] errorArgs = getArgumentsForConstraint(errors.getObjectName(), field, violation.getConstraintDescriptor());
                // NOTE: Super implementation of getInvalidValue() failed on a nested component. 
                // E.g. LocalizedString.fi returned LocalizedString instead of String as invalidValue
                errors.rejectValue(field, errorCode, errorArgs, violation.getMessage());
            }
            catch (NotReadablePropertyException ex) {
                throw new IllegalStateException("JSR-303 validated property '" + field +
                        "' does not have a corresponding accessor for Spring data binding - " +
                        "check your DataBinder's configuration (bean property versus direct field access)", ex);
            }
        }
    }
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:22,代码来源:LocalValidatorFactoryBeanFix.java

示例2: testGetValueModelFromPAS

import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
public void testGetValueModelFromPAS() {
	TestBean p = new TestBean();
	TestPropertyAccessStrategy tpas = new TestPropertyAccessStrategy(p);
	AbstractFormModel fm = getFormModel(tpas, true);
	ValueModel vm1 = fm.getValueModel("simpleProperty");
	assertEquals(1, tpas.numValueModelRequests());
	assertEquals("simpleProperty", tpas.lastRequestedValueModel());
	ValueModel vm2 = fm.getValueModel("simpleProperty");
	assertEquals(vm1, vm2);
	assertEquals(1, tpas.numValueModelRequests());

	try {
		fm.getValueModel("iDontExist");
		fail("should't be able to get value model for invalid property");
	}
	catch (NotReadablePropertyException e) {
		// exprected
	}
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:20,代码来源:AbstractFormModelTests.java

示例3: createNotReadablePropertyException

import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
protected NotReadablePropertyException createNotReadablePropertyException(String propertyName, Exception e) {
	if (JdkVersion.isAtLeastJava14()) {
		NotReadablePropertyException beanException = new NotReadablePropertyException(getTargetClass(),
				propertyName);
		beanException.initCause(e);
		return beanException;
	}
	else {
		ByteArrayOutputStream stackTrace = new ByteArrayOutputStream();
		PrintWriter stackTraceWriter = new PrintWriter(stackTrace);
		e.printStackTrace(stackTraceWriter);
		stackTraceWriter.close();
		return new NotReadablePropertyException(getTargetClass(), propertyName,
				new String(stackTrace.toByteArray()));
	}
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:17,代码来源:AbstractMemberPropertyAccessor.java

示例4: getValue

import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
@Override
public Object getValue(String paramName) throws IllegalArgumentException {
	try {
		return this.beanWrapper.getPropertyValue(paramName);
	}
	catch (NotReadablePropertyException ex) {
		throw new IllegalArgumentException(ex.getMessage());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:BeanPropertySqlParameterSource.java

示例5: isSecure

import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
/**
 * Checks whether the given property is secure.
 *
 * @param wrappedClass class the property is associated with
 * @param propertyPath path to the property
 * @return boolean true if the property is secure, false if not
 */
protected boolean isSecure(Class<?> wrappedClass, String propertyPath) {
    if (KRADUtils.isSecure(propertyPath, wrappedClass)) {
        return true;
    }

    // since this is part of a set, we want to make sure nested paths grow
    setAutoGrowNestedPaths(true);

    BeanWrapperImpl beanWrapper;
    try {
        beanWrapper = getBeanWrapperForPropertyPath(propertyPath);
    } catch (NotReadablePropertyException | NullValueInNestedPathException e) {
        LOG.debug("Bean wrapper was not found for " + propertyPath
                + ", but since it cannot be accessed it will not be set as secure.", e);
        return false;
    }

    if (org.apache.commons.lang.StringUtils.isNotBlank(beanWrapper.getNestedPath())) {
        PropertyTokenHolder tokens = getPropertyNameTokens(propertyPath);
        String nestedPropertyPath = org.apache.commons.lang.StringUtils.removeStart(tokens.canonicalName,
                beanWrapper.getNestedPath());

        return isSecure(beanWrapper.getWrappedClass(), nestedPropertyPath);
    }

    return false;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:35,代码来源:UifViewBeanWrapper.java

示例6: getValue

import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
public Object getValue(String paramName) throws IllegalArgumentException {
	try {
		return this.beanWrapper.getPropertyValue(paramName);
	}
	catch (NotReadablePropertyException ex) {
		throw new IllegalArgumentException(ex.getMessage());
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:BeanPropertySqlParameterSource.java

示例7: testWriteOnlyProperty

import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
public void testWriteOnlyProperty() {
    vm = pas.getPropertyValueModel("writeOnly");

    vm.setValue("2");
    assertEquals("2" , testBean.writeOnly);

    try {
        vm.getValue();
        fail("should have thrown NotReadablePropertyException");
    } catch(NotReadablePropertyException e) {
        // expected
    }
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:14,代码来源:AbstractPropertyAccessStrategyTests.java

示例8: getIndexedPropertyValue

import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
public Object getIndexedPropertyValue(String propertyName) throws BeansException {
	if (getPropertyType(propertyName) == null) {
		throw new NotReadablePropertyException(getTargetClass(), propertyName,
				"property type could not be determined");
	}
	String rootPropertyName = getRootPropertyName(propertyName);
	Member readAccessor = getReadPropertyAccessor(rootPropertyName);
	if (readAccessor == null) {
		throw new NotReadablePropertyException(getTargetClass(), propertyName,
				"Neither non-static field nor get-method exists for indexed property");
	}
	Object rootProperty = getPropertyValue(rootPropertyName);
	if (rootProperty == null) {
		if (isStrictNullHandlingEnabled()) {
			throw new NullValueInNestedPathException(getTargetClass(), propertyName);
		}
		else if (isWritableProperty(rootPropertyName)) {
			return null;
		}
		else {
			throw new NotReadablePropertyException(getTargetClass(), propertyName);
		}
	}
	Object[] indices;
	try {
		indices = getIndices(propertyName);
	}
	catch (Exception e) {
		// could not convert indices
		throw createNotReadablePropertyException(propertyName, e);
	}
	return getPropertyValue(rootProperty, indices);
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:34,代码来源:DefaultMemberPropertyAccessor.java

示例9: getPropertyValue

import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
@Override
public Object getPropertyValue(String propertyName) throws BeansException {
	Field field = this.fieldMap.get(propertyName);
	if (field == null) {
		throw new NotReadablePropertyException(
				this.target.getClass(), propertyName, "Field '" + propertyName + "' does not exist");
	}
	try {
		ReflectionUtils.makeAccessible(field);
		return field.get(this.target);
	}
	catch (IllegalAccessException ex) {
		throw new InvalidPropertyException(this.target.getClass(), propertyName, "Field is not accessible", ex);
	}
}
 
开发者ID:chelu,项目名称:jdal,代码行数:16,代码来源:DirectFieldAccessor.java


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