List of usage examples for java.lang NumberFormatException getMessage
public String getMessage()
From source file:de.ncoder.studipsync.StarterOptions.java
public void set(CommandLine cmd) throws ParseException { if (cmd.hasOption(OPTION_OUT)) { setCachePath(Paths.get(cmd.getOptionValue(OPTION_OUT))); }//from www.j a v a2 s. co m if (cmd.hasOption(OPTION_COOKIES)) { setCookiesPath(Paths.get(cmd.getOptionValue(OPTION_COOKIES))); } if (cmd.hasOption(OPTION_NO_COOKIES)) { setCookiesPath(null); } if (cmd.hasOption(OPTION_TIMEOUT)) { try { setTimeoutMs(Integer.parseInt(cmd.getOptionValue(OPTION_TIMEOUT))); } catch (NumberFormatException e) { throw new ParseException(e.getMessage()); } } if (cmd.hasOption(OPTION_CHECK_LEVEL)) { setCheckLevel(Syncer.CheckLevel.get(cmd.getOptionValue(OPTION_CHECK_LEVEL))); } if (cmd.hasOption(OPTION_UI)) { setUIAdapter(StandardUIAdapter.getUIAdapter(cmd.getOptionValue(OPTION_UI))); } if (cmd.hasOption(OPTION_PATH_RESOLVER)) { setPathResolver(StandardPathResolver.getPathResolver(cmd.getOptionValue(OPTION_PATH_RESOLVER))); } setPersitent(cmd.hasOption(OPTION_PERSISTENT)); }
From source file:net.sinequanon.grails.StructuredDateOrTimestampEditor.java
@SuppressWarnings("rawtypes") public Object assemble(Class type, Map fieldValues) throws IllegalArgumentException { String yearString = (String) fieldValues.get("year"); String monthString = (String) fieldValues.get("month"); String dayString = (String) fieldValues.get("day"); String hourString = (String) fieldValues.get("hour"); String minuteString = (String) fieldValues.get("minute"); String secondString = (String) fieldValues.get("second"); String milliSecondString = (String) fieldValues.get("millisecond"); String nanoSecondString = (String) fieldValues.get("nanosecond"); String epochString = (String) fieldValues.get("epoch"); if (StringUtils.isBlank(yearString) && StringUtils.isBlank(monthString) && StringUtils.isBlank(dayString) && StringUtils.isBlank(hourString) && StringUtils.isBlank(minuteString) && StringUtils.isBlank(secondString) && StringUtils.isBlank(milliSecondString) && StringUtils.isBlank(nanoSecondString) && StringUtils.isBlank(epochString)) { if (this.myAllowEmpty) { setValue(null);/*from w w w .j a v a 2 s .c o m*/ return null; } throw new IllegalArgumentException("Date struct values cannot all be empty"); } try { Calendar c = null; long epoch = 0; if (!StringUtils.isBlank(epochString)) { epoch = getLongValue(fieldValues, "epoch", 0); } else { int year = getIntegerValue(fieldValues, "year", 1970); int month = getIntegerValue(fieldValues, "month", 1); int day = getIntegerValue(fieldValues, "day", 1); int hour = getIntegerValue(fieldValues, "hour", 0); int minute = getIntegerValue(fieldValues, "minute", 0); int second = getIntegerValue(fieldValues, "second", 0); int milliSecond = getIntegerValue(fieldValues, "millisecond", 0); c = new GregorianCalendar(year, month - 1, day, hour, minute, second); epoch = c.getTimeInMillis() + milliSecond; } if (type == java.util.Date.class) { setValue(new java.util.Date(epoch)); return (getValue()); } if (type == java.sql.Date.class) { setValue(new java.sql.Date(epoch)); return (getValue()); } if (type == java.sql.Timestamp.class) { java.sql.Timestamp ts = new java.sql.Timestamp(epoch); if (fieldValues.containsKey("nanosecond") && !StringUtils.isBlank(nanoSecondString)) { ts.setNanos(getIntegerValue(fieldValues, "nanosecond", 0)); } setValue(ts); return ts; } if (c == null) { c = new GregorianCalendar(); c.setTimeInMillis(epoch); } setValue(c); return c; } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Bad number format: " + nfe.getMessage()); } }
From source file:ch.cyberduck.core.importer.FireFtpBookmarkCollection.java
private void read(final ProtocolFactory protocols, final String entry) { final Host current = new Host(protocols.forScheme(Scheme.ftp)); current.getCredentials().setUsername(PreferencesFactory.get().getProperty("connection.login.anon.name")); for (String attribute : entry.split(", ")) { Scanner scanner = new Scanner(attribute); scanner.useDelimiter(":"); if (!scanner.hasNext()) { log.warn("Missing key in line:" + attribute); continue; }//from w w w . j a v a 2 s . co m String name = scanner.next().toLowerCase(Locale.ROOT); if (!scanner.hasNext()) { log.warn("Missing value in line:" + attribute); continue; } String value = scanner.next().replaceAll("\"", StringUtils.EMPTY); if ("host".equals(name)) { current.setHostname(value); } else if ("port".equals(name)) { try { current.setPort(Integer.parseInt(value)); } catch (NumberFormatException e) { log.warn("Invalid Port:" + e.getMessage()); } } else if ("remotedir".equals(name)) { current.setDefaultPath(value); } else if ("webhost".equals(name)) { current.setWebURL(value); } else if ("encoding".equals(name)) { current.setEncoding(value); } else if ("notes".equals(name)) { current.setComment(value); } else if ("account".equals(name)) { current.setNickname(value); } else if ("privatekey".equals(name)) { current.getCredentials().setIdentity(LocalFactory.get(value)); } else if ("pasvmode".equals(name)) { if (Boolean.TRUE.toString().equals(value)) { current.setFTPConnectMode(FTPConnectMode.passive); } if (Boolean.FALSE.toString().equals(value)) { current.setFTPConnectMode(FTPConnectMode.active); } } else if ("login".equals(name)) { current.getCredentials().setUsername(value); } else if ("password".equals(name)) { current.getCredentials().setPassword(value); } else if ("anonymous".equals(name)) { if (Boolean.TRUE.toString().equals(value)) { current.getCredentials() .setUsername(PreferencesFactory.get().getProperty("connection.login.anon.name")); } } else if ("security".equals(name)) { if ("authtls".equals(value)) { current.setProtocol(protocols.forScheme(Scheme.ftps)); // Reset port to default current.setPort(-1); } if ("sftp".equals(value)) { current.setProtocol(protocols.forScheme(Scheme.sftp)); // Reset port to default current.setPort(-1); } } } this.add(current); }
From source file:fr.paris.lutece.portal.web.dashboard.DashboardJspBean.java
/** * Reorders columns// w ww .j a v a2s . c o m * @param request the request * @return url */ public String doReorderColumn(HttpServletRequest request) { String strColumnName = request.getParameter(PARAMETER_COLUMN); if (StringUtils.isBlank(strColumnName)) { return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } int nColumn = 0; try { nColumn = Integer.parseInt(strColumnName); } catch (NumberFormatException nfe) { AppLogService.error("DashboardJspBean.doReorderColumn : " + nfe.getMessage(), nfe); return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP); } _service.doReorderColumn(nColumn); return JSP_MANAGE_DASHBOARDS; }
From source file:me.willowcheng.makerthings.model.OpenHABItem.java
public Float getStateAsFloat() { // For uninitialized/null state return zero if (state == null) { return new Float(0); }/*from w ww . j av a 2 s .c o m*/ if ("ON".equals(state)) { return new Float(100); } if ("OFF".equals(state)) { return new Float(0); } try { Float result = Float.parseFloat(state); } catch (NumberFormatException e) { if (e != null) { Crittercism.logHandledException(e); Log.e(TAG, e.getMessage()); } } return Float.parseFloat(state); }
From source file:de.forsthaus.policy.model.PolicyManager.java
@Override public UserDetails loadUserByUsername(String userId) { SecUser user = null;/*from ww w .j av a 2 s. co m*/ Collection<GrantedAuthority> grantedAuthorities = null; try { user = getUserByLoginname(userId); if (user == null) { throw new UsernameNotFoundException("Invalid User"); } grantedAuthorities = getGrantedAuthority(user); } catch (final NumberFormatException e) { throw new DataRetrievalFailureException( "Cannot loadUserByUsername userId:" + userId + " Exception:" + e.getMessage(), e); } // Create the UserDetails object for a specified user with // their grantedAuthorities List. final UserDetails userDetails = new UserImpl(user, grantedAuthorities); if (logger.isDebugEnabled()) { logger.debug("Rights for '" + user.getUsrLoginname() + "' (ID: " + user.getId() + ") evaluated. [" + this + "]"); } return userDetails; }
From source file:fr.paris.lutece.plugins.genericattributes.service.entrytype.AbstractEntryTypeCheckBox.java
/** * {@inheritDoc}/*from ww w .j a va 2 s . c o m*/ */ @Override public GenericAttributeError getResponseData(Entry entry, HttpServletRequest request, List<Response> listResponse, Locale locale) { String[] strTabIdField = request.getParameterValues(PREFIX_ATTRIBUTE + entry.getIdEntry()); List<Field> listFieldInResponse = new ArrayList<Field>(); int nIdField = -1; Field field = null; Response response; if (strTabIdField != null) { for (int cpt = 0; cpt < strTabIdField.length; cpt++) { try { nIdField = Integer.parseInt(strTabIdField[cpt]); } catch (NumberFormatException ne) { AppLogService.error(ne.getMessage(), ne); } field = GenericAttributesUtils.findFieldByIdInTheList(nIdField, entry.getFields()); if (field != null) { listFieldInResponse.add(field); } } } if (listFieldInResponse.size() != 0) { for (Field fieldInResponse : listFieldInResponse) { response = new Response(); response.setEntry(entry); response.setResponseValue(fieldInResponse.getValue()); response.setField(fieldInResponse); listResponse.add(response); } } if (entry.isMandatory()) { boolean bAllFieldEmpty = true; for (Field fieldInResponse : listFieldInResponse) { if (!fieldInResponse.getValue().equals(StringUtils.EMPTY)) { bAllFieldEmpty = false; } } if (bAllFieldEmpty) { if (StringUtils.isNotBlank(entry.getErrorMessage())) { GenericAttributeError error = new GenericAttributeError(); error.setMandatoryError(true); error.setErrorMessage(entry.getErrorMessage()); return error; } return new MandatoryError(entry, locale); } } return null; }
From source file:com.ephesoft.dcma.heartbeat.HeartBeat.java
/** * This method will check the health of all the servers registered to the common data base pool. *//* www .ja va 2 s. com*/ public void heartBeatHealth() { if (null == serverRegistryService) { throw new DCMABusinessException("Not able to find ServerRegistryService service of the system."); } List<ServerRegistry> serverRegistries = serverRegistryService.getAllServerRegistry(); StringBuilder url = null; String pathUrl = null; boolean isActive = false; if (null == serverRegistries || serverRegistries.isEmpty()) { LOGGER.info("No server registry found."); } else { for (ServerRegistry serverRegistry : serverRegistries) { String ipAddress = serverRegistry.getIpAddress(); String portNumber = serverRegistry.getPort(); String context = serverRegistry.getAppContext(); if (ipAddress == null || null == portNumber || null == context) { LOGGER.error("Problem in creating. Server Registry Info is Null."); } else { url = new StringBuilder("http://"); url.append(ipAddress); url.append(":"); url.append(portNumber); if (!context.contains("/")) { url.append("/"); } url.append(context); url.append("/"); url.append(HEALTH_FILE_NAME); pathUrl = url.toString(); LOGGER.info(pathUrl); isActive = checkHealth(pathUrl); if (!isActive) { int noOfPings = 1; try { noOfPings = Integer.parseInt(getNumberOfPings()); } catch (NumberFormatException nfe) { LOGGER.error(nfe.getMessage()); } for (int i = 1; i < noOfPings; i++) { isActive = checkHealth(pathUrl); if (isActive) { break; } } } if (serverRegistry.isActive() != isActive) { serverRegistry.setActive(isActive); serverRegistryService.updateServerRegistry(serverRegistry); } } } } }
From source file:hudson.plugins.blazemeter.BzmBuild.java
private int getReportLinkNameLength() { try {/*from www.jav a 2 s. co m*/ String len = this.envVars.get("bzm.reportLinkName.length"); if (StringUtils.isBlank(len)) { LOGGER.fine("Property bzm.reportLinkName.length did not find in Jenkins envVars"); len = System.getProperty("bzm.reportLinkName.length"); if (StringUtils.isBlank(len)) { LOGGER.fine("Property bzm.reportLinkName.length did not find in System.properties"); len = "35"; } } LOGGER.info("Get report link name length = " + len); return Integer.parseInt(len); } catch (NumberFormatException ex) { LOGGER.warning("Cannot parse report link name length = " + ex.getMessage()); return 35; } }
From source file:com.feedzai.fos.api.ModelConfig.java
/** * Returns properties as an integer value * * @param name property name/*from w w w. ja v a 2 s .com*/ * @return property value * @throws FOSException if property name is invalid or if it wasn't possible to parse an integer from the value */ public int getIntProperty(String name) throws FOSException { checkNotNull(name, "Configuration option must be defined"); notEmpty(name, "Configuration option must not be blank"); String svalue = properties.get(name); checkNotNull(svalue, "Configuration option '" + name + "' does not exist"); notEmpty(name, "Configuration option '" + name + "' must not be blank"); int value = 0; try { value = Integer.parseInt(svalue); } catch (NumberFormatException e) { throw new FOSException(e.getMessage(), e); } return value; }