Example usage for java.lang NoSuchMethodException NoSuchMethodException

List of usage examples for java.lang NoSuchMethodException NoSuchMethodException

Introduction

In this page you can find the example usage for java.lang NoSuchMethodException NoSuchMethodException.

Prototype

public NoSuchMethodException(String s) 

Source Link

Document

Constructs a NoSuchMethodException with a detail message.

Usage

From source file:eu.qualityontime.commons.QPropertyUtilsBean.java

public void _setIndexedProperty(final Object bean, final String name, final int index, final Object value)
        throws Exception {

    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }/*  w  w w . j ava  2 s.  c o  m*/
    if (name == null || name.length() == 0) {
        if (bean.getClass().isArray()) {
            Array.set(bean, index, value);
            return;
        } else if (bean instanceof List) {
            final List<Object> list = toObjectList(bean);
            list.set(index, value);
            return;
        }
    }
    if (name == null) {
        throw new IllegalArgumentException("No name specified for bean class '" + bean.getClass() + "'");
    }

    if (name.startsWith("@")) {
        Object f = FieldUtils.readField(bean, name.substring(1));
        if (null == f)
            throw new NestedNullException();
        if (f.getClass().isArray()) {
            Array.set(f, index, value);
            return;
        } else if (f instanceof List) {
            final List<Object> list = toObjectList(f);
            list.set(index, value);
            return;
        }
        return;
    }
    // Retrieve the property descriptor for the specified property
    final PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
    if (descriptor == null) {
        throw new NoSuchMethodException(
                "Unknown property '" + name + "' on bean class '" + bean.getClass() + "'");
    }

    // Call the indexed setter method if there is one
    if (descriptor instanceof IndexedPropertyDescriptor) {
        Method writeMethod = ((IndexedPropertyDescriptor) descriptor).getIndexedWriteMethod();
        writeMethod = MethodUtils.getAccessibleMethod(bean.getClass(), writeMethod);
        if (writeMethod != null) {
            final Object[] subscript = new Object[2];
            subscript[0] = new Integer(index);
            subscript[1] = value;
            try {
                if (log.isTraceEnabled()) {
                    final String valueClassName = value == null ? "<null>" : value.getClass().getName();
                    log.trace("setSimpleProperty: Invoking method " + writeMethod + " with index=" + index
                            + ", value=" + value + " (class " + valueClassName + ")");
                }
                invokeMethod(writeMethod, bean, subscript);
            } catch (final InvocationTargetException e) {
                if (e.getTargetException() instanceof IndexOutOfBoundsException) {
                    throw (IndexOutOfBoundsException) e.getTargetException();
                } else {
                    throw e;
                }
            }
            return;
        }
    }

    // Otherwise, the underlying property must be an array or a list
    final Method readMethod = getReadMethod(bean.getClass(), descriptor);
    if (readMethod == null) {
        throw new NoSuchMethodException(
                "Property '" + name + "' has no getter method on bean class '" + bean.getClass() + "'");
    }

    // Call the property getter to get the array or list
    final Object array = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
    if (!array.getClass().isArray()) {
        if (array instanceof List) {
            // Modify the specified value in the List
            final List<Object> list = toObjectList(array);
            list.set(index, value);
        } else {
            throw new IllegalArgumentException(
                    "Property '" + name + "' is not indexed on bean class '" + bean.getClass() + "'");
        }
    } else {
        // Modify the specified value in the array
        Array.set(array, index, value);
    }

}

From source file:alice.tuprolog.lib.OOLibrary.java

private static Method mostSpecificMethod(Vector<Method> methods) throws NoSuchMethodException {
    for (int i = 0; i != methods.size(); i++) {
        for (int j = 0; j != methods.size(); j++) {
            if ((i != j) && (moreSpecific(methods.elementAt(i), methods.elementAt(j)))) {
                methods.removeElementAt(j);
                if (i > j)
                    i--;//from w ww .jav a  2  s .  co  m
                j--;
            }
        }
    }
    if (methods.size() == 1)
        return methods.elementAt(0);
    else
        throw new NoSuchMethodException(">1 most specific method");
}

From source file:alice.tuprolog.lib.OOLibrary.java

private static Constructor<?> mostSpecificConstructor(Vector<Constructor<?>> constructors)
        throws NoSuchMethodException {
    for (int i = 0; i != constructors.size(); i++) {
        for (int j = 0; j != constructors.size(); j++) {
            if ((i != j) && (moreSpecific(constructors.elementAt(i), constructors.elementAt(j)))) {
                constructors.removeElementAt(j);
                if (i > j)
                    i--;/*from www .java2 s  . co  m*/
                j--;
            }
        }
    }
    if (constructors.size() == 1)
        return constructors.elementAt(0);
    else
        throw new NoSuchMethodException(">1 most specific constructor");
}

From source file:javadz.beanutils.PropertyUtilsBean.java

/**
 * Set the value of the specified mapped property of the specified
 * bean, with no type conversions.// w  ww .ja v a 2  s .c  o  m
 *
 * @param bean Bean whose property is to be set
 * @param name Mapped property name of the property value to be set
 * @param key Key of the property value to be set
 * @param value The property value to be set
 *
 * @exception IllegalAccessException if the caller does not have
 *  access to the property accessor method
 * @exception InvocationTargetException if the property accessor method
 *  throws an exception
 * @exception NoSuchMethodException if an accessor method for this
 *  propety cannot be found
 */
public void setMappedProperty(Object bean, String name, String key, Object value)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }
    if (name == null) {
        throw new IllegalArgumentException("No name specified for bean class '" + bean.getClass() + "'");
    }
    if (key == null) {
        throw new IllegalArgumentException(
                "No key specified for property '" + name + "' on bean class '" + bean.getClass() + "'");
    }

    // Handle DynaBean instances specially
    if (bean instanceof DynaBean) {
        DynaProperty descriptor = ((DynaBean) bean).getDynaClass().getDynaProperty(name);
        if (descriptor == null) {
            throw new NoSuchMethodException(
                    "Unknown property '" + name + "' on bean class '" + bean.getClass() + "'");
        }
        ((DynaBean) bean).set(name, key, value);
        return;
    }

    // Retrieve the property descriptor for the specified property
    PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
    if (descriptor == null) {
        throw new NoSuchMethodException(
                "Unknown property '" + name + "' on bean class '" + bean.getClass() + "'");
    }

    if (descriptor instanceof MappedPropertyDescriptor) {
        // Call the keyed setter method if there is one
        Method mappedWriteMethod = ((MappedPropertyDescriptor) descriptor).getMappedWriteMethod();
        mappedWriteMethod = MethodUtils.getAccessibleMethod(bean.getClass(), mappedWriteMethod);
        if (mappedWriteMethod != null) {
            Object[] params = new Object[2];
            params[0] = key;
            params[1] = value;
            if (log.isTraceEnabled()) {
                String valueClassName = value == null ? "<null>" : value.getClass().getName();
                log.trace("setSimpleProperty: Invoking method " + mappedWriteMethod + " with key=" + key
                        + ", value=" + value + " (class " + valueClassName + ")");
            }
            invokeMethod(mappedWriteMethod, bean, params);
        } else {
            throw new NoSuchMethodException("Property '" + name + "' has no mapped setter method"
                    + "on bean class '" + bean.getClass() + "'");
        }
    } else {
        /* means that the result has to be retrieved from a map */
        Method readMethod = getReadMethod(bean.getClass(), descriptor);
        if (readMethod != null) {
            Object invokeResult = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
            /* test and fetch from the map */
            if (invokeResult instanceof java.util.Map) {
                ((java.util.Map) invokeResult).put(key, value);
            }
        } else {
            throw new NoSuchMethodException("Property '" + name
                    + "' has no mapped getter method on bean class '" + bean.getClass() + "'");
        }
    }

}

From source file:org.evergreen.web.utils.beanutils.PropertyUtilsBean.java

/**
 * Set the value of the specified mapped property of the specified
 * bean, with no type conversions./*from w  w  w . j  a v  a 2 s. c o m*/
 *
 * @param bean Bean whose property is to be set
 * @param name Mapped property name of the property value to be set
 * @param key Key of the property value to be set
 * @param value The property value to be set
 *
 * @exception IllegalAccessException if the caller does not have
 *  access to the property accessor method
 * @exception InvocationTargetException if the property accessor method
 *  throws an exception
 * @exception NoSuchMethodException if an accessor method for this
 *  propety cannot be found
 */
public void setMappedProperty(Object bean, String name, String key, Object value)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }
    if (name == null) {
        throw new IllegalArgumentException("No name specified for bean class '" + bean.getClass() + "'");
    }
    if (key == null) {
        throw new IllegalArgumentException(
                "No key specified for property '" + name + "' on bean class '" + bean.getClass() + "'");
    }

    // Handle DynaBean instances specially
    if (bean instanceof DynaBean) {
        DynaProperty descriptor = ((DynaBean) bean).getDynaClass().getDynaProperty(name);
        if (descriptor == null) {
            throw new NoSuchMethodException(
                    "Unknown property '" + name + "' on bean class '" + bean.getClass() + "'");
        }
        ((DynaBean) bean).set(name, key, value);
        return;
    }

    // Retrieve the property descriptor for the specified property
    PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
    if (descriptor == null) {
        throw new NoSuchMethodException(
                "Unknown property '" + name + "' on bean class '" + bean.getClass() + "'");
    }

    if (descriptor instanceof MappedPropertyDescriptor) {
        // Call the keyed setter method if there is one
        Method mappedWriteMethod = ((MappedPropertyDescriptor) descriptor).getMappedWriteMethod();
        mappedWriteMethod = MethodUtils.getAccessibleMethod(bean.getClass(), mappedWriteMethod);
        if (mappedWriteMethod != null) {
            Object[] params = new Object[2];
            params[0] = key;
            params[1] = value;
            if (log.isTraceEnabled()) {
                String valueClassName = value == null ? "<null>" : value.getClass().getName();
                log.trace("setSimpleProperty: Invoking method " + mappedWriteMethod + " with key=" + key
                        + ", value=" + value + " (class " + valueClassName + ")");
            }
            invokeMethod(mappedWriteMethod, bean, params);
        } else {
            throw new NoSuchMethodException("Property '" + name + "' has no mapped setter method"
                    + "on bean class '" + bean.getClass() + "'");
        }
    } else {
        /* means that the result has to be retrieved from a map */
        Method readMethod = getReadMethod(bean.getClass(), descriptor);
        if (readMethod != null) {
            Object invokeResult = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
            /* test and fetch from the map */
            if (invokeResult instanceof java.util.Map) {
                //((java.util.Map)invokeResult).put(key, value);
                //?
                Map<Object, Object> map = (Map<Object, Object>) invokeResult;
                Type returnType = readMethod.getGenericReturnType();
                Type keyType = ((ParameterizedType) returnType).getActualTypeArguments()[0];
                Type valType = ((ParameterizedType) returnType).getActualTypeArguments()[1];
                Object mapKey = ConvertUtils.convert(key, (Class<?>) keyType);
                Object mapValue = ConvertUtils.convert(value, (Class<?>) valType);
                map.put(mapKey, mapValue);
            }
        } else {
            throw new NoSuchMethodException("Property '" + name
                    + "' has no mapped getter method on bean class '" + bean.getClass() + "'");
        }
    }

}

From source file:eu.qualityontime.commons.QPropertyUtilsBean.java

public void _setMappedProperty(final Object bean, final String name, final String key, final Object value)
        throws Exception {

    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }//w ww .j av  a 2  s  . com
    if (name == null) {
        throw new IllegalArgumentException("No name specified for bean class '" + bean.getClass() + "'");
    }
    if (key == null) {
        throw new IllegalArgumentException(
                "No key specified for property '" + name + "' on bean class '" + bean.getClass() + "'");
    }

    if (name.startsWith("@")) {
        Object f = FieldUtils.readField(bean, name.substring(1));
        if (null == f)
            throw new NestedNullException();
        if (f instanceof Map) {
            final java.util.Map<String, Object> map = toPropertyMap(f);
            map.put(key, value);
            return;
        }
        throw new NoSuchFieldException(
                "Field '" + name + "' is not mapped " + "on bean class '" + bean.getClass() + "'");
    }
    // Retrieve the property descriptor for the specified property
    final PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
    if (descriptor == null) {
        throw new NoSuchMethodException(
                "Unknown property '" + name + "' on bean class '" + bean.getClass() + "'");
    }

    if (descriptor instanceof MappedPropertyDescriptor) {
        // Call the keyed setter method if there is one
        Method mappedWriteMethod = ((MappedPropertyDescriptor) descriptor).getMappedWriteMethod();
        mappedWriteMethod = MethodUtils.getAccessibleMethod(bean.getClass(), mappedWriteMethod);
        if (mappedWriteMethod != null) {
            final Object[] params = new Object[2];
            params[0] = key;
            params[1] = value;
            if (log.isTraceEnabled()) {
                final String valueClassName = value == null ? "<null>" : value.getClass().getName();
                log.trace("setSimpleProperty: Invoking method " + mappedWriteMethod + " with key=" + key
                        + ", value=" + value + " (class " + valueClassName + ")");
            }
            invokeMethod(mappedWriteMethod, bean, params);
        } else {
            throw new NoSuchMethodException("Property '" + name + "' has no mapped setter method"
                    + "on bean class '" + bean.getClass() + "'");
        }
    } else {
        /* means that the result has to be retrieved from a map */
        final Method readMethod = getReadMethod(bean.getClass(), descriptor);
        if (readMethod != null) {
            final Object invokeResult = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
            /* test and fetch from the map */
            if (invokeResult instanceof java.util.Map) {
                final java.util.Map<String, Object> map = toPropertyMap(invokeResult);
                map.put(key, value);
            }
        } else {
            throw new NoSuchMethodException("Property '" + name
                    + "' has no mapped getter method on bean class '" + bean.getClass() + "'");
        }
    }

}

From source file:com.cyberway.issue.crawler.admin.CrawlJob.java

public Object invoke(String operationName, Object[] params, String[] signature) throws ReflectionException {
    if (operationName == null) {
        throw new RuntimeOperationsException(new IllegalArgumentException("Operation name cannot be null"),
                "Cannot call invoke with null operation name");
    }/*  www . j  a  va  2s .c  o  m*/

    controller.installThreadContextSettingsHandler();

    if (this.bdbjeOperationsNameList.contains(operationName)) {
        try {
            Object o = this.bdbjeMBeanHelper.invoke(this.controller.getBdbEnvironment(), operationName, params,
                    signature);
            // If OP_DB_ST, return String version of result.
            if (operationName.equals(OP_DB_STAT)) {
                return o.toString();
            }
            return o;
        } catch (MBeanException e) {
            throw new RuntimeOperationsException(new RuntimeException(e));
        }
    }

    // TODO: Exploit passed signature.

    // The pattern in the below is to match an operation and when found
    // do a return out of if clause.  Doing it this way, I can fall
    // on to the MethodNotFoundException for case where we've an
    // attribute but no handler.
    if (operationName.equals(IMPORT_URI_OPER)) {
        JmxUtils.checkParamsCount(IMPORT_URI_OPER, params, 3);
        mustBeCrawling();
        try {
            importUri((String) params[0], ((Boolean) params[1]).booleanValue(),
                    ((Boolean) params[2]).booleanValue());
        } catch (URIException e) {
            throw new RuntimeOperationsException(new RuntimeException(e));
        }
        return null;
    }

    if (operationName.equals(IMPORT_URIS_OPER)) {
        JmxUtils.checkParamsCount(IMPORT_URIS_OPER, params, 4);
        mustBeCrawling();
        return importUris((String) params[0], ((String) params[1]).toString(),
                ((Boolean) params[2]).booleanValue(), ((Boolean) params[3]).booleanValue());
    }

    if (operationName.equals(DUMP_URIS_OPER)) {
        JmxUtils.checkParamsCount(DUMP_URIS_OPER, params, 4);
        mustBeCrawling();
        if (!this.controller.isPaused()) {
            throw new RuntimeOperationsException(new IllegalArgumentException("Must " + "be paused"),
                    "Cannot dump URI's from running job.");
        }
        dumpUris((String) params[0], (String) params[1], ((Integer) params[2]).intValue(),
                ((Boolean) params[3]).booleanValue());
    }

    if (operationName.equals(PAUSE_OPER)) {
        JmxUtils.checkParamsCount(PAUSE_OPER, params, 0);
        mustBeCrawling();
        pause();
        return null;
    }

    if (operationName.equals(RESUME_OPER)) {
        JmxUtils.checkParamsCount(RESUME_OPER, params, 0);
        mustBeCrawling();
        resume();
        return null;
    }

    if (operationName.equals(FRONTIER_REPORT_OPER)) {
        JmxUtils.checkParamsCount(FRONTIER_REPORT_OPER, params, 1);
        mustBeCrawling();
        return getFrontierReport((String) params[0]);
    }

    if (operationName.equals(THREADS_REPORT_OPER)) {
        JmxUtils.checkParamsCount(THREADS_REPORT_OPER, params, 0);
        mustBeCrawling();
        return getThreadsReport();
    }

    if (operationName.equals(SEEDS_REPORT_OPER)) {
        JmxUtils.checkParamsCount(SEEDS_REPORT_OPER, params, 0);
        mustBeCrawling();
        StringWriter sw = new StringWriter();
        if (getStatisticsTracking() != null && getStatisticsTracking() instanceof StatisticsTracker) {
            ((StatisticsTracker) getStatisticsTracking()).writeSeedsReportTo(new PrintWriter(sw));
        } else {
            sw.write("Unsupported");
        }
        return sw.toString();
    }

    if (operationName.equals(CHECKPOINT_OPER)) {
        JmxUtils.checkParamsCount(CHECKPOINT_OPER, params, 0);
        mustBeCrawling();
        try {
            checkpoint();
        } catch (IllegalStateException e) {
            throw new RuntimeOperationsException(e);
        }
        return null;
    }

    if (operationName.equals(PROGRESS_STATISTICS_OPER)) {
        JmxUtils.checkParamsCount(PROGRESS_STATISTICS_OPER, params, 0);
        mustBeCrawling();
        return getStatisticsTracking().getProgressStatisticsLine();
    }

    if (operationName.equals(PROGRESS_STATISTICS_LEGEND_OPER)) {
        JmxUtils.checkParamsCount(PROGRESS_STATISTICS_LEGEND_OPER, params, 0);
        return getStatisticsTracking().progressStatisticsLegend();
    }

    throw new ReflectionException(new NoSuchMethodException(operationName),
            "Cannot find the operation " + operationName);
}

From source file:javadz.beanutils.PropertyUtilsBean.java

/**
 * Set the value of the specified simple property of the specified bean,
 * with no type conversions.// w w w . j a v a  2s.co m
 *
 * @param bean Bean whose property is to be modified
 * @param name Name of the property to be modified
 * @param value Value to which the property should be set
 *
 * @exception IllegalAccessException if the caller does not have
 *  access to the property accessor method
 * @exception IllegalArgumentException if <code>bean</code> or
 *  <code>name</code> is null
 * @exception IllegalArgumentException if the property name is
 *  nested or indexed
 * @exception InvocationTargetException if the property accessor method
 *  throws an exception
 * @exception NoSuchMethodException if an accessor method for this
 *  propety cannot be found
 */
public void setSimpleProperty(Object bean, String name, Object value)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }
    if (name == null) {
        throw new IllegalArgumentException("No name specified for bean class '" + bean.getClass() + "'");
    }

    // Validate the syntax of the property name
    if (resolver.hasNested(name)) {
        throw new IllegalArgumentException("Nested property names are not allowed: Property '" + name
                + "' on bean class '" + bean.getClass() + "'");
    } else if (resolver.isIndexed(name)) {
        throw new IllegalArgumentException("Indexed property names are not allowed: Property '" + name
                + "' on bean class '" + bean.getClass() + "'");
    } else if (resolver.isMapped(name)) {
        throw new IllegalArgumentException("Mapped property names are not allowed: Property '" + name
                + "' on bean class '" + bean.getClass() + "'");
    }

    // Handle DynaBean instances specially
    if (bean instanceof DynaBean) {
        DynaProperty descriptor = ((DynaBean) bean).getDynaClass().getDynaProperty(name);
        if (descriptor == null) {
            throw new NoSuchMethodException(
                    "Unknown property '" + name + "' on dynaclass '" + ((DynaBean) bean).getDynaClass() + "'");
        }
        ((DynaBean) bean).set(name, value);
        return;
    }

    // Retrieve the property setter method for the specified property
    PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
    if (descriptor == null) {
        throw new NoSuchMethodException("Unknown property '" + name + "' on class '" + bean.getClass() + "'");
    }
    Method writeMethod = getWriteMethod(bean.getClass(), descriptor);
    if (writeMethod == null) {
        throw new NoSuchMethodException(
                "Property '" + name + "' has no setter method in class '" + bean.getClass() + "'");
    }

    // Call the property setter method
    Object[] values = new Object[1];
    values[0] = value;
    if (log.isTraceEnabled()) {
        String valueClassName = value == null ? "<null>" : value.getClass().getName();
        log.trace("setSimpleProperty: Invoking method " + writeMethod + " with value " + value + " (class "
                + valueClassName + ")");
    }
    invokeMethod(writeMethod, bean, values);

}

From source file:org.evergreen.web.utils.beanutils.PropertyUtilsBean.java

/**
 * Set the value of the specified simple property of the specified bean,
 * with no type conversions.//from w  w w  . j av  a2  s.  c  om
 *
 * @param bean Bean whose property is to be modified
 * @param name Name of the property to be modified
 * @param value Value to which the property should be set
 *
 * @exception IllegalAccessException if the caller does not have
 *  access to the property accessor method
 * @exception IllegalArgumentException if <code>bean</code> or
 *  <code>name</code> is null
 * @exception IllegalArgumentException if the property name is
 *  nested or indexed
 * @exception InvocationTargetException if the property accessor method
 *  throws an exception
 * @exception NoSuchMethodException if an accessor method for this
 *  propety cannot be found
 */
public void setSimpleProperty(Object bean, String name, Object value)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    //System.out.println("target: "+bean+"   filed: "+name+"   value: "+value);
    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }
    if (name == null) {
        throw new IllegalArgumentException("No name specified for bean class '" + bean.getClass() + "'");
    }

    // Validate the syntax of the property name
    if (resolver.hasNested(name)) {
        throw new IllegalArgumentException("Nested property names are not allowed: Property '" + name
                + "' on bean class '" + bean.getClass() + "'");
    } else if (resolver.isIndexed(name)) {
        throw new IllegalArgumentException("Indexed property names are not allowed: Property '" + name
                + "' on bean class '" + bean.getClass() + "'");
    } else if (resolver.isMapped(name)) {
        throw new IllegalArgumentException("Mapped property names are not allowed: Property '" + name
                + "' on bean class '" + bean.getClass() + "'");
    }

    // Handle DynaBean instances specially
    if (bean instanceof DynaBean) {
        DynaProperty descriptor = ((DynaBean) bean).getDynaClass().getDynaProperty(name);
        if (descriptor == null) {
            throw new NoSuchMethodException(
                    "Unknown property '" + name + "' on dynaclass '" + ((DynaBean) bean).getDynaClass() + "'");
        }
        ((DynaBean) bean).set(name, value);
        return;
    }

    // Retrieve the property setter method for the specified property
    PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
    if (descriptor == null) {
        throw new NoSuchMethodException("Unknown property '" + name + "' on class '" + bean.getClass() + "'");
    }
    Method writeMethod = getWriteMethod(bean.getClass(), descriptor);
    if (writeMethod == null) {
        throw new NoSuchMethodException(
                "Property '" + name + "' has no setter method in class '" + bean.getClass() + "'");
    }

    // Call the property setter method
    Object[] values = new Object[1];
    values[0] = value;
    if (log.isTraceEnabled()) {
        String valueClassName = value == null ? "<null>" : value.getClass().getName();
        log.trace("setSimpleProperty: Invoking method " + writeMethod + " with value " + value + " (class "
                + valueClassName + ")");
    }
    invokeMethod(writeMethod, bean, values);

}

From source file:eu.qualityontime.commons.QPropertyUtilsBean.java

public void _setSimpleProperty(final Object bean, final String name, final Object value) throws Exception {

    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }/*from  ww w  . ja  v  a  2  s.c  o  m*/
    if (name == null) {
        throw new IllegalArgumentException("No name specified for bean class '" + bean.getClass() + "'");
    }

    // Validate the syntax of the property name
    if (resolver.hasNested(name)) {
        throw new IllegalArgumentException("Nested property names are not allowed: Property '" + name
                + "' on bean class '" + bean.getClass() + "'");
    } else if (resolver.isIndexed(name)) {
        throw new IllegalArgumentException("Indexed property names are not allowed: Property '" + name
                + "' on bean class '" + bean.getClass() + "'");
    } else if (resolver.isMapped(name)) {
        throw new IllegalArgumentException("Mapped property names are not allowed: Property '" + name
                + "' on bean class '" + bean.getClass() + "'");
    }

    if (name.startsWith("@")) {
        FieldUtils.writeField(bean, name.substring(1), value);
        return;
    }
    // Retrieve the property setter method for the specified property
    final PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
    if (descriptor == null) {
        throw new NoSuchMethodException("Unknown property '" + name + "' on class '" + bean.getClass() + "'");
    }
    final Method writeMethod = getWriteMethod(bean.getClass(), descriptor);
    if (writeMethod == null) {
        throw new NoSuchMethodException(
                "Property '" + name + "' has no setter method in class '" + bean.getClass() + "'");
    }

    // Call the property setter method
    final Object[] values = new Object[1];
    values[0] = value;
    if (log.isTraceEnabled()) {
        final String valueClassName = value == null ? "<null>" : value.getClass().getName();
        log.trace("setSimpleProperty: Invoking method " + writeMethod + " with value " + value + " (class "
                + valueClassName + ")");
    }
    invokeMethod(writeMethod, bean, values);

}