List of usage examples for java.lang NumberFormatException getMessage
public String getMessage()
From source file:com.ifountain.compass.CompositeDirectoryWrapperProvider.java
public void configure(CompassSettings settings) throws CompassException { awaitTermination = settings.getSettingAsLong("awaitTermination", 5); try {//from w ww .j av a2 s .c o m maxNumberOfUnProcessedBytes = (long) (Long .parseLong(System.getProperty("mirrorBufferUpperLimit", "128")) * Math.pow(2, 20)); } catch (NumberFormatException e) { throw new InvalidMirrorBufferSizeException("mirrorBufferUpperLimit", System.getProperty("mirrorBufferUpperLimit"), e.getMessage()); } try { minNumberOfUnProcessedBytes = (long) (Long.parseLong(System.getProperty("mirrorBufferLowerLimit", "64")) * Math.pow(2, 20)); } catch (NumberFormatException e) { throw new InvalidMirrorBufferSizeException("mirrorBufferLowerLimit", System.getProperty("mirrorBufferLowerLimit"), e.getMessage()); } if (minNumberOfUnProcessedBytes >= maxNumberOfUnProcessedBytes) { throw new InvalidMirrorBufferSizeException("mirrorBufferLowerLimit", System.getProperty("mirrorBufferLowerLimit"), "mirrorBufferUpperLimit should be greater than mirrorBufferLowerLimit"); } }
From source file:net.mlw.vlh.adapter.hibernate3.util.setter.CalendarSetter.java
/** * <ol>//from ww w . java2 s. com * <li>If is filter value instance of the Calendar, it will set it directly * to query. </li> * <li>If is filter value instance of String, it try to convert it it to long and set to Calendar instance</li> * <li>If is filter value instance of Long, it try to convert it it to long and set to Calendar instance</li> * <li>Otherwise it will set null to query for key.</li> * </ol> * * @see net.mlw.vlh.adapter.hibernate3.util.Setter#set(org.hibernate.Query, * java.lang.String, java.lang.Object) */ public void set(Query query, String key, Object value) throws HibernateException, ParseException { Calendar calendar = null; if (value instanceof String) { calendar = Calendar.getInstance(); try { calendar.setTimeInMillis(Long.valueOf((String) value).longValue()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("The key's='" + key + "' String value='" + value + "' was converted to Calendar."); } } catch (NumberFormatException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("The key's='" + key + "' String value='" + value + "' was not converted to Calendar, error was:" + e.getMessage()); } throw e; } } else if (value instanceof Long) { calendar = Calendar.getInstance(); calendar.setTimeInMillis(((Long) value).longValue()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("The key's='" + key + "' Long value='" + value + "' was converted to Calendar."); } } else if (value instanceof Calendar) { calendar = (Calendar) value; } else if (value == null) { if (LOGGER.isInfoEnabled()) { LOGGER.info("The key='" + key + "'s value is null."); } } else { if (LOGGER.isWarnEnabled()) { LOGGER.warn("The key's='" + key + "' value='" + value + "' was expected as Calendar."); } throw new IllegalArgumentException("Cannot convert value of class " + value.getClass().getName() + " to calendar (key=" + key + ")"); } query.setCalendar(key, calendar); if (LOGGER.isInfoEnabled()) { LOGGER.info("The key='" + key + "' was set to the query as Calendar='" + calendar + "'."); } }
From source file:io.cloudslang.content.httpclient.build.conn.ConnectionManagerBuilder.java
public PoolingHttpClientConnectionManager buildConnectionManager() { if (connectionPoolHolder != null) { PoolingHttpClientConnectionManager connManager = null; synchronized (connectionPoolHolder) { Map<String, PoolingHttpClientConnectionManager> connectionManagerMap = connectionPoolHolder.get(); if (connectionManagerMap == null) { final HashMap<String, PoolingHttpClientConnectionManager> connectionManagerMapFinal = new HashMap<>(); connectionPoolHolder//ww w . j av a2 s . c o m .setResource(new SessionResource<Map<String, PoolingHttpClientConnectionManager>>() { @Override public Map<String, PoolingHttpClientConnectionManager> get() { return connectionManagerMapFinal; } @Override public void release() { } }); connectionManagerMap = connectionPoolHolder.get(); } connManager = connectionManagerMap.get(connectionManagerMapKey); if (connManager == null) { Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder .<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", sslsf).build(); connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); connectionManagerMap.put(connectionManagerMapKey, connManager); } } //the DefaultMaxPerRoute default is 2 if (!StringUtils.isEmpty(defaultMaxPerRoute)) { try { connManager.setDefaultMaxPerRoute(Integer.parseInt(defaultMaxPerRoute)); } catch (NumberFormatException e) { throw new IllegalArgumentException("the '" + HttpClientInputs.CONNECTIONS_MAX_PER_ROUTE + "' input should be integer" + e.getMessage(), e); } } //the Default totalMax default is 20 if (!StringUtils.isEmpty(totalMax)) { try { connManager.setMaxTotal(Integer.parseInt(totalMax)); } catch (NumberFormatException e) { throw new IllegalArgumentException("the '" + HttpClientInputs.CONNECTIONS_MAX_TOTAL + "' input should be integer" + e.getMessage(), e); } } return connManager; } return null; }
From source file:com.meyling.telnet.startup.TelnetD.java
/** * Method to prepare the PortListener.<br> * * Creates and prepares and runs a PortListener, with settings from the * passed in Properties. Yet the Listener will not accept any incoming * connections before startServing() has been called. this has the advantage * that whenever a TelnetD Singleton has been factorized, it WILL 99% not * fail any longer (e.g. serve its purpose). * * @param name Name of listner. * @param settings Properties object that holds main settings. * @throws BootException Preparation failed. *///ww w . j ava 2s . co m private void prepareListener(final String name, final Properties settings) throws BootException { int port = 0; try { port = Integer.parseInt(settings.getProperty(name + ".port")); ServerSocket socket = new ServerSocket(port); socket.close(); } catch (NumberFormatException e) { trace.fatal(e, e); throw new BootException( "Failure while parsing port number for \"" + name + ".port\": " + e.getMessage()); } catch (IOException e) { trace.fatal(e, e); throw new BootException( "Failure while starting listener for port number " + port + ": " + e.getMessage()); } // factorize PortListener final PortListener listener = PortListener.createPortListener(name, settings); // start the Thread derived PortListener try { listeners.add(listener); } catch (Exception e) { trace.fatal(e, e); throw new BootException("Failure while starting PortListener thread: " + e.getMessage()); } }
From source file:com.sfs.whichdoctor.search.http.OnlineApplicationInputHandler.java
/** * Process the incoming HttpRequest for search parameters. * * @param request the request/*from w w w . ja v a2 s .c om*/ * @param user the user * * @return the search bean */ public final SearchBean process(final HttpServletRequest request, final UserBean user) { SearchBean search = onlineApplicationSqlHandler.initiate(user); OnlineApplicationBean searchCriteria = (OnlineApplicationBean) search.getSearchCriteria(); OnlineApplicationBean searchConstraints = (OnlineApplicationBean) search.getSearchConstraints(); /* Process search form */ String strPersonGUID = DataFilter.getHtml(request.getParameter("personGUID")); String strApplicationKey = DataFilter.getHtml(request.getParameter("applicationKey")); String strPersonName = DataFilter.getHtml(request.getParameter("personName")); String strFirstName = DataFilter.getHtml(request.getParameter("firstName")); String strLastName = DataFilter.getHtml(request.getParameter("lastName")); String strType = DataFilter.getHtml(request.getParameter("applicationType")); String strStatus = DataFilter.getHtml(request.getParameter("applicationStatus")); String strProcessed = DataFilter.getHtml(request.getParameter("processed")); String strCreatedA = DataFilter.getHtml(request.getParameter("createdA")); String strCreatedB = DataFilter.getHtml(request.getParameter("createdB")); String strUpdatedA = DataFilter.getHtml(request.getParameter("updatedA")); String strUpdatedB = DataFilter.getHtml(request.getParameter("updatedB")); /* Set the person GUID */ if (StringUtils.isNotBlank(strPersonGUID)) { int personGUID = 0; try { personGUID = Integer.parseInt(strPersonGUID.trim()); } catch (NumberFormatException nfe) { dataLogger.debug("Error parsing person GUID: " + nfe.getMessage()); } searchCriteria.setPersonGUID(personGUID); } /* Set the application key */ if (StringUtils.isNotBlank(strApplicationKey)) { searchCriteria.setKey(strApplicationKey); } /* Set the person name */ if (StringUtils.isNotBlank(strPersonName)) { searchCriteria.setDescription(strPersonName); } /* Set the first name */ if (StringUtils.isNotBlank(strFirstName)) { searchCriteria.setFirstName(strFirstName); } /* Set the last name */ if (StringUtils.isNotBlank(strLastName)) { searchCriteria.setLastName(strLastName); } /* Set the application type */ if (StringUtils.isNotBlank(strType) && !StringUtils.equals(strType, "Null")) { searchCriteria.setType(strType); } /* Set the application status */ if (StringUtils.isNotBlank(strStatus) && !StringUtils.equals(strStatus, "Null")) { searchCriteria.setStatus(strStatus); } /* Set the processed flag */ if (StringUtils.isNotBlank(strProcessed)) { searchCriteria.setProcessed(false); searchConstraints.setProcessed(true); if (StringUtils.equalsIgnoreCase(strProcessed, "true")) { searchCriteria.setProcessed(true); searchConstraints.setProcessed(true); } if (StringUtils.equalsIgnoreCase(strProcessed, "false")) { searchCriteria.setProcessed(false); searchConstraints.setProcessed(false); } } if (StringUtils.isNotBlank(strCreatedA)) { searchCriteria.setCreatedDate(DataFilter.parseDate(strCreatedA, false)); } if (StringUtils.isNotBlank(strCreatedB)) { searchConstraints.setCreatedDate(DataFilter.parseDate(strCreatedB, false)); if (strCreatedB.compareTo("+") == 0) { /* All dates above Date A requested */ searchConstraints.setCreatedDate(getMaximumDate()); } if (strCreatedB.compareTo("-") == 0) { /* Add dates below Date A requested */ searchConstraints.setCreatedDate(getMinimumDate()); } } if (StringUtils.isNotBlank(strUpdatedA)) { searchCriteria.setModifiedDate(DataFilter.parseDate(strUpdatedA, false)); } if (StringUtils.isNotBlank(strUpdatedB)) { searchConstraints.setModifiedDate(DataFilter.parseDate(strUpdatedB, false)); if (strUpdatedB.compareTo("+") == 0) { /* All dates above Date A requested */ searchConstraints.setModifiedDate(getMaximumDate()); } if (strUpdatedB.compareTo("-") == 0) { /* Add dates below Date A requested */ searchConstraints.setModifiedDate(getMinimumDate()); } } search.setSearchCriteria(searchCriteria); search.setSearchConstraints(searchConstraints); return search; }
From source file:com.ephesoft.dcma.ftp.service.FTPServiceImpl.java
/** * API for creating connection to ftp server. * // w w w . ja v a 2 s . co m * @param client {@link FTPClient} the ftp client instance * @throws SocketException if any error occur while making the connection. * @throws IOException generate if any error occur while making the connection */ private void createConnection(FTPClient client) throws SocketException, IOException { client.connect(ftpServerURL); client.login(ftpUsername, ftpPassword); try { int ftpDataTimeOutLocal = Integer.parseInt(ftpDataTimeOut); client.setDataTimeout(ftpDataTimeOutLocal); } catch (NumberFormatException e) { LOGGER.error("Error occuring in converting ftpDataTimeOut :" + e.getMessage(), e); } }
From source file:gov.nih.nci.system.web.struts.action.UpdateAction.java
public Object convertValue(Class klass, Object value) throws Exception { String fieldType = klass.getName(); Object convertedValue = null; try {//from w ww . ja v a2 s. c om if (fieldType.equals("java.lang.Long")) { convertedValue = new Long((String) value); } else if (fieldType.equals("java.lang.Integer")) { convertedValue = new Integer((String) value); } else if (fieldType.equals("java.lang.String")) { convertedValue = value; } else if (fieldType.equals("java.lang.Float")) { convertedValue = new Float((String) value); } else if (fieldType.equals("java.lang.Double")) { convertedValue = new Double((String) value); } else if (fieldType.equals("java.lang.Boolean")) { convertedValue = new Boolean((String) value); } else if (fieldType.equals("java.util.Date")) { SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); convertedValue = format.parse((String) value); } else if (fieldType.equals("java.net.URI")) { convertedValue = new URI((String) value); } else if (fieldType.equals("java.lang.Character")) { convertedValue = new Character(((String) value).charAt(0)); } else if (klass.isEnum()) { Class enumKlass = Class.forName(fieldType); convertedValue = Enum.valueOf(enumKlass, (String) value); } else { throw new Exception("type mismatch - " + fieldType); } } catch (NumberFormatException e) { e.printStackTrace(); throw new Exception(e.getMessage()); } catch (Exception ex) { log.error("ERROR : " + ex.getMessage()); throw ex; } return convertedValue; }
From source file:net.devietti.ArchConfMapServlet.java
/** * Returns the URL of the external conference website (not the WikiCFP page) for the given * eventid./*from www.j a v a 2 s . co m*/ */ private void getConfLink(HttpServletRequest req, HttpServletResponse resp) throws IOException { String eids = req.getParameter("eventid"); if (eids == null) { error("missing required URL parameter: eventid"); return; } Integer eid; try { eid = Integer.valueOf(eids); } catch (NumberFormatException e) { error(e.getMessage()); return; } if (eid == null || eid == 0) { error("error parsing eventid"); return; } // pull down the CFP Document cfp = getURL("http://www.wikicfp.com/cfp/servlet/event.showcfp?eventid=" + eids); for (Element a : cfp.select("tr td[align=center] a")) { Element td = a.parent(); if (td.text().contains("Link:") && a.hasAttr("href") && a.attr("href").contains("http://")) { // got the link! resp.setContentType("application/json"); resp.getWriter().println(GSON.toJson(a.attr("href"))); return; } } error("no matching link"); }
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 a v a 2s . co 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:com.csc.fsg.life.biz.copyobject.XgErrorAreaErrorArrayCopyObject.java
/** Default XgErrorAreaErrorArrayCopyObject constructor. Creates this object and initializes all fields and sub-objects with default values. @throws CopyObjectException If there is an initialization problem. **//*from w w w.j a v a 2s . c o m*/ public XgErrorAreaErrorArrayCopyObject() throws CopyObjectException { bytes = new byte[200]; try { setErrorFieldDisplacement(Long.valueOf(0)); setErrorCode(""); setErrorLevel(""); setErrorMessage(""); setMiscDetail(""); } catch (NumberFormatException nfE) { throw new CopyObjectException(nfE.getMessage()); } }