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.teleca.jamendo.api.impl.JamendoGet2ApiImpl.java

@Override
public Radio[] getRadiosByIdstr(String idstr) throws JSONException, WSError {
    try {/*from ww  w .  j a v  a 2 s  .co m*/
        String jsonString = doGet("id+idstr+name+image/radio/json/?idstr=" + idstr);
        return RadioFunctions.getRadios(new JSONArray(jsonString));
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new JSONException(e.getLocalizedMessage());
    }
}

From source file:com.teleca.jamendo.api.impl.JamendoGet2ApiImpl.java

@Override
public Radio[] getRadiosByIds(int[] id) throws JSONException, WSError {
    try {//from w ww .  j  a  va  2s . c  om
        String id_query = Caller.createStringFromIds(id);
        String jsonString = doGet("id+idstr+name+image/radio/json/?id=" + id_query);
        return RadioFunctions.getRadios(new JSONArray(jsonString));
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new JSONException(e.getLocalizedMessage());
    }
}

From source file:com.teleca.jamendo.api.impl.JamendoGet2ApiImpl.java

@Override
public Review[] getAlbumReviews(Album album) throws JSONException, WSError {
    try {/*from  w  w w .ja  v a2s  .co  m*/
        String jsonString = doGet(
                "id+name+text+rating+lang+user_name+user_image/review/json/?album_id=" + album.getId());
        JSONArray jsonReviewAlbums = new JSONArray(jsonString);
        return ReviewFunctions.getReviews(jsonReviewAlbums);
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new JSONException(e.getLocalizedMessage());
    }
}

From source file:com.teleca.jamendo.api.impl.JamendoGet2ApiImpl.java

@Override
public Album[] getPopularAlbumsWeek() throws JSONException, WSError {

    String jsonString = doGet("id+name+url+image+rating+artist_name/album/json/?n=20&order=ratingweek_desc");
    if (jsonString == null)
        return null;

    try {//from   w w w. ja va2  s  .  com
        JSONArray jsonArrayAlbums = new JSONArray(jsonString);
        return AlbumFunctions.getAlbums(jsonArrayAlbums);
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new JSONException(e.getLocalizedMessage());
    }
}

From source file:net.dian1.player.api.impl.JamendoGet2ApiImpl.java

@Override
public Music[] getTracksByTracksId(int[] id, String encoding) throws JSONException, WSError {
    if (id == null)
        return null;

    String id_query = Caller.createStringFromIds(id);
    try {//from   w  w  w .j a va  2s .c om
        String jsonString = doGet("id+numalbum+name+duration+rating+url+stream/track/json/?streamencoding="
                + encoding + "&n=" + id.length + "&id=" + id_query);
        JSONArray jsonArrayTracks = new JSONArray(jsonString);
        return getTracks(jsonArrayTracks, false);
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new JSONException(e.getLocalizedMessage());
    }
}

From source file:com.example.apis.ifashion.YahooWeather.java

private WeatherInfo parseWeatherInfo(Context context, Document doc) {
    WeatherInfo weatherInfo = new WeatherInfo();
    try {/* w ww  .  j a  va2 s.co m*/

        Node titleNode = doc.getElementsByTagName("title").item(0);

        if (titleNode.getTextContent().equals(YAHOO_WEATHER_ERROR)) {
            return null;
        }

        weatherInfo.setTitle(titleNode.getTextContent());
        weatherInfo.setDescription(doc.getElementsByTagName("description").item(0).getTextContent());
        weatherInfo.setLanguage(doc.getElementsByTagName("language").item(0).getTextContent());
        weatherInfo.setLastBuildDate(doc.getElementsByTagName("lastBuildDate").item(0).getTextContent());

        Node locationNode = doc.getElementsByTagName("yweather:location").item(0);
        weatherInfo.setLocationCity(locationNode.getAttributes().getNamedItem("city").getNodeValue());
        weatherInfo.setLocationRegion(locationNode.getAttributes().getNamedItem("region").getNodeValue());
        weatherInfo.setLocationCountry(locationNode.getAttributes().getNamedItem("country").getNodeValue());

        Node windNode = doc.getElementsByTagName("yweather:wind").item(0);
        weatherInfo.setWindChill(windNode.getAttributes().getNamedItem("chill").getNodeValue());
        weatherInfo.setWindDirection(windNode.getAttributes().getNamedItem("direction").getNodeValue());
        weatherInfo.setWindSpeed(windNode.getAttributes().getNamedItem("speed").getNodeValue());

        Node atmosphereNode = doc.getElementsByTagName("yweather:atmosphere").item(0);
        weatherInfo
                .setAtmosphereHumidity(atmosphereNode.getAttributes().getNamedItem("humidity").getNodeValue());
        weatherInfo.setAtmosphereVisibility(
                atmosphereNode.getAttributes().getNamedItem("visibility").getNodeValue());
        weatherInfo
                .setAtmospherePressure(atmosphereNode.getAttributes().getNamedItem("pressure").getNodeValue());
        weatherInfo.setAtmosphereRising(atmosphereNode.getAttributes().getNamedItem("rising").getNodeValue());

        Node astronomyNode = doc.getElementsByTagName("yweather:astronomy").item(0);
        weatherInfo.setAstronomySunrise(astronomyNode.getAttributes().getNamedItem("sunrise").getNodeValue());
        weatherInfo.setAstronomySunset(astronomyNode.getAttributes().getNamedItem("sunset").getNodeValue());

        weatherInfo.setConditionTitle(doc.getElementsByTagName("title").item(2).getTextContent());
        weatherInfo.setConditionLat(doc.getElementsByTagName("geo:lat").item(0).getTextContent());
        weatherInfo.setConditionLon(doc.getElementsByTagName("geo:long").item(0).getTextContent());

        Node currentConditionNode = doc.getElementsByTagName("yweather:condition").item(0);
        weatherInfo.setCurrentCode(
                Integer.parseInt(currentConditionNode.getAttributes().getNamedItem("code").getNodeValue()));
        weatherInfo.setCurrentText(currentConditionNode.getAttributes().getNamedItem("text").getNodeValue());
        weatherInfo.setCurrentTempF(
                Integer.parseInt(currentConditionNode.getAttributes().getNamedItem("temp").getNodeValue()));
        weatherInfo.setCurrentConditionDate(
                currentConditionNode.getAttributes().getNamedItem("date").getNodeValue());

        if (mNeedDownloadIcons) {
            weatherInfo.setCurrentConditionIcon(
                    ImageUtils.getBitmapFromWeb(weatherInfo.getCurrentConditionIconURL()));
        }

        for (int i = 0; i < FORECAST_INFO_MAX_SIZE; i++) {
            this.parseForecastInfo(weatherInfo.getForecastInfoList().get(i), doc, i);
        }

    } catch (NullPointerException e) {
        e.printStackTrace();
        Toast.makeText(context, "Parse XML failed - Unrecognized Tag", Toast.LENGTH_SHORT).show();
        weatherInfo = null;
    }

    return weatherInfo;
}

From source file:com.teleca.jamendo.api.impl.JamendoGet2ApiImpl.java

@Override
public Track[] getTracksByTracksId(int[] id, String encoding) throws JSONException, WSError {
    if (id == null)
        return null;

    String id_query = Caller.createStringFromIds(id);
    try {/*from w  ww  .ja v  a 2s  . c  om*/
        String jsonString = doGet("id+numalbum+name+duration+rating+url+stream/track/json/?streamencoding="
                + encoding + "&n=" + id.length + "&id=" + id_query);
        JSONArray jsonArrayTracks = new JSONArray(jsonString);
        return getTracks(jsonArrayTracks, false);
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new JSONException(e.getLocalizedMessage());
    }
}

From source file:net.dian1.player.api.impl.JamendoGet2ApiImpl.java

@Override
public Music[] getAlbumTracks(Album album, String encoding, int count, int page) throws JSONException, WSError {
    try {//  w w  w .  j a  v  a 2s.co m
        String pagination = "&n=all";
        if (count != 0 && page != 0) {
            pagination = "&n=" + count + "&pn=" + page;
        }
        String jsonString = doGet("numalbum+id+name+duration+rating+url+stream/track/json/?album_id="
                + album.getId() + "&streamencoding=" + encoding + pagination);
        JSONArray jsonArrayTracks = new JSONArray(jsonString);

        return getTracks(jsonArrayTracks, true);
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new JSONException(e.getLocalizedMessage());
    }
}

From source file:com.teleca.jamendo.api.impl.JamendoGet2ApiImpl.java

@Override
public Track[] getAlbumTracks(Album album, String encoding, int count, int page) throws JSONException, WSError {
    try {//  w  w w .  j a  v  a 2s.  c  om
        String pagination = "&n=all";
        if (count != 0 && page != 0) {
            pagination = "&n=" + count + "&pn=" + page;
        }
        String jsonString = doGet("numalbum+id+name+duration+rating+url+stream/track/json/?album_id="
                + album.getId() + "&streamencoding=" + encoding + pagination);
        JSONArray jsonArrayTracks = new JSONArray(jsonString);

        return getTracks(jsonArrayTracks, true);
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new JSONException(e.getLocalizedMessage());
    }
}

From source file:com.teleca.jamendo.api.impl.JamendoGet2ApiImpl.java

@Override
public Album[] getAlbumsByTracksId(int[] id) throws JSONException, WSError {
    if (id == null)
        return null;

    String id_query = Caller.createStringFromIds(id);

    try {//from w ww.j a va  2  s.  co  m
        String jsonString = doGet(
                "id+name+url+image+rating+artist_name/album/json/?n=" + id.length + "&track_id=" + id_query);
        JSONArray jsonArrayAlbums = new JSONArray(jsonString);
        return AlbumFunctions.getAlbums(jsonArrayAlbums);
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new JSONException(e.getLocalizedMessage());
    }
}