List of usage examples for java.lang NumberFormatException getMessage
public String getMessage()
From source file:ch.cyberduck.core.importer.FlashFxpBookmarkCollection.java
@Override protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException { try {//from ww w. j a va2 s.c o m final BufferedReader in = new BufferedReader( new InputStreamReader(file.getInputStream(), Charset.forName("UTF-8"))); try { Host current = null; String line; while ((line = in.readLine()) != null) { if (line.startsWith("[")) { current = new Host(protocols.forScheme(Scheme.ftp)); current.getCredentials() .setUsername(PreferencesFactory.get().getProperty("connection.login.anon.name")); Pattern pattern = Pattern.compile("\\[(.*)\\]"); Matcher matcher = pattern.matcher(line); if (matcher.matches()) { current.setNickname(matcher.group(1)); } } else if (StringUtils.isBlank(line)) { this.add(current); current = null; } else { if (null == current) { log.warn("Failed to detect start of bookmark"); continue; } Scanner scanner = new Scanner(line); scanner.useDelimiter("="); if (!scanner.hasNext()) { log.warn("Missing key in line:" + line); continue; } String name = scanner.next().toLowerCase(Locale.ROOT); if (!scanner.hasNext()) { log.warn("Missing value in line:" + line); continue; } String value = scanner.next(); if ("ip".equals(name)) { current.setHostname(StringUtils.substringBefore(value, "\u0001")); } else if ("port".equals(name)) { try { current.setPort(Integer.parseInt(value)); } catch (NumberFormatException e) { log.warn("Invalid Port:" + e.getMessage()); } } else if ("path".equals(name)) { current.setDefaultPath(value); } else if ("notes".equals(name)) { current.setComment(value); } else if ("user".equals(name)) { current.getCredentials().setUsername(value); } } } } finally { IOUtils.closeQuietly(in); } } catch (IOException e) { throw new AccessDeniedException(e.getMessage(), e); } }
From source file:me.bramhaag.discordselfbot.commands.fun.CommandTriggered.java
@Command(name = "triggered", aliases = { "trigger", "triggering" }, minArgs = 1) public void execute(@NonNull Message message, @NonNull TextChannel channel, @NonNull String[] args) { User user;//from w ww .ja v a 2s. c om String image = "triggered"; final String text; try { user = message.getJDA().getUserById(args[0].replaceAll("[^\\d.]", "")); } catch (NumberFormatException e) { Util.sendError(message, e.getMessage()); return; } if (user == null) { Util.sendError(message, "Invalid user!"); return; } if (args.length >= 3 && (args[1].equalsIgnoreCase("--image") || args[1].equals("-i"))) { image = args[2]; } if (args.length >= 2 && image == null) { text = StringUtils.join(args, 1, args.length); } else if (args.length >= 4 && image != null) { text = StringUtils.join(args, 4, args.length); } else { text = null; } message.editMessage("```Generating GIF...```").queue(); File avatar = new File("avatar_" + user.getId() + "_" + System.currentTimeMillis() + ".png"); try { ImageIO.write(Util.getImage(user.getAvatarUrl()), "png", avatar); } catch (IOException e) { e.printStackTrace(); Util.sendError(message, e.getMessage()); return; } File output = new File("triggered_" + user.getId() + "_" + System.currentTimeMillis() + ".gif"); File triggered = new File("assets/" + image + ".png"); String avatarPath = avatar.getAbsolutePath(); String triggeredPath = triggered.getAbsolutePath(); new Thread(() -> { try { Process generateGif = Runtime.getRuntime().exec((Bot.getConfig().getImagemagickPath() + " convert canvas:none -size 512x680 -resize 512x680! -draw \"image over -60,-60 640,640 \"\"{avatar}\"\"\" -draw \"image over 0,512 0,0 \"\"{triggered}\"\"\" " + "( canvas:none -size 512x680! -draw \"image over -45,-50 640,640 \"\"{avatar}\"\"\" -draw \"image over -5,512 0,0 \"\"{triggered}\"\"\" ) " + "( canvas:none -size 512x680! -draw \"image over -50,-45 640,640 \"\"{avatar}\"\"\" -draw \"image over -1,505 0,0 \"\"{triggered}\"\"\" ) " + "( canvas:none -size 512x680! -draw \"image over -45,-65 640,640 \"\"{avatar}\"\"\" -draw \"image over -5,530 0,0 \"\"{triggered}\"\"\" ) " + "-layers Optimize -set delay 2 " + output.getPath()).replace("{avatar}", avatarPath) .replace("{triggered}", triggeredPath)); generateGif.waitFor(); if (text != null) { Process addText = Runtime.getRuntime() .exec(String.format("%s convert %s -font Calibri -pointsize 60 caption:\"%s\" %s", Constants.MAGICK_PATH, output, text, output)); addText.waitFor(); } message.getChannel().sendFile(output, new MessageBuilder().append(" ").build()).queue(m -> { message.delete().queue(); Preconditions.checkState(avatar.delete(), String.format("File %s not deleted!", avatar.getName())); Preconditions.checkState(output.delete(), String.format("File %s not deleted!", output.getName())); }); } catch (IOException | InterruptedException e) { e.printStackTrace(); } }).start(); }
From source file:it.unibas.spicy.model.expressions.operators.EvaluateExpression.java
public Double evaluateCondition(Expression expression, INode tuple) throws ExpressionSyntaxException { if (logger.isDebugEnabled()) logger.debug("Evaluating condition: " + expression + " on tuple " + tuple); if (expression.toString().equals("true")) { return SpicyEngineConstants.TRUE; }// w w w . java 2 s. com setVariableValues(expression, tuple); Object value = expression.getJepExpression().getValueAsObject(); if (expression.getJepExpression().hasError()) { throw new ExpressionSyntaxException(expression.getJepExpression().getErrorInfo()); } if (logger.isDebugEnabled()) logger.debug("Value of condition: " + value); try { Double result = Double.parseDouble(value.toString()); return result; } catch (NumberFormatException numberFormatException) { logger.error(numberFormatException); throw new ExpressionSyntaxException(numberFormatException.getMessage()); } }
From source file:org.jasig.portlet.announcements.controller.AnnouncementsPreferencesController.java
@RequestMapping() public void savePreferences(ActionRequest request, ActionResponse response, @RequestParam("topicsToUpdate") Integer topicsToUpdate) throws PortletException, IOException { PortletPreferences prefs = request.getPreferences(); List<TopicSubscription> newSubscription = new ArrayList<TopicSubscription>(); for (int i = 0; i < topicsToUpdate; i++) { Long topicId = Long.valueOf(request.getParameter("topicId_" + i)); // Will be numeric for existing, persisted TopicSubscription // instances; blank (due to null id field) otherwise String topicSubId = request.getParameter("topicSubId_" + i).trim(); Boolean subscribed = Boolean.valueOf(request.getParameter("subscribed_" + i)); Topic topic = announcementService.getTopic(topicId); // Make sure that any pushed_forced topics weren't sneakingly removed (by tweaking the URL, for example) if (topic.getSubscriptionMethod() == Topic.PUSHED_FORCED) { subscribed = Boolean.TRUE; }/* w w w.j a va 2 s .co m*/ TopicSubscription ts = new TopicSubscription(request.getRemoteUser(), topic, subscribed); if (topicSubId.length() > 0) { // This TopicSubscription represents an existing, persisted entity try { ts.setId(Long.valueOf(topicSubId)); } catch (NumberFormatException nfe) { logger.debug(nfe.getMessage(), nfe); } } newSubscription.add(ts); } if (newSubscription.size() > 0) { try { announcementService.addOrSaveTopicSubscription(newSubscription); } catch (Exception e) { logger.error("ERROR saving TopicSubscriptions for user " + request.getRemoteUser() + ". Message: " + e.getMessage()); } } String hideAbstract = Boolean.valueOf(request.getParameter("hideAbstract")).toString(); prefs.setValue(PREFERENCE_HIDE_ABSTRACT, hideAbstract); prefs.store(); response.setPortletMode(PortletMode.VIEW); response.setRenderParameter("action", "displayAnnouncements"); }
From source file:pzalejko.iot.hardware.home.core.task.LedAlertTask.java
/** * Updates an alert value according to the payload provided by the given event. An expected payload is an instance of the * {@link TemperatureAlertEntity}.//from www . j av a 2 s . co m * * @param event the event. */ private void updateAlertTemperature(Event event) { final Object payload = event.getPayload(); if (payload instanceof TemperatureAlertEntity) { try { maxTemperature = ((TemperatureAlertEntity) payload).getAlert(); LOG.info(LogMessages.UPDATED_AN_ALERT_TEMPERATURE_TO, maxTemperature); publishCurrentAlertValue(); } catch (final NumberFormatException e) { LOG.error(LogMessages.COULD_NOT_UPDATE_TEMPERATURE_ALERT, e.getMessage(), e); } } else { LOG.error(LogMessages.PAYLOAD_NOT_SUPPORTED, payload); } }
From source file:org.openscore.content.httpclient.build.RequestConfigBuilder.java
public RequestConfig buildRequestConfig() { HttpHost proxy = null;/* w ww. j a va 2s . co m*/ if (proxyHost != null && !proxyHost.isEmpty()) { try { proxy = new HttpHost(proxyHost, Integer.parseInt(proxyPort)); } catch (NumberFormatException e) { throw new IllegalArgumentException( "Cound not parse '" + HttpClientInputs.PROXY_PORT + "' input: " + e.getMessage(), e); } } int connectionTimeout = Integer.parseInt(this.connectionTimeout); int socketTimeout = Integer.parseInt(this.socketTimeout); //todo should we also allow user to enable redirects prohibited by the HTTP specification (on POST and PUT)? See 'LaxRedirectStrategy' return RequestConfig.custom() .setConnectTimeout(connectionTimeout <= 0 ? connectionTimeout : connectionTimeout * 1000) .setSocketTimeout(socketTimeout <= 0 ? socketTimeout : socketTimeout * 1000).setProxy(proxy) .setRedirectsEnabled(Boolean.parseBoolean(followRedirects)).build(); }
From source file:com.ms.commons.fasttext.psoriasis.Configuration.java
private void init(Properties props) { quickMatch = Boolean.parseBoolean(props.getProperty(DECOR_QUICKMATCH_ENABLE_KEY, "false")); String skipStr = props.getProperty(DARTS_SKIP_VALUE_KEY, "3"); try {//from w w w.ja v a 2 s . co m skip = Integer.parseInt(skipStr); } catch (NumberFormatException e) { logger.error("Invalid skip value. " + e.getMessage()); throw new IllegalArgumentException(e); } pinyin = Boolean.parseBoolean(props.getProperty(DARTS_ENABLE_PINYIN_KEY, "true")); fork = Boolean.parseBoolean(props.getProperty(DARTS_ENALBLE_FORK_KEY, "true")); homophone = Boolean.parseBoolean(props.getProperty(DARTS_ENABLE_HOMOPHONE_KEY, "true")); deform = Boolean.parseBoolean(props.getProperty(DARTS_ENABLE_DEFORM_KEY, "true")); toLowcase = Boolean.parseBoolean(props.getProperty(DARTS_ENABLE_TOLOWERCASE, "true")); }
From source file:com.sec.ose.osi.util.ProxyUtil.java
private boolean isValidProxyInfo(String mProxyHost, String mProxyPort, String mProxyBypass) { if (mProxyHost == null || mProxyHost.trim().length() == 0) { log.info("Proxy Host is not existed: no proxy host"); return false; }// w ww.j ava2 s. c o m if (mProxyPort == null || mProxyPort.trim().length() == 0) { log.info("Proxy Server Info is not existed: no proxy port"); return false; } try { Integer.parseInt(mProxyPort); } catch (NumberFormatException e) { log.error("Malformed Proxy Server Info: <" + mProxyPort + ">"); log.debug(e.getMessage()); return false; } return true; }
From source file:com.cloudera.oryx.app.serving.als.Ingest.java
private void doPost(BufferedReader buffered) throws IOException, OryxServingException { TopicProducer<?, String> inputTopic = getInputProducer(); String line;/*from w ww. j a v a 2 s . c om*/ while ((line = buffered.readLine()) != null) { String[] tokens = TextUtils.parseDelimited(line, ','); check(tokens.length >= 2, line); String userID = tokens[0]; String itemID = tokens[1]; String strength; long timestamp; // Has a strength? if (tokens.length >= 3) { String rawStrength = tokens[2]; // Special case deletes: if (rawStrength.isEmpty()) { strength = ""; } else { strength = Preference.validateAndStandardizeStrength(rawStrength); } // Has a timestamp? if (tokens.length >= 4) { try { timestamp = Long.parseLong(tokens[3]); } catch (NumberFormatException nfe) { throw new OryxServingException(Response.Status.BAD_REQUEST, nfe.getMessage()); } check(timestamp > 0, line); } else { timestamp = System.currentTimeMillis(); } } else { strength = "1"; timestamp = System.currentTimeMillis(); } inputTopic.send(userID + "," + itemID + "," + strength + "," + timestamp); } }
From source file:com.clustercontrol.maintenance.composite.action.HinemosPropertyDoubleClickListener.java
/** * ?????<BR>/*from ww w . ja v a2s. co m*/ * []????????????? * <P> * <ol> * <li>???????????</li> * <li>?????????</li> * </ol> * * @param event * * @see com.clustercontrol.maintenance.dialog.HinemosPropertyDialog * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent) */ @SuppressWarnings("rawtypes") @Override public void doubleClick(DoubleClickEvent event) { ArrayList list; HinemosPropertyInfo info = new HinemosPropertyInfo(); String managerName = null; int valueType = 0; //? if (((StructuredSelection) event.getSelection()).getFirstElement() != null) { list = (ArrayList) ((StructuredSelection) event.getSelection()).getFirstElement(); } else { return; } info.setKey((String) list.get(GetHinemosPropertyTableDefine.KEY)); managerName = (String) list.get(GetHinemosPropertyTableDefine.MANAGER_NAME); valueType = HinemosPropertyTypeMessage .stringToType((String) list.get(GetHinemosPropertyTableDefine.VALUE_TYPE)); info.setValueType(valueType); if (valueType == HinemosPropertyTypeConstant.TYPE_STRING) { String value = (String) list.get(GetHinemosPropertyTableDefine.VALUE); info.setValueString(value); } else if (valueType == HinemosPropertyTypeConstant.TYPE_NUMERIC) { Object val = list.get(GetHinemosPropertyTableDefine.VALUE); try { if (val != null) { info.setValueNumeric(Long.parseLong(val.toString())); } else { info.setValueNumeric(null); } } catch (NumberFormatException e) { m_log.info("run() setValueNumeric(), " + e.getMessage()); Object[] args = { Messages.getString("hinemos.property.key"), Long.MIN_VALUE, Long.MAX_VALUE }; MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.common.4", args)); } } else { boolean value = Boolean.parseBoolean((String) list.get(GetHinemosPropertyTableDefine.VALUE)); info.setValueBoolean(value); } info.setDescription((String) list.get(GetHinemosPropertyTableDefine.DESCRIPTION)); // ? HinemosPropertyDialog dialog = new HinemosPropertyDialog(m_composite.getShell(), managerName, valueType, PropertyDefineConstant.MODE_MODIFY, info); // ??????????? if (dialog.open() == IDialogConstants.OK_ID) { Table table = m_composite.getTableViewer().getTable(); WidgetTestUtil.setTestId(this, null, table); int selectIndex = table.getSelectionIndex(); m_composite.update(); table.setSelection(selectIndex); } }