Example usage for java.lang IllegalAccessException getMessage

List of usage examples for java.lang IllegalAccessException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.iflytek.edu.cloud.frame.utils.ReflectionUtils.java

/**
 * ?,private/protected,??getter.//from   w w  w  .  jav  a 2  s.  com
 */
public static Object getFieldValue(final Object object, final String fieldName) {
    Field field = getDeclaredField(object, fieldName);

    if (field == null)
        throw new IllegalArgumentException(
                "Could not find field [" + fieldName + "] on target [" + object + "]");

    makeAccessible(field);

    Object result = null;
    try {
        result = field.get(object);
    } catch (IllegalAccessException e) {
        logger.error("??{}", e.getMessage());
    }
    return result;
}

From source file:org.wso2.carbon.ganalytics.publisher.GoogleAnalyticsDataPublisher.java

private static String getFieldValue(Field f, Object o) {
    try {//from   w  w w .j av  a  2s .co  m
        Object value = f.get(o);
        if (value instanceof String) {
            return (String) value;
        } else {
            if (value == null) {
                return null;
            } else {
                return String.valueOf(value);
            }
        }
    } catch (IllegalAccessException e) {
        log.error("Error while obtaining field value. " + e.getMessage());
    }

    return null;
}

From source file:com.github.hibatis.ReflectionUtils.java

/**
 * , private/protected, ??setter./*ww w.j a v  a  2  s.co  m*/
 */
public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
    Field field = getAccessibleField(obj, fieldName);

    if (field == null) {
        throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
    }

    try {
        field.set(obj, value);
    } catch (IllegalAccessException e) {
        logger.error("??:" + e.getMessage());
    }
}

From source file:com.github.hibatis.ReflectionUtils.java

/**
 * ?, private/protected, ??getter.//from   www.  j  a  v a 2  s  .  c o  m
 */
public static Object getFieldValue(final Object obj, final String fieldName) {
    Field field = getAccessibleField(obj, fieldName);

    if (field == null) {
        throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
    }

    Object result = null;
    try {
        result = field.get(obj);
    } catch (IllegalAccessException e) {
        logger.error("??:" + e.getMessage());
    }
    return result;
}

From source file:org.apache.beehive.netui.pageflow.internal.BaseActionForm.java

private static Validator initValidator(String beanName, Object bean, ServletContext context,
        HttpServletRequest request, ActionErrors errors, int page) {
    if (_legacyInitValidatorMethod != null) {
        try {/*from  w  w w .  ja  va2  s.c  om*/
            Object[] args = new Object[] { beanName, bean, context, request, errors, new Integer(page) };
            Validator validator = (Validator) _legacyInitValidatorMethod.invoke(Resources.class, args);

            //
            // The NetUI validator rules work on both 1.1 and 1.2.  They take ActionMessages instead of ActionErrors.
            //
            validator.addResource("org.apache.struts.action.ActionMessages", errors);
            return validator;
        } catch (IllegalAccessException e) {
            assert false : e.getMessage();
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            assert false : e.getMessage();
            throw new RuntimeException(e);
        }
    } else {
        return Resources.initValidator(beanName, bean, context, request, errors, page);
    }
}

From source file:nl.talsmasoftware.enumerables.support.json.jackson2.Compatibility.java

@SuppressWarnings("unchecked")
private static <T> T call(Object target, String method) throws NoSuchMethodException {
    try {//from  ww w .j a  v  a 2 s . c o m

        return (T) method(target.getClass(), method).invoke(target);

    } catch (IllegalAccessException iae) {
        NoSuchMethodException nsme = new NoSuchMethodException(
                String.format("Not allowed to call method \"%s\": %s", method, iae.getMessage()));
        nsme.initCause(iae);
        throw nsme;
    } catch (InvocationTargetException ite) {
        Throwable cause = ite.getCause();
        if (cause == null)
            cause = ite; // shouldn't happen!
        throw cause instanceof RuntimeException ? (RuntimeException) cause
                : new RuntimeException(cause.getMessage(), cause);
    }
}

From source file:gov.abrs.etms.common.util.ReflectionUtils.java

/**
 * , private/protected, ??setter./*www . jav  a2 s . c om*/
 */
public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
    Field field = getAccessibleField(obj, fieldName);

    if (field == null) {
        throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
    }

    try {
        field.set(obj, value);
    } catch (IllegalAccessException e) {
        logger.error("??:{}" + e.getMessage());
    }
}

From source file:com.yize.broadcast.core.util.ReflectionUtils.java

/**
 * , private/protected, ??setter.//from ww  w  .  j  a v a 2  s .c om
 */
public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
    Field field = getAccessibleField(obj, fieldName);

    if (field == null) {
        throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
    }

    try {
        field.set(obj, value);
    } catch (IllegalAccessException e) {
        LOGGER.error("??:{}", e.getMessage());
    }
}

From source file:gov.abrs.etms.common.util.ReflectionUtils.java

/**
 * ?, private/protected, ??getter./*from   ww  w.  jav a 2 s .c  om*/
 */
public static Object getFieldValue(final Object obj, final String fieldName) {
    Field field = getAccessibleField(obj, fieldName);

    if (field == null) {
        throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
    }

    Object result = null;
    try {
        result = field.get(obj);
    } catch (IllegalAccessException e) {
        logger.error("??{}" + e.getMessage());
    }
    return result;
}

From source file:com.yize.broadcast.core.util.ReflectionUtils.java

/**
 * ?, private/protected, ??getter./*www.  jav  a2s  .  c o  m*/
 */
public static Object getFieldValue(final Object obj, final String fieldName) {
    Field field = getAccessibleField(obj, fieldName);

    if (field == null) {
        throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
    }

    Object result = null;
    try {
        result = field.get(obj);
    } catch (IllegalAccessException e) {
        LOGGER.error("??{}", e.getMessage());
    }
    return result;
}