Example usage for java.lang IllegalArgumentException initCause

List of usage examples for java.lang IllegalArgumentException initCause

Introduction

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

Prototype

public synchronized Throwable initCause(Throwable cause) 

Source Link

Document

Initializes the cause of this throwable to the specified value.

Usage

From source file:org.jcurl.core.base.ColliderBase.java

public static Collider newInstance(final Class clz) {
    final Class parent = ColliderBase.class;
    if (!parent.isAssignableFrom(clz))
        throw new IllegalArgumentException(
                "Class [" + clz.getName() + "] is no descendant of [" + parent.getName() + "]");
    try {/*w ww.j  a v a  2s .  c om*/
        return (Collider) clz.newInstance();
    } catch (final InstantiationException e) {
        final IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
    } catch (final IllegalAccessException e) {
        final IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
    }
}

From source file:org.jcurl.core.base.CollissionStrategy.java

public static CollissionStrategy newInstance(final Class clz) {
    final Class parent = CollissionStrategy.class;
    if (!parent.isAssignableFrom(clz))
        throw new IllegalArgumentException(
                "Class [" + clz.getName() + "] is no descendant of [" + parent.getName() + "]");
    try {//from w ww.  j  a v  a2s.c  o m
        return (CollissionStrategy) clz.newInstance();
    } catch (InstantiationException e) {
        final IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
    } catch (IllegalAccessException e) {
        final IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
    }
}

From source file:org.jcurl.core.base.SlideStrategy.java

public static SlideStrategy newInstance(final Class clz) {
    final Class parent = SlideStrategy.class;
    if (!parent.isAssignableFrom(clz))
        throw new IllegalArgumentException(
                "Class [" + clz.getName() + "] is no descendant of [" + parent.getName() + "]");
    try {/*  w w  w .  ja v a 2 s  .co m*/
        return (SlideStrategy) clz.newInstance();
    } catch (final InstantiationException e) {
        final IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
    } catch (final IllegalAccessException e) {
        final IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
    } catch (final SecurityException e) {
        final IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
    }
}

From source file:org.jcurl.model.CollissionModel.java

public static CollissionModel newInstance(final Class clz) {
    final Class parent = CollissionModel.class;
    if (!parent.isAssignableFrom(clz))
        throw new IllegalArgumentException(
                "Class [" + clz.getName() + "] is no descendant of [" + parent.getName() + "]");
    try {/*  ww w.  j  a  v a  2s. c om*/
        return (CollissionModel) clz.newInstance();
    } catch (InstantiationException e) {
        final IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
    } catch (IllegalAccessException e) {
        final IllegalArgumentException ex = new IllegalArgumentException();
        ex.initCause(e);
        throw ex;
    }
}

From source file:org.mule.routing.filters.ExpressionFilter.java

protected String getFullExpression() {
    if (config.getEvaluator() == null) {
        return config.getExpression();
    }//from  w w  w  .jav a2s. c  o m
    if (fullExpression == null) {
        // Handle non-expression filters
        if (config.getEvaluator().equals("header")) {
            delegateFilter = new MessagePropertyFilter(config.getExpression());
        } else if (config.getEvaluator().equals("variable")) {
            delegateFilter = new MessagePropertyFilter(
                    PropertyScope.INVOCATION_NAME + ":" + config.getExpression());
        } else if (config.getEvaluator().equals(RegexExpressionEvaluator.NAME)) {
            delegateFilter = new RegExFilter(config.getExpression());
        } else if (config.getEvaluator().equals(WilcardExpressionEvaluator.NAME)) {
            delegateFilter = new WildcardFilter(config.getExpression());
        } else if (config.getEvaluator().equals(PayloadTypeExpressionEvaluator.NAME)) {
            try {
                delegateFilter = new PayloadTypeFilter(config.getExpression());
            } catch (ClassNotFoundException e) {
                IllegalArgumentException iae = new IllegalArgumentException();
                iae.initCause(e);
                throw iae;
            }
        } else if (config.getEvaluator().equals(ExceptionTypeExpressionEvaluator.NAME)) {
            try {
                if (StringUtils.isEmpty(config.getExpression())) {
                    delegateFilter = new ExceptionTypeFilter();
                } else {
                    delegateFilter = new ExceptionTypeFilter(config.getExpression());
                }
            } catch (ClassNotFoundException e) {
                IllegalArgumentException iae = new IllegalArgumentException();
                iae.initCause(e);
                throw iae;
            }
        } else {
            // In the case of 'payload' the expression can be null
            fullExpression = config.getFullExpression(muleContext.getExpressionManager());
        }
    }
    return fullExpression;
}

From source file:org.springframework.security.ldap.LdapUtils.java

/**
 * Parses the supplied LDAP URL.// w ww .ja va  2 s .c  o  m
 * @param url the URL (e.g.
 * <tt>ldap://monkeymachine:11389/dc=springframework,dc=org</tt>).
 * @return the URI object created from the URL
 * @throws IllegalArgumentException if the URL is null, empty or the URI syntax is
 * invalid.
 */

private static URI parseLdapUrl(String url) {
    Assert.hasLength(url, "url must have length");

    try {
        return new URI(url);
    } catch (URISyntaxException e) {
        IllegalArgumentException iae = new IllegalArgumentException("Unable to parse url: " + url);
        iae.initCause(e);
        throw iae;
    }
}

From source file:wicket.util.resource.UrlResourceStream.java

/**
 * Private constructor to force use of static factory methods.
 * //from w  w w. jav a  2s . c o  m
 * @param url
 *            URL of resource
 */
public UrlResourceStream(final URL url) {
    // Save URL
    this.url = url;
    URLConnection connection = null;
    try {
        connection = url.openConnection();
        contentLength = connection.getContentLength();
        contentType = connection.getContentType();
        lastModified = connection.getLastModified();
        try {
            file = new File(new URI(url.toExternalForm()));
        } catch (Exception ex) {
            log.debug("cannot convert url: " + url + " to file (" + ex.getMessage()
                    + "), falling back to the inputstream for polling");
        }
        if (file != null && !file.exists()) {
            file = null;
        }
    } catch (IOException ex) {
        // It should be impossible to get here or the original URL
        // couldn't have been constructed. But we re-throw with details
        // anyway.
        final IllegalArgumentException illegalArgumentException = new IllegalArgumentException(
                "Invalid URL parameter " + url);
        illegalArgumentException.initCause(ex);
        throw illegalArgumentException;
    } finally {
        // if applicable, disconnect
        if (connection != null) {
            if (connection instanceof HttpURLConnection) {
                ((HttpURLConnection) connection).disconnect();
            } else {
                try {
                    connection.getInputStream().close();
                } catch (Exception ex) {
                    // ignore
                }
            }
        }
    }
}