List of usage examples for java.lang NullPointerException printStackTrace
public void printStackTrace()
From source file:org.prom5.analysis.performance.PerformanceLogReplayResult.java
/** * Calculates the average, min ad max throughput time out of the throughput times of all * traces in piList. Next to this, the arrival rate is calculated. * All metrics are based on the process instances in piList only * * @param piList ArrayList: the process instances used * @param fitOption int: the fit option used (how to deal with non-conformance) * @throws Exception/*from www. j av a2s .com*/ */ public void calculateMetrics(ArrayList piList, int fitOption) throws Exception { properFrequency = 0; timeStats.clear(); arrivalStats.clear(); ArrayList arrivalDates = new ArrayList(); ListIterator lit = piList.listIterator(); while (lit.hasNext()) { ExtendedLogTrace currentTrace = (ExtendedLogTrace) lit.next(); if (currentTrace.hasProperlyTerminated() && currentTrace.hasSuccessfullyExecuted()) { properFrequency++; } try { long tp = (currentTrace.getEndDate().getTime() - currentTrace.getBeginDate().getTime()); if (fitOption == 0) { //timeStats based on all traces timeStats.addValue(tp); arrivalDates.add(currentTrace.getBeginDate()); } if (currentTrace.hasProperlyTerminated() && currentTrace.hasSuccessfullyExecuted()) { if (fitOption == 1) { //timeStats based on fitting traces only timeStats.addValue(tp); arrivalDates.add(currentTrace.getBeginDate()); } } } catch (NullPointerException ex) { ex.printStackTrace(); } } Date[] arrivals = (Date[]) arrivalDates.toArray(new Date[0]); //make sure arrivaldates are sorted Arrays.sort(arrivals); if (arrivals.length > 1) { for (int i = 1; i < arrivals.length; i++) { long t1 = arrivals[i].getTime(); long t2 = arrivals[i - 1].getTime(); long iat = arrivals[i].getTime() - arrivals[i - 1].getTime(); if (iat >= 0) { arrivalStats.addValue(iat); } } } }
From source file:com.example.d062654.faciliman._2_IncidentPicture.java
private void previewCapturedImage(Intent data) { try {// w ww. j ava 2 s.c o m //Bundle extras = data.getExtras(); imgPreview.setVisibility(View.VISIBLE); int targetW = imgPreview.getWidth(); int targetH = imgPreview.getHeight(); // bimatp factory BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(mCurrentPhotoPath, options); int photoW = options.outWidth; int photoH = options.outHeight; int scaleFactor = Math.min(photoW / targetW, photoH / targetH); options.inJustDecodeBounds = false; options.inSampleSize = scaleFactor; options.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, options); Matrix matrix = new Matrix(); matrix.postRotate(90); Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(), true); Bitmap rotatedBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix, true); imgPreview.setImageBitmap(rotatedBitmap); } catch (NullPointerException e) { e.printStackTrace(); } }
From source file:com.phildatoon.weather.YahooWeather.java
@Override public void gotLocation(Location location) { try {/* w w w . j av a 2 s .c om*/ final String lat = String.valueOf(location.getLatitude()); final String lon = String.valueOf(location.getLongitude()); // queryYahooWeather(mContext, lat, lon, this); final WeatherQueryByLatLonTask task = new WeatherQueryByLatLonTask(); task.execute(new String[] { lat, lon }); } catch (NullPointerException e) { e.printStackTrace(); } }
From source file:com.YahooWeather.utils.YahooWeatherUtils.java
private WeatherInfo parseWeatherInfo(Context context, Document doc) { WeatherInfo weatherInfo = new WeatherInfo(); try {//from ww w .java 2s.c o m Node titleNode = doc.getElementsByTagName("title").item(0); if (titleNode.getTextContent().equals(YAHOO_WEATHER_ERROR)) { return null; } weatherInfo.setWeatherurl(doc.getElementsByTagName("link").item(0).getTextContent()); 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()); Node forecast1ConditionNode = doc.getElementsByTagName("yweather:forecast").item(0); weatherInfo.setForecast1Code( Integer.parseInt(forecast1ConditionNode.getAttributes().getNamedItem("code").getNodeValue())); weatherInfo .setForecast1Text(forecast1ConditionNode.getAttributes().getNamedItem("text").getNodeValue()); weatherInfo .setForecast1Date(forecast1ConditionNode.getAttributes().getNamedItem("date").getNodeValue()); weatherInfo.setForecast1Day(forecast1ConditionNode.getAttributes().getNamedItem("day").getNodeValue()); weatherInfo.setForecast1TempHighF( Integer.parseInt(forecast1ConditionNode.getAttributes().getNamedItem("high").getNodeValue())); weatherInfo.setForecast1TempLowF( Integer.parseInt(forecast1ConditionNode.getAttributes().getNamedItem("low").getNodeValue())); Node forecast2ConditionNode = doc.getElementsByTagName("yweather:forecast").item(1); weatherInfo.setForecast2Code( Integer.parseInt(forecast2ConditionNode.getAttributes().getNamedItem("code").getNodeValue())); weatherInfo .setForecast2Text(forecast2ConditionNode.getAttributes().getNamedItem("text").getNodeValue()); weatherInfo .setForecast2Date(forecast2ConditionNode.getAttributes().getNamedItem("date").getNodeValue()); weatherInfo.setForecast2Day(forecast2ConditionNode.getAttributes().getNamedItem("day").getNodeValue()); weatherInfo.setForecast2TempHighF( Integer.parseInt(forecast2ConditionNode.getAttributes().getNamedItem("high").getNodeValue())); weatherInfo.setForecast2TempLowF( Integer.parseInt(forecast2ConditionNode.getAttributes().getNamedItem("low").getNodeValue())); Node forecast3ConditionNode = doc.getElementsByTagName("yweather:forecast").item(2); weatherInfo.setForecast3Code( Integer.parseInt(forecast3ConditionNode.getAttributes().getNamedItem("code").getNodeValue())); weatherInfo .setForecast3Text(forecast3ConditionNode.getAttributes().getNamedItem("text").getNodeValue()); weatherInfo .setForecast3Date(forecast3ConditionNode.getAttributes().getNamedItem("date").getNodeValue()); weatherInfo.setForecast3Day(forecast3ConditionNode.getAttributes().getNamedItem("day").getNodeValue()); weatherInfo.setForecast3TempHighF( Integer.parseInt(forecast3ConditionNode.getAttributes().getNamedItem("high").getNodeValue())); weatherInfo.setForecast3TempLowF( Integer.parseInt(forecast3ConditionNode.getAttributes().getNamedItem("low").getNodeValue())); Node forecast4ConditionNode = doc.getElementsByTagName("yweather:forecast").item(3); weatherInfo.setForecast4Code( Integer.parseInt(forecast4ConditionNode.getAttributes().getNamedItem("code").getNodeValue())); weatherInfo .setForecast4Text(forecast4ConditionNode.getAttributes().getNamedItem("text").getNodeValue()); weatherInfo .setForecast4Date(forecast4ConditionNode.getAttributes().getNamedItem("date").getNodeValue()); weatherInfo.setForecast4Day(forecast4ConditionNode.getAttributes().getNamedItem("day").getNodeValue()); weatherInfo.setForecast4TempHighF( Integer.parseInt(forecast4ConditionNode.getAttributes().getNamedItem("high").getNodeValue())); weatherInfo.setForecast4TempLowF( Integer.parseInt(forecast4ConditionNode.getAttributes().getNamedItem("low").getNodeValue())); Node forecast5ConditionNode = doc.getElementsByTagName("yweather:forecast").item(4); weatherInfo.setForecast5Code( Integer.parseInt(forecast5ConditionNode.getAttributes().getNamedItem("code").getNodeValue())); weatherInfo .setForecast5Text(forecast5ConditionNode.getAttributes().getNamedItem("text").getNodeValue()); weatherInfo .setForecast5Date(forecast5ConditionNode.getAttributes().getNamedItem("date").getNodeValue()); weatherInfo.setForecast5Day(forecast5ConditionNode.getAttributes().getNamedItem("day").getNodeValue()); weatherInfo.setForecast5TempHighF( Integer.parseInt(forecast5ConditionNode.getAttributes().getNamedItem("high").getNodeValue())); weatherInfo.setForecast5TempLowF( Integer.parseInt(forecast5ConditionNode.getAttributes().getNamedItem("low").getNodeValue())); } catch (NullPointerException e) { e.printStackTrace(); Toast.makeText(context, "Parse XML failed - Unrecognized Tag", Toast.LENGTH_SHORT).show(); weatherInfo = null; } return weatherInfo; }
From source file:sos.net.SOSFTPS.java
public void connect(String ftpHost, int ftpPort1) throws SocketException, IOException { initProxy();//from ww w . j av a 2 s . c o m if (isConnected() == false) { this.setSocketFactory(new SOSSSLSocketFactory(getProxyHost(), getProxyPort(), getSecurityProtocol())); // this.setSocketFactory(new SOSSSLSocketFactory()); try { super.connect(ftpHost, ftpPort1); } catch (NullPointerException e) { throw new SocketException( "Connect failed! Probably HTTP proxy in use or the entered ftps port is invalid: " + e.toString()); } catch (Exception e) { e.printStackTrace(); throw new SocketException("Connect failed, reason: " + e.toString()); } this.sendCommand("PBSZ 0"); this.sendCommand("PROT P"); this.enterLocalPassiveMode(); } }
From source file:org.pentaho.reporting.engine.classic.extensions.datasources.olap4j.DenormalizedMDXTableModel.java
public Object getValueAt(final int rowIndex, final int columnIndex) { if (columnIndex >= columnNames.size()) { throw new IndexOutOfBoundsException(); }//from w w w .j a v a 2 s.c o m if (isMeasureColumn(columnIndex)) { final List<Integer> cellKey = computeCellKey(rowIndex); try { final Cell cell = resultSet.getCell(cellKey); if (cell.isNull()) { return null; } return cell.getValue(); } catch (final NullPointerException pe) { pe.printStackTrace(); } } final List<Integer> cellKey = computeCellKey(rowIndex); Member candidateMember = getCandidateMembers(columnIndex, cellKey); if (candidateMember != null) { return candidateMember.getName(); } return null; }
From source file:edu.toronto.cs.ontools.taxonomy.AbstractTaxonomy.java
public int load(File source) { // Make sure we can read the data if (source == null) { return -1; }/*from w w w . j a v a2 s .com*/ // Load data clear(); TermData data = new TermData(); try { BufferedReader in = new BufferedReader(new FileReader(source)); String line; while ((line = in.readLine()) != null) { if (line.trim().equalsIgnoreCase(END_OF_TERM_LIST_MARKER)) { break; } if (line.trim().equalsIgnoreCase(TERM_MARKER)) { if (data.isValid()) { this.createTaxonomyTerm(data); } else if (data.getReplacement() != null) { this.alternateIdMapping.put(data.getId(), data.getReplacement()); } data.clear(); continue; } String pieces[] = line.split(FIELD_NAME_VALUE_SEPARATOR, 2); if (pieces.length != 2) { continue; } String name = pieces[0], value = pieces[1]; data.addTo(name, value); } if (data.isValid()) { this.createTaxonomyTerm(data); } else if (data.getReplacement() != null) { this.alternateIdMapping.put(data.getId(), data.getReplacement()); } in.close(); } catch (NullPointerException ex) { ex.printStackTrace(); System.err.println("File does not exist"); } catch (FileNotFoundException ex) { ex.printStackTrace(); System.err.println("Could not locate source file: " + source.getAbsolutePath()); } catch (IOException ex) { // TODO Auto-generated catch block ex.printStackTrace(); } cleanArcs(); // How much did we load: return size(); }
From source file:com.phildatoon.weather.YahooWeather.java
private void parseForecastInfo(final ForecastInfo forecastInfo, final Document doc, final int index) { try {/* w w w .ja va 2 s. com*/ Node forecast1ConditionNode = doc.getElementsByTagName("yweather:forecast").item(index); forecastInfo.setForecastCode( Integer.parseInt(forecast1ConditionNode.getAttributes().getNamedItem("code").getNodeValue())); forecastInfo .setForecastText(forecast1ConditionNode.getAttributes().getNamedItem("text").getNodeValue()); forecastInfo .setForecastDate(forecast1ConditionNode.getAttributes().getNamedItem("date").getNodeValue()); forecastInfo.setForecastDay(forecast1ConditionNode.getAttributes().getNamedItem("day").getNodeValue()); forecastInfo.setForecastTempHighF( Integer.parseInt(forecast1ConditionNode.getAttributes().getNamedItem("high").getNodeValue())); forecastInfo.setForecastTempLowF( Integer.parseInt(forecast1ConditionNode.getAttributes().getNamedItem("low").getNodeValue())); if (mNeedDownloadIcons) { forecastInfo.setForecastConditionIcon( ImageUtils.getBitmapFromWeb(forecastInfo.getForecastConditionIconURL())); } } catch (NullPointerException e) { e.printStackTrace(); } }
From source file:edu.tcu.gaduo.ihe.iti.ct_transaction.service.NTPClient.java
public Date processResponse(String host) { TimeInfo info = null;/*from w ww . j a v a 2s .c o m*/ try { NTPUDPClient client = new NTPUDPClient(); client.setDefaultTimeout(10000); client.open(); InetAddress hostAddr = InetAddress.getByName(host); info = client.getTime(hostAddr); client.close(); } catch (NullPointerException e) { logger.info(e.toString()); return null; } catch (IOException e) { logger.info(e.toString()); e.printStackTrace(); return null; } message = info.getMessage(); stratum = message.getStratum(); // if (stratum <= 0) refType = "(??)"; else if (stratum == 1) refType = "(??; e.g., GPS)"; // GPS, radio clock, else refType = "(??; e.g. via NTP or SNTP)"; // stratum should be 0..15... logger.info(" Stratum: " + stratum + " " + refType); this.setRefNtpTime(message.getReferenceTimeStamp()); // Originate Time is time request sent by client (t1) this.setOrigNtpTime(message.getOriginateTimeStamp()); // Receive Time is time request received by server (t2) this.setRcvNtpTime(message.getReceiveTimeStamp()); // Transmit time is time reply sent by server (t3) this.setXmitNtpTime(message.getTransmitTimeStamp()); // Destination time is time reply received by client (t4) long destTime = info.getReturnTime(); this.setDestNtpTime(TimeStamp.getNtpTime(destTime)); info.computeDetails(); // compute offset/delay if not already done Long offsetValue = info.getOffset(); Long delayValue = info.getDelay(); this.setDelay(delay = (delayValue == null) ? "N/A" : delayValue.toString()); this.setOffset((offsetValue == null) ? "N/A" : offsetValue.toString()); Date Date = message.getReferenceTimeStamp().getDate(); return Date; }
From source file:ilearn.orb.controller.ProfilesController.java
@RequestMapping(value = "/profiles") public ModelAndView profiles(Locale locale, ModelMap modelMap, HttpSession session) { ModelAndView model = new ModelAndView(); model.setViewName("profiles"); try {//w w w .jav a2s.c om Gson gson = new GsonBuilder().registerTypeAdapter(java.util.Date.class, new UtilDateDeserializer()) .setDateFormat(DateFormat.LONG).create(); User[] students = null; try { String json = UserServices.getProfiles(Integer.parseInt(session.getAttribute("id").toString()), session.getAttribute("auth").toString()); students = gson.fromJson(json, User[].class); } catch (NullPointerException e) { } if (students == null || students.length == 0) { students = HardcodedUsers.defaultStudents(); } modelMap.put("students", students); } catch (NumberFormatException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return model; }