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:Main.java

public static int hashCode(Object paramObject) {
    int i = 1;//from w  w w.j  ava 2s  .  c  om
    Field[] arrayOfField = paramObject.getClass().getDeclaredFields();
    int j = arrayOfField.length;
    for (int k = 0;; k++) {
        int m;
        int i1;
        if (k < j) {
            Field localField = arrayOfField[k];
            localField.setAccessible(true);
            try {
                Object localObject = localField.get(paramObject);
                m = i * 31;
                if (localObject == null) {
                    i1 = 0;
                } else {
                    int n = localObject.hashCode();
                    i1 = n;
                }
            } catch (IllegalArgumentException localIllegalArgumentException) {
                localIllegalArgumentException.printStackTrace();
                continue;
            } catch (IllegalAccessException localIllegalAccessException) {
                localIllegalAccessException.printStackTrace();
                continue;
            }
        } else {
            return i;
        }
        i = m + i1;
    }
}

From source file:Main.java

private static boolean equalFields(Object paramObject1, Object paramObject2) {
    boolean bool1 = false;
    Field[] arrayOfField1 = paramObject1.getClass().getDeclaredFields();
    Field[] arrayOfField2 = paramObject2.getClass().getDeclaredFields();
    if (arrayOfField1.length != arrayOfField2.length) {
        return bool1;
    }//from  w  w w.  j a  v  a 2  s. c om

    int i = 0;
    try {
        while (true) {
            if (i >= arrayOfField1.length)
                break;
            Field localField1 = arrayOfField1[i];
            localField1.setAccessible(true);
            Field localField2 = arrayOfField2[i];
            localField2.setAccessible(true);
            Object localObject1 = localField1.get(paramObject1);
            Object localObject2 = localField2.get(paramObject2);
            if ((localObject1 == null) && (localObject2 != null))
                break;
            if (localObject1 != null) {
                boolean bool2 = localObject1.equals(localObject2);
                if (!bool2)
                    break;
            }
            i++;
        }
    } catch (IllegalArgumentException localIllegalArgumentException) {
        localIllegalArgumentException.printStackTrace();
        bool1 = true;
    } catch (IllegalAccessException localIllegalAccessException) {
        label122: localIllegalAccessException.printStackTrace();
    }

    return bool1;
}

From source file:Main.java

public static void takeScreenshot(String fileName, String directory, int quality, Instrumentation inst) {
    Method takeScreenshot;//from www .  ja  va  2 s. c o m
    Method getUiAutomation;
    Object mUiAutomationVaule;
    Bitmap bitmap = null;
    if (android.os.Build.VERSION.SDK_INT < 18) {
        Log.e(TAG, "Build.VERSION is :" + android.os.Build.VERSION.SDK_INT + ", it should >= API 18");
        return;
    }
    try {
        getUiAutomation = Instrumentation.class.getDeclaredMethod("getUiAutomation");
        mUiAutomationVaule = getUiAutomation.invoke(inst, new Object[] {});
        takeScreenshot = mUiAutomationVaule.getClass().getDeclaredMethod("takeScreenshot", new Class[] {});
        if (mUiAutomationVaule != null)
            bitmap = (Bitmap) takeScreenshot.invoke(mUiAutomationVaule, new Object[] {});
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(directory + File.separator + fileName);
        if (fileName.endsWith(".png")) {
            bitmap.compress(Bitmap.CompressFormat.PNG, quality, fos);
        } else if (fileName.endsWith(".jpg")) {
            bitmap.compress(Bitmap.CompressFormat.JPEG, quality, fos);
        }
        fos.flush();
        fos.close();
    } catch (Exception e) {
        Log.e(TAG,
                "Can't save the screenshot! Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in AndroidManifest.xml of the application under test.");
        e.printStackTrace();
    }
}

From source file:com.connectsdk.etc.helper.HttpMessage.java

public static HttpPost getHttpPost(String uri) {
    HttpPost post = null;//from  ww w .  j a  v a2 s  .  c o  m
    try {
        post = new HttpPost(uri);
        post.setHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_TEXT_XML);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }

    return post;
}

From source file:com.aw.support.reflection.AttributeAccessor.java

/**
 * @param target/*w  w  w .  ja  va 2  s. com*/
 * @param attrName
 * @return
 */
public static void set(Object target, String attrName, Object value) {
    Field field = null;
    try {
        Class cls = target.getClass();
        field = getField(cls, attrName);
        field.setAccessible(true);
        field.set(target, value);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        throw new IllegalArgumentException("Error setting the value of the attribute:<" + attrName
                + "> of object:<" + target + "> check: Attribute Type:<" + field.getType() + "> value Type: <"
                + value.getClass() + ">");
    } catch (Throwable e) {
        e.printStackTrace();
        throw new IllegalStateException(
                "Error setting the value of the attribute:<" + attrName + "> of object:<" + target + ">");
    }
}

From source file:Main.java

public static void createWifiAccessPoint(Context context, String ntId, String password) {
    try {//from   w w  w .ja  v a 2  s . c  o m
        WifiManager wifiManager = (WifiManager) context.getSystemService(context.WIFI_SERVICE);

        if (wifiManager.isWifiEnabled()) {
            wifiManager.setWifiEnabled(false);
        }

        Method[] wmMethods = wifiManager.getClass().getDeclaredMethods(); //Get all declared methods in WifiManager class     
        for (Method method : wmMethods) {
            if (method.getName().equals("setWifiApEnabled")) {
                WifiConfiguration netConfig = new WifiConfiguration();
                netConfig.SSID = ntId;
                netConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
                netConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
                netConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
                netConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
                netConfig.preSharedKey = password;
                netConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
                netConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
                netConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
                netConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
                try {
                    boolean apstatus = (Boolean) method.invoke(wifiManager, netConfig, true);

                    for (Method isWifiApEnabledmethod : wmMethods) {
                        if (isWifiApEnabledmethod.getName().equals("isWifiApEnabled")) {
                            while (!(Boolean) isWifiApEnabledmethod.invoke(wifiManager)) {
                            }
                            ;
                            for (Method method1 : wmMethods) {
                                if (method1.getName().equals("getWifiApState")) {
                                    int apstate;
                                    apstate = (Integer) method1.invoke(wifiManager);
                                }
                            }
                        }
                    }
                    if (apstatus) {
                        Log.d("better", "Access Point Created");
                    } else {
                        Log.d("better", "Failed to create Access Point!");
                    }

                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:Main.java

public static boolean hasSdCard() {
    boolean sResult = false;

    String stateString = null;/*from   www.j  ava  2 s  .  c o  m*/
    try {
        Class c = Class.forName("android.os.SystemProperties");
        Method m[] = c.getDeclaredMethods();

        try {
            try {
                stateString = (String) m[1].invoke(null, "EXTERNAL_STORAGE_STATE", "unmounted");
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (stateString != null) {
        if (stateString.equals(Environment.MEDIA_MOUNTED)) {
            sResult = true;
        }
    }
    return sResult;
}

From source file:com.drextended.rvdbsample.util.Converters.java

@BindingAdapter(value = { "glidePath", "glidePlaceholder", "glideSignature", "glideCacheStrategy",
        "glideCrossFadeDisabled", "glideAnimation", "glideTransform" }, requireAll = false)
public static void setImageUri(ImageView imageView, String path, Drawable placeholder, String glideSignature,
        String glideCacheStrategy, boolean crossFadeDisabled, Integer animationResId, String glideTransform) {
    Context context = imageView.getContext();

    if (context instanceof Activity && ((Activity) context).isFinishing())
        return;/*from ww  w .j av a 2  s .c om*/
    if (context instanceof ContextWrapper) {
        final Context baseContext = ((ContextWrapper) context).getBaseContext();
        if (baseContext instanceof Activity && ((Activity) baseContext).isFinishing())
            return;
    }
    boolean isEmptyPath = TextUtils.isEmpty(path);
    if (isEmptyPath) {
        if (placeholder != null) {
            imageView.setImageDrawable(placeholder);
        }
        return;
    }
    try {
        RequestManager glide = Glide.with(context);
        DrawableRequestBuilder request = glide.load(path);

        if (placeholder != null) {
            if (!crossFadeDisabled && animationResId == null)
                request.crossFade();
            request.placeholder(placeholder);
        }
        if (animationResId != null) {
            request.animate(animationResId);
        }
        if (!TextUtils.isEmpty(glideSignature)) {
            request.signature(new StringSignature(glideSignature));
        }
        if (glideTransform != null) {
            switch (glideTransform) {
            case "CIRCLE":
                request.bitmapTransform(
                        new CircleBorderedTransform(Glide.get(context).getBitmapPool(), Color.WHITE));
                break;
            case "BLUR":
                break;
            }
        }

        if (!TextUtils.isEmpty(glideCacheStrategy)) {
            request.diskCacheStrategy(DiskCacheStrategy.valueOf(glideCacheStrategy));
        }

        request.into(imageView);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
}

From source file:com.ExtendedAlpha.SWI.SeparatorLib.FireworkEffectSeparator.java

public static FireworkEffect getFireworkEffect(JSONObject json) {
    try {//from   ww w . j  a  va  2 s.  co m
        FireworkEffect.Builder builder = FireworkEffect.builder();

        //colors
        JSONArray colors = json.getJSONArray("colors");
        for (int j = 0; j < colors.length(); j++) {
            builder.withColor(ColorSeparator.getColor(colors.getJSONObject(j)));
        }

        //fade colors
        JSONArray fadeColors = json.getJSONArray("fade-colors");
        for (int j = 0; j < fadeColors.length(); j++) {
            builder.withFade(ColorSeparator.getColor(colors.getJSONObject(j)));
        }

        //hasFlicker
        if (json.getBoolean("flicker"))
            builder.withFlicker();

        //trail
        if (json.getBoolean("trail"))
            builder.withTrail();

        //type
        builder.with(FireworkEffect.Type.valueOf(json.getString("type")));

        return builder.build();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.smartitengineering.util.bean.BeanFactoryRegistrar.java

private static boolean aggregate(Class<? extends Object> aggregatorClass, Object aggregator)
        throws SecurityException {
    if (aggregatorClass.equals(Object.class)) {
        return true;
    }//  w w  w . j av  a  2s .c om
    Class<? extends Object> superClass = aggregatorClass.getSuperclass();
    if (superClass != null) {
        aggregate(superClass, aggregator);
    }
    Aggregator aggregatorAnnotation = aggregatorClass.getAnnotation(Aggregator.class);
    if (aggregatorAnnotation == null || StringUtils.isBlank(aggregatorAnnotation.contextName())) {
        return true;
    }
    BeanFactory beanFactory = getBeanFactorForContext(aggregatorAnnotation.contextName());
    if (beanFactory == null) {
        return true;
    }
    Field[] declaredFields = aggregatorClass.getDeclaredFields();
    for (Field declaredField : declaredFields) {
        InjectableField injectableField = declaredField.getAnnotation(InjectableField.class);
        if (injectableField == null) {
            continue;
        }
        String beanName = StringUtils.isBlank(injectableField.beanName()) && beanFactory.isNameMandatory()
                ? declaredField.getName()
                : injectableField.beanName();
        if (StringUtils.isBlank(beanName) && beanFactory.isNameMandatory()) {
            return true;
        }
        try {
            declaredField.setAccessible(true);
            final Class<?> fieldType = declaredField.getType();
            if (beanFactory.containsBean(beanName, fieldType)) {
                declaredField.set(aggregator, beanFactory.getBean(beanName, fieldType));
            }
        } catch (IllegalArgumentException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        }

    }
    return false;
}