List of usage examples for java.lang Double intValue
public int intValue()
From source file:org.fenixedu.ulisboa.specifications.dto.evaluation.markSheet.MarkBean.java
private String cleanupNumber(String toCleanup) { final Double parsedValue = Double.valueOf(toCleanup); return parsedValue % 1 == 0 ? String.valueOf(parsedValue.intValue()) : parsedValue.toString(); }
From source file:org.webcurator.core.check.ProcessorCheck.java
public void check() { try {//from www .ja v a 2 s . c o m String sar = IoUtils.readFullyAsString(Runtime.getRuntime().exec(command).getInputStream()); if (null == sar || sar.trim().equals("")) { return; } String lastVal = ""; Pattern procesorPattern = Pattern.compile(pattern); Matcher matcher = procesorPattern.matcher(sar); while (matcher.find()) { lastVal = matcher.group(1); } Double processorAvail = Double.parseDouble(lastVal); if (log.isDebugEnabled()) { log.debug("The processor is " + processorAvail + "% available."); } if (processorAvail.intValue() <= warnThreshold && !belowWarnThreshold) { belowWarnThreshold = true; if (log.isWarnEnabled()) { log.warn("The available processor has fallen below the warning threshold " + warnThreshold + "% and is " + processorAvail.intValue() + "%"); } notify(LEVEL_WARNING, "The available processor has fallen below the warning threshold " + warnThreshold + "% and is " + processorAvail.intValue() + "%"); } else if (processorAvail.intValue() <= errorThreshold && !belowErrorThreshold) { belowErrorThreshold = true; if (log.isErrorEnabled()) { log.error("The available processor has fallen below the error threshold " + errorThreshold + "% and is " + processorAvail.intValue() + "%"); } notify(LEVEL_ERROR, "The available processor has fallen below the error threshold " + errorThreshold + "% and is " + processorAvail.intValue() + "%"); } else if (processorAvail.intValue() > warnThreshold && belowWarnThreshold) { belowWarnThreshold = false; if (log.isInfoEnabled()) { log.info("The available processor has recovered above the warning threshold " + warnThreshold + "% and is " + processorAvail.intValue() + "%"); } } else if (processorAvail.intValue() > errorThreshold && belowErrorThreshold) { belowErrorThreshold = false; if (log.isInfoEnabled()) { log.info("The available processor has recovered above the error threshold " + errorThreshold + "% and is " + processorAvail.intValue() + "%"); } } } catch (Exception e) { if (log.isErrorEnabled()) { log.error("Failed to complete processor check " + e.getMessage(), e); } } }
From source file:it.geosolutions.geobatch.destination.vulnerability.VulnerabilityComputation.java
/** * Build the Fid associated to the arcId * /*from w w w . jav a 2 s. c o m*/ * @param idArco * @param el * @return */ private static String buildFid(String idArco, Double el) { return idArco + "." + el.intValue(); }
From source file:com.willwinder.ugs.nbp.core.windows.StateTopComponent.java
private void setFeedAndSpeed(Double feed, Double speed) { if (!feedBox.hasFocus()) { feedBox.setText(Integer.toString(feed.intValue())); }//from w w w. j a v a2 s.c o m if (!speedBox.hasFocus()) { speedBox.setText(Integer.toString(speed.intValue())); } }
From source file:com.ec2box.manage.socket.SecureShellWS.java
@OnMessage public void onMessage(String message) { if (session.isOpen() && StringUtils.isNotEmpty(message)) { Map jsonRoot = new Gson().fromJson(message, Map.class); String command = (String) jsonRoot.get("command"); Integer keyCode = null;/*from w w w . j a va 2s .c om*/ Double keyCodeDbl = (Double) jsonRoot.get("keyCode"); if (keyCodeDbl != null) { keyCode = keyCodeDbl.intValue(); } for (String idStr : (ArrayList<String>) jsonRoot.get("id")) { Integer id = Integer.parseInt(idStr); //get servletRequest.getSession() for user UserSchSessions userSchSessions = SecureShellAction.getUserSchSessionMap().get(sessionId); if (userSchSessions != null) { SchSession schSession = userSchSessions.getSchSessionMap().get(id); if (keyCode != null) { if (keyMap.containsKey(keyCode)) { try { schSession.getCommander().write(keyMap.get(keyCode)); } catch (IOException ex) { log.error(ex.toString(), ex); } } } else { schSession.getCommander().print(command); } } } //update timeout AuthUtil.setTimeout(httpSession); } }
From source file:GeneticAlgorithm.Population.java
public void mutateIndividual(Individual mem) { int AllorOne = 1; if (AllorOne == 0) { int increaseORdrop = (int) (0.5 + this.RN()); Double targetparam = this.RN() * nparam; int targetparam1 = targetparam.intValue(); if (increaseORdrop == 0) { mem.x[targetparam1] = mem.x[targetparam1] * 1.13; } else if (increaseORdrop == 1) { mem.x[targetparam1] = mem.x[targetparam1] * 0.87; }//w ww . j av a 2 s . c o m } else { for (int i = 0; i < nparam; i++) { int increaseORdrop = (int) (0.5 + this.RN()); //to determine if it goes up or down in value int change = (int) (0.5 + this.RN()); //to determine if this parameter is going to be modified or not if (change == 1) { if (increaseORdrop == 0) { mem.x[i] = mem.x[i] * 1.13; } else if (increaseORdrop == 1) { mem.x[i] = mem.x[i] * 0.87; } } } } }
From source file:com.keybox.manage.socket.SecureShellWS.java
@OnMessage public void onMessage(String message) { if (session.isOpen() && StringUtils.isNotEmpty(message)) { Map jsonRoot = new Gson().fromJson(message, Map.class); String command = (String) jsonRoot.get("command"); Integer keyCode = null;//from w w w . j a v a 2 s. c o m Double keyCodeDbl = (Double) jsonRoot.get("keyCode"); if (keyCodeDbl != null) { keyCode = keyCodeDbl.intValue(); } for (String idStr : (ArrayList<String>) jsonRoot.get("id")) { Integer id = Integer.parseInt(idStr); //get servletRequest.getSession() for user UserSchSessions userSchSessions = SecureShellAction.getUserSchSessionMap().get(sessionId); if (userSchSessions != null) { SchSession schSession = userSchSessions.getSchSessionMap().get(id); if (keyCode != null) { if (keyMap.containsKey(keyCode)) { try { schSession.getCommander().write(keyMap.get(keyCode)); } catch (IOException ex) { log.error(ex.toString(), ex); } } } else { schSession.getCommander().print(command); } } } //update timeout AuthUtil.setTimeout(httpSession); } }
From source file:tudarmstadt.lt.ABSentiment.training.util.ProblemBuilder.java
protected static INDArray classifyTestSet(String inputFile, Model model, Vector<FeatureExtractor> features, String predictionFile, String type, boolean printResult) { InputReader fr;/* ww w .j a va2 s . c o m*/ if (inputFile.endsWith("xml")) { fr = new XMLReader(inputFile); } else { fr = new TsvReader(inputFile); } Writer out = null; Writer featureOut = null; try { OutputStream predStream = new FileOutputStream(predictionFile); out = new OutputStreamWriter(predStream, "UTF-8"); if (featureOutputFile != null) { OutputStream vectorStream = new FileOutputStream(featureOutputFile); featureOut = new OutputStreamWriter(vectorStream, "UTF-8"); } } catch (FileNotFoundException | UnsupportedEncodingException e1) { e1.printStackTrace(); System.exit(1); } Feature[] instance; Vector<Feature[]> instanceFeatures; confusionMatrix = new ConfusionMatrix(); String item; for (int j = 0; j < model.getNrClass(); j++) { item = labelLookup.get(Integer.parseInt(model.getLabels()[j] + "")); confusionMatrix.addLabel(item); allLabels.add(item); } ArrayList<double[]> probability = new ArrayList<>(); confusionMatrix.createMatrix(); for (Document doc : fr) { for (Sentence sentence : doc.getSentences()) { int i = 0; preprocessor.processText(sentence.getText()); instanceFeatures = applyFeatures(preprocessor.getCas(), features); Double prediction; instance = combineInstanceFeatures(instanceFeatures); double[] prob_estimates = new double[model.getNrClass()]; prediction = Linear.predictProbability(model, instance, prob_estimates); probability.add(prob_estimates); try { out.write(sentence.getId() + "\t" + sentence.getText() + "\t"); String goldLabel = null; String predictedLabel = labelLookup.get(prediction.intValue()); if (type.compareTo("relevance") == 0) { goldLabel = sentence.getRelevance()[0]; confusionMatrix.updateMatrix(predictedLabel, goldLabel); } else if (type.compareTo("sentiment") == 0) { try { while (i < sentence.getSentiment().length) { goldLabel = sentence.getSentiment()[i++]; confusionMatrix.updateMatrix(predictedLabel, goldLabel); } } catch (NoSuchFieldException e) { } } else if (useCoarseLabels) { out.append(StringUtils.join(sentence.getAspectCategoriesCoarse(), " ")); goldLabel = StringUtils.join(sentence.getAspectCategoriesCoarse(), " "); confusionMatrix.updateMatrix(predictedLabel, goldLabel); } else { out.append(StringUtils.join(sentence.getAspectCategories(), " ")); goldLabel = StringUtils.join(sentence.getAspectCategories(), " "); confusionMatrix.updateMatrix(predictedLabel, goldLabel); } out.append("\t").append(labelLookup.get(prediction.intValue())).append("\n"); } catch (IOException e) { e.printStackTrace(); } if (featureOutputFile != null) { String[] labels = sentence.getAspectCategories(); if (useCoarseLabels) { labels = sentence.getAspectCategoriesCoarse(); } for (String label : labels) { try { assert featureOut != null; for (Feature f : instance) { featureOut.write(" " + f.getIndex() + ":" + f.getValue()); } featureOut.write("\n"); } catch (IOException e) { e.printStackTrace(); } } } } } INDArray classificationProbability = Nd4j.zeros(probability.size(), model.getNrClass()); int j = -1; for (double prob_estimates[] : probability) { classificationProbability.putRow(++j, Nd4j.create(prob_estimates)); } try { out.close(); } catch (IOException e) { e.printStackTrace(); } HashMap<String, Float> recall; HashMap<String, Float> precision; HashMap<String, Float> fMeasure; recall = getRecallForAll(); precision = getPrecisionForAll(); fMeasure = getFMeasureForAll(); if (printResult) { System.out.println("Label" + "\t" + "Recall" + "\t" + "Precision" + "\t" + "F Score"); for (String itemLabel : allLabels) { System.out.println(itemLabel + "\t" + recall.get(itemLabel) + "\t" + precision.get(itemLabel) + "\t" + fMeasure.get(itemLabel)); } printFeatureStatistics(features); printConfusionMatrix(); System.out.println("\n"); System.out.println("True positive : " + getTruePositive()); System.out.println("Accuracy : " + getOverallAccuracy()); System.out.println("Overall Precision : " + getOverallPrecision()); System.out.println("Overall Recall : " + getOverallRecall()); System.out.println("Overall FMeasure : " + getOverallFMeasure()); } return classificationProbability; }
From source file:com.tethrnet.manage.socket.SecureShellWS.java
@OnMessage public void onMessage(String message) { if (session.isOpen()) { if (StringUtils.isNotEmpty(message)) { Map jsonRoot = new Gson().fromJson(message, Map.class); String command = (String) jsonRoot.get("command"); Integer keyCode = null; Double keyCodeDbl = (Double) jsonRoot.get("keyCode"); if (keyCodeDbl != null) { keyCode = keyCodeDbl.intValue(); }// w ww.j a v a2 s . c o m for (String idStr : (ArrayList<String>) jsonRoot.get("id")) { Integer id = Integer.parseInt(idStr); //get servletRequest.getSession() for user UserSchSessions userSchSessions = SecureShellAction.getUserSchSessionMap().get(sessionId); if (userSchSessions != null) { SchSession schSession = userSchSessions.getSchSessionMap().get(id); if (keyCode != null) { if (keyMap.containsKey(keyCode)) { try { schSession.getCommander().write(keyMap.get(keyCode)); } catch (IOException ex) { log.error(ex.toString(), ex); } } } else { schSession.getCommander().print(command); } } } //update timeout AuthUtil.setTimeout(httpSession); } } }
From source file:com.epam.ta.reportportal.core.widget.content.LaunchesComparisonContentLoader.java
private Map<String, List<ChartObject>> convertResult(List<ChartObject> objects) { Map<String, List<ChartObject>> result = new HashMap<>(); DecimalFormat formatter = new DecimalFormat("###.##"); for (ChartObject object : objects) { Map<String, String> values = new HashMap<>(); /* Total */ Double totalValue = Double.valueOf(object.getValues().get(getTotalFieldName())); values.put(getTotalFieldName(), formatter.format(totalValue)); /* Failed */ Double failedItems = totalValue.intValue() == 0 ? 0.0 : Double.valueOf(object.getValues().get(getFailedFieldName())) / totalValue * 100; values.put(getFailedFieldName(), formatter.format(failedItems)); /* Skipped */ Double skippedItems = totalValue.intValue() == 0 ? 0.0 : Double.valueOf(object.getValues().get(getSkippedFieldName())) / totalValue * 100; values.put(getSkippedFieldName(), formatter.format(skippedItems)); /* Passed */ values.put(getPassedFieldName(), formatter.format((totalValue.intValue() == 0) ? 0.0 : 100 - failedItems - skippedItems)); /* To Investigate */ int toInvestigateQuantity = Integer.parseInt(object.getValues().get(getToInvestigateFieldName())); /* Product Bugs */ int productBugsQuantity = Integer.parseInt(object.getValues().get(getProductBugFieldName())); /* System Issues */ int systemIssuesQuantity = Integer.parseInt(object.getValues().get(getSystemIssueFieldName())); /* Automation Bugs */ int testBugsQuantity = Integer.parseInt(object.getValues().get(getAutomationBugFieldName())); String noDefectValue = object.getValues().get(getNoDefectFieldName()); int noDefectQuantity = noDefectValue == null ? 0 : Integer.parseInt(noDefectValue); int failedQuantity = toInvestigateQuantity + productBugsQuantity + systemIssuesQuantity + testBugsQuantity + noDefectQuantity; if (failedQuantity != 0) { Double investigatedItems = (double) toInvestigateQuantity / failedQuantity * 100; values.put(getToInvestigateFieldName(), formatter.format(investigatedItems)); Double productBugItems = (double) productBugsQuantity / failedQuantity * 100; values.put(getProductBugFieldName(), formatter.format(productBugItems)); Double systemIssueItems = (double) systemIssuesQuantity / failedQuantity * 100; values.put(getSystemIssueFieldName(), formatter.format(systemIssueItems)); Double noDefectItems = (double) noDefectQuantity / failedQuantity * 100; values.put(getNoDefectFieldName(), formatter.format(noDefectItems)); values.put(getAutomationBugFieldName(), formatter .format(100 - investigatedItems - productBugItems - systemIssueItems - noDefectItems)); } else {// w ww . j a v a2 s . c om String formatted = formatter.format(0.0); values.put(getToInvestigateFieldName(), formatted); values.put(getProductBugFieldName(), formatted); values.put(getSystemIssueFieldName(), formatted); values.put(getAutomationBugFieldName(), formatted); values.put(getNoDefectFieldName(), formatted); } object.setValues(values); } result.put(RESULT, objects); return result; }