List of usage examples for java.lang NumberFormatException getMessage
public String getMessage()
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.filtering.SingleCutOffFilteringController.java
/** * Initialize the main view./*w w w . j av a 2 s . c om*/ */ private void initMainView() { // make a new view singleCutOffPanel = new SingleCutOffPanel(); singleCutOffPanel.getMedianDisplList().setModel(new DefaultListModel()); // action listeners singleCutOffPanel.getApplyCutOffButton().addActionListener((ActionEvent e) -> { // try to read the user-inserted values for up and down limit // check for number format exception try { cutOff = Double.parseDouble(singleCutOffPanel.getCutOffTextField().getText()); FilterSwingWorker filterSwingWorker = new FilterSwingWorker(); filterSwingWorker.execute(); } catch (NumberFormatException ex) { // warn the user and log the error for info filteringController.showMessage( "Please insert a valid number for the cut-off!" + "\n " + ex.getMessage(), "number format exception", JOptionPane.ERROR_MESSAGE); LOG.error(ex.getMessage()); } }); AlignedTableRenderer alignedTableRenderer = new AlignedTableRenderer(SwingConstants.LEFT); for (int i = 0; i < singleCutOffPanel.getSummaryTable().getColumnModel().getColumnCount(); i++) { singleCutOffPanel.getSummaryTable().getColumnModel().getColumn(i).setCellRenderer(alignedTableRenderer); } singleCutOffPanel.getSummaryTable().getTableHeader() .setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); // add view to parent container filteringController.getFilteringPanel().getSingleCutOffParentPanel().add(singleCutOffPanel, gridBagConstraints); }
From source file:com.brianscottrussell.gameoflife.GameGrid.java
/** * given the grid input String, parses the row count if this is a valid input String * * Sample of expected format of input String where rowCount = 4: * 4 8/*w ww . j a v a2 s. co m*/ ......../n ....*.../n ...**.../n ........ * * @param input String * @return int as the row count * @throws InvalidGameGridInputException */ private int parseRowCountFromInputString(String input) throws InvalidGameGridInputException { try { // get the character(s), before the 1st space as the rowCount return Integer.valueOf(StringUtils.substring(input, 0, StringUtils.indexOf(input, ' '))); } catch (NumberFormatException e) { throw new InvalidGameGridInputException(e.getClass().getSimpleName() + ": " + e.getMessage()); } }
From source file:com.brianscottrussell.gameoflife.GameGrid.java
/** * given the grid input String, parses the column count if this is a valid input String * * Sample of expected format of input String where columnCount = 8: * 4 8/*from w ww . ja v a 2 s. c o m*/ ......../n ....*.../n ...**.../n ........ * * @param input String * @return int as the column count * @throws InvalidGameGridInputException */ private int parseColumnCountFromInputString(String input) throws InvalidGameGridInputException { try { // get the character(s), before the 1st carriage return as the rowCount return Integer.valueOf(StringUtils.substring(input, StringUtils.indexOf(input, ' ') + 1, StringUtils.indexOf(input, GameOfLife.LF))); } catch (NumberFormatException e) { throw new InvalidGameGridInputException(e.getClass().getSimpleName() + ": " + e.getMessage()); } }
From source file:eu.trentorise.smartcampus.ac.provider.services.AcProviderServiceImpl.java
/** * Returns true if the user can access the specified resource. Currently, the resource should * correspond to the entityId as stored in the Social Engine entity space. * //from ww w . j a v a2 s . co m * @return true if the read permission is granted for the resource * @throws AcServiceException */ @Override public boolean canReadResource(String authToken, String resourceId) throws AcServiceException { User user = getUserByToken(authToken); if (user == null) { throw new AcServiceException("User matching the token " + authToken + " is not found."); } try { return socialManager.checkResourceAccess(user.getSocialId(), Long.parseLong(resourceId)); } catch (NumberFormatException e) { throw new AcServiceException("Resource ID should be a number."); } catch (Exception e) { e.printStackTrace(); throw new AcServiceException("Error reading the access rights: " + e.getMessage()); } }
From source file:de.pdark.dsmp.Config.java
private int getIntProperty(Element root, String element, String attribute, int defaultValue) { String value = getStringProperty(root, element, attribute, null); if (value == null) return defaultValue; try {/*from w w w . j a v a 2 s .c o m*/ return Integer.parseInt(value); } catch (NumberFormatException e) { throw (NumberFormatException) (new NumberFormatException("Error convertion value '" + value + "' of property " + element + "@" + attribute + ": " + e.getMessage()).initCause(e)); } }
From source file:com.hp.application.automation.tools.octane.CIJenkinsServicesImpl.java
@Override public SnapshotNode getSnapshotByNumber(String jobCiId, String buildCiId, boolean subTree) { SecurityContext securityContext = startImpersonation(); SnapshotNode result = null;//w w w. ja v a 2 s. co m Job job = getJobByRefId(jobCiId); Integer buildNumber = null; try { buildNumber = Integer.parseInt(buildCiId); } catch (NumberFormatException nfe) { logger.error("failed to parse build CI ID to build number, " + nfe.getMessage(), nfe); } if (job != null && buildNumber != null) { Run build = job.getBuildByNumber(buildNumber); if (build != null) { result = ModelFactory.createSnapshotItem(build, subTree); } } stopImpersonation(securityContext); return result; }
From source file:com.alexa.oms.service.AlexaOmsSpeechlet.java
@Override public SpeechletResponse onIntent(final IntentRequest request, final Session session) throws SpeechletException, HttpServerErrorException { //LOG.debug("onIntent requestId={}, sessionId={}, access_token={}, userid={}", request.getRequestId(), session.getSessionId(), session.getUser().getAccessToken(), session.getUser().getUserId()); int customerId; try {//from w ww. ja v a 2 s . c o m customerId = (Integer) session.getAttribute(CUSTOMER_ID); if (!session.getApplication().getApplicationId().equalsIgnoreCase(applicationId)) { //return getResponse(RESPONSE_NOT_AUTHORIZED); throw new HttpServerErrorException(HttpStatus.UNAUTHORIZED, RESPONSE_NOT_AUTHORIZED); } Intent intent = request.getIntent(); String intentName = (intent != null) ? intent.getName() : null; IntentType reqIntent = getIntentType(intentName); if (reqIntent != null) { LOG.debug("Intent ==> " + reqIntent + " Slot Keys : " + intent.getSlots().keySet() + "Slot Keys :" + intent.getSlots().values()); switch (reqIntent) { case HelloWorldIntent: return getResponse(RESPONSE_HELLO_INTENT); case OrderStatusIntent: return getOrderStatusIntentResponse(intent, customerId, session); case OrdersIntent: return getOrdersIntentResponse(intent, customerId, session); case OrderDetailIntent: return getOrderDetailIntentResponse(intent, customerId, session); case AmazonHelpIntent: return newAskResponse(RESPONSE_HELP_INTENT, true, RESPONSE_REPROMPT_HELP_INTENT, false); case AmazonCancelIntent: return getResponse(RESPONSE_GOODBYE, true); case AmazonStopIntent: return getResponse(RESPONSE_GOODBYE, true); default: throw new SpeechletException(RESPONSE_INVALID_INTENT); } } else { throw new SpeechletException(RESPONSE_INVALID_INTENT); } } catch (NumberFormatException e) { LOG.error("", e); throw new SpeechletException(RESPONSE_UNKNOWN_CUSTOMER); } catch (Exception e) { LOG.error("", e); throw new SpeechletException(e.getMessage()); } }
From source file:com.parking.billing.ParkingPayment.java
/** Called when the activity is first created. */ @Override//w w w . j a va 2s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.parkingpayment); mHandler = new Handler(); mParkingPurchaseObserver = new ParkingPurchaseObserver(mHandler); mBillingService = new BillingService(); mBillingService.setContext(this); mPurchaseDatabase = new PurchaseDatabase(DashboardActivity.myContext); //Get on the spot selected Intent starterIntent = getIntent(); Bundle bundle = starterIntent.getExtras(); TextView textAll = (TextView) findViewById(R.id.parkingAllDetailsTextView); /** Obtain time object **/ String timeObj = bundle.getString("time"); try { paidTime = Integer.parseInt(timeObj); Log.v(TAG, "Calculated time : " + paidTime); } catch (NumberFormatException nfe) { Log.v(TAG, "NumberFormatException: " + nfe.getMessage()); } /** Create parkingLocationObj */ String all = bundle.getString("info"); parkingLocationObj = LocationUtility.convertStringToObject(all); /** Use the object to populate fields */ String locAddress = "Address unavailable"; Geocoder geoCoder = new Geocoder(DashboardActivity.myContext, Locale.getDefault()); GeoPoint gp = new GeoPoint((int) (parkingLocationObj.getLatitude() * 1E6), (int) (parkingLocationObj.getLongitude() * 1E6)); locAddress = LocationUtility.ConvertPointToLocation(gp, geoCoder); Log.v(TAG, "Setting address to: " + locAddress); parkingLocationObj.setAddress(locAddress); String typeToDisplay = parkingLocationObj.getType() == null ? "Not known" : "" + parkingLocationObj.getType(); textAll.setText("\n" + "Address: " + parkingLocationObj.getAddress() + "\n" + "Type:" + typeToDisplay + "\n" + "MeterId: " + parkingLocationObj.getMeterID() + "\n" + "Number of Parking Spots at this location: " + parkingLocationObj.getQuantity() + "\n"); setupWidgets(); // Check if billing is supported. ResponseHandler.register(mParkingPurchaseObserver); if (!mBillingService.checkBillingSupported()) { showDialog(DIALOG_CANNOT_CONNECT_ID); } }
From source file:edu.nwpu.gemfire.monitor.controllers.PulseController.java
@RequestMapping(value = "/dataBrowserQuery", method = RequestMethod.GET) public void dataBrowserQuery(HttpServletRequest request, HttpServletResponse response) throws IOException { // get query string String query = request.getParameter("query"); String members = request.getParameter("members"); int limit = 0; try {/*from w w w . j ava 2s . com*/ limit = Integer.valueOf(request.getParameter("limit")); } catch (NumberFormatException e) { limit = 0; if (LOGGER.finerEnabled()) { LOGGER.finer(e.getMessage()); } } ObjectNode queryResult = mapper.createObjectNode(); try { if (StringUtils.isNotNullNotEmptyNotWhiteSpace(query)) { // get cluster object Cluster cluster = Repository.get().getCluster(); String userName = request.getUserPrincipal().getName(); // Call execute query method queryResult = cluster.executeQuery(query, members, limit); // Add query in history if query is executed successfully if (!queryResult.has("error")) { // Add html escaped query to history String escapedQuery = StringEscapeUtils.escapeHtml(query); cluster.addQueryInHistory(escapedQuery, userName); } } } catch (Exception e) { if (LOGGER.fineEnabled()) { LOGGER.fine("Exception Occured : " + e.getMessage()); } } response.getOutputStream().write(queryResult.toString().getBytes()); }
From source file:de.ub0r.android.websms.connector.sms77.ConnectorSms77.java
/** * Send data.//from w w w . j a v a 2 s. com * * @param context * Context * @param command * ConnectorCommand */ private void sendData(final Context context, // . final ConnectorCommand command) { // do IO try { // get Connection final ConnectorSpec cs = this.getSpec(context); final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); String url; ArrayList<BasicNameValuePair> d = // . new ArrayList<BasicNameValuePair>(); final String text = command.getText(); if (text != null && text.length() > 0) { url = URL_SEND; final String subCon = command.getSelectedSubConnector(); d.add(new BasicNameValuePair(PARAM_TEXT, text)); d.add(new BasicNameValuePair(PARAM_TO, Utils.joinRecipientsNumbers(command.getRecipients(), ",", true))); if (command.getFlashSMS()) { d.add(new BasicNameValuePair(PARAM_SUBCONNECTOR, "flash")); } else { d.add(new BasicNameValuePair(PARAM_SUBCONNECTOR, subCon)); } final String customSender = command.getCustomSender(); if (customSender == null) { // sms77.de don't like "+" in front of the number d.add(new BasicNameValuePair(PARAM_SENDER, Utils.national2international(command.getDefPrefix(), Utils.getSender(context, command.getDefSender())).substring(1))); } else { d.add(new BasicNameValuePair(PARAM_SENDER, customSender)); } long sendLater = command.getSendLater(); if (sendLater > 0) { d.add(new BasicNameValuePair(PARAM_SENDLATER, String.valueOf(sendLater / 1000))); } } else { url = URL_BALACNCE; } d.add(new BasicNameValuePair(PARAM_USERNAME, p.getString(Preferences.PREFS_USER, ""))); d.add(new BasicNameValuePair(PARAM_PASSWORD, Utils.md5(p.getString(Preferences.PREFS_PASSWORD, "")))); if (!USE_POST) { StringBuilder u = new StringBuilder(url); u.append("?"); final int l = d.size(); for (int i = 0; i < l; i++) { BasicNameValuePair nv = d.get(i); u.append(nv.getName()); u.append("="); u.append(URLEncoder.encode(nv.getValue(), "ISO-8859-15")); u.append("&"); } url = u.toString(); d = null; } Log.d(TAG, "HTTP REQUEST: " + url); HttpOptions httpOpts = new HttpOptions("ISO-8859-15"); httpOpts.url = url; if (d != null) { httpOpts.postData = new UrlEncodedFormEntity(d, "ISO-8859-15"); } httpOpts.knownFingerprints = CERT_FINGERPRINT; HttpResponse response = Utils.getHttpClient(httpOpts); int resp = response.getStatusLine().getStatusCode(); if (resp != HttpURLConnection.HTTP_OK) { throw new WebSMSException(context, R.string.error_http, " " + resp); } String htmlText = Utils.stream2str(response.getEntity().getContent()).trim(); Log.d(TAG, "HTTP RESPONSE: " + htmlText); int i = htmlText.indexOf('.'); if (i > 0) { cs.setBalance(htmlText.replace('.', ',') + "\u20AC"); } else { int ret; try { ret = Integer.parseInt(htmlText.trim()); } catch (NumberFormatException e) { Log.e(TAG, "could not parse text to int: " + htmlText); ret = 700; } checkReturnCode(context, ret); } } catch (IOException e) { Log.e(TAG, null, e); throw new WebSMSException(e.getMessage()); } }