List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:it.crs4.most.ehrlib.widgets.DvQuantityWidget.java
/** * @see it.crs4.most.ehrlib.widgets.DatatypeWidget#save() *///from w ww .j av a2 s .co m @Override public void save() throws InvalidDatatypeException { String magnitude = _input.getText().toString().trim(); try { this.datatype.setMagnitude(Double.valueOf(magnitude)); } catch (NumberFormatException ex) { ex.printStackTrace(); throw new InvalidDatatypeException("No Double Number specified for magnitude:" + magnitude); } }
From source file:ilearn.orb.controller.ProfilesController.java
@RequestMapping(value = "/profiles/{userid}", method = RequestMethod.GET) public ModelAndView userProfile(Locale locale, @PathVariable("userid") Integer userid, ModelMap modelMap, HttpSession session) {/*w w w . j a v a 2 s. c o m*/ ModelAndView model = new ModelAndView(); model.setViewName("profiles"); try { String json; User[] students = null; UserProfile p = null; User selectedStudent = null; if (userid < 0) { students = HardcodedUsers.defaultStudents(); selectedStudent = selectedStudent(students, userid.intValue()); //p = HardcodedUsers.defaultProfile(selectedStudent.getId()); json = UserServices.getDefaultProfile(HardcodedUsers.defaultProfileLanguage(userid)); if (json != null) p = new Gson().fromJson(json, UserProfile.class); } else { Gson gson = new GsonBuilder().registerTypeAdapter(java.util.Date.class, new UtilDateDeserializer()) .setDateFormat(DateFormat.LONG).create(); json = UserServices.getProfiles(Integer.parseInt(session.getAttribute("id").toString()), session.getAttribute("auth").toString()); students = gson.fromJson(json, User[].class); selectedStudent = selectedStudent(students, userid.intValue()); json = UserServices.getJsonProfile(userid, session.getAttribute("auth").toString()); if (json != null) p = new Gson().fromJson(json, UserProfile.class); } String dataForCircles = ""; if (p != null) { String categories = "["; dataForCircles = "["; ProblemDescription probs[][] = p.getUserProblems().getProblems().getProblems(); for (int i = 0; i < probs.length; i++) { for (int j = 0; j < probs[i].length; j++) { dataForCircles = dataForCircles + "[" + i + ", " + p.getUserProblems().getUserSeverity(i, j) + ",\"" + probs[i][j].getHumanReadableDescription() + "\"]"; if (i != probs.length - 1 || j != probs[i].length - 1) dataForCircles = dataForCircles + ", "; } categories = categories + "\"" + p.getUserProblems().getProblemDefinition(i).getUri() + "\""; if (i != probs.length - 1) categories = categories + ", "; } categories = categories + "]"; dataForCircles = dataForCircles + "], " + categories + ", " + probs.length + ", \"" + p.getLanguage() + "\""; } modelMap.put("selectedStudent", selectedStudent); modelMap.put("students", students); modelMap.put("selectedProfile", p); modelMap.put("dataForCircles", dataForCircles); } catch (NumberFormatException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return model; }
From source file:com.zhihu.android.app.mirror.widget.ArtboardView.java
public boolean isScaling() { float scale;//w ww . j ava 2 s .c o m float minScale; try { BigDecimal decimal = new BigDecimal(getScale()); scale = decimal.setScale(2, BigDecimal.ROUND_FLOOR).floatValue(); decimal = new BigDecimal(getMinScale()); minScale = decimal.setScale(2, BigDecimal.ROUND_FLOOR).floatValue(); return scale > minScale; } catch (NumberFormatException e) { e.printStackTrace(); return false; } }
From source file:org.sonews.daemon.command.ArticleCommand.java
@Override public void processLine(NNTPConnection conn, final String line, byte[] raw) throws IOException { final String[] command = line.split(" "); Article article = null;//from w w w .j a va 2 s .c om long artIndex = -1; if (command.length == 1) { article = conn.getCurrentArticle(); if (article == null) { conn.println("420 no current article has been selected"); return; } } else if (command[1].matches(SynchronousNNTPConnection.MESSAGE_ID_PATTERN)) { // Message-ID article = Article.getByMessageID(command[1]); if (article == null) { conn.println("430 no such article found"); return; } } else { // Message Number try { Group currentGroup = conn.getCurrentGroup(); if (currentGroup == null) { conn.println("400 no group selected"); return; } artIndex = Long.parseLong(command[1]); article = currentGroup.getArticle(artIndex); } catch (NumberFormatException ex) { ex.printStackTrace(); } catch (StorageBackendException ex) { ex.printStackTrace(); } if (article == null) { conn.println("423 no such article number in this group"); return; } conn.setCurrentArticle(article); } if (command[0].equalsIgnoreCase("ARTICLE")) { conn.println( "220 " + artIndex + " " + article.getMessageID() + " article retrieved - head and body follow"); conn.println(article.getHeaderSource()); conn.println(""); conn.println(article.getBody()); conn.println("."); } else if (command[0].equalsIgnoreCase("BODY")) { conn.println("222 " + artIndex + " " + article.getMessageID() + " body"); conn.println(article.getBody()); conn.println("."); } /* * HEAD: This command is mandatory. * * Syntax HEAD message-id HEAD number HEAD * * Responses * * First form (message-id specified) 221 0|n message-id Headers follow * (multi-line) 430 No article with that message-id * * Second form (article number specified) 221 n message-id Headers * follow (multi-line) 412 No newsgroup selected 423 No article with * that number * * Third form (current article number used) 221 n message-id Headers * follow (multi-line) 412 No newsgroup selected 420 Current article * number is invalid * * Parameters number Requested article number n Returned article * number message-id Article message-id */else if (command[0].equalsIgnoreCase("HEAD")) { conn.println("221 " + artIndex + " " + article.getMessageID() + " Headers follow (multi-line)"); conn.println(article.getHeaderSource()); conn.println("."); } }
From source file:de.badaix.snapcast.ServerDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout View view = inflater.inflate(R.layout.dialog_server, null); btnScan = (Button) view.findViewById(R.id.btn_scan); btnScan.setOnClickListener(this); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) btnScan.setVisibility(View.GONE); editHost = (EditText) view.findViewById(R.id.host); editStreamPort = (EditText) view.findViewById(R.id.stream_port); editControlPort = (EditText) view.findViewById(R.id.control_port); checkBoxAutoStart = (CheckBox) view.findViewById(R.id.checkBoxAutoStart); update();/*from ww w. j a va 2 s. c o m*/ builder.setView(view) // Add action buttons .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // sign in the user ... host = editHost.getText().toString(); try { streamPort = Integer.parseInt(editStreamPort.getText().toString()); controlPort = Integer.parseInt(editControlPort.getText().toString()); } catch (NumberFormatException e) { e.printStackTrace(); } if (listener != null) { listener.onHostChanged(host, streamPort, controlPort); listener.onAutoStartChanged(checkBoxAutoStart.isChecked()); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { ServerDialogFragment.this.getDialog().cancel(); } }).setTitle(R.string.server_host).setCancelable(false); return builder.create(); }
From source file:it.isislab.sof.core.engine.hadoop.sshclient.connection.SofManager.java
/** * download the simulation's folder from hdfs filesystem in zip format * @param session//from w ww . ja va2 s . c om * @param simID simulation id * @param dowload_client_path destination download directory (client side) */ public static void downloadSimulation(EnvironmentSession session, String simID, String dowload_client_path) { String hdfs_sim_path = fs.getHdfsUserPathSimulationByID(simID); String client_tmp_file_path = fs.getClientPathForTmpFile(); try { if (!HadoopFileSystemManager.ifExists(session, hdfs_sim_path)) { System.err.println("Simulation SIM-" + simID + " not exists"); return; } } catch (NumberFormatException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (JSchException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String client_tmp_download = fs.getClientPathForTmpFolder(); makeLocalTemporaryFolder(client_tmp_download); try { HadoopFileSystemManager.downloadFolderFromHdfsToClient(session, hdfs_sim_path, client_tmp_download); } catch (NumberFormatException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return; } catch (JSchException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return; } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); return; } String fileZipName = session.getUsername() + "-SIM" + simID + ".zip"; File zip = new File(dowload_client_path + File.separator + fileZipName); if (zip.exists()) zip.delete(); try { zipDir(client_tmp_file_path, client_tmp_download); FileUtils.moveFile(new File(client_tmp_file_path), new File(dowload_client_path + File.separator + fileZipName)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return; } removeLocalTemporaryFolder(fs.getClientSOFHome()); }
From source file:com.coco.rolldigitaltextview.RollDigitalTextView.java
private void saveOriginalText(CharSequence text, BufferType type) { mOriginalText = text;// ww w.j a va2 s. c om mOriginalTextType = type; try { mOriginalDigital = Double.parseDouble(mOriginalText.toString()); } catch (NumberFormatException e) { e.printStackTrace(); mOriginalDigital = 0f; } }
From source file:es.rafaespillaque.RealTimeApp.java
private void updatePos(int newPosId, JSONObject jsonObject) { try {//from w ww. j av a 2s . c om float x = Float.parseFloat(jsonObject.getString("x")); float y = Float.parseFloat(jsonObject.getString("y")); Model m = new Model(false); m.pos.set(x, y); users.put(newPosId, m); } catch (NumberFormatException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.amo.meer.APPVersion.java
public void needUpdate() { RequestQueue mQueue = Volley.newRequestQueue(context); JsonObjectUTF8Request jReq = new JsonObjectUTF8Request(updateJsonURL, null, new Response.Listener<JSONObject>() { @Override/*from ww w. ja va 2 s. c om*/ public void onResponse(JSONObject response) { try { Log.d("TAG", response.toString()); if (Integer.valueOf(response.get("versionCode").toString()) > getVerCode()) { showUpdateNotice(response); } else { showNotNewVersion(context); } } catch (NumberFormatException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { } }); mQueue.add(jReq); mQueue.start(); }
From source file:e.pkg3.pkg6a.acertijo.acertijo.java
private void botonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonActionPerformed int numero_Usuario = 0; try {//from w w w. ja v a2s.co m numero_Usuario = Integer.valueOf(texto.getText()); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(this, "Introduce un Numero"); e.printStackTrace(); contador++; } int resta = numero_Aleatorio - numero_Usuario; if (resta < 0) { area.setText("El numero es menor que " + numero_Usuario); } if (resta > 0) { area.setText("El numero es mayor que " + numero_Usuario); } contador++; if (resta == 0) { Calendar fin = Calendar.getInstance(); String formato = "HH:mm:ss"; long inicioMilis = (inicio.get(Calendar.HOUR) * 3600000L) + (inicio.get(Calendar.MINUTE) * 60000L) + (inicio.get(Calendar.SECOND) * 1000L); long finalMilis = (fin.get(Calendar.HOUR) * 3600000L) + (fin.get(Calendar.MINUTE) * 60000L) + (fin.get(Calendar.SECOND) * 1000L); String duracion = DurationFormatUtils.formatPeriod(inicioMilis, finalMilis, formato); area.setText("El numero es Correcto!\n"); area.append("Acertado en " + contador + " intentos\n"); area.append("Acertado en " + duracion); contador = 0; boton.setEnabled(false); texto.setEnabled(false); } }