List of usage examples for java.lang NumberFormatException printStackTrace
public void printStackTrace()
From source file:com.piusvelte.hydra.UnidataConnection.java
private String getRecordID(String object, String[] columns, String[] values) throws Exception { String recordID = null;/*from ww w . j a va2s. c om*/ for (int c = 0; (c < columns.length) && (c < values.length); c++) { if (("@ID").equals(columns[c])) { recordID = values[c]; break; } } ArrayList<String> keyNames = new ArrayList<String>(); if (recordID == null) { // @ID wasn't sent, look for the Colleague I-descriptors ArrayList<Integer> keyLocs = new ArrayList<Integer>(); UniCommand uCommand = mSession.command(); uCommand.setCommand(String.format(SELECTION_QUERY_FORMAT, "DICT " + object, "SELECT DICT STUDENT.TERMS WITH LOC LIKE 'FIELD(@ID,...*...'").toString()); UniSelectList uSelect = mSession.selectList(0); uCommand.exec(); UniDictionary dict = mSession.openDict(object); UniString fieldID = null; Pattern keyPattern = Pattern.compile("^FIELD\\(@ID,\"\\*\",\\d+\\)"); try { while ((fieldID = uSelect.next()).length() > 0) { dict.setRecordID(fieldID); String loc = dict.getLoc().toString(); if (keyPattern.matcher(loc).matches()) { int keyLoc = Integer.parseInt(loc.substring(14, loc.length() - 1)); if (!keyLocs.contains(keyLoc)) { keyLocs.add(keyLoc); keyNames.add(fieldID.toString()); } } } } catch (NumberFormatException e) { e.printStackTrace(); } catch (UniSelectListException e) { e.printStackTrace(); } catch (UniFileException e) { e.printStackTrace(); } dict.close(); int s = keyNames.size(); if (s > 0) { // check if the keys are defined String[] keyParts = new String[s]; int partsFound = 0; for (int k = 0; k < s; k++) { for (int c = 0; (c < columns.length) && (c < values.length); c++) { if (keyNames.get(k).equals(columns[c])) { keyParts[keyLocs.get(k)] = values[c]; partsFound++; break; } } } if (partsFound < s) throw new Exception("key not defined"); else { recordID = ""; for (int k = 0; k < s; k++) recordID += keyParts[k]; } } } return recordID; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SelectGeneRawFileListener.java
public boolean checkFormat(File file) { try {/*w w w . ja v a 2 s.c om*/ BufferedReader br = new BufferedReader(new FileReader(file)); String line = br.readLine(); line = br.readLine(); //split must has a limit to take into account empty strings int columnsNbr = line.split("\t", -1).length; if (columnsNbr < 2) { this.selectRawFileUI.displayMessage("Error:\nAt least two columns are required"); br.close(); return false; } while ((line = br.readLine()) != null) { if (line.compareTo("") != 0) { String[] fields = line.split("\t", -1); if (fields.length != columnsNbr) { this.selectRawFileUI.displayMessage("Error:\nLines have no the same number of columns"); br.close(); return false; } for (int i = 1; i < fields.length; i++) { try { Double.valueOf(fields[i]); } catch (NumberFormatException e) { this.selectRawFileUI.displayMessage("Error:\nIntensity values are to be numbers"); br.close(); return false; } } } } br.close(); } catch (Exception e) { selectRawFileUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); return false; } return true; }
From source file:org.apache.hadoop.hbase.master.GroupAssignmentManager.java
/** * set the table priority,because disable sometimes failed,so we disable one * table twice./* w ww .ja v a 2s . c o m*/ * * @param priority * priority String * @param table * table name */ @SuppressWarnings("static-access") public static void setPriority(String priority, String table) { try { Integer.parseInt(priority); } catch (NumberFormatException e) { e.printStackTrace(); return; } try { HBaseAdmin admin = new HBaseAdmin(conf); HTableDescriptor des = admin.getTableDescriptor(Bytes.toBytes(table)); des.setValue(Bytes.toBytes(ScheduleHBaseServer.pri_string), Bytes.toBytes(priority)); LOG.info("disable table start ............."); try { admin.disableTable(table); Thread.currentThread().sleep(3000); admin.disableTable(table); } catch (Exception e1) { e1.printStackTrace(); } try { Thread.currentThread().sleep(10000); } catch (InterruptedException e1) { e1.printStackTrace(); } LOG.info(".....disable finished ............."); try { admin.modifyTable(des.getName(), des); LOG.info(".....modify priority finished ............."); } catch (Exception e) { e.printStackTrace(); } try { admin.enableTable(table); LOG.info(".....enable table finished ............."); } catch (Exception e) { e.printStackTrace(); } } catch (MasterNotRunningException e) { e.printStackTrace(); } catch (ZooKeeperConnectionException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:prism.PlotsExporter.java
/** * Parse and set the options if given by the user. If not, keep the defaults * @param option the options to be parsed *//*ww w .j a va 2 s. c o m*/ public void parseOptions(String option) { // tokenize using the '=' sign StringTokenizer tokens = new StringTokenizer(option, "="); try { switch (tokens.nextToken()) { case "height": height = Integer.parseInt(tokens.nextToken()); break; case "width": width = Integer.parseInt(tokens.nextToken()); break; case "sr": samplingRate = Integer.parseInt(tokens.nextToken()); break; case "errortype": String type = tokens.nextToken(); if (type.equalsIgnoreCase("deviation")) { errorType = PrismErrorRenderer.ERRORDEVIATION; } else if (type.equalsIgnoreCase("errorbars")) { errorType = PrismErrorRenderer.ERRORBARS; } break; } } catch (NumberFormatException e) { System.out.println("Invalid format of options given."); e.printStackTrace(); } }
From source file:cn.vlabs.duckling.vwb.VWBContext.java
public String getHTML(String pagename) { int id = 0;/*from w w w .j av a 2s . c o m*/ if (pagename != null) { try { id = Integer.valueOf(pagename); } catch (NumberFormatException e) { e.printStackTrace(); } } DPage dpage = getContainer().getDpageService().getLatestDpageByResourceId(getSiteId(), id); return getHTML(dpage); }
From source file:cn.vlabs.duckling.vwb.VWBContext.java
public String getHTML(String pagename, int version) { int id = 0;/* w w w .j a v a 2 s .c o m*/ if (pagename != null) { try { id = Integer.valueOf(pagename); } catch (NumberFormatException e) { e.printStackTrace(); } } DPage dpage = getContainer().getDpageService().getDpageVersionContent(getSiteId(), id, version); return getHTML(dpage); }
From source file:org.frontcache.core.RequestContext.java
/** * sets the content-length from the origin response * * @param v parses the string into an int *//* w w w. j ava 2s .co m*/ public void setOriginContentLength(String v) { try { final Long i = Long.valueOf(v); set("originContentLength", i); } catch (NumberFormatException e) { e.printStackTrace(); } }
From source file:org.archive.wayback.webapp.AccessPoint.java
public void setBeanName(String beanName) { this.beanName = beanName; this.contextName = ""; int idx = beanName.indexOf(":"); if (idx > -1) { contextPort = Integer.valueOf(beanName.substring(0, idx)); contextName = beanName.substring(idx + 1); } else {/*from w w w .ja v a 2s . c om*/ try { this.contextPort = Integer.valueOf(beanName); } catch (NumberFormatException e) { e.printStackTrace(); } } }
From source file:com.objy.se.ClassAccessor.java
public Object getCorrectValue(String strValue, LogicalType logicalType) { Object retValue = null;//from w w w . j ava2 s. c om switch (logicalType) { case INTEGER: { long attrValue = 0; try { if (!strValue.equals("")) { attrValue = Long.parseLong(strValue); } } catch (NumberFormatException nfEx) { // System.out.println("... entry: " + entry.getValue() + " for raw: " + entry.getKey()); nfEx.printStackTrace(); throw nfEx; } retValue = Long.valueOf(attrValue); } break; case REAL: { double attrValue = 0; try { if (!strValue.equals("")) { attrValue = Double.parseDouble(strValue); } } catch (NumberFormatException nfEx) { // System.out.println("... entry: " + entry.getValue() + " for raw: " + entry.getKey()); nfEx.printStackTrace(); throw nfEx; } retValue = Double.valueOf(attrValue); } break; case STRING: retValue = strValue; break; case BOOLEAN: { if (strValue.equalsIgnoreCase("TRUE") || strValue.equals("1")) { retValue = Boolean.valueOf(true); } else if (strValue.equalsIgnoreCase("FALSE") || strValue.equals("0")) { retValue = Boolean.valueOf(false); } else { LOG.error("Expected Boolean value but got: {}", strValue); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } break; case CHARACTER: { if (strValue.length() == 1) { retValue = Character.valueOf(strValue.charAt(0)); } else { /* not a char value... report that */ LOG.error("Expected Character value but got: {}", strValue); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } break; case DATE: { try { LocalDate ldate = LocalDate.parse(strValue, dateFormatter); // System.out.println("... ... year: " + ldate.getYear() + " - month:" + ldate.getMonthValue()); retValue = new com.objy.db.Date(ldate.getYear(), ldate.getMonthValue(), ldate.getDayOfMonth()); } catch (DateTimeParseException ex) { LOG.error(ex.toString()); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } break; case DATE_TIME: { try { // System.out.println(".... formatter: " + mapper.getDateTimeFormat()); LocalDateTime ldt = LocalDateTime.parse(strValue, dateTimeFormatter); // System.out.println("... ... year: " + ldt.getYear() + // " - month:" + ldt.getMonthValue() + " - day: " + // ldt.getDayOfMonth() + " - hour: " + ldt.getHour() + // " - min: " + ldt.getMinute() + " - sec: " + // ldt.getSecond() + " - nsec: " + ldt.getNano() ); //retValue = new com.objy.db.DateTime(date.getTime(), TimeKind.LOCAL); retValue = new com.objy.db.DateTime(ldt.getYear(), ldt.getMonthValue(), ldt.getDayOfMonth(), ldt.getHour(), ldt.getMinute(), ldt.getSecond(), ldt.getNano()); } catch (DateTimeParseException ex) { LOG.error(ex.toString()); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } break; case TIME: { try { // System.out.println(".... formatter: " + mapper.getTimeFormat()); LocalDateTime ltime = LocalDateTime.parse(strValue, dateFormatter); // System.out.println("... ... hour: " + ltime.getHour() + // " - min: " + ltime.getMinute() + " - sec: " + // ltime.getSecond() + " - nsec: " + ltime.getNano() ); //retValue = new com.objy.db.DateTime(date.getTime(), TimeKind.LOCAL); retValue = new com.objy.db.Time(ltime.getHour(), ltime.getMinute(), ltime.getSecond(), ltime.getNano()); } catch (DateTimeParseException ex) { LOG.error(ex.toString()); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } default: { throw new UnsupportedOperationException("LogicalType: " + logicalType + " is not supported!!!"); } } return retValue; }
From source file:massbank.BatchJobWorker.java
/** * Ytt@C???ieLXg`?j/*from w w w .ja va 2 s .c om*/ * @param time NGXg * @param resultFile t@C * @param textFile YtpeLXgt@C */ private void createTextFile(String time, File resultFile, File textFile) { NumberFormat nf = NumberFormat.getNumberInstance(); LineNumberReader in = null; PrintWriter out = null; try { in = new LineNumberReader(new FileReader(resultFile)); out = new PrintWriter(new BufferedWriter(new FileWriter(textFile))); // wb_?[?o String reqIonStr = "Both"; try { if (Integer.parseInt(this.ion) > 0) { reqIonStr = "Positive"; } else if (Integer.parseInt(this.ion) < 0) { reqIonStr = "Negative"; } } catch (NumberFormatException nfe) { nfe.printStackTrace(); } out.println("***** MassBank Batch Service Results *****"); out.println(); out.println("Request Date: " + time); out.println("# Instrument Type: " + this.inst); out.println("# Ion Mode: " + reqIonStr); out.println(); out.println(); // ?o String line; long queryCnt = 0; boolean readName = false; boolean readHit = false; boolean readNum = false; boolean isFinalLine = false; while ((line = in.readLine()) != null) { isFinalLine = false; if (in.getLineNumber() < 4) { continue; } if (!readName) { queryCnt++; out.println("### Query " + nf.format(queryCnt) + " ###"); out.println("# Name: " + line.trim()); readName = true; } else if (!readHit) { out.println("# Hit: " + nf.format(Integer.parseInt(line.trim()))); out.println(); readHit = true; } else if (!readNum) { out.println("Top " + line.trim() + " List"); out.println("Accession\tTitle\tFormula\tIon\tScore\tHit"); out.println(); readNum = true; } else { if (!line.trim().equals("")) { String[] data = formatLine(line); StringBuilder sb = new StringBuilder(); sb.append(data[0]).append("\t").append(data[1]).append("\t").append(data[2]).append("\t") .append(data[3]).append("\t").append(data[4]).append("\t").append(data[5]); out.println(sb.toString()); } else { out.println(); out.println(); readName = false; readHit = false; readNum = false; isFinalLine = true; } } } if (!isFinalLine) { out.println(); out.println(); } out.println("##### END #####"); out.println(); out.println("**********************************************************"); out.println("* MassBank.jp - High Resolution Mass Spectral Database *"); out.println("* URL: http://www.massbank.jp/ *"); out.println("**********************************************************"); out.println(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (in != null) { in.close(); } } catch (IOException e) { } if (out != null) { out.flush(); out.close(); } } }