List of usage examples for java.lang Double doubleValue
@HotSpotIntrinsicCandidate public double doubleValue()
From source file:de.hybris.platform.commercefacades.search.converters.populator.SearchResultProductPopulator.java
protected void populatePrices(final SearchResultValueData source, final ProductData target) { // Pull the volume prices flag final Boolean volumePrices = this.<Boolean>getValue(source, "volumePrices"); target.setVolumePricesFlag(volumePrices == null ? Boolean.FALSE : volumePrices); // Pull the price value for the current currency final Double priceValue = this.<Double>getValue(source, "priceValue"); if (priceValue != null) { final PriceData priceData = getPriceDataFactory().create(PriceDataType.BUY, BigDecimal.valueOf(priceValue.doubleValue()), getCommonI18NService().getCurrentCurrency()); target.setPrice(priceData);/*from w ww .jav a2s. c o m*/ } }
From source file:org.apache.ctakes.ytex.kernel.pagerank.PageRankServiceImpl.java
/** * cosine of two vectors//from w ww. j a v a2 s .co m * * @param u * @param v * @return */ private <T> double cosine(Map<T, Double> u, Map<T, Double> v) { double uu = 0d; double uv = 0d; double vv = 0d; if (u.isEmpty() || v.isEmpty()) return 0d; // in this loop compute u*u, and u*v for (Map.Entry<T, Double> uEntry : u.entrySet()) { double ui = uEntry.getValue(); T uC = uEntry.getKey(); uu += ui * ui; Double vi = v.get(uC); if (vi != null) uv += ui * vi.doubleValue(); } if (uv == 0) return 0d; // in this loop, compute v*v for (double vi : v.values()) { vv += vi * vi; } // u*v/sqrt(v*v)*sqrt(u*u) return uv / Math.sqrt(vv * uu); }
From source file:com.aurel.track.item.AddScreenshotAction.java
public String saveScreenshot() { LOGGER.debug("Save screenshot workItemID=" + workItemID); List<LabelValueBean> errors = new ArrayList<LabelValueBean>(); if (file == null || file.length() == 0) { String err = getText("common.err.required", new String[] { getText("report.export.manager.upload.file") }); errors.add(new LabelValueBean(err, "file")); JSONUtility.encodeJSONErrors(ServletActionContext.getResponse(), errors); return null; }/*w w w . j a v a 2 s. c o m*/ if (!file.endsWith(".png")) { file = file + ".png"; } ApplicationBean applicationBean = (ApplicationBean) application.get(Constants.APPLICATION_BEAN); Double maxAttachmentSizeInMb = AttachBL.getMaxAttachmentSizeInMb(applicationBean); int MAXFILESIZE = AttachBL.getMaxFileSize(applicationBean); if (maxAttachmentSizeInMb != null && Double.compare(maxAttachmentSizeInMb.doubleValue(), 0.0) != 0) { MAXFILESIZE = (int) (maxAttachmentSizeInMb.doubleValue() * 1024 * 1024); } else { MAXFILESIZE = 4 * 1024 * 1024; } byte[] bytearray = null; try { bytearray = new Base64().decode(bytes); } catch (Exception e1) { // TODO Auto-generated catch block LOGGER.error(ExceptionUtils.getStackTrace(e1)); errors.add(new LabelValueBean(e1.getMessage(), "file")); JSONUtility.encodeJSONErrors(ServletActionContext.getResponse(), errors); return null; } if (bytearray.length > MAXFILESIZE) { errors.add(new LabelValueBean( getText("attachment.maxLengthExceeded", new String[] { maxAttachmentSizeInMb + "" }), "file")); JSONUtility.encodeJSONErrors(ServletActionContext.getResponse(), errors); return null; } int maxDescriptionSize = ApplicationBean.getInstance().getDescriptionMaxLength(); if (description.length() > maxDescriptionSize) { errors.add(new LabelValueBean(getText("item.err.tooLong", new String[] { getText("common.lbl.description"), Integer.toString(maxDescriptionSize) }), "description")); JSONUtility.encodeJSONErrors(ServletActionContext.getResponse(), errors); return null; } InputStream is = new ByteArrayInputStream(bytearray); ApplicationBean appBean = ApplicationBean.getInstance(); if (appBean.isBackupInProgress()) { errors.add(new LabelValueBean(getText("item.tabs.attachment.err.backupInProgress"), "file")); JSONUtility.encodeJSONErrors(ServletActionContext.getResponse(), errors); return null; } if (workItemID == null/*||workItemID.intValue()==-1*/) { HttpServletRequest request = org.apache.struts2.ServletActionContext.getRequest(); HttpSession httpSession = request.getSession(); WorkItemContext ctx = (WorkItemContext) session.get("workItemContext"); if (ctx == null) { LOGGER.error("No context on session"); errors.add(new LabelValueBean("No context on session", "file")); JSONUtility.encodeJSONErrors(ServletActionContext.getResponse(), errors); return null; } List<TAttachmentBean> attachments = ctx.getAttachmentsList(); if (attachments == null) { attachments = new ArrayList<TAttachmentBean>(); } String sessionID = httpSession.getId(); try { AttachBL.saveLocal(workItemID, description, file, is, attachments, sessionID, personID); } catch (AttachBLException e) { String err = ""; if (e.getLocalizedKey() != null) { err = getText(e.getLocalizedKey(), e.getLocalizedParameteres()); } else { err = e.getMessage(); } errors.add(new LabelValueBean(err, "file")); JSONUtility.encodeJSONErrors(ServletActionContext.getResponse(), errors); return null; } ctx.setAttachmentsList(attachments); } else { try { AttachBL.save(workItemID, description, file, is, personID); //add to history HistorySaverBL.addAttachment(workItemID, personID, locale, file, description, Long.valueOf(bytearray.length), false); } catch (AttachBLException e) { LOGGER.error("Can't save attachemnt", e); String err = ""; if (e.getLocalizedKey() != null) { err = getText(e.getLocalizedKey(), e.getLocalizedParameteres()); } else { err = e.getMessage(); } errors.add(new LabelValueBean(err, "file")); JSONUtility.encodeJSONErrors(ServletActionContext.getResponse(), errors); return null; } } description = null; JSONUtility.encodeJSONSuccess(ServletActionContext.getResponse()); return null; }
From source file:com.netcrest.pado.index.provider.lucene.TopNLuceneSearch.java
@Override public List combineAndSort(List entities, GridQuery criteria, boolean isMember) { // TODO Auto-generated method stub ITemporalKey tk = null;//from w w w. j a v a2 s.co m Map<String, Object> intermMap = new HashMap<String, Object>(entities.size()); List<Object> finalResult = new ArrayList(entities.size()); List<JsonLite> sortedSet = new ArrayList<JsonLite>(entities.size()); String toCompare = PqlParser.getTextSearchPHRASE(criteria); String targetField = PqlParser.getTextSearchTargetField(criteria); if (!isMember) { int i = 0; for (Object obj : entities) { intermMap.put(String.valueOf(i), obj); IndexableResult<Integer, Object> indexableResult = (IndexableResult<Integer, Object>) obj; Object rsObj = indexableResult.getValue(); TemporalEntry resultTemEntry = null; if (rsObj instanceof ResultItem) { ResultItem<Object> valueObj = (ResultItem<Object>) indexableResult.getValue(); Object resultObj = ((ValueInfo) valueObj.getItem()).getValue(); if (resultObj instanceof TemporalEntry) { resultTemEntry = ((TemporalEntry) resultObj); } } else if (rsObj instanceof TemporalEntry) { resultTemEntry = ((TemporalEntry) rsObj); } tk = resultTemEntry.getTemporalKey(); ITemporalData temporaData = ((TemporalEntry) resultTemEntry).getTemporalData(); if (temporaData instanceof GemfireTemporalData) { JsonLite gemFireData = (JsonLite) ((GemfireTemporalData) temporaData).getValue(); gemFireData.put("Temp_index", String.valueOf(i)); sortedSet.add(gemFireData); } else { // what to do it here ?? } i++; } } else { int i = 0; for (Object obj : entities) { intermMap.put(String.valueOf(i), obj); ITemporalData temporaData = ((TemporalEntry) obj).getTemporalData(); tk = ((TemporalEntry) obj).getTemporalKey(); JsonLite gemFireData = (JsonLite) ((GemfireTemporalData) temporaData).getValue(); String targetFieldValue = (String) gemFireData.get(targetField); double score = TopNLuceneSearch.getLSScore(toCompare, targetFieldValue); gemFireData.put(Constants.TEXT_SEARCH_SCORE, score); gemFireData.put("Temp_index", String.valueOf(i)); sortedSet.add(gemFireData); i++; } } Collections.sort(sortedSet, new Comparator<JsonLite>() { @Override public int compare(JsonLite o1, JsonLite o2) { // TODO Auto-generated method stub Double o2Score = (Double) o2.get(Constants.TEXT_SEARCH_SCORE); Double o1Score = (Double) o1.get(Constants.TEXT_SEARCH_SCORE); return o2Score.doubleValue() == o1Score.doubleValue() ? 0 : (o2Score.doubleValue() > o1Score.doubleValue() ? 1 : -1); } }); int j = 0; for (JsonLite lite : sortedSet) { String index = (String) lite.get("Temp_index"); lite.remove("Temp_index"); Object originalEntity = intermMap.get(index); finalResult.add(originalEntity); j++; } entities.clear(); entities.addAll(finalResult); return finalResult; }
From source file:org.sakaiproject.tool.assessment.data.dao.grading.AssessmentGradingData.java
public void setTotalAutoScore(Double totalAutoScore) { if (totalAutoScore != null) { if (totalAutoScore.doubleValue() < 0) { this.totalAutoScore = new Double("0"); } else {//from w ww.j av a 2 s . c o m this.totalAutoScore = totalAutoScore; } } else { this.totalAutoScore = null; } }
From source file:com.github.kingtim1.jmdp.approx.SMDPEstimator.java
private void updateR(S state, A action, S terminalState, int duration, double r) { Map<A, Map<S, Map<Integer, Double>>> aRSum = MapUtil.getValueMap(_rsum, state); Map<S, Map<Integer, Double>> asRSum = MapUtil.getValueMap(aRSum, action); Map<Integer, Double> asdRSum = MapUtil.getValueMap(asRSum, terminalState); Double rsum = asdRSum.get(duration); if (rsum == null) { asdRSum.put(duration, r);// w ww . j a v a 2 s.c o m } else { asdRSum.put(duration, rsum.doubleValue() + r); } }
From source file:org.apache.ctakes.ytex.kernel.pagerank.PageRankServiceImpl.java
/** * difference between 2 vectors//w w w. j a va 2s .c o m * * @param a * @param b * @return a-b */ private <T> double difference(Map<T, Double> a, Map<T, Double> b) { double diff = 0d; for (Map.Entry<T, Double> aiEntry : a.entrySet()) { Double bi = b.get(aiEntry.getKey()); diff += Math.pow(aiEntry.getValue() - (bi != null ? bi.doubleValue() : 0d), 2); } for (Map.Entry<T, Double> biEntry : b.entrySet()) { if (!a.containsKey(biEntry.getKey())) { diff += Math.pow(biEntry.getValue(), 2); } } return diff; }
From source file:com.userweave.module.methoden.iconunderstandability.service.IconMatchingStatistics.java
public IconMatchingStatistics(ReactionTimeStatisticsDao reactionTimeStatisticsDao, IconTermMatchingConfigurationEntity configuration, FilterFunctor filterFunctor) { Injector.get().inject(this); this.configuration = configuration; iconCountForConfiguration = configuration.getImages().size(); List<Object[]> mappingsRaw = iconTermMappingDao.findValidResultsFast(configuration, filterFunctor); Set<Object> results = new HashSet<Object>(); for (Object[] mapping : mappingsRaw) { results.add(mapping[3]);//ww w. jav a 2 s . c o m } totalNumberOfSurveyExecutions = results.size(); valueArray = new ValueArray(mappingsRaw); final Double predictedReactionTime = computeOverallPredictedReactionTime(reactionTimeStatisticsDao); if (predictedReactionTime != null) { isValid = true; overallPredictedReactionTime = predictedReactionTime.doubleValue(); } else { isValid = false; overallPredictedReactionTime = -1; } }
From source file:com.joliciel.jochre.lexicon.MostLikelyWordChooserImpl.java
double getFrequencyAdjustment(int minFrequency) { if (frequencyAdjusted) { Double freqLogObj = this.frequencyLogs.get(minFrequency); double freqLog = 0; if (freqLogObj != null) freqLog = freqLogObj.doubleValue(); else {//from w ww .ja va 2s . c o m // Assume the base is 2, and additive smoothing = 0.4. // -1 = 0.04 // 0 = 0.4 // 1 = 1 // 2 = 1 + log2(2) = 2 // 4 = 1 + log2(4) = 3 // etc. double minFreq = minFrequency; if (minFrequency < 0) freqLog = additiveSmoothing / 10.0; else if (minFrequency == 0) freqLog = additiveSmoothing; else freqLog = 1 + (Math.log(minFreq) / Math.log(frequencyLogBase)); this.frequencyLogs.put(minFrequency, freqLog); } return freqLog; } else { if (minFrequency < 0) return additiveSmoothing / 10.0; else if (minFrequency == 0) return additiveSmoothing; else return 1; } }
From source file:com.aurel.track.attachment.AttachBL.java
public static int getMaxFileSize(TSiteBean siteBean) { Double maxAttachmentSizeInMb = siteBean.getMaxAttachmentSize(); int max = 0;//from w w w.ja v a 2 s. co m if (maxAttachmentSizeInMb == null || maxAttachmentSizeInMb.doubleValue() <= 0) { //default value 4MB max = new Double(4.0 * 1024 * 1024).intValue(); } else { max = new Double(maxAttachmentSizeInMb.doubleValue() * 1024 * 1024).intValue(); } return max; }