List of usage examples for java.lang NumberFormatException getMessage
public String getMessage()
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.action.TraceFileProcessor.java
private void processLine(final String line, final int lineNum, final Map<String, Integer> barcodeIds, final File traceFile, final Date fileDate, final Long fileInfoId, final QcContext context) { // validator checks that first element is an integer and second is barcode. first line may be header. final String[] fields = line.split("\\t"); final Long traceId; try {// w w w . j a v a2s . c o m traceId = Long.parseLong(fields[0]); } catch (NumberFormatException e) { if (lineNum > 1) { // if not the first line, a non-integer is an error context.getArchive().setDeployStatus(Archive.STATUS_IN_REVIEW); context.addError(MessageFormat.format(MessagePropertyType.TRACE_FILE_PROCESSING_ERROR, traceFile.getName(), "Contains an invalid trace ID: " + fields[0])); } return; } final String barcode = fields[1].trim(); Integer barcodeId = barcodeIds.get(barcode); // have not seen this barcode yet, so get the id from the db if (barcodeId == null) { barcodeId = bcrIdQueries.exists(barcode); if (barcodeId == -1) { // not in db, so orphan... need to insert it try { BCRID commonBcrId = bcrDataService.parseAliquotBarcode(barcode); commonBcrId.setFullID(barcode); bcrDataService.storeBarcode(commonBcrId, -1, context.getArchive().getTheTumor()); barcodeIds.put(barcode, barcodeId); } catch (ParseException e) { context.getArchive().setDeployStatus(Archive.STATUS_IN_REVIEW); context.addError(MessageFormat.format(MessagePropertyType.TRACE_FILE_PROCESSING_ERROR, traceFile.getName(), new StringBuilder().append("Barcode '").append(barcode).append("', on line '") .append(lineNum).append("' is in an invalid format").toString())); return; } catch (UUIDException e) { context.getArchive().setDeployStatus(Archive.STATUS_IN_REVIEW); context.addError(MessageFormat.format(MessagePropertyType.TRACE_FILE_PROCESSING_ERROR, traceFile.getName(), e.getMessage())); return; } } else { barcodeIds.put(barcode, barcodeId); } } // now add trace relationship insertTraceRelationship(barcodeId, traceId, fileInfoId, fileDate, context); }
From source file:com.krawler.formbuilder.servlet.ModuleBuilderController.java
private List<ModuleClause> prepareClauses(HttpServletRequest request) { List<ModuleClause> clauses = new ArrayList<ModuleClause>(); String js = request.getParameter(PARAM_FILTER_JSON); try {//from www. j a v a 2 s . c o m clauses.add(new ModuleClause("deleteflag", "=", 0.0)); JSONArray jArr = new JSONArray(js); ModuleClause mc; for (int i = 0; i < jArr.length(); i++) { JSONObject objJSONObject = (JSONObject) jArr.get(i); if (objJSONObject.getString(CONST_XTYPE).equals(PARAM_DATEFIELD)) { String[] splitString = objJSONObject.getString(PARAM_SEARCH_TEXT).split(COMMA); String fromDate = splitString[0]; String toDate = splitString[1]; mc = new ModuleClause(objJSONObject.getString(CONST_COLUMN), OP_GREATER_THAN_EQUAL, fromDate + CONST_DAY_START_TIME); clauses.add(mc); mc = new ModuleClause(objJSONObject.getString(CONST_COLUMN), OP_LESS_THAN_EQUAL, toDate + CONST_DAY_START_TIME); clauses.add(mc); } else if (objJSONObject.getString(CONST_XTYPE).equals(PARAM_NUMBERFIELD)) { Number num; try { num = Long.parseLong(objJSONObject.getString(PARAM_SEARCH_TEXT)); } catch (NumberFormatException ex) { num = Double.parseDouble(objJSONObject.getString(PARAM_SEARCH_TEXT)); } mc = new ModuleClause(objJSONObject.getString(CONST_COLUMN), PARAM_OP_EQUAL, num); clauses.add(mc); } else if (objJSONObject.getString(CONST_XTYPE).equals(PARAM_RADIO) || objJSONObject.getString(CONST_XTYPE).equals(PARAM_CHECKBOX)) { mc = new ModuleClause(objJSONObject.getString(CONST_COLUMN), PARAM_OP_EQUAL, Boolean.parseBoolean(objJSONObject.getString(PARAM_SEARCH_TEXT))); clauses.add(mc); } else if (objJSONObject.getString(CONST_XTYPE).equals(PARAM_TIMEFIELD)) { mc = new ModuleClause(objJSONObject.getString(CONST_COLUMN), PARAM_OP_EQUAL, objJSONObject.getString(PARAM_SEARCH_TEXT)); clauses.add(mc); } else if (objJSONObject.getString(CONST_XTYPE).equals(PARAM_COMBO)) { mc = new ModuleClause(objJSONObject.getString(CONST_COLUMN), PARAM_OP_EQUAL, objJSONObject.getString(PARAM_SEARCH_TEXT)); clauses.add(mc); } else { mc = new ModuleClause(objJSONObject.getString(CONST_COLUMN), PARAM_OP_LIKE, PARAM_OP_MATCH + objJSONObject.getString(PARAM_SEARCH_TEXT) + PARAM_OP_MATCH); clauses.add(mc); } } } catch (JSONException ex) { logger.warn(ex.getMessage(), ex); } return clauses; }
From source file:com.npower.dm.processor.JobProcessSelector.java
/** * Get a processor for server initiated. * @param dms//from w w w . jav a 2s. c o m * @param devInfo * @param init * @return */ private ManagementProcessor getProcessor4ServerInitiated(DeviceDMState dms, DevInfo devInfo, ManagementInitialization init) { if (log.isDebugEnabled()) { log.debug("select a processor for DMState: " + dms); } String deviceExternalID = devInfo.getDevId(); if (log.isDebugEnabled()) { log.debug("device id: " + deviceExternalID); } if (deviceExternalID.toUpperCase().startsWith("IMEI:")) { // Clear the prefix "IMEI:" //deviceExternalID = deviceExternalID.substring(5, deviceExternalID.length()); } ManagementBeanFactory factory = null; try { factory = ManagementBeanFactory.newInstance(EngineConfig.getProperties()); DeviceBean deviceBean = factory.createDeviceBean(); Device device = deviceBean.getDeviceByExternalID(deviceExternalID); if (device == null) { // Return a defaultProcessor for none-register device. if (log.isDebugEnabled()) { log.debug("No job for this processor, reset the DMState.mssid=0"); } dms.mssid = "0"; return getProcessorByName(this.getErrorProcessor()); } ProvisionJobBean jobBean = factory.createProvisionJobBean(); /** * SelectorProcessor: * 1. DeviceDMStatemssid0, DefaultProcessor. * 2. DeviceDMStatemssidJobID, jobIDJobTypeProcessor. * 3. mssid0jobID, JobIDJobDone, RuntimeException, mssidJob * * 0JobIDJobQueueProcessor, JobQueueProcessor,getProcessor(...)mssidJobID. */ String processorName = null; long jobID = 0; try { if (dms.mssid != null) { jobID = new Long(dms.mssid).longValue(); } } catch (NumberFormatException e) { } if (jobID <= 1) { // Find job if (log.isDebugEnabled()) { log.debug("No jobID assigned for ProcessorSelector, Find jobs from DM inventory."); } // JobQueue, Processor ProcessorRecord result = getProcessorByJobQueue(jobBean, device); jobID = result.getJobID(); processorName = result.getProcessName(); } else { // Load Job, checking the job status. ProvisionJob job = jobBean.loadJobByID(jobID); if (job == null) { throw new RuntimeException("Invalidate jobID: " + jobID + ", no exists!"); } processorName = JobProcessSelector.getProcessorByJobType(job.getJobType()); jobID = job.getID(); } // Store the jobID into dmState.mssid if (log.isDebugEnabled()) { log.debug("Set the jobID: " + jobID + " to the DMState.mssid"); } dms.mssid = Long.toString(jobID); if (log.isDebugEnabled()) { log.debug("selected processor: " + processorName); } log.info("selected processor: " + processorName + " for device: " + device.getID()); ManagementProcessor processor = getProcessorByName(processorName); return processor; } catch (Exception e) { log.error("Error select procesor: " + e.getMessage(), e); } finally { if (factory != null) { factory.release(); } } return null; }
From source file:org.kuali.mobility.knowledgebase.service.KnowledgeBaseServiceImpl.java
private KnowledgeBaseSearchResultContainer convertSearchDocument(Document doc) { KnowledgeBaseSearchResultContainer container = new KnowledgeBaseSearchResultContainer(); try {/*from w w w .j a va 2s . c om*/ if (doc != null) { Element root = doc.getRootElement(); String numResultsStr = root.getChildText("numResults"); int numResults = 0; try { numResults = Integer.parseInt(numResultsStr); if (numResults > 300) { numResults = 300; } container.setNumberOfResults(numResults); } catch (NumberFormatException e) { } String startStr = root.getChildText("start"); int start = 0; try { start = Integer.parseInt(startStr); container.setStart(start); container.setIndexLastInView(start); } catch (NumberFormatException e) { } if (numResults > 0) { Element results = root.getChild("results"); List resultList = results.getChildren("result"); boolean firstResult = true; int count = 0; for (Iterator iterator = resultList.iterator(); iterator.hasNext();) { Element result = (Element) iterator.next(); String documentId = processChildText(result, "docid"); String title = processChildText(result, "title"); KnowledgeBaseSearchResult searchResult = new KnowledgeBaseSearchResult(); searchResult.setDocumentId(documentId); searchResult.setTitle(title); container.getResults().add(searchResult); // Index of the last item in view should not increment for the first result. if (firstResult) { firstResult = false; } else { container.setIndexLastInView(container.getIndexLastInView() + 1); } count++; } } // TESTING // String xml = new XMLOutputter().outputString(doc); // LOG.info(xml); } } catch (Exception e) { LOG.error(e.getMessage(), e); } return container; }
From source file:jp.zippyzip.impl.GeneratorServiceImpl.java
String fromHex(String hex) { StringBuilder ret = new StringBuilder(); for (int i = 0; i < hex.length(); i += 4) { try {// w w w . j a v a 2 s . co m ret.append((char) Integer.parseInt(hex.substring(i, i + 4), 16)); } catch (NumberFormatException e) { log.warning(e.getMessage() + " : \"" + hex.substring(i, i + 4) + "\""); } } return ret.toString(); }
From source file:com.ephesoft.dcma.gwt.admin.bm.server.BatchClassManagementServiceImpl.java
private void setBatchClassInfo(BatchClassDTO batchClassDTO, BatchClass batchClass) { batchClass.setDescription(batchClassDTO.getDescription()); String batchClassPriority = batchClassDTO.getPriority(); try {// w w w. ja v a 2 s . c o m int priority = Integer.valueOf(batchClassPriority); batchClass.setPriority(priority); } catch (NumberFormatException e) { LOGGER.error("Error converting priority: " + batchClassPriority + "for batch class:" + batchClassDTO.getName() + " ." + e.getMessage(), e); } batchClass.setUncFolder(batchClassDTO.getUncFolder()); batchClass.setName(batchClassDTO.getName()); batchClass.setId(0); batchClass.setIdentifier(null); batchClass.setCurrentUser(null); batchClass.setVersion(AdminConstants.VERSION); batchClass.setEmailConfigurations(null); batchClass.setSystemFolder(batchClassDTO.getSystemFolder()); List<BatchClassGroups> batchClassGroupsList = batchClass.getAssignedGroups(); for (BatchClassGroups batchClassGroups : batchClassGroupsList) { batchClassGroups.setId(0); } batchClass.setAssignedGroups(batchClassGroupsList); batchClass.setDeleted(false); }
From source file:io.datenwelt.cargo.rest.Request.java
public <T> Optional<T> getBodyAs(Class<? extends T> targetClass) throws APIException { Optional<ContentTypeHeader> contentTypeHeader = contentType(); if (!contentTypeHeader.isPresent()) { return Optional.empty(); }// w w w . j a va 2s . c om String contentLengthString = header("Content-Length") .orElseThrow(() -> (new APIException(new LengthRequired()))).asString(); int contentLength; try { contentLength = Integer.parseInt(contentLengthString); } catch (NumberFormatException ex) { throw new APIException(new BadRequest("Unparseable number in Content-Length header.")); } if (contentLength < 0) { throw new APIException(new BadRequest("Negative number value in Content-Length header.")); } if (contentLength == 0) { return Optional.empty(); } ContentConsumer consumer = null; for (ContentType contentType : supportedContentTypes) { try { Optional<ContentConsumer> optionalConsumer = contentType.consumerFrom(contentTypeHeader.get(), this, targetClass); if (optionalConsumer != null && optionalConsumer.isPresent()) { consumer = optionalConsumer.get(); break; } } catch (Exception ex) { LOG.debug("Error trying to retrieve consumer from content type {}for \"{}\" - skipping: ", contentType, contentTypeHeader.get().combined(), ex); } } if (consumer == null) { throw new APIException(new UnsupportedMediaType()); } InputStream encodingInputStream = null; for (ContentEncoding encoding : supportedContentEncodings) { try { Optional<ContentDecoder> decoder = encoding.decoderFor(this); if (decoder.isPresent()) { encodingInputStream = decoder.get().decode(servletRequest.getInputStream(), this); } } catch (IOException | RuntimeException ex) { LOG.debug("Error trying to retrieve decoder from content encoding {}for \"{}\" - skipping: {}", encoding, this, ex.getMessage(), ex); } } if (encodingInputStream == null) { throw new APIException(new UnprocessableEntity()); } try { return Optional.ofNullable(consumer.consume(encodingInputStream, this, targetClass)); } catch (IOException | RuntimeException ex) { LOG.debug("Unable to deserialize body from request {} as {}: {}", this, targetClass.getName(), ex.getMessage(), ex); throw new APIException(new InternalServerError()); } }
From source file:com.craftcosta.jailrules.rpgcraftcosta.GUI.java
private void draw_graph_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_draw_graph_btnActionPerformed int level;/*from ww w . j a v a 2 s. c o m*/ boolean error; try { graph_panel.removeAll(); if (max_level.getText().equals("")) { this.max_level.setBackground(Color.red); throw new Exception("Rellena el campo nivel mximo"); } else { level = Integer.parseInt(max_level.getText()); if (level <= 0) { this.max_level.setBackground(Color.red); throw new Exception("Selecciona un nivel mayor que 0 para continuar"); } else { this.max_level.setBackground(Color.white); //dibujar grafico XYDataset dataset = createDataset(level); JFreeChart chart = ChartFactory.createXYLineChart("Level Progression", "level", "experience needed", dataset); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(800, 500)); chartPanel.setMouseWheelEnabled(true); graph_panel.setLayout(new java.awt.BorderLayout()); graph_panel.add(chartPanel, BorderLayout.CENTER); graph_panel.validate(); graph_panel.repaint(); } } } catch (NumberFormatException e) { JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Error en nivel maximo", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } catch (Exception e) { JOptionPane.showMessageDialog(rootPane, e.getMessage(), "Error en nivel maximo", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } }
From source file:com.clustercontrol.agent.Agent.java
/** * ??awakeAgent?/* w w w . java2s . c o m*/ * Agent.properties???UDP?24005??????????(releaseLatch) * ????ReceiveTopic????Topic???? */ public void waitAwakeAgent() { final int BUFSIZE = 1; byte[] buf = new byte[BUFSIZE]; InetAddress cAddr; // ??IP int cPort; // ??? DatagramSocket sock = null; boolean flag = true; int port = 24005; int awakeDelay = 1000; try { String awakeDelayStr = AgentProperties.getProperty("awake.delay", Integer.toString(1000)); awakeDelay = Integer.parseInt(awakeDelayStr); m_log.info("awake.delay = " + awakeDelay + " msec"); } catch (NumberFormatException e) { m_log.error("awake.delay", e); } while (true) { /* * UDP???flag?true?? * ?????flag?false?????getTopic(releaseLatch)? * * UDP???????getTopic???????? * ?????? */ try { if (sock != null && port != awakePort) { sock.close(); sock = null; } if (sock == null || !sock.isBound()) { port = awakePort; sock = new DatagramSocket(port); sock.setSoTimeout(awakeDelay); } DatagramPacket recvPacket = new DatagramPacket(buf, BUFSIZE); sock.receive(recvPacket); cAddr = recvPacket.getAddress(); cPort = recvPacket.getPort(); flag = true; m_log.info("waitAwakeAgent (" + cAddr.getHostAddress() + " onPort=" + cPort + ") buf.length=" + buf.length); } catch (SocketTimeoutException e) { if (flag) { m_log.info("waitAwakeAgent packet end"); m_receiveTopic.releaseLatch(); flag = false; } } catch (Exception e) { String msg = "waitAwakeAgent port=" + awakePort + ", " + e.getClass().getSimpleName() + ", " + e.getMessage(); if (e instanceof BindException) { m_log.warn(msg); } else { m_log.warn(msg, e); } try { Thread.sleep(60 * 1000); } catch (InterruptedException e1) { m_log.warn(e1, e1); } } } }
From source file:com.flexive.core.search.genericSQL.GenericSQLDataFilter.java
/** * Helper function for getConditionSubQuery(__). * * @param cond the condition/*from w w w .ja v a 2s .c om*/ * @param mode tree mode * @return the filter sub-statement * @throws com.flexive.shared.exceptions.FxSqlSearchException * if the tree node was invalid or could not be found */ public String getTreeFilter(Condition cond, FxTreeMode mode) throws FxSqlSearchException { boolean direct = cond.getComperator() == ValueComparator.IS_DIRECT_CHILD_OF; // String table = DatabaseConst.TBL_TREE+(mode == FxTreeMode.Live ?"L":""); long parentNode; final String value = cond.getConstant().getValue(); try { parentNode = Long.valueOf(value); } catch (NumberFormatException e) { final String path = FxSharedUtils.stripQuotes(value, '\''); try { // Lookup the path in the tree parentNode = search.getTreeEngine().getIdByPath(mode, path); } catch (FxApplicationException e2) { throw new FxSqlSearchException(LOG, e2, "ex.sqlSearch.filter.invalidTreePath", path); } if (parentNode == -1) { throw new FxSqlSearchException(LOG, "ex.sqlSearch.filter.invalidTreePath", path); } } if (parentNode < 0) { throw new FxSqlSearchException(LOG, "ex.sqlSearch.filter.invalidTreeId", parentNode); } final FxTreeNodeInfo nodeInfo; try { nodeInfo = search.getStorage().getTreeStorage().getTreeNodeInfo(con, mode, parentNode); } catch (FxApplicationException e) { throw new FxSqlSearchException(LOG, e, "ex.sqlSearch.filter.loadTreeNode", parentNode, e.getMessage()); } String mandators = search.getEnvironment().getInactiveMandatorList(); final String mandatorFilter; if (mandators.length() > 0) mandatorFilter = " AND cd.mandator NOT IN(" + mandators + ")"; else mandatorFilter = mandators; //empty String types = search.getEnvironment().getDeactivatedTypesList(); final String typeFilter; if (types.length() > 0) typeFilter = " AND cd.tdef NOT IN(" + types + ")"; else typeFilter = types; //empty final String versionFilter = " AND cd." + (mode.equals(FxTreeMode.Edit) ? "ismax_ver" : "islive_ver") + "=" + search.getStorage().getBooleanTrueExpression(); return "(SELECT DISTINCT cd.id,cd.ver," + getEmptyLanguage() + " AS lang FROM " + tableMain + " cd WHERE " + "cd.id IN (SELECT ref FROM " + GenericTreeStorage.getTable(mode) + " WHERE " + (direct // select all direct children ? "PARENT=" + parentNode // select subtree with ranges : "LFT>" + nodeInfo.getLeft() + " AND RGT<" + nodeInfo.getRight()) + ")" + mandatorFilter + typeFilter + versionFilter + ")"; }