Example usage for java.lang Double valueOf

List of usage examples for java.lang Double valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Double valueOf(double d) 

Source Link

Document

Returns a Double instance representing the specified double value.

Usage

From source file:marytts.util.string.StringUtils.java

public static double string2double(String str) {
    return Double.valueOf(str).doubleValue();
}

From source file:ml.shifu.shifu.udf.stats.NumericalVarStats.java

@Override
public void runVarStats(String binningInfo, DataBag databag) throws ExecException {
    String[] binningDataArr = StringUtils.split(binningInfo, CalculateStatsUDF.CATEGORY_VAL_SEPARATOR);

    log.info("Column Name - " + this.columnConfig.getColumnName() + ", Column Bin Length - "
            + binningDataArr.length);//from   w w  w. j a v  a2  s . c  om

    List<Double> binBoundary = new ArrayList<Double>();
    for (String binningElement : binningDataArr) {
        binBoundary.add(Double.valueOf(binningElement));
    }

    columnConfig.setBinBoundary(binBoundary);
    statsNumericalColumnInfo(databag, columnConfig);
}

From source file:com.l2jfree.sql.L2DatabaseInstaller.java

public static void check() throws SAXException, IOException, ParserConfigurationException {
    final TreeMap<String, String> tables = new TreeMap<String, String>();
    final TreeMap<Double, String> updates = new TreeMap<Double, String>();

    final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(false); // FIXME add validation
    factory.setIgnoringComments(true);/*from   w ww .j  a va 2 s. c  om*/

    final List<Document> documents = new ArrayList<Document>();

    InputStream is = null;
    try {
        // load default database schema from resources
        is = L2DatabaseInstaller.class.getResourceAsStream("database_schema.xml");

        documents.add(factory.newDocumentBuilder().parse(is));
    } finally {
        IOUtils.closeQuietly(is);
    }

    final File f = new File("./config/database_schema.xml");

    // load optional project specific database tables/updates (fails on already existing)
    if (f.exists())
        documents.add(factory.newDocumentBuilder().parse(f));

    for (Document doc : documents) {
        for (Node n1 : L2XML.listNodesByNodeName(doc, "database")) {
            for (Node n2 : L2XML.listNodesByNodeName(n1, "table")) {
                final String name = L2XML.getAttribute(n2, "name");
                final String definition = L2XML.getAttribute(n2, "definition");

                final String oldDefinition = tables.put(name, definition);
                if (oldDefinition != null)
                    throw new RuntimeException("Found multiple tables with name " + name + "!");
            }

            for (Node n2 : L2XML.listNodesByNodeName(n1, "update")) {
                final Double revision = Double.valueOf(L2XML.getAttribute(n2, "revision"));
                final String query = L2XML.getAttribute(n2, "query");

                final String oldQuery = updates.put(revision, query);
                if (oldQuery != null)
                    throw new RuntimeException("Found multiple updates with revision " + revision + "!");
            }
        }
    }

    createRevisionTable();

    final double databaseRevision = getDatabaseRevision();

    if (databaseRevision == -1) // no table exists
    {
        for (Entry<String, String> table : tables.entrySet()) {
            final String tableName = table.getKey();
            final String tableDefinition = table.getValue();

            installTable(tableName, tableDefinition);
        }

        if (updates.isEmpty())
            insertRevision(0);
        else
            insertRevision(updates.lastKey());
    } else
    // check for possibly required updates
    {
        for (Entry<String, String> table : tables.entrySet()) {
            final String tableName = table.getKey();
            final String tableDefinition = table.getValue();

            if (L2Database.tableExists(tableName))
                continue;

            System.err.println("Table '" + tableName + "' is missing, so the server attempts to install it.");
            System.err.println("WARNING! It's highly recommended to check the results manually.");

            installTable(tableName, tableDefinition);
        }

        for (Entry<Double, String> update : updates.entrySet()) {
            final double updateRevision = update.getKey();
            final String updateQuery = update.getValue();

            if (updateRevision > databaseRevision) {
                executeUpdate(updateQuery);

                insertRevision(updateRevision);
            }
        }
    }
}

From source file:demo.FleetLocationNarrower.java

private boolean closeEnough(Map<String, Object> location) {
    if (location.get("longitude") == null || location.get("latitude") == null) {
        return false;
    }// w  w w. java2 s . co m
    Double locLong = Double.valueOf((String) location.get("longitude"));
    Double locLat = Double.valueOf((String) location.get("latitude"));
    if (locLat != null && locLong != null) {
        if (this.latitude + 5 > locLat && this.latitude - this.radius < locLat
                && this.longitude + this.radius > locLong && this.longitude - this.radius < locLong) {
            return true;
        }
    }
    return false;
}

From source file:com.jyothigas.app.dao.DealerBookingDAO.java

public List<Reports> getPurchaseReport(Date fromDate, Date toDate, int userId) {
    log.info("Getting bookingEntity Instance");
    List<Reports> report = new ArrayList<Reports>();
    try {/*from ww  w.j  a v a 2 s . c o m*/
        List<Object[]> object = entityManager.createQuery(
                "select SUM(s.quantity),bookingType,SUM(total) from DealerBookingEntity s where s.created_date >=:fromDate and s.created_date <=:toDate "
                        + " and s.user_id=:userId group by bookingType",
                Object[].class).setParameter("userId", userId).setParameter("fromDate", fromDate)
                .setParameter("toDate", toDate).getResultList();
        for (Object[] result : object) {
            System.out.println((Long) result[0]);
            Reports info = new Reports();
            info.setCount((Long) result[0]);
            info.setType((String) result[1]);
            info.setTotal(Double.valueOf(String.valueOf(result[2])));
            report.add(info);
        }

        log.info("get successfull");
    } catch (Exception e) {
        log.error("Failed : " + e);
        e.printStackTrace();
    }
    return report;
}

From source file:com.amazon.s3.util.XpathUtils.java

/**
 * Evaluates the specified XPath expression and returns the results as a
 * Double.//from  w ww .ja v a  2  s .  c  om
 *
 * @param expression
 *            The XPath expression to evaluate.
 * @param node
 *            The node to run the expression on.
 *
 * @return The Double result.
 *
 * @throws XPathExpressionException
 *             If there was a problem processing the specified XPath
 *             expression.
 */
public static Double asDouble(String expression, Node node) throws XPathExpressionException {
    String doubleString = evaluateAsString(expression, node);
    return (isEmptyString(doubleString)) ? null : Double.valueOf(doubleString);
}

From source file:com.exxonmobile.ace.hybris.core.btg.condition.operand.valueproviders.OrganizationTotalSpentInCurrencyLastYearOperandValueProvider.java

@Override
public Object getValue(final BTGOrganizationTotalSpentInCurrencyLastYearOperandModel operand,
        final UserModel user, final BTGConditionEvaluationScope evaluationScope) {
    if (user instanceof B2BCustomerModel) {
        final B2BUnitModel unit = getB2bUnitService()
                .getRootUnit(getB2bUnitService().getParent((B2BCustomerModel) user));

        Date startDateInclusive = DateUtils.addYears(new Date(), -1);
        startDateInclusive = DateUtils.setHours(startDateInclusive, 0);
        startDateInclusive = DateUtils.setMinutes(startDateInclusive, 0);
        startDateInclusive = DateUtils.setSeconds(startDateInclusive, 0);
        startDateInclusive = DateUtils.setMonths(startDateInclusive, Calendar.JANUARY);
        startDateInclusive = DateUtils.setDays(startDateInclusive, 1);

        final Date endDateNonInclusive = DateUtils.addYears(startDateInclusive, 1);

        final double total = getTotalSpentByBranch(unit, operand.getCurrency(), startDateInclusive,
                endDateNonInclusive, operand.getProductCatalogId(), operand.getCategoryCode());
        return Double.valueOf(total);
    }//from   w  ww  . j a  v  a 2s  . c om
    return Double.valueOf(0);
}

From source file:org.springframework.batch.admin.domain.support.JobParameterJacksonDeserializer.java

@Override
public JobParameter deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException {
    SimpleDateFormat formatter = new SimpleDateFormat();
    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);

    final String value = node.get("value").asText();
    final boolean identifying = node.get("identifying").asBoolean();
    final String type = node.get("type").asText();

    final JobParameter jobParameter;

    if (!type.isEmpty() && !type.equalsIgnoreCase("STRING")) {
        if ("DATE".equalsIgnoreCase(type)) {
            try {
                jobParameter = new JobParameter(formatter.parse(value), identifying);
            } catch (ParseException e) {
                throw new IOException(e);
            }//from www.j a  v a 2  s.  c  o  m
        } else if ("DOUBLE".equalsIgnoreCase(type)) {
            jobParameter = new JobParameter(Double.valueOf(value), identifying);
        } else if ("LONG".equalsIgnoreCase(type)) {
            jobParameter = new JobParameter(Long.valueOf(value), identifying);
        } else {
            throw new IllegalStateException("Unsupported JobParameter type: " + type);
        }
    } else {
        jobParameter = new JobParameter(value, identifying);
    }

    if (logger.isDebugEnabled()) {
        logger.debug(String.format("jobParameter - value: %s (type: %s, isIdentifying: %s)",
                jobParameter.getValue(), jobParameter.getType().name(), jobParameter.isIdentifying()));
    }

    return jobParameter;
}

From source file:com.sarm.aussiepayslipgenerator.service.BracketServiceImpl.java

@Override
public Bracket populate(String bracketType) {
    Bracket bracket = new Bracket();
    Properties prop = new Properties();

    String propFileName = "brackets.properties";

    try (InputStream input = getClass().getClassLoader().getResourceAsStream(propFileName)) {

        if (input == null) {
            logger.debug("input Stream for brackets.properties file : is Null  ");
            throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
        }//from   ww  w.j  av  a 2s. c o m
        prop.load(input);
        //            for (String key : prop.stringPropertyNames()) {
        //                String value = prop.getProperty(key);
        //                System.out.println(key + " => " + value);
        //            }
        //load a properties file from class path, inside static method

        //get the property value and print it out
        logger.debug("bracketType : " + bracketType);
        logger.debug(prop.getProperty(bracketType + ".low"));
        logger.debug(prop.getProperty(bracketType + ".ceiling"));
        logger.debug(prop.getProperty(bracketType + ".flat"));
        logger.debug(prop.getProperty(bracketType + ".rate"));
        logger.debug(prop.getProperty(bracketType + ".over"));

        bracket.setLowerLimit(Integer.valueOf(prop.getProperty(bracketType + ".low")));
        bracket.setCeiling(Integer.valueOf(prop.getProperty(bracketType + ".ceiling")));
        bracket.setIncomeTaxRate(Double.valueOf(prop.getProperty(bracketType + ".rate")));
        bracket.setOver(Integer.valueOf(prop.getProperty(bracketType + ".over")));
        bracket.setFlat(Integer.valueOf(prop.getProperty(bracketType + ".flat")));

    } catch (IOException ex) {
        logger.debug(" IOException caught while populating Bracket" + ex);
        ex.printStackTrace();

    } catch (Exception e) {
        logger.debug(" Exception caught while populating Bracket" + e);

        e.printStackTrace();
    } finally {
        // try with resources will close the inputstream
    }

    return bracket;

}

From source file:com.userweave.domain.service.impl.GeneralStatisticsImpl.java

@Override
public Integer getDropout() {
    if (getStarted() != null && getStarted() != 0) {
        return Double.valueOf((getStarted() - getFinished()) * 100.0 / getStarted()).intValue();
    } else {//from w ww. j  av  a2s .c  o m
        return 0;
    }
}