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

public Config() {
    super("cfg.json");

    if (cfg == null) {
        return;//  w w  w  .ja  va  2s . co m
    }

    iconType = new HashMap<String, Integer>();

    try {
        JSONObject json = new JSONObject(cfg);
        iconName = json.getString("name");

        JSONArray arr = json.getJSONArray("type");
        int len = arr.length();
        for (int i = 0; i < len; ++i) {
            JSONObject type = arr.getJSONObject(i);
            iconType.put(type.getString("name"), type.getInt("size"));
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.optimusinfo.elasticpath.cortex.authentication.newaccount.AsyncTaskAddUser.java

@Override
protected void onPostExecute(Integer responseCode) {
    super.onPostExecute(responseCode);
    try {//www . j  a  v a2  s  .  c  o m
        if (responseCode == Constants.ApiResponseCode.REQUEST_SUCCESSFUL_CREATED
                || responseCode == Constants.ApiResponseCode.REQUEST_SUCCESSFUL_UPDATED) {
            mListener.onTaskSuccessful(responseCode);
        } else {
            mListener.onTaskFailed(responseCode);
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:com.optimusinfo.elasticpath.cortex.cart.AsyncTaskAddToCart.java

@Override
protected Integer doInBackground(Void... params) {
    int responseCode = 0;
    try {//from www  . jav a 2s. c  o  m
        JSONObject objInput = new JSONObject();
        objInput.put("quantity", mQuantityToAdd);
        responseCode = Utils.postData(urlAddToCartForm, objInput, accessToken,
                Constants.RequestHeaders.CONTENT_TYPE, Constants.RequestHeaders.AUTHORIZATION_INITIALIZER);
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return responseCode;
}

From source file:com.optimusinfo.elasticpath.cortex.cart.AsyncTaskAddToCart.java

@Override
protected void onPostExecute(Integer responseCode) {
    super.onPostExecute(responseCode);
    try {//from  w  w w .  j  av  a 2s.c o  m
        if (responseCode == Constants.ApiResponseCode.REQUEST_SUCCESSFUL_CREATED
                || responseCode == Constants.ApiResponseCode.REQUEST_SUCCESSFUL_UPDATED) {
            mListener.onTaskSuccessful(responseCode);
        } else {
            mListener.onTaskFailed(responseCode);
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (JsonParseException e) {
        e.printStackTrace();
        mListener.onTaskFailed(Constants.ErrorCodes.ERROR_SERVER);
    }
}

From source file:com.optimusinfo.elasticpath.cortex.profile.address.AsyncTaskUpdateAddress.java

@Override
protected Boolean doInBackground(Void... params) {
    try {//from   w w  w. j  a va2 s . co  m
        if (Utils.isNetworkAvailable(mCurrent)) {
            int responseCode = 0;
            responseCode = Utils.putRequest(URL, objInput, accessToken, headerContentTypeValue,
                    headerContentTypeString, headerAuthorizationTypeString, headerAccessTokenInitializer);
            if (responseCode != 0) {
                mListener.onTaskSuccessful(responseCode);
                return true;
            }
        } else {
            mListener.onTaskFailed(Constants.ErrorCodes.ERROR_NETWORK);
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (JsonParseException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:com.optimusinfo.elasticpath.cortex.cart.AsyncTaskGetCompleteCart.java

@Override
protected String doInBackground(Void... params) {
    String responseCart = null;/*from  w  w w  . ja  va  2s  . co  m*/
    try {
        responseCart = Utils.getJSONFromCortexUrl(URL, accessToken, headerContentTypeValue,
                headerContentTypeString, headerAuthorizationTypeString, headerAccessTokenInitializer);
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return responseCart;
}

From source file:com.hygenics.parser.DropTables.java

/**
 * Public method that calls the drop script
 *//*from w ww .ja v  a 2 s  .co  m*/
public void run() {
    log.info("Checking if Tables Exist");
    if (tables != null) {
        drop();
    } else {
        try {
            throw new NullPointerException("No Tables provided!");
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }
    log.info("Complete");
}

From source file:com.optimusinfo.elasticpath.cortex.checkout.AsyncTaskGetCheckout.java

@Override
protected String doInBackground(Void... params) {
    String responseCheckOut = null;
    try {//from   w  w  w .j  a  v a2s .c o  m

        responseCheckOut = Utils.getJSONFromCortexUrl(URL, accessToken, headerContentTypeValue,
                headerContentTypeString, headerAuthorizationTypeString, headerAccessTokenInitializer);

    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return responseCheckOut;
}

From source file:com.optimusinfo.elasticpath.cortex.cart.AsyncTaskGetCompleteCart.java

@Override
protected void onPostExecute(String responseCart) {
    super.onPostExecute(responseCart);
    try {//  w w w  .  jav  a  2s  . c om
        if (responseCart != null && responseCart.length() != 0) {
            if (0 == responseCart.compareTo(Integer.toString(Constants.ApiResponseCode.UNAUTHORIZED_ACCESS))) {
                mListener.onAuthenticationFailed();
            } else {

                mListener.onTaskSuccessful(new Gson().fromJson(responseCart, CartModel.class));
            }
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (JsonParseException e) {
        e.printStackTrace();
        mListener.onTaskFailed(Constants.ErrorCodes.ERROR_SERVER);
    }
}

From source file:com.optimusinfo.elasticpath.cortex.cart.AsyncTaskUpdateCartItem.java

@Override
protected void onPostExecute(Integer responseCode) {
    super.onPostExecute(responseCode);
    try {//from   w w w  .  j a  va2 s .c om
        if (responseCode != 0) {
            mListener.onTaskSuccessful(responseCode);
        } else {
            mListener.onTaskFailed(responseCode);
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    } catch (JsonParseException e) {
        e.printStackTrace();
        mListener.onTaskFailed(Constants.ErrorCodes.ERROR_SERVER);
    }
}