Example usage for java.lang IllegalArgumentException printStackTrace

List of usage examples for java.lang IllegalArgumentException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.xhsoft.framework.common.utils.ReflectUtil.java

/**
 * <p>Description:ReflectionMap?</p>
 * @param target/*  w  w w .ja v a 2s .  co m*/
 * @return Map<String,Object>
 * @author wanggq
 * @since  2009-9-9
 */
@SuppressWarnings("unchecked")
public static Map<String, Object> getMapFieldData(Object target) {
    Map<String, Object> map = new HashMap<String, Object>();
    Class clazz = target.getClass();
    Field[] fields = clazz.getDeclaredFields();
    Method[] methods = clazz.getDeclaredMethods();
    for (Field field : fields) {
        String fieldName = field.getName();

        if ("messageTypeId".equals(fieldName)) {
            continue;
        }

        String getMethod = "get" + StringUtils.capitalize(fieldName);
        for (Method method : methods) {
            if (method.getName().equals(getMethod)) {

                try {
                    Object ret = method.invoke(target, null);
                    map.put(fieldName, ret);
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                }

            }

        }

    }

    return map;
}

From source file:se.berazy.api.examples.App.java

/**
 * Writes out all public fields./*from ww w.  j  a  v a2s  .  co  m*/
 * @param T response
 */
static <T> void outPutResponse(T response) {
    String retval = "\nResponse: \n";
    Class<?> clazz = response.getClass();
    Field[] fields = clazz.getDeclaredFields();
    for (Field field : fields) {
        field.setAccessible(true);
        if (!field.getName().equalsIgnoreCase("ExtensionData")) {
            try {
                retval += String.format("%s: %s\n", field.getName(), field.get(response));
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
    System.out.println(retval);
}

From source file:org.kalypsodeegree.KalypsoDeegreePreferences.java

public static Interpolation getRasterPaintingInterpolationMethod() {
    final String methodName = getStore().getString(SETTING_RASTER_PAINTING_INTERPOLATION_METHOD);

    try {//w w  w .j  a  v a 2s  .  c  om
        if (StringUtils.isBlank(methodName))
            return RASTER_PAINTING_INTERPOLATION_METHOD_DEFAULT_VALUE;

        return Interpolation.valueOf(methodName);
    } catch (final IllegalArgumentException e) {
        e.printStackTrace();
        return RASTER_PAINTING_INTERPOLATION_METHOD_DEFAULT_VALUE;
    }
}

From source file:com.lee.sdk.utils.NetUtils.java

/**
 * ?get?/* w w w  .ja  va 2 s .c o m*/
 * 
 * @param url url
 * @return string
 * @throws IOException IOException
 * @throws ClientProtocolException ClientProtocolException
 */
public static String getStringFromUrl(String url) throws ClientProtocolException, IOException {
    HttpGet get;
    try {
        get = new HttpGet(url);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        return null;
    }
    HttpClient client = new DefaultHttpClient();
    HttpResponse response = client.execute(get);
    if (response != null) {
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            return EntityUtils.toString(entity, "UTF-8");
        }
    }
    return null;
}

From source file:com.jadarstudios.developercapes.cape.CapeConfigManager.java

public static int claimId(int id) throws InvalidCapeConfigIdException {
    if (id <= 0) {
        throw new InvalidCapeConfigIdException("The config ID must be a positive non-zero integer");
    }/*w  w  w  .  j  a  v a 2 s  .  com*/
    try {
        UnsignedBytes.checkedCast(id);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }

    boolean isRegistered = availableIds.get(id);
    if (isRegistered) {
        throw new InvalidCapeConfigIdException(String.format("The config ID %d is already claimed.", id));
    }

    availableIds.set(id);
    return id;
}

From source file:misc.TestUtils.java

public static List<Pair<String, Object>> getEntityFields(Object o) {
    List<Pair<String, Object>> ret = new ArrayList<Pair<String, Object>>();
    for (Class<?> clazz = o.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
        for (Field field : clazz.getDeclaredFields()) {
            //ignore some weird fields with unique values
            if (field.getName().contains("$"))
                continue;
            boolean accessible = field.isAccessible();
            try {
                field.setAccessible(true);
                Object val = field.get(o);
                ret.add(new Pair<String, Object>(field.getName(), val));
                //               System.out.println(field.getName()+"="+val);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();/*w w  w  .  java2 s  .  c  o m*/
            } catch (SecurityException e) {
                e.printStackTrace();
            } finally {
                field.setAccessible(accessible);
            }
        }
    }
    return ret;
}

From source file:org.apache.hadoop.gateway.filter.IdentityAssertionHttpServletRequestWrapper.java

static String urlEncode(Map<String, String[]> map, String encoding) {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<?, ?> entry : map.entrySet()) {
        if (sb.length() > 0) {
            sb.append("&");
        }/*from ww  w.  ja  v  a  2  s . c om*/
        String[] values = (String[]) entry.getValue();
        for (int i = 0; i < values.length; i++) {
            if (values[i] != null) {
                try {
                    sb.append(String.format("%s=%s", urlEncode(entry.getKey().toString(), encoding),
                            urlEncode(values[i], encoding)));
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                    System.out.println(
                            "SKIPPING PARAM: " + entry.getKey().toString() + " with value: " + values[i]);
                }
            }
        }
    }
    return sb.toString();
}

From source file:com.vivekpanyam.evolve.Utils.java

/**
 * Set the ClassLoader for the running application
 *
 * @param a An activity in the currently running application
 * @param classLoader The ClassLoader used to load the new DEX file
 */// w  w w  .j ava  2  s .  co m

public static void setClassLoader(Activity a, ClassLoader classLoader) {
    try {
        Field mMainThread = getField(Activity.class, "mMainThread");
        Object mainThread = mMainThread.get(a);
        Class<?> threadClass = mainThread.getClass();
        Field mPackages = getField(threadClass, "mPackages");

        HashMap<String, ?> map = (HashMap<String, ?>) mPackages.get(mainThread);
        WeakReference<?> ref = (WeakReference<?>) map.get(a.getPackageName());
        Object apk = ref.get();
        Class<?> apkClass = apk.getClass();
        Field mClassLoader = getField(apkClass, "mClassLoader");

        mClassLoader.set(apk, classLoader);
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:in.goahead.apps.util.URLUtils.java

public static Proxy getProxy() {
    Proxy proxy = null;//from   w  w  w. j  ava  2 s  .com
    String proxyType = System.getProperty("YAYTD.PROXY_TYPE");
    String proxyServer = System.getProperty("YAYTD.PROXY_SERVER");
    String proxyPort = System.getProperty("YAYTD.PROXY_PORT");

    try {
        if (proxyType != null && proxyServer != null && proxyPort != null) {
            proxy = new Proxy(Proxy.Type.valueOf(proxyType),
                    new InetSocketAddress(proxyServer, Integer.parseInt(proxyPort)));
        }
    } catch (IllegalArgumentException ile) {
        ile.printStackTrace();
    }

    return proxy;
}

From source file:com.example.propertylist.MainActivity.java

private static void hideProgressDialog() {
    if (pDialog != null) {
        try {/*  w  ww. j  a v  a2  s  . c om*/
            pDialog.dismiss();
            pDialog = null;
        } catch (IllegalArgumentException e) {// nothing
            e.printStackTrace();
        }
    }
}