List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:calendarexportplugin.exporter.GoogleExporter.java
public boolean exportPrograms(Program[] programs, CalendarExportSettings settings, AbstractPluginProgramFormating formatting) { try {/*w w w . ja v a 2 s. c o m*/ boolean uploadedItems = false; mPassword = IOUtilities.xorDecode(settings.getExporterProperty(PASSWORD), 345903).trim(); if (!settings.getExporterProperty(STORE_PASSWORD, false)) { if (!showLoginDialog(settings)) { return false; } } if (!settings.getExporterProperty(STORE_SETTINGS, false)) { if (!showCalendarSettings(settings)) { return false; } } GoogleService myService = new GoogleService("cl", "tvbrowser-tvbrowsercalenderplugin-" + CalendarExportPlugin.getInstance().getInfo().getVersion().toString()); myService.setUserCredentials(settings.getExporterProperty(USERNAME).trim(), mPassword); URL postUrl = new URL("http://www.google.com/calendar/feeds/" + settings.getExporterProperty(SELECTED_CALENDAR) + "/private/full"); SimpleDateFormat formatDay = new SimpleDateFormat("yyyy-MM-dd"); formatDay.setTimeZone(TimeZone.getTimeZone("GMT")); SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm:ss"); formatTime.setTimeZone(TimeZone.getTimeZone("GMT")); ParamParser parser = new ParamParser(); for (Program program : programs) { final String title = parser.analyse(formatting.getTitleValue(), program); // First step: search for event in calendar boolean createEvent = true; CalendarEventEntry entry = findEntryForProgram(myService, postUrl, title, program); if (entry != null) { int ret = JOptionPane.showConfirmDialog(null, mLocalizer.msg("alreadyAvailable", "already available", program.getTitle()), mLocalizer.msg("title", "Add event?"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret != JOptionPane.YES_OPTION) { createEvent = false; } } // add event to calendar if (createEvent) { EventEntry myEntry = new EventEntry(); myEntry.setTitle(new PlainTextConstruct(title)); String desc = parser.analyse(formatting.getContentValue(), program); myEntry.setContent(new PlainTextConstruct(desc)); Calendar c = CalendarToolbox.getStartAsCalendar(program); DateTime startTime = new DateTime(c.getTime(), c.getTimeZone()); c = CalendarToolbox.getEndAsCalendar(program); DateTime endTime = new DateTime(c.getTime(), c.getTimeZone()); When eventTimes = new When(); eventTimes.setStartTime(startTime); eventTimes.setEndTime(endTime); myEntry.addTime(eventTimes); if (settings.getExporterProperty(REMINDER, false)) { int reminderMinutes = 0; try { reminderMinutes = settings.getExporterProperty(REMINDER_MINUTES, 0); } catch (NumberFormatException e) { e.printStackTrace(); } if (settings.getExporterProperty(REMINDER_ALERT, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.ALERT); } if (settings.getExporterProperty(REMINDER_EMAIL, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.EMAIL); } if (settings.getExporterProperty(REMINDER_SMS, false)) { addReminder(myEntry, reminderMinutes, Reminder.Method.SMS); } } if (settings.isShowBusy()) { myEntry.setTransparency(BaseEventEntry.Transparency.OPAQUE); } else { myEntry.setTransparency(BaseEventEntry.Transparency.TRANSPARENT); } // Send the request and receive the response: myService.insert(postUrl, myEntry); uploadedItems = true; } } if (uploadedItems) { JOptionPane.showMessageDialog(CalendarExportPlugin.getInstance().getBestParentFrame(), mLocalizer.msg("exportDone", "Google Export done."), mLocalizer.msg("export", "Export"), JOptionPane.INFORMATION_MESSAGE); } return true; } catch (AuthenticationException e) { ErrorHandler.handle(mLocalizer.msg("loginFailure", "Problems during login to Service.\nMaybe bad username or password?"), e); settings.setExporterProperty(STORE_PASSWORD, false); } catch (Exception e) { ErrorHandler.handle(mLocalizer.msg("commError", "Error while communicating with Google!"), e); } return false; }
From source file:org.remus.marketplace.servlets.SearchListing.java
@Override public void handleRequest(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { String query = arg0.getParameter("query"); String parameter = arg0.getParameter("filters"); arg1.setContentType("text/xml"); int category = 0; String marketId = null;/* w ww . j av a 2s. co m*/ if (parameter != null) { String[] split = parameter.split("\\s"); for (String string : split) { String replace = string.replace("tid:", ""); if (replace != null && replace.trim().length() > 0) { try { category = Integer.parseInt(replace); } catch (NumberFormatException e1) { marketId = replace; } } } } try { category = Integer.parseInt(arg0.getParameter("categoryId")); } catch (NumberFormatException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { JAXBContext newInstance = JAXBContext.newInstance(Marketplace.class, org.remus.marketplace.xml.Market.class); Marketplace marketplace = new Marketplace(); List<Integer> searchNodes = indexService.searchNodes(query, category, marketId); Search search = new Search(); search.setTerm(query); search.setCount(searchNodes.size()); search.setUrl(serverPrefix + "search/apachesolr/" + URLEncoder.encode(query, "UTF-8") + (category != 0 && marketId != null ? "?filters=" : "") + (category != 0 ? "tid:" + category : "") + (marketId != null ? " tid:" + marketId : "")); for (int i = 0, n = Math.min(searchNodes.size(), 10); i < n; i++) { Node findById = nodeDao.findById(searchNodes.get(i)); org.remus.marketplace.xml.Node node = XMLBuilder.buildNode(serverPrefix, findById); search.getNode().add(node); } marketplace.setSearch(search); Marshaller createMarshaller = newInstance.createMarshaller(); XMLSerializer xmlSerializer = XMLBuilder.getXMLSerializer(arg1.getOutputStream()); createMarshaller.marshal(marketplace, xmlSerializer.asContentHandler()); } catch (JAXBException e) { throw new ServletException(e); } }
From source file:cs544.wamp_blog_engine.controller.PostController.java
@InitBinder protected void initBinder(WebDataBinder binder) { // System.out.println("fancy thingssss one"); binder.registerCustomEditor(List.class, "categories", new CustomCollectionEditor(List.class) { @Override/* ww w . ja v a 2 s . c om*/ protected Object convertElement(Object element) { // System.out.println("fancy thingssss"); Integer id = null; if (element instanceof String && !((String) element).equals("")) { //From the JSP 'element' will be a String try { id = Integer.parseInt((String) element); } catch (NumberFormatException e) { System.out.println("Element was " + ((String) element)); e.printStackTrace(); } } else if (element instanceof Integer) { //From the database 'element' will be a Long id = (Integer) element; } return id != null ? categoryTagService.getCategory(id) : null; } }); }
From source file:cs544.wamp_blog_engine.controller.PostController.java
@InitBinder protected void initBinder2(WebDataBinder binder) { // System.out.println("fancy thingssss two"); binder.registerCustomEditor(List.class, "postTags", new CustomCollectionEditor(List.class) { @Override/* w w w. j a va2 s . c om*/ protected Object convertElement(Object element) { // System.out.println("fancy thingssss"); Integer id = null; if (element instanceof String && !((String) element).equals("")) { //From the JSP 'element' will be a String try { id = Integer.parseInt((String) element); } catch (NumberFormatException e) { System.out.println("Element was " + ((String) element)); e.printStackTrace(); } } else if (element instanceof Integer) { //From the database 'element' will be a Long id = (Integer) element; } return id != null ? categoryTagService.getTag(id) : null; } }); }
From source file:com.android.talkback.SpeechController.java
/** * @return The utterance ID, or -1 if the ID is invalid. */// w w w .j ava 2 s.c o m private static int parseUtteranceId(String utteranceId) { // Check for bad utterance ID. This should never happen. if (!utteranceId.startsWith(UTTERANCE_ID_PREFIX)) { LogUtils.log(SpeechController.class, Log.ERROR, "Bad utterance ID: %s", utteranceId); return -1; } try { return Integer.parseInt(utteranceId.substring(UTTERANCE_ID_PREFIX.length())); } catch (NumberFormatException e) { e.printStackTrace(); return -1; } }
From source file:com.android.talkback.SpeechController.java
/** * Attempts to parse a float value from a {@link HashMap} of strings. * * @param params The map to obtain the value from. * @param key The key that the value is assigned to. * @param defaultValue The default value. * @return The parsed float value, or the default value on failure. *///from w w w. jav a 2 s. c o m private static float parseFloatParam(HashMap<String, String> params, String key, float defaultValue) { final String value = params.get(key); if (value == null) { return defaultValue; } try { return Float.parseFloat(value); } catch (NumberFormatException e) { e.printStackTrace(); } return defaultValue; }
From source file:com.ght.cerberus.StatusFragment.java
private float parseZ(String msg) { String[] v = msg.split(":"); if (v.length < 2) { throw new IllegalArgumentException("Could not parse string:" + msg); }// w w w.j a v a2s . c o m try { if (v[0].equalsIgnoreCase("Z")) { float val = Float.parseFloat(v[1]); return val; } } catch (NumberFormatException e) { e.printStackTrace(); } throw new IllegalArgumentException("Could not parse string:" + msg); }
From source file:org.owasp.proxy.http.server.ConversationServiceHttpRequestHandler.java
private StreamingResponse handleLocalRequest(StreamingRequest request) { try {/* w w w . ja v a 2 s . co m*/ String resource = request.getResource(); if ("/".equals(resource)) return getIndexPage(); int q = resource.indexOf('?'); NamedValue[] parameters = null; if (q > -1) { parameters = NamedValue.parse(resource.substring(q + 1), "&", "="); resource = resource.substring(0, q); } if (resource.equals(CONVERSATIONS)) { String since = NamedValue.findValue(parameters, "since"); if (since != null) return listConversations(Integer.parseInt(since)); return listConversations(0); } else if (resource.equals(SUMMARIES)) { String since = NamedValue.findValue(parameters, "since"); if (since != null) return getSummaries(Integer.parseInt(since)); return getSummaries(0); } else if (resource.equals(SUMMARY)) { String id = NamedValue.findValue(parameters, "id"); if (id != null) return getSummary(Integer.parseInt(id)); } else if (resource.equals(REQUEST)) { String id = NamedValue.findValue(parameters, "id"); if (id != null) return getRequest(Integer.parseInt(id)); } else if (resource.equals(REQUEST_HEADER)) { String id = NamedValue.findValue(parameters, "id"); if (id != null) return getRequestHeader(Integer.parseInt(id)); } else if (resource.equals(RESPONSE)) { String id = NamedValue.findValue(parameters, "id"); if (id != null) return getResponse(Integer.parseInt(id)); } else if (resource.equals(RESPONSE_HEADER)) { String id = NamedValue.findValue(parameters, "id"); if (id != null) return getResponseHeader(Integer.parseInt(id)); } else if (resource.equals(REQUEST_CONTENT)) { String id = NamedValue.findValue(parameters, "id"); String decode = NamedValue.findValue(parameters, "decode"); if (id != null) return getRequestContent(Integer.parseInt(id), "true".equals(decode)); } else if (resource.equals(RESPONSE_CONTENT)) { String id = NamedValue.findValue(parameters, "id"); String decode = NamedValue.findValue(parameters, "decode"); if (id != null) return getResponseContent(Integer.parseInt(id), "true".equals(decode)); } } catch (MessageFormatException mfe) { mfe.printStackTrace(); return err_400(); } catch (DataAccessException dae) { dae.printStackTrace(); return err_500(); } catch (NumberFormatException nfe) { nfe.printStackTrace(); return err_400(); } return err_404(); }
From source file:org.kalypso.kalypsomodel1d2d.conv.RMA10S2GmlConv.java
private void interpreteArcLine(final String line) { final RMA10ResultsLineSplitter lStringParser = new RMA10ResultsLineSplitter(line, " \t"); //$NON-NLS-1$ try {/*w w w. j av a 2 s . co m*/ if (lStringParser.getIntSepCounter() == 7) { lStringParser.getFirstSub(); final int id = Integer.parseInt(lStringParser.getNextSub()); final int node1ID = Integer.parseInt(lStringParser.getNextSub()); final int node2ID = Integer.parseInt(lStringParser.getNextSub()); final int elementLeftID = Integer.parseInt(lStringParser.getNextSub()); final int elementRightID = Integer.parseInt(lStringParser.getNextSub()); final int middleNodeID = Integer.parseInt(lStringParser.getNextSub()); m_handler.handleArc(line, id, node1ID, node2ID, elementLeftID, elementRightID, middleNodeID); } else if (lStringParser.getIntSepCounter() == 6) { { lStringParser.getFirstSub(); final int id = Integer.parseInt(lStringParser.getNextSub()); final int node1ID = Integer.parseInt(lStringParser.getNextSub()); final int node2ID = Integer.parseInt(lStringParser.getNextSub()); final int elementLeftID = Integer.parseInt(lStringParser.getNextSub()); final int elementRightID = Integer.parseInt(lStringParser.getNextSub()); m_handler.handleArc(line, id, node1ID, node2ID, elementLeftID, elementRightID, -1); } } } catch (final NumberFormatException e) { e.printStackTrace(); m_handler.handleError(line, EReadError.ILLEGAL_SECTION); } }
From source file:com.amaze.filemanager.asynchronous.asynctasks.LoadFilesListTask.java
private LayoutElementParcelable createListParcelables(HybridFileParcelable baseFile) { if (!dataUtils.isFileHidden(baseFile.getPath())) { String size = ""; long longSize = 0; if (baseFile.isDirectory()) { ma.folder_count++;// ww w . j av a 2 s. com } else { if (baseFile.getSize() != -1) { try { longSize = baseFile.getSize(); size = Formatter.formatFileSize(c, longSize); } catch (NumberFormatException e) { e.printStackTrace(); } } ma.file_count++; } LayoutElementParcelable layoutElement = new LayoutElementParcelable(baseFile.getName(), baseFile.getPath(), baseFile.getPermission(), baseFile.getLink(), size, longSize, false, baseFile.getDate() + "", baseFile.isDirectory(), showThumbs, baseFile.getMode()); return layoutElement; } return null; }