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:com.yahoo.elide.core.EntityDictionary.java

/**
 * Find an arbitrary method./*from  w w w.j  a v  a 2s  . co m*/
 *
 * @param entityClass the entity class
 * @param name the name
 * @param paramClass the param class
 * @return method method
 * @throws NoSuchMethodException the no such method exception
 */
public static Method findMethod(Class<?> entityClass, String name, Class<?>... paramClass)
        throws NoSuchMethodException {
    Method m = entityClass.getMethod(name, paramClass);
    int modifiers = m.getModifiers();
    if (Modifier.isAbstract(modifiers)
            || (m.isAnnotationPresent(Transient.class) && !m.isAnnotationPresent(ComputedAttribute.class))) {
        throw new NoSuchMethodException(name);
    }
    return m;
}

From source file:com.ottogroup.bi.streaming.operator.json.filter.JsonContentFilter.java

/**
 * Returns a {@link Matcher} instance depending on the provided input
 * @param matcherType/*w ww.j  av  a  2  s .  c om*/
 * @param value
 * @param type
 * @return
 * @throws NoSuchMethodException
 * @throws IllegalArgumentException
 */
protected <T extends Comparable<T>> Matcher<T> matcher(final FieldConditionOperator matcherType, final T value,
        final JsonContentType type) throws NoSuchMethodException, IllegalArgumentException {

    ///////////////////////////////////////////////////////////////////////
    // validate provided input
    if (matcherType == null)
        throw new IllegalArgumentException("Missing required matcher type");
    if (type == null)
        throw new IllegalArgumentException("Missing required content type");
    ///////////////////////////////////////////////////////////////////////

    switch (matcherType) {
    case GREATER_THAN: {
        return Matchers.greaterThan(value);
    }
    case IS: {
        return Matchers.is(value);
    }
    case IS_EMPTY: {
        throw new NoSuchMethodException("is_empty is currently not supported");
    }
    case LESS_THAN: {
        return Matchers.lessThan(value);
    }
    case LIKE: {
        return RegularExpressionMatcher.matchesPattern((value != null ? value.toString() : null));
    }
    case NOT: {
        return Matchers.not(value);
    }
    case NOT_EMPTY: {
        throw new NoSuchMethodException("not_empty is not supported");
    }
    default:
        throw new NoSuchMethodException(matcherType + " is currently not supported");
    }

}

From source file:org.apache.hadoop.hbase.io.asyncfs.FanOutOneBlockAsyncDFSOutputHelper.java

private static FileCreater createFileCreater() throws ClassNotFoundException, NoSuchMethodException,
        IllegalAccessException, InvocationTargetException {
    for (Method method : ClientProtocol.class.getMethods()) {
        if (method.getName().equals("create")) {
            final Method createMethod = method;
            Class<?>[] paramTypes = createMethod.getParameterTypes();
            if (paramTypes[paramTypes.length - 1] == long.class) {
                return new FileCreater() {

                    @Override//from  w ww.  j  ava2  s  .  c  om
                    public HdfsFileStatus create(ClientProtocol namenode, String src, FsPermission masked,
                            String clientName, EnumSetWritable<CreateFlag> flag, boolean createParent,
                            short replication, long blockSize) throws IOException {
                        try {
                            return (HdfsFileStatus) createMethod.invoke(namenode, src, masked, clientName, flag,
                                    createParent, replication, blockSize);
                        } catch (IllegalAccessException e) {
                            throw new RuntimeException(e);
                        } catch (InvocationTargetException e) {
                            Throwables.propagateIfPossible(e.getTargetException(), IOException.class);
                            throw new RuntimeException(e);
                        }
                    }
                };
            } else {
                Class<?> cryptoProtocolVersionClass = Class
                        .forName("org.apache.hadoop.crypto.CryptoProtocolVersion");
                Method supportedMethod = cryptoProtocolVersionClass.getMethod("supported");
                final Object supported = supportedMethod.invoke(null);
                return new FileCreater() {

                    @Override
                    public HdfsFileStatus create(ClientProtocol namenode, String src, FsPermission masked,
                            String clientName, EnumSetWritable<CreateFlag> flag, boolean createParent,
                            short replication, long blockSize) throws IOException {
                        try {
                            return (HdfsFileStatus) createMethod.invoke(namenode, src, masked, clientName, flag,
                                    createParent, replication, blockSize, supported);
                        } catch (IllegalAccessException e) {
                            throw new RuntimeException(e);
                        } catch (InvocationTargetException e) {
                            Throwables.propagateIfPossible(e.getTargetException(), IOException.class);
                            throw new RuntimeException(e);
                        }
                    }
                };
            }
        }
    }
    throw new NoSuchMethodException("Can not find create method in ClientProtocol");
}

From source file:javadz.beanutils.PropertyUtilsBean.java

/**
 * Return the value of the specified indexed property of the specified
 * bean, with no type conversions.  In addition to supporting the JavaBeans
 * specification, this method has been extended to support
 * <code>List</code> objects as well.
 *
 * @param bean Bean whose property is to be extracted
 * @param name Simple property name of the property value to be extracted
 * @param index Index of the property value to be extracted
 * @return the indexed property value//w w  w . j  a  va 2 s  .com
 *
 * @exception IndexOutOfBoundsException if the specified index
 *  is outside the valid range for the underlying property
 * @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 InvocationTargetException if the property accessor method
 *  throws an exception
 * @exception NoSuchMethodException if an accessor method for this
 *  propety cannot be found
 */
public Object getIndexedProperty(Object bean, String name, int index)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }
    if (name == null || name.length() == 0) {
        if (bean.getClass().isArray()) {
            return Array.get(bean, index);
        } else if (bean instanceof List) {
            return ((List) bean).get(index);
        }
    }
    if (name == null) {
        throw new IllegalArgumentException("No name specified for 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() + "'");
        }
        return (((DynaBean) bean).get(name, index));
    }

    // 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() + "'");
    }

    // Call the indexed getter method if there is one
    if (descriptor instanceof IndexedPropertyDescriptor) {
        Method readMethod = ((IndexedPropertyDescriptor) descriptor).getIndexedReadMethod();
        readMethod = MethodUtils.getAccessibleMethod(bean.getClass(), readMethod);
        if (readMethod != null) {
            Object[] subscript = new Object[1];
            subscript[0] = new Integer(index);
            try {
                return (invokeMethod(readMethod, bean, subscript));
            } catch (InvocationTargetException e) {
                if (e.getTargetException() instanceof IndexOutOfBoundsException) {
                    throw (IndexOutOfBoundsException) e.getTargetException();
                } else {
                    throw e;
                }
            }
        }
    }

    // Otherwise, the underlying property must be an array
    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 and return the value
    Object value = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
    if (!value.getClass().isArray()) {
        if (!(value instanceof java.util.List)) {
            throw new IllegalArgumentException(
                    "Property '" + name + "' is not indexed on bean class '" + bean.getClass() + "'");
        } else {
            //get the List's value
            return ((java.util.List) value).get(index);
        }
    } else {
        //get the array's value
        try {
            return (Array.get(value, index));
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new ArrayIndexOutOfBoundsException(
                    "Index: " + index + ", Size: " + Array.getLength(value) + " for property '" + name + "'");
        }
    }

}

From source file:org.pentaho.platform.engine.services.solution.PojoComponent.java

@SuppressWarnings({ "unchecked" })
@Override//  ww w  .j  a va2 s  .  c o m
protected boolean executeAction() throws Throwable {

    Set<?> inputNames = getInputNames();
    Element defnNode = (Element) getComponentDefinition();

    // first do the system settings so that component settings and inputs can override them if necessary
    // if( pojo instanceof IConfiguredPojo ) {
    if (getMethods.containsKey("CONFIGSETTINGSPATHS") && configureMethod != null) { //$NON-NLS-1$

        Method method = getMethods.get("CONFIGSETTINGSPATHS"); //$NON-NLS-1$
        Set<String> settingsPaths = (Set<String>) method.invoke(pojo, new Object[] {});
        Iterator<String> keys = settingsPaths.iterator();
        Map<String, String> settings = new HashMap<String, String>();
        SystemSettingsParameterProvider params = new SystemSettingsParameterProvider();
        while (keys.hasNext()) {
            String path = keys.next();
            String value = params.getStringParameter(path, null);
            if (value != null) {
                settings.put(path, value);
            }
        }
        configureMethod.invoke(pojo, new Object[] { settings });
    }

    // set the PentahoSession
    if (sessionMethod != null) {
        callMethods(Arrays.asList(new Method[] { sessionMethod }), getSession());
    }

    // set the logger
    if (loggerMethod != null) {
        callMethods(Arrays.asList(new Method[] { loggerMethod }), getLogger());
    }

    Map<String, Object> inputMap = new HashMap<String, Object>();
    // look at the component settings
    List<?> nodes = defnNode.selectNodes("*"); //$NON-NLS-1$
    for (int idx = 0; idx < nodes.size(); idx++) {
        Element node = (Element) nodes.get(idx);
        // inputs may typically contain a dash in them, such as
        // something like "report-definition" and we should expect
        // a setter as setReportDefinition, so we will remove the
        // dashes and everything should proceed as expected
        String name = node.getName().replace("-", "").toUpperCase(); //$NON-NLS-1$ //$NON-NLS-2$
        if (!name.equals("CLASS") && !name.equals("OUTPUTSTREAM")) { //$NON-NLS-1$ //$NON-NLS-2$
            String value = node.getText();

            List<Method> method = setMethods.get(name);
            if (method != null) {
                callMethodWithString(method, value);
            } else if (runtimeInputsMethod != null) {
                inputMap.put(name, value);
            } else {
                // Supress error (For string/value replacement)
                getLogger().warn(Messages.getInstance().getString("PojoComponent.UNUSED_INPUT", name)); //$NON-NLS-1$
            }
        }
    }

    Iterator<?> it = null;

    // now process all of the resources and see if we can call them as setters
    Set<?> resourceNames = getResourceNames();
    Map<String, IActionSequenceResource> resourceMap = new HashMap<String, IActionSequenceResource>();
    if (resourceNames != null && resourceNames.size() > 0) {
        it = resourceNames.iterator();
        while (it.hasNext()) {
            String name = (String) it.next();
            IActionSequenceResource resource = getResource(name);
            name = name.replace("-", ""); //$NON-NLS-1$ //$NON-NLS-2$
            resourceMap.put(name, resource);
            List<Method> methods = setMethods.get(name.toUpperCase());

            if (methods != null) {
                for (Method method : methods) {
                    Class<?>[] paramTypes = method.getParameterTypes();
                    if (paramTypes.length == 1) {
                        Object value = null;

                        if (paramTypes[0] == InputStream.class) {
                            value = resource.getInputStream(RepositoryFilePermission.READ,
                                    LocaleHelper.getLocale());
                        } else if (paramTypes[0] == IActionSequenceResource.class) {
                            value = resource;
                        } else if (paramTypes[0] == String.class) {
                            value = getRuntimeContext().getResourceAsString(resource);
                        } else if (paramTypes[0] == Document.class) {
                            value = getRuntimeContext().getResourceAsDocument(resource);
                        }

                        callMethod(method, value);
                    }
                }
                //CHECKSTYLE IGNORE EmptyBlock FOR NEXT 3 LINES
            } else {
                // BISERVER-2715 we should ignore this as the resource might be meant for another component
            }
        }
    }

    // now process all of the inputs, overriding the component settings
    it = inputNames.iterator();
    while (it.hasNext()) {
        String name = (String) it.next();
        Object value = getInputValue(name);
        // now that we have the value, we can fix the name
        name = name.replace("-", ""); //$NON-NLS-1$ //$NON-NLS-2$
        List<Method> methods = setMethods.get(name.toUpperCase());
        if (methods != null) {
            callMethods(methods, value);
        } else if (runtimeInputsMethod != null) {
            inputMap.put(name, value);
        } else {
            // Supress error (For string/value replacement)
            getLogger().warn(Messages.getInstance().getString("PojoComponent.UNUSED_INPUT", name)); //$NON-NLS-1$
        }
    }

    if (resourceMap.size() > 0 && resourcesMethod != null) {
        // call the resources setter
        resourcesMethod.invoke(pojo, new Object[] { resourceMap });
    }

    if (inputMap.size() > 0 && runtimeInputsMethod != null) {
        // call the generic input setter
        runtimeInputsMethod.invoke(pojo, new Object[] { inputMap });
    }

    if (getOutputNames().contains("outputstream") && setMethods.containsKey("OUTPUTSTREAM") //$NON-NLS-1$ //$NON-NLS-2$
            && getMethods.containsKey("MIMETYPE")) { //$NON-NLS-1$ 
        // get the mime-type
        // Get the first method to match
        Method method = getMethods.get("MIMETYPE"); //$NON-NLS-1$
        String mimeType = (String) method.invoke(pojo, new Object[] {});
        String mappedOutputName = "outputstream"; //$NON-NLS-1$
        if ((getActionDefinition() != null) && (getActionDefinition().getOutput("outputstream") != null)) { //$NON-NLS-1$
            mappedOutputName = getActionDefinition().getOutput("outputstream").getPublicName(); //$NON-NLS-1$
        }

        // this marks the HttpOutputHandler as contentDone=true, causing the MessageFormatter to not print an error
        IContentItem contentItem = getOutputContentItem(mappedOutputName, mimeType);
        if (!(contentItem instanceof SimpleContentItem)) {
            // SimpleContentItem can't handle being added to outputs because it
            // doesn't have a getInputStream(), and the path used to return
            // null.
            setOutputValue("outputstream", contentItem); //$NON-NLS-1$
        }
        // set the output stream
        OutputStream out = contentItem.getOutputStream(getActionName());
        method = setMethods.get("OUTPUTSTREAM").get(0); //$NON-NLS-1$
        method.invoke(pojo, new Object[] { out });
    }

    if (validateMethod != null) {
        Object obj = validateMethod.invoke(pojo, (Object[]) null);
        if (obj instanceof Boolean) {
            Boolean ok = (Boolean) obj;
            if (!ok) {
                return false;
            }
        }
    }

    // now execute the pojo
    Boolean result = Boolean.FALSE;
    if (executeMethod != null) {
        result = (Boolean) executeMethod.invoke(pojo, new Object[] {});
    } else {
        // we can only assume we are ok so far
        result = Boolean.TRUE;
    }

    // now handle outputs
    Set<?> outputNames = getOutputNames();
    // first get the runtime outputs
    Map<String, Object> outputMap = new HashMap<String, Object>();
    if (runtimeOutputsMethod != null) {
        outputMap = (Map<String, Object>) runtimeOutputsMethod.invoke(pojo, new Object[] {});
    }
    it = outputNames.iterator();
    while (it.hasNext()) {
        String name = (String) it.next();
        //CHECKSTYLE IGNORE EmptyBlock FOR NEXT 3 LINES
        if (name.equals("outputstream")) { //$NON-NLS-1$
            // we should be done
        } else {
            IActionParameter param = getOutputItem(name);
            Method method = getMethods.get(name.toUpperCase());
            if (method != null) {
                Object value = method.invoke(pojo, new Object[] {});
                param.setValue(value);
            } else {
                Object value = outputMap.get(name);
                if (value != null) {
                    param.setValue(value);
                } else {
                    throw new NoSuchMethodException(name);
                }
            }
        }
    }

    return result.booleanValue();
}

From source file:org.evosuite.testcarver.testcase.EvoTestCaseCodeGenerator.java

private Method getDeclaredMethod(final Class<?> clazz, final String methodName, Class<?>[] paramTypes)
        throws NoSuchMethodException {
    // logger.info("Trying to get method "+methodName +" from class "+clazz+" with parameters "+Arrays.asList(paramTypes));
    if (clazz == null || Object.class.equals(clazz)) {
        throw new NoSuchMethodException(methodName + "(" + Arrays.toString(paramTypes) + ")");
    }/*from  w  ww .j  av  a  2  s.  c o  m*/

    try {
        final Method m = clazz.getDeclaredMethod(methodName, paramTypes);
        m.setAccessible(true);
        return m;
    } catch (final NoSuchMethodException e) {
        //logger.info("Not found {}, available methods: {}", methodName, Arrays.asList(clazz.getDeclaredMethods()));
        return getDeclaredMethod(clazz.getSuperclass(), methodName, paramTypes);
    }
}

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

/**
* 
* Calls a method of a Java object/*from   ww  w.  j  av  a 2s  .com*/
* 
* @throws JavaException
* 
*/
public boolean java_call_3(PTerm objId, PTerm method_name, PTerm idResult) throws JavaException {
    objId = objId.getTerm();
    idResult = idResult.getTerm();
    Struct method = (Struct) method_name.getTerm();
    Object obj = null;
    Signature args = null;
    String methodName = null;
    try {
        methodName = method.getName();
        if (!objId.isAtom()) {
            if (objId instanceof Var) {
                throw new JavaException(new IllegalArgumentException(objId.toString()));
            }
            Struct sel = (Struct) objId;
            if (sel.getName().equals(".") && sel.getArity() == 2 && method.getArity() == 1) {
                if (methodName.equals("set")) {
                    return java_set(sel.getTerm(0), sel.getTerm(1), method.getTerm(0));
                } else if (methodName.equals("get")) {
                    return java_get(sel.getTerm(0), sel.getTerm(1), method.getTerm(0));
                }
            }
        }
        args = parseArg(method);
        // object and argument must be instantiated
        if (objId instanceof Var)
            throw new JavaException(new IllegalArgumentException(objId.toString()));
        if (args == null) {
            throw new JavaException(new IllegalArgumentException());
        }
        String objName = alice.util.Tools.removeApices(objId.toString());
        obj = staticObjects.containsKey(objName) ? staticObjects.get(objName) : currentObjects.get(objName);
        Object res = null;

        if (obj != null) {
            Class<?> cl = obj.getClass();
            Object[] args_values = args.getValues();
            Method m = lookupMethod(cl, methodName, args.getTypes(), args_values);
            if (m != null) {
                try {
                    m.setAccessible(true);
                    res = m.invoke(obj, args_values);
                } catch (IllegalAccessException ex) {
                    getEngine().logger
                            .warn("Method invocation failed: " + methodName + "( signature: " + args + " )");
                    throw new JavaException(ex);
                }
            } else {
                getEngine().logger.warn("Method not found: " + methodName + "( signature: " + args + " )");
                throw new JavaException(new NoSuchMethodException(
                        "Method not found: " + methodName + "( signature: " + args + " )"));
            }
        } else {
            if (objId.isCompound()) {
                Struct id = (Struct) objId;

                if (id.getArity() == 1 && id.getName().equals("class")) {
                    try {
                        String clName = alice.util.Tools.removeApices(id.getArg(0).toString());
                        Class<?> cl = Class.forName(clName, true, dynamicLoader);

                        Method m = InspectionUtils.searchForMethod(cl, methodName, args.getTypes());
                        m.setAccessible(true);
                        res = m.invoke(null, args.getValues());
                    } catch (ClassNotFoundException ex) {
                        // if not found even as a class id -> consider as a
                        // String object value
                        getEngine().logger.warn("Unknown class.");
                        throw new JavaException(ex);
                    }
                } else {
                    // the object is the string itself
                    Method m = java.lang.String.class.getMethod(methodName, args.getTypes());
                    m.setAccessible(true);
                    res = m.invoke(objName, args.getValues());
                }
            } else {
                // the object is the string itself
                Method m = java.lang.String.class.getMethod(methodName, args.getTypes());
                m.setAccessible(true);
                res = m.invoke(objName, args.getValues());
            }
        }
        if (parseResult(idResult, res))
            return true;
        else
            throw new JavaException(new Exception());
    } catch (InvocationTargetException ex) {
        getEngine().logger.warn("Method failed: " + methodName + " - ( signature: " + args
                + " ) - Original Exception: " + ex.getTargetException());
        throw new JavaException(new IllegalArgumentException());
    } catch (NoSuchMethodException ex) {
        getEngine().logger.warn("Method not found: " + methodName + " - ( signature: " + args + " )");
        throw new JavaException(ex);
    } catch (IllegalArgumentException ex) {
        getEngine().logger.warn("Invalid arguments " + args + " - ( method: " + methodName + " )");
        throw new JavaException(ex);
    } catch (Exception ex) {
        getEngine().logger.warn("Generic error in method invocation " + methodName);
        throw new JavaException(ex);
    }
}

From source file:javadz.beanutils.MethodUtils.java

/**
 * <p>Invoke a named static method whose parameter type matches the object type.</p>
 *
 * <p>The behaviour of this method is less deterministic 
 * than {@link /* w  w w . j a  v  a  2  s  .  c o  m*/
 * #invokeExactStaticMethod(Class objectClass,String methodName,Object [] args,Class[] parameterTypes)}. 
 * It loops through all methods with names that match
 * and then executes the first it finds with compatable parameters.</p>
 *
 * <p>This method supports calls to methods taking primitive parameters 
 * via passing in wrapping classes. So, for example, a <code>Boolean</code> class
 * would match a <code>boolean</code> primitive.</p>
 *
 *
 * @param objectClass invoke static method on this class
 * @param methodName get method with this name
 * @param args use these arguments - treat null as empty array
 * @param parameterTypes match these parameters - treat null as empty array
 * @return The value returned by the invoked method
 *
 * @throws NoSuchMethodException if there is no such accessible method
 * @throws InvocationTargetException wraps an exception thrown by the
 *  method invoked
 * @throws IllegalAccessException if the requested method is not accessible
 *  via reflection
 * @since 1.8.0
 */
public static Object invokeStaticMethod(Class objectClass, String methodName, Object[] args,
        Class[] parameterTypes)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

    if (parameterTypes == null) {
        parameterTypes = EMPTY_CLASS_PARAMETERS;
    }
    if (args == null) {
        args = EMPTY_OBJECT_ARRAY;
    }

    Method method = getMatchingAccessibleMethod(objectClass, methodName, parameterTypes);
    if (method == null) {
        throw new NoSuchMethodException(
                "No such accessible method: " + methodName + "() on class: " + objectClass.getName());
    }
    return method.invoke(null, args);
}

From source file:org.mypsycho.beans.PropertyUtilsBean.java

protected PropertyDescriptor getRequiredDescriptor(Object bean, String name)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    PropertyDescriptor descriptor = getPropertyDescriptor(bean, name);
    if (descriptor == null) {
        throw new NoSuchMethodException(
                "Unknown property '" + name + "'+ on bean class '" + bean.getClass() + "'");
    }/*from  www  .  j a v a 2 s .c o  m*/
    return descriptor;
}

From source file:org.enerj.apache.commons.beanutils.PropertyUtilsBean.java

/**
 * Return the value of the specified mapped property of the specified
 * bean, with no type conversions./*from  ww  w  .jav  a 2s  . c  o  m*/
 *
 * @param bean Bean whose property is to be extracted
 * @param name Mapped property name of the property value to be extracted
 * @param key Key of the property value to be extracted
 *
 * @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 Object getMappedProperty(Object bean, String name, String key)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    if (bean == null) {
        throw new IllegalArgumentException("No bean specified");
    }
    if (name == null) {
        throw new IllegalArgumentException("No name specified");
    }
    if (key == null) {
        throw new IllegalArgumentException("No key specified");
    }

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

    Object result = null;

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

    if (descriptor instanceof MappedPropertyDescriptor) {
        // Call the keyed getter method if there is one
        Method readMethod = ((MappedPropertyDescriptor) descriptor).getMappedReadMethod();
        if (readMethod != null) {
            Object keyArray[] = new Object[1];
            keyArray[0] = key;
            result = invokeMethod(readMethod, bean, keyArray);
        } else {
            throw new NoSuchMethodException("Property '" + name + "' has no mapped getter method");
        }
    } else {
        /* means that the result has to be retrieved from a map */
        Method readMethod = descriptor.getReadMethod();
        if (readMethod != null) {
            Object invokeResult = invokeMethod(readMethod, bean, new Object[0]);
            /* test and fetch from the map */
            if (invokeResult instanceof java.util.Map) {
                result = ((java.util.Map) invokeResult).get(key);
            }
        } else {
            throw new NoSuchMethodException("Property '" + name + "' has no mapped getter method");
        }
    }
    return result;

}