Example usage for java.lang NullPointerException printStackTrace

List of usage examples for java.lang NullPointerException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.google.developers.actions.debugger.CayleyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {//  w ww .  ja va  2s.c o  m
        getActionBar().setDisplayHomeAsUpEnabled(true);
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    setContentView(R.layout.activity_cayley);
    Intent intent = getIntent();
    intent.setAction(intent.getStringExtra(MainActivity.ACTION));
    intent.setComponent(null);
    mIntent = intent;
    mActionType = intent.getStringExtra(MainActivity.ACTION_TYPE);
    if (mActionType.equals("PLAY_ARTIST")) {
        mEditText = (EditText) findViewById(R.id.artist);
        mEditText.setVisibility(View.VISIBLE);
        mEditText.setText(getString(R.string.dual_core));
    } else {
        mEditText = (EditText) findViewById(R.id.genre);
        mEditText.setVisibility(View.VISIBLE);
        mEditText.setText(getString(R.string.nerdcore));
    }
}

From source file:org.ubicompforall.BusTUC.Calc.Calculate.java

public Route[] createRoutesServer(String jsonString, String dest) {
    Route[] routeSuggestions = null;//from   ww w .  j  a  va  2s  .co  m
    try {
        json_obj = new JSONObject(jsonString);
        json_arr = new JSONArray(json_obj.getString("alts"));
        System.out.println("arrayLength: " + json_arr.length());

        if (json_arr != null) {
            int ArrayLength = json_arr.length();
            Log.v("arraylength", "ar:" + ArrayLength);
            // Empty array, which means no routes were found
            if (ArrayLength == 0) {
                routeSuggestions = new Route[1];
                routeSuggestions[0] = new Route();
                routeSuggestions[0].setBusStopName("Bussorakelet");
                return routeSuggestions;
            }
            routeSuggestions = new Route[ArrayLength];
            GeoPoint location;
            for (int i = 0; i < ArrayLength; i++) {

                routeSuggestions[i] = new Route();
                routeSuggestions[i]
                        .setTransfer(Boolean.parseBoolean(json_arr.getJSONObject(i).getString("transfer")));
                routeSuggestions[i].setBusStopNumber(
                        Integer.parseInt(json_arr.getJSONObject(i).getString("busStopNumber")));
                routeSuggestions[i].setArrivalTime(json_arr.getJSONObject(i).getString("arrivalTime"));
                routeSuggestions[i].setBusStopName(json_arr.getJSONObject(i).getString("busStopName"));
                if (routeSuggestions[i].isTransfer() && i < ArrayLength - 1) {
                    System.out.println("Found transfer: " + routeSuggestions[i].getBusStopName() + " dest: "
                            + json_arr.getJSONObject(i + 1).getString("busStopName"));
                    routeSuggestions[i].setDestination(json_arr.getJSONObject(i + 1).getString("busStopName"));
                } else
                    routeSuggestions[i].setDestination(dest);

                routeSuggestions[i].setTravelTime(json_arr.getJSONObject(i).getString("travelTime"));
                routeSuggestions[i]
                        .setBusNumber(Integer.parseInt(json_arr.getJSONObject(i).getString("busNumber")));
                routeSuggestions[i].setWalkingDistance(
                        Integer.parseInt(json_arr.getJSONObject(i).getString("walkingDistance")));

            }
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        Log.v("jsonError", "e:" + e.toString());
        // e.printStackTrace();
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
    return routeSuggestions;
}

From source file:org.cbio.portal.pipelines.foundation.FoundationCompositeProcessor.java

@Override
public CompositeResultBean process(CaseType ct) throws Exception {

    final CompositeResultBean compositeResultBean = new CompositeResultBean();
    try {/*from  w  w w . jav a 2  s .  c  o m*/
        compositeResultBean.setClinicalDataResult(clinicalDataProcessor.process(ct));
        compositeResultBean.setMutationDataResult(mutationDataProcessor.process(ct));
        compositeResultBean.setFusionDataResult(fusionDataProcessor.process(ct));
    } catch (NullPointerException ex) {
        LOG.error("Error processing clinical, fusion, or mutation data for case: " + ct.getCase());
        ex.printStackTrace();
    }

    return compositeResultBean;
}

From source file:com.parallax.server.blocklyprop.services.impl.SecurityServiceImpl.java

public User authenticateLocalUser(Long idUser)
        throws UnknownUserIdException, UserBlockedException, EmailNotConfirmedException {
    try {// ww  w  .  j  a va2s .c  om
        User user = userService.getUser(idUser);
        //            sessionData.get().setUser(user);
        //            sessionData.get().setIdUser(userDao.getUserIdForCloudSessionUserId(user.getId()));
        return user;
    } catch (NullPointerException npe) {
        npe.printStackTrace();
        throw npe;
    } catch (ServerException se) {
        return null;
    }
}

From source file:models.GeoModel.java

private ArrayList<Address> search(String places) {
    //parser rhe return JSON
    ArrayList<Address> addresses = new ArrayList<Address>();
    JSONParser parser = new JSONParser();

    String json = this.searh(places);

    try {//from w ww . ja  va2  s .c  o m
        JSONObject response = (JSONObject) parser.parse(json);

        JSONObject contentList = (JSONObject) response.get("content");

        for (int i = 0; i < contentList.size(); i++) {
            JSONObject context = (JSONObject) contentList.get(String.valueOf(i));

            JSONObject postage = (JSONObject) context.get("postage");
            String address = (String) context.get("address");
            JSONObject location = (JSONObject) context.get("location");

            Address addr;
            addr = new Address();

            addr.addr = address;
            addr.postcode = postage.get("postcode").toString();
            addr.town = postage.get("town").toString();
            try {
                addr.lat = Double.parseDouble(location.get("lat").toString());
                addr.lng = Double.parseDouble(location.get("lng").toString());
            } catch (NullPointerException err) {
                err.printStackTrace();
            }
            addresses.add(addr);

        }

    } catch (Exception err) {
        err.printStackTrace();
    }

    return addresses;

}

From source file:com.parallax.server.blocklyprop.services.impl.SecurityServiceImpl.java

@Override
public User authenticateLocalUser(String email, String password)
        throws UnknownUserException, UserBlockedException, EmailNotConfirmedException,
        InsufficientBucketTokensException, WrongAuthenticationSourceException {
    try {/*from www .  jav a  2 s .c om*/
        User user = authenticateService.authenticateLocalUser(email, password);
        //            sessionData.get().setUser(user);
        //            sessionData.get().setIdUser(userDao.getUserIdForCloudSessionUserId(user.getId()));
        return user;
    } catch (NullPointerException npe) {
        npe.printStackTrace();
        throw npe;
    } catch (ServerException se) {
        return null;
    }
}

From source file:com.codepiex.droidlibx.permission.PermissionRequestor.java

private boolean requestPermissions(Activity activity, String[] permissions) {
    boolean status = false;
    try {//from   ww  w  .  j a  v a2  s  .  co  m
        ActivityCompat.requestPermissions(activity, permissions, requestCode);
        status = true;
    } catch (NullPointerException e) {
        e.printStackTrace();
        Log.e(TAG, e.getMessage() + " At requestPermissions(...) of PermissionRequestor");
    }
    return status;
}

From source file:com.inc.playground.playground.MyGcmListenerService.java

/**
 * Called when message is received./*from w w  w  .  ja v  a2s.c  o m*/
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {
    String message = data.getString("message");
    String title = data.getString("title");
    JSONObject responseJSON = null;
    if (!title.contains("canceled")) {
        String eventToDisplay = data.getString("more");
        try {
            responseJSON = new JSONObject(eventToDisplay);
        } catch (JSONException e) {
            e.printStackTrace();
        } catch (NullPointerException nPoitExc) {
            nPoitExc.printStackTrace();
        }
        Log.d(TAG, "more: " + eventToDisplay);
    }

    Log.d(TAG, "From: " + from);
    Log.d(TAG, "Message: " + message);
    sendNotification(message, title, responseJSON);

    //        if(eventToDisplay!=null){

    //        }

    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        // normal downstream message.
    }

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */

    // [END_EXCLUDE]
}

From source file:com.softminds.matrixcalculator.base_fragments.VariableListAdd.java

private void AddToQueue(MatrixV2 click) {
    try {//  w w  w.  j  a v  a2  s  . c  o m
        @SuppressWarnings("ConstantConditions") //to suppress the null pointer exception of the  textview
        TextView textView = getParentFragment().getView().findViewById(R.id.AdditionStatus);
        String Initial = textView.getText().toString();
        if (Initial.isEmpty()) {
            textView.setText(click.getName());
            ((GlobalValues) getActivity().getApplication()).MatrixQueue.add(click);
        } else {
            String Complete = Initial + " + " + click.getName();
            textView.setText(Complete);
            ((GlobalValues) getActivity().getApplication()).MatrixQueue.add(click);
        }
    } catch (NullPointerException e) {
        Log.d("AddToQueue", "Exception raised, cannot get textview from parent fragment");
        e.printStackTrace();
    }

}

From source file:com.softminds.matrixcalculator.base_fragments.VariableListSub.java

private void AddToQueue(MatrixV2 click) {
    try {//  w w  w . j  a v a2 s  .co  m
        @SuppressWarnings("ConstantConditions") //to suppress the null pointer exception of the  textview
        TextView textView = getParentFragment().getView().findViewById(R.id.AdditionStatus);
        String Initial = textView.getText().toString();
        if (Initial.isEmpty()) {
            textView.setText(click.getName());
            ((GlobalValues) getActivity().getApplication()).MatrixQueue.add(click);
        } else {
            String Complete = Initial + " - " + click.getName();
            textView.setText(Complete);
            ((GlobalValues) getActivity().getApplication()).MatrixQueue.add(click);
        }
    } catch (NullPointerException e) {
        Log.d("AddToQueue", "Exception raised, cannot get textview from parent fragment");
        e.printStackTrace();
    }

}