List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:com.spstudio.modules.sales.service.impl.SaleServiceImpl.java
@Override // /*from w w w . j ava2 s.c om*/ public Float getGlobalDepositRate() { SystemConfig config = configService.findModuleSingleConfig(Configuration.SALE_MODULE_NAME, Configuration.CONFIG_GLOBAL_DEPOSIT_BONUSRATE); if (config == null) { return 0.0f; } try { float bonusRate = Float.valueOf(config.getConfigValue()); return bonusRate; } catch (NumberFormatException ex) { ex.printStackTrace(); return 0.0f; } }
From source file:org.akaza.openclinica.control.managestudy.DefineStudyEventServlet.java
/** * Processes the 'define study event' request * /*w ww.jav a2 s .c o m*/ */ @Override public void processRequest() throws Exception { FormProcessor fpr = new FormProcessor(request); // logger.info("actionName*******" + fpr.getString("actionName")); // logger.info("pageNum*******" + fpr.getString("pageNum")); String actionName = request.getParameter("actionName"); ArrayList crfsWithVersion = (ArrayList) session.getAttribute("crfsWithVersion"); if (crfsWithVersion == null) { crfsWithVersion = new ArrayList(); CRFDAO cdao = new CRFDAO(sm.getDataSource()); CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource()); ArrayList crfs = (ArrayList) cdao.findAllByStatus(Status.AVAILABLE); for (int i = 0; i < crfs.size(); i++) { CRFBean crf = (CRFBean) crfs.get(i); ArrayList versions = cvdao.findAllByCRFId(crf.getId()); if (!versions.isEmpty()) { crfsWithVersion.add(crf); } } session.setAttribute("crfsWithVersion", crfsWithVersion); } if (StringUtil.isBlank(actionName)) { StudyEventDefinitionBean sed = new StudyEventDefinitionBean(); sed.setStudyId(currentStudy.getId()); session.setAttribute("definition", sed); session.removeAttribute("tmpCRFIdMap"); forwardPage(Page.DEFINE_STUDY_EVENT1); } else { if ("confirm".equalsIgnoreCase(actionName)) { confirmWholeDefinition(); } else if ("submit".equalsIgnoreCase(actionName)) { // put a try catch in here to fix task # 1642 in Mantis, added // 092007 tbh try { Integer nextAction = Integer.valueOf(request.getParameter("nextAction")); if (nextAction != null) { if (nextAction.intValue() == 1) { session.removeAttribute("definition"); addPageMessage(respage.getString("the_new_event_definition_creation_cancelled")); forwardPage(Page.LIST_DEFINITION_SERVLET); } else if (nextAction.intValue() == 2) { submitDefinition(); //forwardPage(Page.LIST_DEFINITION_SERVLET); ArrayList pageMessages = (ArrayList) request.getAttribute(PAGE_MESSAGE); session.setAttribute("pageMessages", pageMessages); response.sendRedirect( request.getContextPath() + Page.MANAGE_STUDY_MODULE.getFileName()); //forwardPage(Page.MANAGE_STUDY_MODULE); // request.getRequestDispatcher("/pages/studymodule").forward(request, response); // org.akaza.openclinica.service.sdv.SDVUtil sdvUtil = new org.akaza.openclinica.service.sdv.SDVUtil(); // sdvUtil.forwardRequestFromController(request,response,"http://localhost:8080/OpenClinica-SNAPSHOT/pages/studymodule"); //This last part is necessary because the compiler will complain about the return; //statement in the absence of the "if" [the following statements are "reachable"] // boolean redir = "y".equalsIgnoreCase((String)request.getParameter("r")); // if(redir) { return;} } else { logger.debug("actionName ==> 3"); submitDefinition(); StudyEventDefinitionBean sed = new StudyEventDefinitionBean(); sed.setStudyId(currentStudy.getId()); session.setAttribute("definition", sed); forwardPage(Page.DEFINE_STUDY_EVENT1); } } } catch (NumberFormatException e) { e.printStackTrace(); addPageMessage(respage.getString("the_new_event_definition_creation_cancelled")); forwardPage(Page.LIST_DEFINITION_SERVLET); } catch (NullPointerException e) { e.printStackTrace(); addPageMessage(respage.getString("the_new_event_definition_creation_cancelled")); forwardPage(Page.LIST_DEFINITION_SERVLET); } // above added 092007 tbh } else if ("next".equalsIgnoreCase(actionName)) { Integer pageNumber = Integer.valueOf(request.getParameter("pageNum")); if (pageNumber != null) { if (pageNumber.intValue() == 2) { String nextListPage = request.getParameter("next_list_page"); if (nextListPage != null && nextListPage.equalsIgnoreCase("true")) { confirmDefinition1(); } else { confirmDefinition2(); } } else { confirmDefinition1(); } } else { if (session.getAttribute("definition") == null) { StudyEventDefinitionBean sed = new StudyEventDefinitionBean(); sed.setStudyId(currentStudy.getId()); session.setAttribute("definition", sed); } forwardPage(Page.DEFINE_STUDY_EVENT1); } } } }
From source file:org.apache.xml.security.test.encryption.XMLCipherTester.java
private int index() { int result = -1; try {/*from w w w . j a v a 2s. co m*/ result = Integer.parseInt(elementIndex); } catch (NumberFormatException nfe) { nfe.printStackTrace(); System.exit(-1); } return (result); }
From source file:com.spstudio.modules.sales.service.impl.SaleServiceImpl.java
@Override // ?/* ww w . j a va 2 s . c o m*/ public Float getDepositRate(MemberType memberType) { List<SystemConfig> configs = configService.findModuleConfig(Configuration.SALE_MODULE_NAME, Configuration.CONFIG_MEMBER_TYPE_DEPOSIT_BONUSRATE); if (configs == null || configs.size() == 0) { return getGlobalDepositRate(); } for (SystemConfig config : configs) { String condition = config.getConfigCondition(); if (condition.startsWith(ConfigConditions.EQUAL)) { String memberTypeId = condition.replace(ConfigConditions.EQUAL, ""); if (memberType.getMemberTypeId().equalsIgnoreCase(memberTypeId)) { try { float bonusRate = Float.valueOf(config.getConfigValue()); return bonusRate; } catch (NumberFormatException ex) { ex.printStackTrace(); } } } } return getGlobalDepositRate(); }
From source file:org.matsim.pt2matsim.gtfs.GtfsFeedImpl.java
/** * Loads the frequencies (if available) and adds them to their respective trips in {@link #routes}. * <p/>//w w w .j a v a 2 s . c om * <br/><br/> * frequencies.txt <i>[https://developers.google.com/transit/gtfs/reference]</i><br/> * Headway (time between trips) for routes with variable frequency of service. */ protected void loadFrequencies() { log.info("Looking for frequencies.txt"); // frequencies are optional try { CSVReader reader = createCSVReader(root + GtfsDefinitions.Files.FREQUENCIES.fileName); String[] header = reader.readNext(); Map<String, Integer> col = getIndices(header, GtfsDefinitions.Files.FREQUENCIES.columns, GtfsDefinitions.Files.FREQUENCIES.optionalColumns); String[] line = reader.readNext(); while (line != null) { usesFrequencies = true; // frequencies file might exists but could be empty for (Route actualGtfsRoute : routes.values()) { Trip trip = actualGtfsRoute.getTrips().get(line[col.get(GtfsDefinitions.TRIP_ID)]); if (trip != null) { try { Frequency newFreq = new FrequencyImpl( (int) Time.parseTime(line[col.get(GtfsDefinitions.START_TIME)].trim()), (int) Time.parseTime(line[col.get(GtfsDefinitions.END_TIME)].trim()), Integer.parseInt(line[col.get(GtfsDefinitions.HEADWAY_SECS)])); ((TripImpl) trip).addFrequency(newFreq); } catch (NumberFormatException e) { e.printStackTrace(); } } } line = reader.readNext(); } reader.close(); if (usesFrequencies) { log.info("... frequencies.txt loaded"); } else { log.info("... frequencies.txt has no entries"); } } catch (FileNotFoundException e) { log.info("... no frequencies file found"); } catch (ArrayIndexOutOfBoundsException e) { throw new RuntimeException("Emtpy line found in frequencies.txt"); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.sonews.daemon.command.OverCommand.java
@Override public void processLine(NNTPConnection conn, final String line, byte[] raw) throws IOException, StorageBackendException { if (conn.getCurrentGroup() == null) { conn.println("412 no newsgroup selected"); } else {//w ww. j av a 2 s . c o m String[] command = line.split(" "); // If no parameter was specified, show information about // the currently selected article(s) if (command.length == 1) { final Article art = conn.getCurrentArticle(); if (art == null) { conn.println("420 no article(s) selected"); return; } conn.println(buildOverview(art, -1)); } // otherwise print information about the specified range else { long artStart; long artEnd = conn.getCurrentGroup().getLastArticleNumber(); String[] nums = command[1].split("-"); if (nums.length >= 1) { try { artStart = Integer.parseInt(nums[0]); } catch (NumberFormatException e) { Log.get().info(e.getMessage()); artStart = Integer.parseInt(command[1]); } } else { artStart = conn.getCurrentGroup().getFirstArticleNumber(); } if (nums.length >= 2) { try { artEnd = Integer.parseInt(nums[1]); } catch (NumberFormatException e) { e.printStackTrace(); } } if (artStart > artEnd) { if (command[0].equalsIgnoreCase("OVER")) { conn.println("423 no articles in that range"); } else { conn.println("224 (empty) overview information follows:"); conn.println("."); } } else { for (long n = artStart; n <= artEnd; n += MAX_LINES_PER_DBREQUEST) { long nEnd = Math.min(n + MAX_LINES_PER_DBREQUEST - 1, artEnd); List<Pair<Long, ArticleHead>> articleHeads = conn.getCurrentGroup().getArticleHeads(n, nEnd); if (articleHeads.isEmpty() && n == artStart && command[0].equalsIgnoreCase("OVER")) { // This reply is only valid for OVER, not for XOVER // command conn.println("423 no articles in that range"); return; } else if (n == artStart) { // XOVER replies this although there is no data // available conn.println("224 overview information follows"); } for (Pair<Long, ArticleHead> article : articleHeads) { String overview = buildOverview(article.getB(), article.getA()); conn.println(overview); } } // for conn.println("."); } } } }
From source file:neembuu.release1.externalImpl.linkhandler.SaveVideoYoutubeLinkHandlerProvider.java
private BasicLinkHandler.Builder saveVideoExtraction(TrialLinkHandler tlh, int retryCount) throws Exception { String url = tlh.getReferenceLinkString(); BasicLinkHandler.Builder linkHandlerBuilder = BasicLinkHandler.Builder.create(); try {/*from w ww . j a va2s. c o m*/ DefaultHttpClient httpClient = NHttpClient.getNewInstance(); String requestUrl = "http://www.save-video.com/download.php?url=" + URLEncoder.encode(url, "UTF-8"); final String responseString = NHttpClientUtils.getData(requestUrl, httpClient); //Set the group name as the name of the video String nameOfVideo = getVideoName(url); String fileName = "text"; linkHandlerBuilder.setGroupName(nameOfVideo); long c_duration = -1; Document doc = Jsoup.parse(responseString); Elements elements = doc.select(".sv-download-links ul li a"); for (Element element : elements) { String singleUrl = element.attr("href"); if (!singleUrl.startsWith("DownloadFile.php")) { fileName = element.text(); singleUrl = Utils.normalize(singleUrl); LOGGER.log(Level.INFO, "Normalized URL: {0}", singleUrl); long length = NHttpClientUtils.calculateLength(singleUrl, httpClient); //LOGGER.log(Level.INFO,"Length: " + length); if (length <= 0) { continue; /*skip this url*/ } BasicOnlineFile.Builder fileBuilder = linkHandlerBuilder.createFile(); try { // finding video/audio length // String dur = StringUtils.stringBetweenTwoStrings(singleUrl, "dur=", "&"); // long duration = (int)(Double.parseDouble(dur)*1000); // if(c_duration < 0 ){ c_duration = duration; } // fileBuilder.putLongPropertyValue(PropertyProvider.LongProperty.MEDIA_DURATION_IN_MILLISECONDS, duration); // LOGGER.log(Level.INFO,"dur="+dur); } catch (NumberFormatException a) { // ignore } try { // finding the quality short name // String type = fileName.substring(fileName.indexOf("(")+1); String type = fileName; fileBuilder.putStringPropertyValue(PropertyProvider.StringProperty.VARIANT_DESCRIPTION, type); LOGGER.log(Level.INFO, "type={0}", type); } catch (Exception a) { a.printStackTrace(); } fileName = nameOfVideo + " " + fileName; fileBuilder.setName(fileName).setUrl(singleUrl).setSize(length).next(); } } for (OnlineFile of : linkHandlerBuilder.getFiles()) { long dur = of.getPropertyProvider() .getLongPropertyValue(PropertyProvider.LongProperty.MEDIA_DURATION_IN_MILLISECONDS); if (dur < 0 && c_duration > 0 && of.getPropertyProvider() instanceof BasicPropertyProvider) { ((BasicPropertyProvider) of.getPropertyProvider()).putLongPropertyValue( PropertyProvider.LongProperty.MEDIA_DURATION_IN_MILLISECONDS, c_duration); } } } catch (Exception ex) { ex.printStackTrace(); } return linkHandlerBuilder; }
From source file:it.wami.map.mongodeploy.OsmSaxHandler.java
/** * //from ww w. j a v a2 s . c om * @param atts the Attributes */ private void processND(Attributes atts) { long[] nodes = (long[]) entry.get(Way.NODES); if (nodes == null) { nodes = new long[1]; } else { long[] tmp = new long[nodes.length + 1]; System.arraycopy(nodes, 0, tmp, 0, nodes.length); nodes = tmp; } try { long ref = Long.parseLong(atts.getValue(Way.ND.REF)); nodes[nodes.length - 1] = ref; entry.remove(Way.NODES); entry.append(Way.NODES, nodes); } catch (NumberFormatException e) { e.printStackTrace(); } }
From source file:im.ene.lab.attiq.ui.activities.ProfileActivity.java
@SuppressWarnings("unused") public void onEventMainThread(DocumentEvent event) { if (event.document != null) { Elements stats = event.document.getElementsByClass("userActivityChart_stats"); Element statBlock;//from www .ja va 2 s .co m if (!UIUtil.isEmpty(stats) && (statBlock = stats.first()) != null) { Elements statElements = statBlock.children(); Integer contribution = null; for (Element element : statElements) { String unit = element.getElementsByClass("userActivityChart_statUnit").text(); if ("Contribution".equals(unit.trim())) { try { contribution = Integer .valueOf(element.getElementsByClass("userActivityChart_statCount").text()); } catch (NumberFormatException er) { er.printStackTrace(); } break; } } if (contribution != null) { ((State) mState).contribution = contribution; EventBus.getDefault().post(new StateEvent<>(getClass().getSimpleName(), true, null, mState)); } } } }
From source file:eu.europeana.uim.gui.cp.server.RetrievalServiceImpl.java
/** * Creates a new instance of this class. *//*w w w . j av a2 s . c o m*/ public RetrievalServiceImpl() { super(); PORTAL_SINGLE_RECORD_URL = PropertyReader.getProperty(UimConfigurationProperty.PORTAL_URI); PORTAL_PREVIEW_URL = PropertyReader.getProperty(UimConfigurationProperty.TESTPORTAL_URI); try { IBindingFactory bfact = BindingDirectory.getFactory(RDF.class); uctx = bfact.createUnmarshallingContext(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); db = dbf.newDocumentBuilder(); BlockingInitializer initializer = new BlockingInitializer() { @Override protected void initializeInternal() { solrServer = new HttpSolrServer( PropertyReader.getProperty(UimConfigurationProperty.SOLR_HOSTURL) + PropertyReader.getProperty(UimConfigurationProperty.SOLR_CORE)); } }; initializer.initialize(HttpSolrServer.class.getClassLoader()); BlockingInitializer mongoInitializer = new BlockingInitializer() { @Override protected void initializeInternal() { try { mongoServer = new EdmMongoServerImpl( new Mongo(PropertyReader.getProperty(UimConfigurationProperty.MONGO_HOSTURL), Integer.parseInt(PropertyReader .getProperty(UimConfigurationProperty.MONGO_HOSTPORT))), PropertyReader.getProperty(UimConfigurationProperty.MONGO_DB_EUROPEANA), "", ""); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MongoDBException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MongoException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; mongoInitializer.initialize(EdmMongoServerImpl.class.getClassLoader()); } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); } }