Example usage for java.lang Double doubleValue

List of usage examples for java.lang Double doubleValue

Introduction

In this page you can find the example usage for java.lang Double doubleValue.

Prototype

@HotSpotIntrinsicCandidate
public double doubleValue() 

Source Link

Document

Returns the double value of this Double object.

Usage

From source file:org.kalypsodeegree_impl.model.feature.Feature_Impl.java

protected double getDoubleProperty(final QName property, final double defaultValue) {
    final Double value = getProperty(property, Double.class);
    if (value == null)
        return defaultValue;

    return value.doubleValue();
}

From source file:org.sakaiproject.tool.gradebook.ui.InstructorViewBean.java

/**
 * Save the input scores for the user//  w  w w. ja  v  a2 s . co  m
 * @throws StaleObjectModificationException
 */
public void saveScoresWithoutConfirmation() throws StaleObjectModificationException {
    if (logger.isInfoEnabled())
        logger.info("saveScores for " + getStudentUid());

    // first, determine which scores were updated
    List updatedGradeRecords = new ArrayList();
    if (getGradebookItems() != null) {
        Iterator itemIter = getGradebookItems().iterator();
        while (itemIter.hasNext()) {
            Object item = itemIter.next();
            if (item instanceof AssignmentGradeRow) {
                AssignmentGradeRow gradeRow = (AssignmentGradeRow) item;
                AssignmentGradeRecord gradeRecord = gradeRow.getGradeRecord();

                if (gradeRecord == null && (gradeRow.getScore() != null || gradeRow.getLetterScore() != null)) {
                    // this is a new grade
                    gradeRecord = new AssignmentGradeRecord(gradeRow.getAssociatedAssignment(), getStudentUid(),
                            null);
                }
                if (gradeRecord != null) {
                    if (getGradeEntryByPoints()) {
                        Double originalScore = null;
                        originalScore = gradeRecord.getPointsEarned();

                        if (originalScore != null) {
                            // truncate to two decimals for more accurate comparison
                            originalScore = new Double(FacesUtil.getRoundDown(originalScore.doubleValue(), 2));
                        }
                        Double newScore = gradeRow.getScore();
                        if ((originalScore != null && !originalScore.equals(newScore))
                                || (originalScore == null && newScore != null)) {
                            gradeRecord.setPointsEarned(newScore);
                            updatedGradeRecords.add(gradeRecord);
                        }
                    } else if (getGradeEntryByPercent()) {
                        Double originalScore = null;
                        originalScore = gradeRecord.getPercentEarned();

                        if (originalScore != null) {
                            // truncate to two decimals for more accurate comparison
                            originalScore = new Double(FacesUtil.getRoundDown(originalScore.doubleValue(), 2));
                        }
                        Double newScore = gradeRow.getScore();
                        if ((originalScore != null && !originalScore.equals(newScore))
                                || (originalScore == null && newScore != null)) {
                            gradeRecord.setPercentEarned(newScore);
                            updatedGradeRecords.add(gradeRecord);
                        }

                    } else if (getGradeEntryByLetter()) {

                        String originalScore = gradeRecord.getLetterEarned();
                        String newScore = gradeRow.getLetterScore();
                        if ((originalScore != null && !originalScore.equals(newScore))
                                || (originalScore == null && newScore != null)) {
                            gradeRecord.setLetterEarned(newScore);
                            updatedGradeRecords.add(gradeRecord);
                        }
                    }
                }
            }
        }
    }

    Set excessiveScores = getGradebookManager().updateStudentGradeRecords(updatedGradeRecords,
            getGradebook().getGrade_type(), getStudentUid());

    if (updatedGradeRecords.size() > 0) {
        getGradebookBean().getEventTrackingService().postEvent("gradebook.updateItemScores",
                "/gradebook/" + getGradebookId() + "/" + updatedGradeRecords.size() + "/" + getAuthzLevel());
    }
}

From source file:com.acc.storefront.controllers.pages.StorePageController.java

@RequestMapping(value = STORE_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET)
public String storeDetail(@PathVariable("storeCode") final String storeCode,
        @RequestParam(value = "lat", required = false) final Double sourceLatitude,
        @RequestParam(value = "long", required = false) final Double sourceLongitude,
        @RequestParam(value = "q", required = false) final String locationQuery, final Model model,
        final RedirectAttributes redirectModel) throws CMSItemNotFoundException {
    final StoreFinderForm storeFinderForm = new StoreFinderForm();
    model.addAttribute("storeFinderForm", storeFinderForm);
    final StorePositionForm storePositionForm = new StorePositionForm();
    model.addAttribute("storePositionForm", storePositionForm);

    if (sourceLatitude != null && sourceLongitude != null) {
        final GeoPoint geoPoint = new GeoPoint();
        geoPoint.setLatitude(sourceLatitude.doubleValue());
        geoPoint.setLongitude(sourceLongitude.doubleValue());

        // Get the point of service data with the formatted distance
        try {//  ww w .  j  av a 2  s .  c o  m
            final PointOfServiceData pointOfServiceData = storeFinderFacade
                    .getPointOfServiceForNameAndPosition(storeCode, geoPoint);
            if (pointOfServiceData == null) {
                return handleStoreNotFoundCase(redirectModel);
            }
            pointOfServiceData.setUrl("/store/" + pointOfServiceData.getName());
            model.addAttribute("store", pointOfServiceData);

            if (locationQuery != null && !locationQuery.isEmpty()) {
                model.addAttribute("locationQuery", locationQuery);

                // Build URL to location query
                final String storeFinderSearchUrl = UriComponentsBuilder.fromPath("/store-finder")
                        .queryParam("q", locationQuery).build().toString();
                model.addAttribute(WebConstants.BREADCRUMBS_KEY,
                        storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData, storeFinderSearchUrl));
            } else {
                // Build URL to position query
                final String storeFinderSearchUrl = UriComponentsBuilder.fromPath("/store-finder/position")
                        .queryParam("lat", sourceLatitude).queryParam("long", sourceLongitude).build()
                        .toString();
                model.addAttribute(WebConstants.BREADCRUMBS_KEY,
                        storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData, storeFinderSearchUrl));
            }
            setUpMetaData(model, pointOfServiceData);
        } catch (final ModelNotFoundException e) {
            return handleStoreNotFoundCase(redirectModel);
        }
    } else {
        // No source point specified - just lookup the POS by name
        try {
            final PointOfServiceData pointOfServiceData = storeFinderFacade.getPointOfServiceForName(storeCode);
            pointOfServiceData.setUrl("/store/" + pointOfServiceData.getName());
            model.addAttribute("store", pointOfServiceData);
            model.addAttribute(WebConstants.BREADCRUMBS_KEY,
                    storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData));
            setUpMetaData(model, pointOfServiceData);
        } catch (final ModelNotFoundException e) {
            return handleStoreNotFoundCase(redirectModel);
        }
    }

    storeCmsPageInModel(model, getStoreFinderPage());
    return ControllerConstants.Views.Pages.StoreFinder.StoreFinderDetailsPage;
}

From source file:de.hybris.platform.order.ZoneDeliveryModeServiceTest.java

private void testGetDeliveryValue(final String currencyCode, final String zoneCode,
        final String deliveryModeCode, final Double min, final Double expectedDeliveryValue,
        final Class expectedExceptionClass) {
    final CurrencyModel currency = commonI18NService.getCurrency(currencyCode);
    final ZoneModel zone = zoneDeliveryModeService.getZoneForCode(zoneCode);
    final DeliveryModeModel deliveryMode = zoneDeliveryModeService.getDeliveryModeForCode(deliveryModeCode);
    try {/*w w  w  .j  av a2  s .  co m*/
        final ZoneDeliveryModeValueModel zoneDeliveryModeValue = zoneDeliveryModeService.getDeliveryValue(zone,
                currency, min, (ZoneDeliveryModeModel) deliveryMode);
        assertEquals(expectedDeliveryValue.doubleValue(), zoneDeliveryModeValue.getValue().doubleValue(), 0.01);
    } catch (final UnknownIdentifierException e) {
        if (e.getClass().equals(expectedExceptionClass)) { //NOPMD
                                                           //expected
        } else {
            throw e;
        }
    }
}

From source file:com.ctc.storefront.controllers.pages.StorePageController.java

@RequestMapping(value = STORE_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET)
public String storeDetail(@PathVariable("storeCode") final String storeCode,
        @RequestParam(value = "lat", required = false) final Double sourceLatitude,
        @RequestParam(value = "long", required = false) final Double sourceLongitude,
        @RequestParam(value = "q", required = false) final String locationQuery, final Model model,
        final RedirectAttributes redirectModel) throws CMSItemNotFoundException {
    final StoreFinderForm storeFinderForm = new StoreFinderForm();
    model.addAttribute("storeFinderForm", storeFinderForm);
    final StorePositionForm storePositionForm = new StorePositionForm();
    model.addAttribute("storePositionForm", storePositionForm);

    if (sourceLatitude != null && sourceLongitude != null) {
        final GeoPoint geoPoint = new GeoPoint();
        geoPoint.setLatitude(sourceLatitude.doubleValue());
        geoPoint.setLongitude(sourceLongitude.doubleValue());

        // Get the point of service data with the formatted distance
        try {/*www  .  j a v a  2 s.  co  m*/
            final PointOfServiceData pointOfServiceData = storeFinderFacade
                    .getPointOfServiceForNameAndPosition(storeCode, geoPoint);
            if (pointOfServiceData == null) {
                return handleStoreNotFoundCase(redirectModel);
            }
            pointOfServiceData.setUrl(STORE_URL + pointOfServiceData.getName());
            model.addAttribute(STORE_ATTR, pointOfServiceData);

            processLocation(sourceLatitude, sourceLongitude, locationQuery, model, pointOfServiceData);

            setUpMetaData(model, pointOfServiceData);
        } catch (final ModelNotFoundException e) {
            return handleStoreNotFoundCase(redirectModel);
        } catch (final UnsupportedEncodingException e) {
            logDebugInfo(e);
        }
    } else {
        // No source point specified - just lookup the POS by name
        try {
            final PointOfServiceData pointOfServiceData = storeFinderFacade.getPointOfServiceForName(storeCode);
            pointOfServiceData.setUrl(STORE_URL + pointOfServiceData.getName());
            model.addAttribute(STORE_ATTR, pointOfServiceData);
            model.addAttribute(WebConstants.BREADCRUMBS_KEY,
                    storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData));
            setUpMetaData(model, pointOfServiceData);
        } catch (final ModelNotFoundException e) {
            return handleStoreNotFoundCase(redirectModel);
        }
    }

    storeCmsPageInModel(model, getStoreFinderPage());
    return ControllerConstants.Views.Pages.StoreFinder.StoreFinderDetailsPage;
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.teacher.onlineTests.InsertTestQuestion.java

protected void run(String executionCourseId, String testId, String[] metadataId, Integer questionOrder,
        Double questionValue, CorrectionFormula formula) throws FenixServiceException {

    for (String element : metadataId) {
        Metadata metadata = FenixFramework.getDomainObject(element);
        if (metadata == null) {
            throw new InvalidArgumentsServiceException();
        }//from  ww w  . j  av  a2s  .  c o m
        Question question = null;
        if (metadata.getVisibleQuestions() != null && metadata.getVisibleQuestions().size() != 0) {
            question = metadata.getVisibleQuestions().iterator().next();
        } else {
            throw new InvalidArgumentsServiceException();
        }
        if (question == null) {
            throw new InvalidArgumentsServiceException();
        }
        Test test = FenixFramework.getDomainObject(testId);
        if (test == null) {
            throw new InvalidArgumentsServiceException();
        }
        List<TestQuestion> testQuestionList = new ArrayList<TestQuestion>(test.getTestQuestionsSet());
        Collections.sort(testQuestionList, new BeanComparator("testQuestionOrder"));
        if (testQuestionList != null) {
            if (questionOrder == null || questionOrder.equals(Integer.valueOf(-1))) {
                questionOrder = Integer.valueOf(testQuestionList.size() + 1);
            } else {
                questionOrder = Integer.valueOf(questionOrder.intValue() + 1);
            }
            for (TestQuestion iterTestQuestion : testQuestionList) {
                Integer iterQuestionOrder = iterTestQuestion.getTestQuestionOrder();
                if (questionOrder.compareTo(iterQuestionOrder) <= 0) {
                    iterTestQuestion.setTestQuestionOrder(Integer.valueOf(iterQuestionOrder.intValue() + 1));
                }
            }
        }
        Double thisQuestionValue = questionValue;
        if (questionValue == null) {
            ParseSubQuestion parseQuestion = new ParseSubQuestion();
            if (thisQuestionValue == null) {
                thisQuestionValue = new Double(0);
            }
            try {
                InfoQuestion infoQuestion = InfoQuestion.newInfoFromDomain(question);
                question = parseQuestion.parseSubQuestion(question);
                if (infoQuestion.getQuestionValue() != null) {
                    thisQuestionValue = infoQuestion.getQuestionValue();
                } else {
                    for (SubQuestion subQuestion : question.getSubQuestions()) {
                        if (subQuestion.getQuestionValue() != null) {
                            thisQuestionValue = new Double(thisQuestionValue.doubleValue()
                                    + subQuestion.getQuestionValue().doubleValue());
                        }
                    }
                }

            } catch (Exception e) {
                throw new FenixServiceException(e);
            }

        }
        TestQuestion testQuestion = new TestQuestion();
        test.setLastModifiedDate(Calendar.getInstance().getTime());
        testQuestion.setQuestion(question);
        testQuestion.setTest(test);
        testQuestion.setTestQuestionOrder(questionOrder);
        testQuestion.setTestQuestionValue(thisQuestionValue);
        testQuestion.setCorrectionFormula(formula);
    }
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.AccountingTimeMatcherRT.java

private double getHourPerWorkday() {
    Double hoursPerWorkday = null;
    Map<Integer, ProjectAccountingTO> projectAccountingMap = matcherContext.getProjectAccountingMap();
    if (projectAccountingMap != null) {
        TWorkItemBean workItemBean = matcherContext.getWorkItemBean();
        if (workItemBean != null) {
            Integer projectID = workItemBean.getProjectID();
            if (projectID != null) {
                ProjectAccountingTO projectAccountingTO = projectAccountingMap.get(projectID);
                if (projectAccountingTO != null) {
                    hoursPerWorkday = projectAccountingTO.getHoursPerWorkday();
                }//  www.j  a  v  a2s .  c o m
            }
        }
    }
    if (hoursPerWorkday == null) {
        hoursPerWorkday = AccountingBL.DEFAULTHOURSPERWORKINGDAY;
    }
    return hoursPerWorkday.doubleValue();
}

From source file:org.eclipse.birt.report.engine.odf.writer.AbstractOdfWriter.java

/**
 * @param data//  w w  w .  j av a  2s  .co m
 * @param height
 * @param width
 * @param style
 * @param altText
 * @param imageId
 */
protected void drawImage(String imageUrl, byte[] imageData, Double positionX, Double positionY, double height,
        double width, StyleEntry style, String altText, String layer, int imageId) {
    writer.openTag("draw:frame");
    if (style != null) {
        writer.attribute("draw:style-name", style.getName());
    }

    if (layer != null) {
        writer.attribute("draw:layer", layer);
    }

    writer.attribute("draw:name", "Image" + imageId);
    writer.attribute("text:anchor-type", "paragraph");
    writer.attribute("svg:width", width + "in");
    writer.attribute("svg:height", height + "in");

    if (positionX != null) {
        writer.attribute("svg:x", positionX.doubleValue() + "in");
    }
    if (positionY != null) {
        writer.attribute("svg:y", positionY.doubleValue() + "in");
    }

    writer.attribute("draw:z-index", "0");

    writer.openTag("draw:image");
    if (imageData != null) {
        drawImageData(imageData);
    } else {
        drawImageData(imageUrl);
    }
    writer.closeTag("draw:image");

    writer.openTag("svg:title");
    writer.text(altText);
    writer.closeTag("svg:title");

    writer.closeTag("draw:frame");
}

From source file:org.sakaiproject.tool.gradebook.ui.InstructorViewBean.java

/**
 * Save the input scores for the user//from w w w  . ja va2  s.  c om
 * @throws StaleObjectModificationException
 */
public void saveScores() throws StaleObjectModificationException {
    if (logger.isInfoEnabled())
        logger.info("saveScores for " + getStudentUid());

    // first, determine which scores were updated
    List updatedGradeRecords = new ArrayList();
    if (getGradebookItems() != null) {
        Iterator itemIter = getGradebookItems().iterator();
        while (itemIter.hasNext()) {
            Object item = itemIter.next();
            if (item instanceof AssignmentGradeRow) {
                AssignmentGradeRow gradeRow = (AssignmentGradeRow) item;
                AssignmentGradeRecord gradeRecord = gradeRow.getGradeRecord();

                if (gradeRecord == null && (gradeRow.getScore() != null || gradeRow.getLetterScore() != null)) {
                    // this is a new grade
                    gradeRecord = new AssignmentGradeRecord(gradeRow.getAssociatedAssignment(), getStudentUid(),
                            null);
                }
                if (gradeRecord != null) {
                    if (getGradeEntryByPoints()) {
                        Double originalScore = null;
                        originalScore = gradeRecord.getPointsEarned();

                        if (originalScore != null) {
                            // truncate to two decimals for more accurate comparison
                            originalScore = new Double(FacesUtil.getRoundDown(originalScore.doubleValue(), 2));
                        }
                        Double newScore = gradeRow.getScore();
                        if ((originalScore != null && !originalScore.equals(newScore))
                                || (originalScore == null && newScore != null)) {
                            gradeRecord.setPointsEarned(newScore);
                            updatedGradeRecords.add(gradeRecord);
                            getGradebookBean().getEventTrackingService().postEvent("gradebook.updateItemScore",
                                    "/gradebook/" + getGradebookUid() + "/"
                                            + gradeRecord.getAssignment().getName() + "/"
                                            + gradeRecord.getStudentId() + "/" + gradeRecord.getPointsEarned()
                                            + "/" + getAuthzLevel());
                        }
                    } else if (getGradeEntryByPercent()) {
                        Double originalScore = null;
                        originalScore = gradeRecord.getPercentEarned();

                        if (originalScore != null) {
                            // truncate to two decimals for more accurate comparison
                            originalScore = new Double(FacesUtil.getRoundDown(originalScore.doubleValue(), 2));
                        }
                        Double newScore = gradeRow.getScore();
                        if ((originalScore != null && !originalScore.equals(newScore))
                                || (originalScore == null && newScore != null)) {
                            gradeRecord.setPercentEarned(newScore);
                            updatedGradeRecords.add(gradeRecord);
                        }

                    } else if (getGradeEntryByLetter()) {

                        String originalScore = gradeRecord.getLetterEarned();
                        String newScore = gradeRow.getLetterScore();
                        if ((originalScore != null && !originalScore.equals(newScore))
                                || (originalScore == null && newScore != null)) {
                            gradeRecord.setLetterEarned(newScore);
                            updatedGradeRecords.add(gradeRecord);
                        }
                    }
                }
            }
        }
    }

    Set excessiveScores = getGradebookManager().updateStudentGradeRecords(updatedGradeRecords,
            getGradebook().getGrade_type(), getStudentUid());

    if (updatedGradeRecords.size() > 0) {
        getGradebookBean().getEventTrackingService().postEvent("gradebook.updateItemScores",
                "/gradebook/" + getGradebookId() + "/" + updatedGradeRecords.size() + "/" + getAuthzLevel());
        String messageKey = (excessiveScores.size() > 0) ? "inst_view_scores_saved_excessive"
                : "inst_view_scores_saved";

        // Let the user know.
        FacesUtil.addMessage(getLocalizedString(messageKey));
    }

}

From source file:cec.easyshop.storefront.controllers.pages.StorePageController.java

@RequestMapping(value = STORE_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET)
public String storeDetail(@PathVariable("storeCode") final String storeCode,
        @RequestParam(value = "lat", required = false) final Double sourceLatitude,
        @RequestParam(value = "long", required = false) final Double sourceLongitude,
        @RequestParam(value = "q", required = false) final String locationQuery, final Model model,
        final RedirectAttributes redirectModel) throws CMSItemNotFoundException {
    final StoreFinderForm storeFinderForm = new StoreFinderForm();
    model.addAttribute("storeFinderForm", storeFinderForm);
    final StorePositionForm storePositionForm = new StorePositionForm();
    model.addAttribute("storePositionForm", storePositionForm);

    if (sourceLatitude != null && sourceLongitude != null) {
        final GeoPoint geoPoint = new GeoPoint();
        geoPoint.setLatitude(sourceLatitude.doubleValue());
        geoPoint.setLongitude(sourceLongitude.doubleValue());

        // Get the point of service data with the formatted distance
        try {//w  ww .  ja  v  a  2s . c  o m
            final PointOfServiceData pointOfServiceData = storeFinderFacade
                    .getPointOfServiceForNameAndPosition(storeCode, geoPoint);
            if (pointOfServiceData == null) {
                return handleStoreNotFoundCase(redirectModel);
            }
            pointOfServiceData.setUrl("/store/" + pointOfServiceData.getName());
            model.addAttribute("store", pointOfServiceData);

            if (locationQuery != null && !locationQuery.isEmpty()) {
                model.addAttribute("locationQuery", locationQuery);

                // Build URL to location query
                final String storeFinderSearchUrl = UriComponentsBuilder.fromPath("/store-finder")
                        .queryParam("q", locationQuery).build().toString();
                model.addAttribute(WebConstants.BREADCRUMBS_KEY, storeBreadcrumbBuilder
                        .getBreadcrumbs(pointOfServiceData, XSSEncoder.encodeURL(storeFinderSearchUrl)));
            } else {
                // Build URL to position query
                final String storeFinderSearchUrl = UriComponentsBuilder.fromPath("/store-finder/position")
                        .queryParam("lat", sourceLatitude).queryParam("long", sourceLongitude).build()
                        .toString();
                model.addAttribute(WebConstants.BREADCRUMBS_KEY, storeBreadcrumbBuilder
                        .getBreadcrumbs(pointOfServiceData, XSSEncoder.encodeURL(storeFinderSearchUrl)));
            }
            setUpMetaData(model, pointOfServiceData);
        } catch (final ModelNotFoundException e) {
            return handleStoreNotFoundCase(redirectModel);
        } catch (final UnsupportedEncodingException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Error occured during Encoding the Store Page data values", e);
            }
        }
    } else {
        // No source point specified - just lookup the POS by name
        try {
            final PointOfServiceData pointOfServiceData = storeFinderFacade.getPointOfServiceForName(storeCode);
            pointOfServiceData.setUrl("/store/" + pointOfServiceData.getName());
            model.addAttribute("store", pointOfServiceData);
            model.addAttribute(WebConstants.BREADCRUMBS_KEY,
                    storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData));
            setUpMetaData(model, pointOfServiceData);
        } catch (final ModelNotFoundException e) {
            return handleStoreNotFoundCase(redirectModel);
        }
    }

    storeCmsPageInModel(model, getStoreFinderPage());
    return ControllerConstants.Views.Pages.StoreFinder.StoreFinderDetailsPage;
}