Example usage for java.lang Float valueOf

List of usage examples for java.lang Float valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Float valueOf(float f) 

Source Link

Document

Returns a Float instance representing the specified float value.

Usage

From source file:org.kuali.student.myplan.course.controller.CourseSearchController.java

public HashMap<String, Credit> getCreditMap() {
    HashMap<String, Credit> creditMap = new HashMap<String, Credit>();

    try {/* w ww  .  j  a va 2 s.c  o  m*/
        SearchRequestInfo searchRequest = new SearchRequestInfo(
                CourseSearchConstants.SEARCH_REQUEST_CREDITS_DETAILS);
        List<SearchParamInfo> params = new ArrayList<SearchParamInfo>();
        searchRequest.setParams(params);
        SearchResultInfo searchResult = getLuService().search(searchRequest,
                CourseSearchConstants.CONTEXT_INFO);
        for (SearchResultRow row : searchResult.getRows()) {
            String id = SearchHelper.getCellValue(row, "credit.id");
            String type = SearchHelper.getCellValue(row, "credit.type");
            String min = SearchHelper.getCellValue(row, "credit.min");
            String max = SearchHelper.getCellValue(row, "credit.max");
            Credit credit = new Credit();
            credit.id = id;
            credit.min = Float.valueOf(min);
            credit.max = Float.valueOf(max);
            if (CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_MULTIPLE.equals(type)) {
                credit.display = min + ", " + max;
                credit.type = CourseSearchItem.CreditType.multiple;
            } else if (CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_VARIABLE.equals(type)) {
                credit.display = min + "-" + max;
                credit.type = CourseSearchItem.CreditType.range;
            } else if (CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_FIXED.equals(type)) {
                credit.display = min;
                credit.type = CourseSearchItem.CreditType.fixed;
            }

            creditMap.put(id, credit);
        }
        return creditMap;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:gtu._work.ui.SqlCreaterUI.java

private String formatCellType(Cell cell) {
    String returnVal = StringUtils.EMPTY;
    if (cell == null) {
        return "";
    }// w  w  w  . j  ava 2  s.c  o m
    if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) {
        if (HSSFDateUtil.isCellDateFormatted(cell)) {
            Date d = cell.getDateCellValue();
            returnVal = " to_date('" + SDF.format(d) + "', 'yyyymmdd' ) ";
        } else {
            final NumberFormat formatter = new DecimalFormat("##");
            returnVal = formatter.format(Float.valueOf(cell.toString()));
        }
    } else {
        returnVal = cell.toString();
    }
    return returnVal;
}

From source file:zerogame.info.javapay.web.OrderPayWebCallBack.java

@RequestMapping(value = "/kuaiyong", method = RequestMethod.POST)
@ResponseBody/* w  ww  .  j ava 2  s  .  c o  m*/
public String kuaiyongPayOrder(@RequestParam("uid") String uid, @RequestParam("notify_data") String notify_data,
        @RequestParam("orderid") String orderid, @RequestParam("sign") String sign,
        @RequestParam("dealseq") String dealseq, @RequestParam("subject") String subject,
        @RequestParam("v") String v) {
    logger.info("kuaiyong pay notigydata=" + notify_data + ",orderid=" + orderid + ",dealseq=" + dealseq
            + ",uid=" + uid + ",subject=" + subject + ",version=" + v + ",sign=" + sign);
    Map<String, String> transformedMap = new HashMap<String, String>();
    transformedMap.put("notify_data", notify_data);
    transformedMap.put("orderid", orderid);
    transformedMap.put("sign", sign);
    transformedMap.put("dealseq", dealseq);
    transformedMap.put("uid", uid);
    transformedMap.put("subject", subject);
    transformedMap.put("v", v);
    String signData = Util.getSignData(transformedMap);

    String rsaPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDPXB7aWe9IUh2wz0MyOqxwk3ujF5qmmRzOL4kwfVPVsnEG8d2lSbo+S0/Xm7sivsR1l/LsGWAuoWGLF0bFO5Zm+oh5W6rexuh+mJgAhZfSzrIAgD7QJIZ2TOzQFeCki3xor+62RmEqjePYWJpP0pStVexMZzFaRRFRiYXWMVCeYQIDAQAB";
    if (!com.kuaiyong.pay.util.RSASignature.doCheck(signData, sign, rsaPublicKey, "utf-8")) {
        //RSA???
        //??
        //?
        logger.warn("RSA???");
        return "failed";
    } else {

        //"RSA???
        RSAEncrypt rsaEncrypt = new RSAEncrypt();

        //   
        try {
            rsaEncrypt.loadPublicKey(rsaPublicKey);
            //?
            logger.warn("?");
        } catch (Exception e) {
            //
            logger.warn("");
        }

        //?
        byte[] dcDataStr = Base64.decode(notify_data);
        byte[] plainData;
        try {
            plainData = rsaEncrypt.decrypt(rsaEncrypt.getPublicKey(), dcDataStr);
        } catch (Exception e) {
            logger.warn("");
            return "failed";
        }
        //??
        String notifyData;
        try {
            notifyData = new String(plainData, "UTF-8");
        } catch (Exception e) {
            logger.info(e);
            return "failed";
        }
        logger.info("sign:" + notifyData);
        String[] data = notifyData.split("&");
        String fee = data[1].split("=")[1];//DATA?  fee

        //??
        String[] params = dealseq.split("-");
        String channelId = params[0];
        String accountId = params[1];
        String time = params[2];
        String goodId = params[3];
        String serverId = params[4];
        Player user = userDao.getPlayer(CHANNEL_KUAIYONG, accountId, serverId);
        //logger.info("user is " +user.toString());
        if (user != null) {
            PayOrder payOrder = new PayOrder();
            payOrder.setUin(user.getUin());
            payOrder.setAccountId(accountId);
            payOrder.setChannel(CHANNEL_KUAIYONG);
            payOrder.setOrderId(orderid);
            payOrder.setProductId(goodId);
            payOrder.setServerId(Integer.valueOf(serverId));
            float money = Float.valueOf(fee);
            payOrder.setMoney(Math.round(money));
            //logger.info(payOrder);
            this.payOrderDao.add(payOrder);
        }

        //?
        return "success";
    }
}

From source file:eu.uqasar.model.tree.Project.java

@JsonIgnore
public Integer getDateProgressInPercent() {
    float elapsedDays = getElapsedDays();
    float totalDays = getDurationInDays();
    if (elapsedDays <= 0) {
        return 0;
    }/*from www  .  j  a  va  2  s  .  co m*/
    if (elapsedDays > totalDays) {
        return 100;
    }
    return Float.valueOf((elapsedDays / totalDays) * 100f).intValue();
}

From source file:net.ceos.project.poi.annotated.core.CsvHandler.java

/**
 * Apply a Float value to the object./*from  w  w w . ja v  a  2s  .c om*/
 * 
 * @param o
 *            the object
 * @param field
 *            the field
 * @param values
 *            the array with the content at one line
 * @param idx
 *            the index of the field
 * @throws ConverterException
 *             the conversion exception type
 */
protected static void floatReader(final Object o, final Field field, final String[] values, final int idx)
        throws ConverterException {
    String fValue = values[idx];
    if (StringUtils.isNotBlank(fValue)) {
        try {
            field.set(o, Float.valueOf(fValue));
        } catch (IllegalArgumentException | IllegalAccessException e) {
            throw new ConverterException(ExceptionMessage.CONVERTER_FLOAT.getMessage(), e);
        }
    }
}

From source file:com.netsteadfast.greenstep.bsc.util.AggregationMethod.java

public void countDistinctDateRange(KpiVO kpi, String frequency) throws Exception {
    BscReportSupportUtils.loadExpression();
    for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) {
        List<Float> scores = new ArrayList<Float>();
        float score = 0.0f;
        //int size = 0;
        for (BbMeasureData measureData : kpi.getMeasureDatas()) {
            String date = dateScore.getDate().replaceAll("/", "");
            if (!this.isDateRange(date, frequency, measureData)) {
                continue;
            }/*from   www .  ja v  a  2 s. c om*/
            BscMeasureData data = new BscMeasureData();
            data.setActual(measureData.getActual());
            data.setTarget(measureData.getTarget());
            try {
                Object value = BscFormulaUtils.parse(kpi.getFormula(), data);
                if (value == null) {
                    continue;
                }
                if (!NumberUtils.isNumber(String.valueOf(value))) {
                    continue;
                }
                float nowScore = NumberUtils.toFloat(String.valueOf(value), 0.0f);
                if (!scores.contains(nowScore)) {
                    scores.add(nowScore);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        score = Float.valueOf(scores.size());
        dateScore.setScore(score);
        dateScore.setFontColor(BscScoreColorUtils.getFontColor(score));
        dateScore.setBgColor(BscScoreColorUtils.getBackgroundColor(score));
        dateScore.setImgIcon(BscReportSupportUtils.getHtmlIcon(kpi, score));
    }
}

From source file:com.joint.base.util.excel.ImportExcel.java

/**
* ??/* w w w  .  j ava  2 s .c  om*/
* @param cls 
* @param groups 
*/
public <E> List<E> getDataList(Class<E> cls, int... groups)
        throws InstantiationException, IllegalAccessException {
    List<Object[]> annotationList = Lists.newArrayList();
    // Get annotation field
    Field[] fs = cls.getDeclaredFields();
    for (Field f : fs) {
        ExcelField ef = f.getAnnotation(ExcelField.class);
        if (ef != null && (ef.type() == 0 || ef.type() == 2)) {
            if (groups != null && groups.length > 0) {
                boolean inGroup = false;
                for (int g : groups) {
                    if (inGroup) {
                        break;
                    }
                    for (int efg : ef.groups()) {
                        if (g == efg) {
                            inGroup = true;
                            annotationList.add(new Object[] { ef, f });
                            break;
                        }
                    }
                }
            } else {
                annotationList.add(new Object[] { ef, f });
            }
        }
    }
    // Get annotation method
    Method[] ms = cls.getDeclaredMethods();
    for (Method m : ms) {
        ExcelField ef = m.getAnnotation(ExcelField.class);
        if (ef != null && (ef.type() == 0 || ef.type() == 2)) {
            if (groups != null && groups.length > 0) {
                boolean inGroup = false;
                for (int g : groups) {
                    if (inGroup) {
                        break;
                    }
                    for (int efg : ef.groups()) {
                        if (g == efg) {
                            inGroup = true;
                            annotationList.add(new Object[] { ef, m });
                            break;
                        }
                    }
                }
            } else {
                annotationList.add(new Object[] { ef, m });
            }
        }
    }
    // Field sorting
    Collections.sort(annotationList, new Comparator<Object[]>() {
        public int compare(Object[] o1, Object[] o2) {
            return new Integer(((ExcelField) o1[0]).sort()).compareTo(new Integer(((ExcelField) o2[0]).sort()));
        };
    });
    //log.debug("Import column count:"+annotationList.size());
    // Get excel data
    List<E> dataList = Lists.newArrayList();
    for (int i = this.getDataRowNum(); i < this.getLastDataRowNum(); i++) {
        E e = (E) cls.newInstance();
        int column = 0;
        Row row = this.getRow(i);
        StringBuilder sb = new StringBuilder();
        for (Object[] os : annotationList) {
            Object val = this.getCellValue(row, column++);
            if (val != null) {
                ExcelField ef = (ExcelField) os[0];
                // If is dict type, get dict value
                if (StringUtils.isNotBlank(ef.dictType())) {
                    //val = DictUtils.getDictValue(val.toString(), ef.dictType(), "");
                    //log.debug("Dictionary type value: ["+i+","+colunm+"] " + val);
                }
                // Get param type and type cast
                Class<?> valType = Class.class;
                if (os[1] instanceof Field) {
                    valType = ((Field) os[1]).getType();
                } else if (os[1] instanceof Method) {
                    Method method = ((Method) os[1]);
                    if ("get".equals(method.getName().substring(0, 3))) {
                        valType = method.getReturnType();
                    } else if ("set".equals(method.getName().substring(0, 3))) {
                        valType = ((Method) os[1]).getParameterTypes()[0];
                    }
                }
                //log.debug("Import value type: ["+i+","+column+"] " + valType);
                try {
                    if (valType == String.class) {
                        String s = String.valueOf(val.toString());
                        if (StringUtils.endsWith(s, ".0")) {
                            val = StringUtils.substringBefore(s, ".0");
                        } else {
                            val = String.valueOf(val.toString());
                        }
                    } else if (valType == Integer.class) {
                        val = Double.valueOf(val.toString()).intValue();
                    } else if (valType == Long.class) {
                        val = Double.valueOf(val.toString()).longValue();
                    } else if (valType == Double.class) {
                        val = Double.valueOf(val.toString());
                    } else if (valType == Float.class) {
                        val = Float.valueOf(val.toString());
                    } else if (valType == Date.class) {
                        val = DateUtil.getJavaDate((Double) val);
                    } else {
                        if (ef.fieldType() != Class.class) {
                            val = ef.fieldType().getMethod("getValue", String.class).invoke(null,
                                    val.toString());
                        } else {
                            val = Class
                                    .forName(this.getClass().getName().replaceAll(
                                            this.getClass().getSimpleName(),
                                            "fieldtype." + valType.getSimpleName() + "Type"))
                                    .getMethod("getValue", String.class).invoke(null, val.toString());
                        }
                    }
                } catch (Exception ex) {
                    log.info("Get cell value [" + i + "," + column + "] error: " + ex.toString());
                    val = null;
                }
                // set entity value
                if (os[1] instanceof Field) {
                    Reflections.invokeSetter(e, ((Field) os[1]).getName(), val);
                } else if (os[1] instanceof Method) {
                    String mthodName = ((Method) os[1]).getName();
                    if ("get".equals(mthodName.substring(0, 3))) {
                        mthodName = "set" + StringUtils.substringAfter(mthodName, "get");
                    }
                    Reflections.invokeMethod(e, mthodName, new Class[] { valType }, new Object[] { val });
                }
            }
            sb.append(val + ", ");
        }
        dataList.add(e);
        log.debug("Read success: [" + i + "] " + sb.toString());
    }
    return dataList;
}

From source file:de.pangaea.fixo3.CreateEsonetYellowPages.java

private void addDeviceType(String name, String label, String comment, String seeAlso,
        JsonArray equivalentClasses, JsonArray subClasses) {
    IRI deviceTypeIRI = IRI.create(name);

    m.addClass(deviceTypeIRI);//  www .j ava 2  s  . co  m
    m.addLabel(deviceTypeIRI, label);
    m.addComment(deviceTypeIRI, comment);
    m.addSeeAlso(deviceTypeIRI, seeAlso);

    // Default sub class, though implicit with curated sensing device type
    // hierarchy
    //      m.addSubClass(deviceTypeIRI, SSN.SensingDevice);

    for (JsonObject equivalentClass : equivalentClasses.getValuesAs(JsonObject.class)) {
        if (equivalentClass.containsKey("type")) {
            m.addEquivalentClass(deviceTypeIRI, IRI.create(equivalentClass.getString("type")));
        }
    }

    for (JsonObject subClass : subClasses.getValuesAs(JsonObject.class)) {
        if (subClass.containsKey("type")) {
            m.addSubClass(deviceTypeIRI, IRI.create(subClass.getString("type")));
        } else if (subClass.containsKey("observes")) {
            JsonObject observesJson = subClass.getJsonObject("observes");
            String propertyLabel = observesJson.getString("label");
            String propertyType = observesJson.getString("type");
            JsonObject featureJson = observesJson.getJsonObject("isPropertyOf");
            String featureLabel = featureJson.getString("label");
            String featureType = featureJson.getString("type");

            IRI propertyIRI = IRI.create(EYP.ns.toString() + md5Hex(propertyLabel));
            IRI propertyTypeIRI = IRI.create(propertyType);
            IRI featureIRI = IRI.create(EYP.ns.toString() + md5Hex(featureLabel));
            IRI featureTypeIRI = IRI.create(featureType);

            m.addObjectValue(deviceTypeIRI, observes, propertyIRI);
            m.addIndividual(propertyIRI);
            m.addType(propertyIRI, propertyTypeIRI);
            m.addLabel(propertyIRI, propertyLabel);
            m.addIndividual(featureIRI);
            m.addType(featureIRI, featureTypeIRI);
            m.addLabel(featureIRI, featureLabel);
            m.addObjectAssertion(propertyIRI, isPropertyOf, featureIRI);
        } else if (subClass.containsKey("detects")) {
            JsonObject detectsJson = subClass.getJsonObject("detects");
            String stimulusLabel = detectsJson.getString("label");
            String stimulusType = detectsJson.getString("type");

            IRI stimulusIRI = IRI.create(EYP.ns.toString() + md5Hex(stimulusLabel));
            IRI stimulusTypeIRI = IRI.create(stimulusType);

            m.addObjectValue(deviceTypeIRI, detects, stimulusIRI);
            m.addIndividual(stimulusIRI);
            m.addType(stimulusIRI, stimulusTypeIRI);
            m.addLabel(stimulusIRI, stimulusLabel);
        } else if (subClass.containsKey("capability")) {
            JsonObject capabilityJson = subClass.getJsonObject("capability");
            String capabilityLabel = capabilityJson.getString("label");
            JsonObject propertyJson = capabilityJson.getJsonObject("property");
            String propertyLabel = propertyJson.getString("label");
            String propertyType = propertyJson.getString("type");
            JsonObject valueJson = propertyJson.getJsonObject("value");
            String valueLabel = valueJson.getString("label");

            IRI capabilityIRI = IRI.create(EYP.ns.toString() + md5Hex(capabilityLabel));
            IRI propertyIRI = IRI.create(EYP.ns.toString() + md5Hex(propertyLabel));
            IRI propertyTypeIRI = IRI.create(propertyType);
            IRI valueIRI = IRI.create(EYP.ns.toString() + md5Hex(valueLabel));

            m.addObjectValue(deviceTypeIRI, hasMeasurementCapability, capabilityIRI);
            m.addIndividual(capabilityIRI);
            m.addType(capabilityIRI, MeasurementCapability);
            m.addLabel(capabilityIRI, capabilityLabel);
            m.addObjectAssertion(capabilityIRI, hasMeasurementProperty, propertyIRI);
            m.addIndividual(propertyIRI);
            m.addType(propertyIRI, SSN.MeasurementProperty);
            m.addType(propertyIRI, propertyTypeIRI);
            m.addLabel(propertyIRI, propertyLabel);
            m.addObjectAssertion(propertyIRI, hasValue, valueIRI);
            m.addIndividual(valueIRI);
            m.addType(valueIRI, SSN.ObservationValue);
            m.addLabel(valueIRI, valueLabel);

            if (valueJson.containsKey("value")) {
                m.addType(valueIRI, QuantitativeValue);
                m.addDataAssertion(valueIRI, value, Float.valueOf(valueJson.getString("value")));
            } else if (valueJson.containsKey("minValue") && valueJson.containsKey("maxValue")) {
                m.addType(valueIRI, QuantitativeValue);
                m.addDataAssertion(valueIRI, minValue, Float.valueOf(valueJson.getString("minValue")));
                m.addDataAssertion(valueIRI, maxValue, Float.valueOf(valueJson.getString("maxValue")));
            } else {
                throw new RuntimeException("Expected value or min/max value [valueJson = " + valueJson + "]");
            }

            m.addObjectAssertion(valueIRI, unitCode, IRI.create(valueJson.getString("unitCode")));
        }
    }

}

From source file:com.cm.android.beercellar.ui.ImageDetailFragment.java

private void load() {
    Log.i(sTag, "load");
    try {/*w w  w .  j  av  a 2  s. c  o  m*/
        if (mRowId != null) {
            Note note = mDbHelper.fetchNote(mRowId);
            if (note != null) {
                String ratingStr = note.rating;
                mRatingBar.setRating(Float.valueOf(ratingStr));
                mBeer.setText(note.beer);
                mTextExtract.setText(note.textExtract);
                mNotes.setText(note.notes);
                String dateAdded = "Added on " + mDateFormat.format(note.created);
                mDateCreated.setText(dateAdded);
                String dataUpdated = "Last updated on " + mDateFormat.format(note.updated);
                mDateUpdated.setText(dataUpdated);
            }
        }
    } catch (Throwable e) {
        Log.e(sTag, "error: " + ((e.getMessage() != null) ? e.getMessage().replace(" ", "_") : ""), e);
    }
}

From source file:logica.EstacionMet.java

/**
 * Encargado de actualizar y guardar la informacion de un sensor en los 
 * resumenes XML/* w w  w .  j a  v  a2 s  . c o m*/
 * 
 * @param registro El manejador de XML
 * @param sensorID El id del sensor cuyo resumen hay que actualizar
 * @param tipo El tipo de sensor cuyo resumen hay que actualizar
 * @param medicionS La medicion del sensor
 */
private void resumenSave(XMLConfiguration registro, Integer sensorID, String tipo, String medicionS) {
    try {
        // Busco si ya hay algun registro del sensor.
        List<String> idsRegistro = registro.getList(String.format("estacion%d.sensor.id", ID));
        int index = -1;

        for (String id : idsRegistro) {
            if (Integer.valueOf(id).equals(sensorID)) {
                index = idsRegistro.indexOf(String.valueOf(sensorID));
                break;
            }
        }
        // Si ya hay, actualizo
        if (index != -1) {
            float medicion; // Medicion actual en float
            String nMedicionesS; // Numero de mediciones
            int nMediciones;
            String maximoS; // Valor maximo de las mediciones
            float maximo;
            String minimoS; // Valor minimo de las mediciones
            float minimo;
            String medioS; // Valor medio de las mediciones
            float medio;

            // Cargo los valores
            nMedicionesS = registro.getString(String.format("estacion%d.sensor(%d).mediciones", ID, index));
            maximoS = registro.getString(String.format("estacion%d.sensor(%d).maximo", ID, index));
            minimoS = registro.getString(String.format("estacion%d.sensor(%d).minimo", ID, index));
            medioS = registro.getString(String.format("estacion%d.sensor(%d).medio", ID, index));

            // Aumento en uno la cantidad de mediciones
            nMediciones = Integer.valueOf(nMedicionesS) + 1;
            registro.setProperty(String.format("estacion%d.sensor(%d).mediciones", ID, index),
                    String.valueOf(nMediciones));

            // Recalculo maximo y minimo
            medicion = Float.valueOf(medicionS.split(" ")[0]);
            maximo = Float.valueOf(maximoS.split(" ")[0]);
            minimo = Float.valueOf(minimoS.split(" ")[0]);

            if (medicion > maximo)
                registro.setProperty(String.format("estacion%d.sensor(%d).maximo", ID, index), medicionS);
            if (medicion < minimo)
                registro.setProperty(String.format("estacion%d.sensor(%d).minimo", ID, index), medicionS);

            // Recalculo el valor medio
            medio = Float.valueOf(medioS.split(" ")[0]);

            medio = (medio + medicion) / 2;
            registro.setProperty(String.format("estacion%d.sensor(%d).medio", ID, index),
                    String.valueOf(medio));
        } else { // Si no, creo y cargo los valores como iniciales
            index = idsRegistro.size();
            registro.addProperty(String.format("estacion%d.sensor(%d).id", ID, index), sensorID.toString());
            registro.addProperty(String.format("estacion%d.sensor(%d).tipo", ID, index), tipo);
            registro.addProperty(String.format("estacion%d.sensor(%d).maximo", ID, index), medicionS);
            registro.addProperty(String.format("estacion%d.sensor(%d).minimo", ID, index), medicionS);
            registro.addProperty(String.format("estacion%d.sensor(%d).medio", ID, index), medicionS);
            registro.addProperty(String.format("estacion%d.sensor(%d).mediciones", ID, index), "1");
        }

        registro.save();
    } catch (ConfigurationException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    }
}