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.sshtools.j2ssh.forwarding.XDisplay.java

/**
 * Creates a new XDisplay object.//  ww  w .  j a  v  a2s. c o  m
 *
 * @param string
 */
public XDisplay() {
    try {
        String display = System.getenv("DISPLAY");
        if (display == null) {
            log.warn("Display not set, trying localhost:0.0");
            processDisplay("localhost:0.0");
        } else {
            processDisplay(display);
        }
    } catch (Error e) { // in 1.4 System.getenv was depricated, it is back in 1.5
        if (!System.getProperty("os.name").startsWith("Window")) {
            try {
                String cmd = "env";
                log.debug("Executing " + cmd);
                Process process = Runtime.getRuntime().exec(cmd);
                BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                String line = reader.readLine();
                while (line != null) {
                    if (line.startsWith("DISPLAY=")) {
                        processDisplay(line.substring(8));
                        return;
                    }
                    line = reader.readLine();
                }
                reader.close();
                processDisplay(":0.0");
                return;
            } catch (IllegalArgumentException e1) {
                e1.printStackTrace();
                processDisplay(":0.0");
                return;
            } catch (IOException e1) {
                e1.printStackTrace();
                processDisplay(":0.0");
                return;
            }
        } else {
            processDisplay("localhost:0.0");
        }
    }
}

From source file:com.julia.android.stockhawk.ui.MainActivity.java

@Override
protected void onPause() {
    try {/*from  www . j ava 2 s .c  o  m*/
        if (broadcastReceiver != null) {
            unregisterReceiver(broadcastReceiver);
            broadcastReceiver = null;
        }

        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
        connectivityManager.unregisterNetworkCallback(networkCallback);

    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
    super.onStop();
}

From source file:com.terracom.mumbleclient.service.QRPushToTalkNotification.java

/**
 * Shows the notification and registers the notification action button receiver.
 *//*from   w ww  .j a v a  2 s .com*/
public void show() {
    createNotification();

    IntentFilter filter = new IntentFilter();
    filter.addAction(BROADCAST_DEAFEN);
    filter.addAction(BROADCAST_MUTE);
    filter.addAction(BROADCAST_OVERLAY);
    filter.addAction(BROADCAST_CANCEL_RECONNECT);
    try {
        mService.registerReceiver(mNotificationReceiver, filter);
    } catch (IllegalArgumentException e) {
        // Thrown if receiver is already registered.
        e.printStackTrace();
    }
}

From source file:geogebra.kernel.statistics.AlgoTTest.java

protected final void compute() {

    if (!(tail.getTextString().equals("<") || tail.getTextString().equals(">")
            || tail.getTextString().equals("!=") || tail.getTextString().equals(""))) {
        result.setUndefined();/*from w w  w . j  a v a  2  s . c om*/
        return;
    }

    // sample data input
    if (input.length == 3) {

        int size = geoList.size();
        if (!geoList.isDefined() || size < 2) {
            result.setUndefined();
            return;
        }

        val = new double[size];

        for (int i = 0; i < size; i++) {
            GeoElement geo = geoList.get(i);
            if (geo.isNumberValue()) {
                NumberValue num = (NumberValue) geo;
                val[i] = num.getDouble();

            } else {
                result.setUndefined();
                return;
            }
        }

        try {

            // get the test statistic and p
            if (tTestImpl == null)
                tTestImpl = new TTestImpl();
            testStat = tTestImpl.t(hypMean.getDouble(), val);
            p = tTestImpl.tTest(hypMean.getDouble(), val);
            p = adjustedPValue(p, testStat);

            // put these results into the output list
            result.clear();
            result.add(new GeoNumeric(cons, p));
            result.add(new GeoNumeric(cons, testStat));

        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (MathException e) {
            e.printStackTrace();
        }

        // sample statistics input 
    } else {

        // check for valid standard deviation and sample size
        if (sd.getDouble() < 0 || n.getDouble() < 2) {
            result.setUndefined();
            return;
        }
        StatisticalSummaryValues sumStats = new StatisticalSummaryValues(mean.getDouble(),
                sd.getDouble() * sd.getDouble(), (long) n.getDouble(), -1, -1, -1);

        try {

            // get the test statistic and p
            if (tTestImpl == null)
                tTestImpl = new TTestImpl();
            testStat = tTestImpl.t(hypMean.getDouble(), sumStats);
            p = tTestImpl.tTest(hypMean.getDouble(), sumStats);
            p = adjustedPValue(p, testStat);

            // put these results into the output list
            result.clear();
            result.add(new GeoNumeric(cons, p));
            result.add(new GeoNumeric(cons, testStat));

        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (MathException e) {
            e.printStackTrace();
        }

    }

}

From source file:com.felkertech.n.tv.presenters.CardPresenter.java

@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    final CumulusChannel jsonChannel = (CumulusChannel) item;
    final ImageCardView cardView = (ImageCardView) viewHolder.view;

    cardView.setTitleText(jsonChannel.getName());
    cardView.setContentText(jsonChannel.getNumber());
    cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
    if (jsonChannel.getLogo() == null || jsonChannel.getLogo().isEmpty()) {
        cardView.setMainImage(mContext.getResources().getDrawable(R.drawable.c_banner_3_2));
        cardView.findViewById(R.id.info_field)
                .setBackgroundColor(mContext.getResources().getColor(R.color.colorPrimaryDark));
    } else {/*from  w  w w  .j  a va  2  s. c o  m*/
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    final Bitmap logo = Picasso.with(mContext).load(jsonChannel.getLogo())
                            .error(R.drawable.c_banner_3_2).centerInside().resize(CARD_WIDTH, CARD_HEIGHT)
                            .get();
                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                cardView.getMainImageView().setImageBitmap(logo);
                                Palette colors = Palette.from(logo).generate();
                                if (colors.getDarkVibrantSwatch() != null) {
                                    cardView.findViewById(R.id.info_field)
                                            .setBackgroundColor(colors.getDarkVibrantSwatch().getRgb());
                                } else if (colors.getSwatches().size() > 0) {
                                    cardView.findViewById(R.id.info_field)
                                            .setBackgroundColor(colors.getSwatches().get(0).getRgb());
                                } else {
                                    cardView.findViewById(R.id.info_field).setBackgroundColor(
                                            ContextCompat.getColor(mContext, R.color.colorPrimaryDark));
                                }
                            } catch (IllegalArgumentException e) {
                                Log.e(TAG, "There was a problem loading " + jsonChannel.getLogo());
                                e.printStackTrace();
                            }
                        }
                    });
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}

From source file:geogebra.common.kernel.statistics.AlgoTTest.java

@Override
public final void compute() {

    if (!(StringUtil.isInequality(tail.getTextString()))) {
        result.setUndefined();//from   ww w. ja v a 2s. co  m
        return;
    }

    // sample data input
    if (input.length == 3) {

        int size = geoList.size();
        if (!geoList.isDefined() || size < 2) {
            result.setUndefined();
            return;
        }

        val = new double[size];

        for (int i = 0; i < size; i++) {
            GeoElement geo = geoList.get(i);
            if (geo instanceof NumberValue) {
                NumberValue num = (NumberValue) geo;
                val[i] = num.getDouble();

            } else {
                result.setUndefined();
                return;
            }
        }

        try {

            // get the test statistic and p
            if (tTestImpl == null)
                tTestImpl = new TTestImpl();
            testStat = tTestImpl.t(hypMean.getDouble(), val);
            p = tTestImpl.tTest(hypMean.getDouble(), val);
            p = adjustedPValue(p, testStat);

            // put these results into the output list
            result.clear();
            result.add(new GeoNumeric(cons, p));
            result.add(new GeoNumeric(cons, testStat));

        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (MathException e) {
            e.printStackTrace();
        }

        // sample statistics input
    } else {

        // check for valid standard deviation and sample size
        if (sd.getDouble() < 0 || n.getDouble() < 2) {
            result.setUndefined();
            return;
        }

        try {
            StatisticalSummaryValues sumStats = new StatisticalSummaryValues(mean.getDouble(),
                    sd.getDouble() * sd.getDouble(), (long) n.getDouble(), -1, -1, -1);

            // get the test statistic and p
            if (tTestImpl == null)
                tTestImpl = new TTestImpl();
            testStat = tTestImpl.t(hypMean.getDouble(), sumStats);
            p = tTestImpl.tTest(hypMean.getDouble(), sumStats);
            p = adjustedPValue(p, testStat);

            // put these results into the output list
            result.clear();
            result.add(new GeoNumeric(cons, p));
            result.add(new GeoNumeric(cons, testStat));

        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            result.setUndefined();
            return;

        } catch (MathException e) {
            e.printStackTrace();
            result.setUndefined();
            return;
        }

    }

}

From source file:info.mtgdb.api.CardSet.java

/**
 * Constructor for a CardSet taking a json instance to build it.
 * // w  w w . j ava  2 s . c  o  m
 * @param json JSONObject for a CardSet as described by the mtgdb.info API.
 */
public CardSet(JSONObject json) {
    this();
    @SuppressWarnings("unchecked")
    Set<String> set = json.keySet();
    for (String s : set) {
        CardField cardField = memberTypeHash.get(s);
        if (cardField != null) {
            //System.out.println(s+" is a "+cardField.type);
            try {
                if (cardField.type.matches("int")) {
                    int val = json.getInt(s);
                    cardField.f.set(this, val);
                    //System.out.println("Set "+cardField.name+" to "+cardField.f.getInt(this));
                } else if (cardField.type.matches("java.lang.String")) {
                    Object o = json.get(s);
                    if (o != JSONObject.NULL)
                        cardField.f.set(this, (String) o);
                    else
                        continue;
                    //System.out.println("Set "+cardField.name+" to "+cardField.f.get(this));
                } else if (cardField.type.matches("java.util.Date")) {
                    SimpleDateFormat sdf = new SimpleDateFormat(Dates.dateFormatInput);
                    Date date = sdf.parse(json.getString(s));

                    cardField.f.set(this, date);
                } else if (cardField.type.matches("java.util.List")) {
                    JSONArray jsonArray = json.getJSONArray(s);
                    if (s.matches("cardIds")) {
                        cardIds = new ArrayList<Integer>();
                        for (int i = 0; i < jsonArray.length(); i++) {
                            cardIds.add(jsonArray.getInt(i));
                        }
                    }

                }
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        //else System.out.println(s+" wasn't found.");
    }
}

From source file:com.jifeng.touchgallery.GalleryWidget.GalleryViewPager.java

private boolean isAClick(float startX, float endX, float startY, float endY) {
    float differenceX = 0;
    float differenceY = 0;
    try {//from  w  w  w .j a  va  2 s .com
        differenceX = Math.abs(startX - endX);
        differenceY = Math.abs(startY - endY);
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        //   Log.i("11111", e.toString());
        e.printStackTrace();
    }
    if (differenceX > CLICK_ACTION_THRESHHOLD/* =5 */
            || differenceY > CLICK_ACTION_THRESHHOLD) {
        return false;
    }
    return true;

}

From source file:blue.orchestra.blueSynthBuilder.BSBCloneTest.java

public void testLoadSave() {
    BSBObjectEntry[] bsbObjects = BSBObjectRegistry.getBSBObjects();

    for (int i = 0; i < bsbObjects.length; i++) {
        BSBObjectEntry entry = bsbObjects[i];

        Class class1 = entry.bsbObjectClass;

        BSBObject bsbObj = null;//from   w  w w . jav a2s  . c  o m

        try {
            bsbObj = (BSBObject) class1.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        assertNotNull(bsbObj);

        if (bsbObj == null) {
            continue;
        }

        Element elem1 = bsbObj.saveAsXML();

        Method m = null;
        try {
            m = class1.getMethod("loadFromXML", new Class[] { Element.class });
        } catch (SecurityException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (NoSuchMethodException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        BSBObject bsbObj2 = null;

        assertNotNull(m);
        if (m == null) {
            continue;
        }

        try {
            bsbObj2 = (BSBObject) m.invoke(bsbObj, new Object[] { elem1 });
        } catch (IllegalArgumentException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        } catch (IllegalAccessException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        } catch (InvocationTargetException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        }

        boolean isEqual = EqualsBuilder.reflectionEquals(bsbObj, bsbObj2);

        if (!isEqual) {
            StringBuilder buffer = new StringBuilder();
            buffer.append("Problem with class: ").append(class1.getName()).append("\n");
            buffer.append("Original Object\n");
            buffer.append(ToStringBuilder.reflectionToString(bsbObj)).append("\n");
            buffer.append("Cloned Object\n");
            buffer.append(ToStringBuilder.reflectionToString(bsbObj2)).append("\n");

            System.out.println(buffer.toString());

        }

        assertTrue(isEqual);

    }

}

From source file:edu.cmu.cylab.starslinger.Service.java

@Override
public void onDestroy() {
    super.onDestroy();
    stopForeground(true);//  w  w  w . j  a v a  2 s  .c o m
    mIsRunning = false;

    // attempt to unregister, however we can safely ignore the
    // "IllegalArgumentException: Receiver not registered" called when
    // some hardware experiences a race condition here.
    try {
        unregisterReceiver(mAirplaneModeReceiver);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
}