Example usage for org.springframework.beans NotWritablePropertyException NotWritablePropertyException

List of usage examples for org.springframework.beans NotWritablePropertyException NotWritablePropertyException

Introduction

In this page you can find the example usage for org.springframework.beans NotWritablePropertyException NotWritablePropertyException.

Prototype

public NotWritablePropertyException(Class<?> beanClass, String propertyName, String msg) 

Source Link

Document

Create a new NotWritablePropertyException.

Usage

From source file:org.jdal.ui.bind.DirectFieldAccessor.java

@Override
public void setPropertyValue(String propertyName, Object newValue) throws BeansException {
    Field field = this.fieldMap.get(propertyName);
    if (field == null) {
        throw new NotWritablePropertyException(this.target.getClass(), propertyName,
                "Field '" + propertyName + "' does not exist");
    }//w ww.  j  a v  a  2 s. c o  m
    Object oldValue = null;
    try {
        ReflectionUtils.makeAccessible(field);
        oldValue = field.get(this.target);
        // jlm - Adapt to simpleTypeConverter
        Object convertedValue = this.typeConverterDelegate.convertIfNecessary(newValue, field.getType());
        field.set(this.target, convertedValue);
    } catch (ConverterNotFoundException ex) {
        PropertyChangeEvent pce = new PropertyChangeEvent(this.target, propertyName, oldValue, newValue);
        throw new ConversionNotSupportedException(pce, field.getType(), ex);
    } catch (ConversionException ex) {
        PropertyChangeEvent pce = new PropertyChangeEvent(this.target, propertyName, oldValue, newValue);
        throw new TypeMismatchException(pce, field.getType(), ex);
    } catch (IllegalStateException ex) {
        PropertyChangeEvent pce = new PropertyChangeEvent(this.target, propertyName, oldValue, newValue);
        throw new ConversionNotSupportedException(pce, field.getType(), ex);
    } catch (IllegalArgumentException ex) {
        PropertyChangeEvent pce = new PropertyChangeEvent(this.target, propertyName, oldValue, newValue);
        throw new TypeMismatchException(pce, field.getType(), ex);
    } catch (IllegalAccessException ex) {
        throw new InvalidPropertyException(this.target.getClass(), propertyName, "Field is not accessible", ex);
    }
}

From source file:de.escidoc.core.common.business.fedora.FedoraUtility.java

/**
 * @param fedoraUrl/*  w w  w .  j a v a 2 s  .c  o  m*/
 *            the fedoraUrl to inject
 */
public void setFedoraUrl(final String fedoraUrl) {

    if (this.fedoraUrl != null) {
        throw new NotWritablePropertyException(this.getClass(), "fedoraUrl", "Property must not be set twice.");
    }
    this.fedoraUrl = fedoraUrl;
}

From source file:de.escidoc.core.common.business.fedora.FedoraUtility.java

/**
 * @param fedoraUser/* w w w  .  java2 s.  co  m*/
 *            the fedoraUser to inject
 */
public void setFedoraUser(final String fedoraUser) {

    if (this.fedoraUser != null) {
        throw new NotWritablePropertyException(this.getClass(), "fedoraUser",
                "Property must not be set twice.");
    }
    this.fedoraUser = fedoraUser;
}

From source file:de.escidoc.core.common.business.fedora.FedoraUtility.java

/**
 * @param fedoraPassword/* w  w w.  ja  va2 s.  c  o  m*/
 *            the fedoraPassword to inject
 */
public void setFedoraPassword(final String fedoraPassword) {

    if (this.fedoraPassword != null) {
        throw new NotWritablePropertyException(this.getClass(), "fedoraPassword",
                "Property must not be set twice.");
    }
    this.fedoraPassword = fedoraPassword;
}