Example usage for java.lang NoSuchMethodException equals

List of usage examples for java.lang NoSuchMethodException equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.saiku.adhoc.service.SaikuAdhocContentGenerator.java

@Override
public void createContent(OutputStream out) throws Exception {
    {//from w w  w .  j av a2  s.c om

        final IParameterProvider pathParams = parameterProviders.get("path");
        final IParameterProvider requestParams = parameterProviders.get("request");

        try {

            final Class[] params = { IParameterProvider.class, OutputStream.class };

            final String method = pathParams.getStringParameter("path", null).split("/")[1].toLowerCase();

            try {
                final Method mthd = this.getClass().getMethod(method, params);
                mthd.invoke(this, requestParams, out);
            } catch (NoSuchMethodException e) {
                logger.error("could not invoke " + method);
            } catch (InvocationTargetException e) {
                //get to the cause and rethrow properly
                Throwable target = e.getTargetException();
                if (!e.equals(target)) {//just in case
                                        //get to the real cause
                    while (target != null && target instanceof InvocationTargetException) {
                        target = ((InvocationTargetException) target).getTargetException();
                    }
                }
                if (target instanceof Exception) {
                    throw (Exception) target;
                } else {
                    throw new Exception(target);
                }
            }
        } catch (Exception e) {
            final String message = e.getCause() != null
                    ? e.getCause().getClass().getName() + " - " + e.getCause().getMessage()
                    : e.getClass().getName() + " - " + e.getMessage();
            logger.error(message, e);
        }
    }
}