List of usage examples for java.lang Float floatValue
@HotSpotIntrinsicCandidate public float floatValue()
From source file:org.alfresco.module.org_alfresco_module_wcmquickstart.jobs.feedback.CommentFeedbackProcessorHandler.java
@Override @SuppressWarnings("unchecked") public void processorCallback() { // Get the node summary map HashMap<NodeRef, SummaryInfo> nodeSummaryMap = (HashMap<NodeRef, SummaryInfo>) AlfrescoTransactionSupport .getResource(KEY_SUMMARY_MAP); if (nodeSummaryMap != null) { //Now we can work through the records that we've recorded in memory and update the necessary summary nodes for (Map.Entry<NodeRef, SummaryInfo> entry : nodeSummaryMap.entrySet()) { SummaryInfo summaryInfo = entry.getValue(); NodeRef summaryNode = summaryInfo.summaryNode; Map<QName, Serializable> props = nodeService.getProperties(summaryNode); //Get the current values from the summary node Integer commentCountObj = (Integer) nodeService.getProperty(summaryNode, WebSiteModel.PROP_COMMENT_COUNT); Integer processedRatingsObj = (Integer) nodeService.getProperty(summaryNode, WebSiteModel.PROP_PROCESSED_RATINGS); Float averageRatingObj = (Float) nodeService.getProperty(summaryNode, WebSiteModel.PROP_AVERAGE_RATING); int commentCount = commentCountObj == null ? 0 : commentCountObj.intValue(); int processedRatings = processedRatingsObj == null ? 0 : processedRatingsObj.intValue(); float averageRating = averageRatingObj == null ? 0 : averageRatingObj.floatValue(); if (log.isDebugEnabled()) { log.debug("About to update feedback summary for asset " + entry.getKey() + ". Current values are: " + "commentCount = " + commentCount + "; processedRatings = " + processedRatings + "; averageRating = " + averageRating); }/*www .j a v a 2 s.c o m*/ //Update the values with the information gathered in the SummaryInfo object... commentCount += summaryInfo.commentCount; float totalRatingSoFar = averageRating * processedRatings; if (summaryInfo.ratingCount > 0) { processedRatings += summaryInfo.ratingCount; totalRatingSoFar += summaryInfo.totalRating; averageRating = totalRatingSoFar / processedRatings; } if (log.isDebugEnabled()) { log.debug("About to update feedback summary for asset " + entry.getKey() + ". New values are: " + "commentCount = " + commentCount + "; processedRatings = " + processedRatings + "; averageRating = " + averageRating); } props.put(WebSiteModel.PROP_COMMENT_COUNT, commentCount); props.put(WebSiteModel.PROP_PROCESSED_RATINGS, processedRatings); props.put(WebSiteModel.PROP_AVERAGE_RATING, averageRating); // ... and write the new values back to the repo. nodeService.setProperties(summaryNode, props); } } }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationPropertiesWithFloatArray() { ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); Float floatValue = config.floatArray[0]; assertEquals(Float.class, floatValue.getClass()); assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); assertEquals(5, config.floatArray.length); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationXMLWithFloatArray() { ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); Float floatValue = config.floatArray[0]; assertEquals(Float.class, floatValue.getClass()); assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); assertEquals(5, config.floatArray.length); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationPropertiesWithFloatList() { ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); Float floatValue = config.floatList.get(0); assertEquals(Float.class, floatValue.getClass()); assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); assertEquals(5, config.floatList.size()); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationXMLWithFloatList() { ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); Float floatValue = config.floatList.get(0); assertEquals(Float.class, floatValue.getClass()); assertEquals(Float.MAX_VALUE, floatValue.floatValue(), 1); assertEquals(5, config.floatList.size()); }
From source file:com.eurelis.opencms.workflows.ui.toolobject.WorkflowMenuItemLoader.java
/** * Check that the given value of position doesn't exist. If this one exists, * then create a new position and use it. * /*from ww w . ja v a 2 s . c o m*/ * @param positionProperty * the string value of the position given as property * @return the value that can be use to manage position (sure that it's not * use) */ private float checkAnUpdatePosition(String positionProperty) { if (StringChecker.isNotNullOrEmpty(positionProperty)) { try { Float position = new Float(positionProperty); if (!_foundPosition.contains(position)) { // store new position _foundPosition.add(position); // return value return position.floatValue(); } } catch (NumberFormatException e) { // do nothing, a default position will be set when outgoing if } } // get new Position and update property float newPosition = _lastPositionSet + 1; this._lastPositionSet = newPosition; // store the use position _foundPosition.add(new Float(newPosition)); return newPosition; }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.CFLibXmlUtil.java
public static String formatOptionalFloat(String separator, String attrName, Float val) { final String S_ProcName = "formatOptionalFloat"; if ((attrName == null) || (attrName.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(CFLibXmlUtil.class, S_ProcName, 1, "attrName"); }// www . java2 s . c om String retval; if (val != null) { retval = formatRequiredFloat(separator, attrName, val.floatValue()); } else { retval = S_emptyString; } return (retval); }
From source file:org.intermine.api.lucene.InterMineObjectFetcher.java
private Document createDocument(InterMineObject object, ClassDescriptor classDescriptor) { Document doc = new Document(); Float boost = classBoost.get(classDescriptor); if (boost != null) { doc.setBoost(boost.floatValue()); }/*from w w w . ja v a 2 s.com*/ // id has to be stored so we can fetch the actual objects for the // results doc.add(new Field("id", object.getId().toString(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); // special case for faceting doc.add(new Field("Category", classDescriptor.getUnqualifiedName(), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS)); addToDocument(doc, "classname", classDescriptor.getUnqualifiedName(), 1F, false); addObjectToDocument(object, classDescriptor, doc); return doc; }
From source file:org.etudes.mneme.impl.AnswerImpl.java
/** * {@inheritDoc}/* www . j a v a 2 s . c o m*/ */ public Float getTotalScore() { // if no auto nor evaluation, we have no score Float autoScore = getAutoScore(); if ((autoScore == null) && (this.evaluation.getScore() == null)) return null; float rv = 0f; if (autoScore != null) { rv += autoScore.floatValue(); } if (this.evaluation.getScore() != null) { rv += this.evaluation.getScore().floatValue(); } // round away bogus decimals rv = Math.round(rv * 100.0f) / 100.0f; return Float.valueOf(rv); }
From source file:org.etudes.mneme.impl.AnswerImpl.java
/** * {@inheritDoc}//from ww w .jav a2s. c o m */ public void setTotalScore(Float score) { // take a null to mean clear the evaluation adjustment if (score == null) { this.evaluation.setScore(null); } else { float total = score.floatValue(); // adjust to remove the current auto score Float auto = getAutoScore(); if (auto != null) { total -= auto.floatValue(); } // round away bogus decimals total = Math.round(total * 100.0f) / 100.0f; // if the auto score exists and is the entire desired score, null out the evaluation adjustment if ((total == 0f) && (auto != null)) { this.evaluation.setScore(null); } else { this.evaluation.setScore(Float.valueOf(total)); } } }