List of usage examples for java.lang NumberFormatException toString
public String toString()
From source file:example.Example02.java
@Override public Response init(ChaincodeStub stub) { try {/* w ww. j a va 2s.com*/ final String function = stub.getFunction(); switch (function) { case "init": return init(stub, stub.getParameters().stream().toArray(String[]::new)); default: return newBadRequestResponse(format("Unknown function: %s", function)); } } catch (NumberFormatException e) { return newBadRequestResponse(e.toString()); } catch (IllegalArgumentException e) { return newBadRequestResponse(e.getMessage()); } catch (Throwable e) { return newInternalServerErrorResponse(e); } }
From source file:com.mec.Services.SuperiorService.java
private void initGeo(EstablecimientoPost establecimiento) { establecimiento.getLocalizacion().forEach((loc) -> { loc.getDomicilios().forEach((dom) -> { try { dom.setGeo(geoDAO.getByCueAnexo(Integer.parseInt(establecimiento.getCue()), Integer.parseInt(loc.getAnexo()))); } catch (NumberFormatException e) { System.out.println("NumberFormatException: " + e.toString()); }//www . ja v a 2s . c o m }); }); }
From source file:example.Example02.java
@Override public Response invoke(ChaincodeStub stub) { try {//from w w w. j av a2 s.c o m final String function = stub.getFunction(); final String[] args = stub.getParameters().stream().toArray(String[]::new); switch (function) { case "invoke": return invoke(stub, args); case "delete": return delete(stub, args); case "query": return query(stub, args); default: return newBadRequestResponse(format("Unknown function: %s", function)); } } catch (NumberFormatException e) { return newBadRequestResponse(e.toString()); } catch (IllegalArgumentException e) { return newBadRequestResponse(e.getMessage()); } catch (Throwable e) { return newInternalServerErrorResponse(e); } }
From source file:com.mec.Services.VoteroService.java
private void setGeo(EstablecimientoPost establecimiento) { establecimiento.getLocalizacion().forEach((loc) -> { loc.getDomicilios().forEach((dom) -> { try { dom.setGeo(geoDAO.getByCueAnexo(Integer.parseInt(establecimiento.getCue()), Integer.parseInt(loc.getAnexo()))); } catch (NumberFormatException e) { System.out.println("NumberFormatException: " + e.toString()); }/* ww w . j a v a 2s .com*/ }); }); }
From source file:net.myrrix.web.servlets.EstimateForAnonymousServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { CharSequence pathInfo = request.getPathInfo(); if (pathInfo == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path"); return;//from w ww. j av a 2 s. com } Iterator<String> pathComponents = SLASH.split(pathInfo).iterator(); long toItemID; Pair<long[], float[]> itemIDsAndValue; try { toItemID = Long.parseLong(pathComponents.next()); itemIDsAndValue = RecommendToAnonymousServlet.parseItemValuePairs(pathComponents); } catch (NoSuchElementException nsee) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString()); return; } catch (NumberFormatException nfe) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nfe.toString()); return; } if (itemIDsAndValue.getFirst().length == 0) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No items"); return; } long[] itemIDs = itemIDsAndValue.getFirst(); float[] values = itemIDsAndValue.getSecond(); MyrrixRecommender recommender = getRecommender(); try { float estimate = recommender.estimateForAnonymous(toItemID, itemIDs, values); Writer out = response.getWriter(); out.write(Float.toString(estimate)); out.write('\n'); } catch (NotReadyException nre) { response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString()); } catch (NoSuchItemException nsie) { response.sendError(HttpServletResponse.SC_NOT_FOUND, nsie.toString()); } catch (TasteException te) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.toString()); getServletContext().log("Unexpected error in " + getClass().getSimpleName(), te); } }
From source file:example.SimpleChaincode.java
@Override public Response init(ChaincodeStub stub) { try {/*from w w w . j a va 2 s. co m*/ final List<String> args = stub.getStringArgs(); switch (args.get(0)) { case "init": return init(stub, args.stream().skip(0).toArray(String[]::new)); default: return newBadRequestResponse(format("Unknown function: %s", args.get(0))); } } catch (NumberFormatException e) { return newBadRequestResponse(e.toString()); } catch (IllegalArgumentException e) { return newBadRequestResponse(e.getMessage()); } catch (Throwable e) { return newInternalServerErrorResponse(e); } }
From source file:example.SimpleChaincode.java
@Override public Response invoke(ChaincodeStub stub) { try {//from w w w. j av a2s.c o m final List<String> argList = stub.getStringArgs(); final String function = argList.get(0); final String[] args = argList.stream().skip(1).toArray(String[]::new); switch (function) { case "init": return init(stub, args); case "invoke": return invoke(stub, args); case "transfer": return transfer(stub, args); case "put": for (int i = 0; i < args.length; i += 2) stub.putStringState(args[i], args[i + 1]); return newSuccessResponse(); case "del": for (String arg : args) stub.delState(arg); return newSuccessResponse(); case "query": return query(stub, args); default: return newBadRequestResponse(newErrorJson("Unknown function: %s", function)); } } catch (NumberFormatException e) { return newBadRequestResponse(e.toString()); } catch (IllegalArgumentException e) { return newBadRequestResponse(e.getMessage()); } catch (Throwable e) { return newInternalServerErrorResponse(e); } }
From source file:com.moto.miletus.application.ble.neardevice.NearDeviceNotification.java
/** * notification/*from ww w . j a v a 2 s . c o m*/ * * @param room String * @param light ParameterValue * @param temp ParameterValue */ private void notification(final String room, final ParameterValue light, final ParameterValue temp) { String msg; if (room == null) { systemService.cancelAll(); return; } else if (light != null && temp != null) { msg = "Welcome to: " + room + Strings.NEW_LINE + "Light: " + light.getValue() + Strings.LUX + Strings.NEW_LINE; try { String tempRound = Precision.round(Float.parseFloat(temp.getValue()), 1) + ""; msg = msg + "Temp: " + tempRound + Strings.CELSIUS + Strings.NEW_LINE; } catch (NumberFormatException ex) { Log.e(TAG, ex.toString()); } } else { msg = "Welcome to: " + room + Strings.NEW_LINE; } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.miletus).setContentTitle("Room Status") .setPriority(NotificationCompat.PRIORITY_MAX).setContentText(msg); Intent resultIntent = new Intent(context, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); systemService.notify(9812, mBuilder.build()); Log.i(TAG, msg); }
From source file:net.myrrix.web.servlets.RecommendToAnonymousServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { CharSequence pathInfo = request.getPathInfo(); if (pathInfo == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No path"); return;//from w ww . j a va 2 s .com } Iterator<String> pathComponents = SLASH.split(pathInfo).iterator(); Pair<long[], float[]> itemIDsAndValue; try { itemIDsAndValue = parseItemValuePairs(pathComponents); } catch (NoSuchElementException nsee) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nsee.toString()); return; } catch (NumberFormatException nfe) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, nfe.toString()); return; } if (itemIDsAndValue.getFirst().length == 0) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No items"); return; } long[] itemIDs = itemIDsAndValue.getFirst(); float[] values = itemIDsAndValue.getSecond(); MyrrixRecommender recommender = getRecommender(); RescorerProvider rescorerProvider = getRescorerProvider(); try { IDRescorer rescorer = rescorerProvider == null ? null : rescorerProvider.getRecommendToAnonymousRescorer(itemIDs, recommender, getRescorerParams(request)); Iterable<RecommendedItem> recommended = recommender.recommendToAnonymous(itemIDs, values, getHowMany(request), rescorer); output(request, response, recommended); } catch (NotReadyException nre) { response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, nre.toString()); } catch (NoSuchItemException nsie) { response.sendError(HttpServletResponse.SC_NOT_FOUND, nsie.toString()); } catch (TasteException te) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, te.toString()); getServletContext().log("Unexpected error in " + getClass().getSimpleName(), te); } catch (IllegalArgumentException iae) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, iae.toString()); } }
From source file:cn.code.notes.gtask.data.SqlConn.java
public void commit(long noteId, boolean validateVersion, long version) { if (mIsCreate) { if (mId == INVALID_ID && mDiffDataValues.containsKey(ConnectColumns.NOTE_ID)) { mDiffDataValues.remove(ConnectColumns.NOTE_ID); }/*from www . j av a 2s . co m*/ mDiffDataValues.put(DataColumns.NOTE_ID, noteId); Uri uri = mContentResolver.insert(Notes.CONTENT_CONN_URI, mDiffDataValues); try { mId = Long.valueOf(uri.getPathSegments().get(1)); } catch (NumberFormatException e) { Log.e(TAG, "Get note id error :" + e.toString()); throw new ActionFailureException("create note failed"); } } else { if (mDiffDataValues.size() > 0) { int result = 0; if (!validateVersion) { result = mContentResolver.update(ContentUris.withAppendedId(Notes.CONTENT_CONN_URI, mId), mDiffDataValues, null, null); } else { result = mContentResolver.update(ContentUris.withAppendedId(Notes.CONTENT_CONN_URI, mId), mDiffDataValues, " ? in (SELECT " + NoteColumns.ID + " FROM " + TABLE.NOTE + " WHERE " + NoteColumns.VERSION + "=?)", new String[] { String.valueOf(noteId), String.valueOf(version) }); } if (result == 0) { Log.w(TAG, "there is no update. maybe user updates note when syncing"); } } } mDiffDataValues.clear(); mIsCreate = false; }