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:jenkins.plugins.asqatasun.AsqatasunRunnerBuilder.java

private boolean setBuildStatusSecondIfCondition(AsqatasunRunner asqatasunRunner) {
    return Integer.valueOf(minMarkThresholdForStable) > 0
            && Float.valueOf(asqatasunRunner.getMark()) < Integer.valueOf(minMarkThresholdForStable);
}

From source file:com.connectsdk.service.AirPlayService.java

private long parseTimeValueFromString(String value) {
    long duration = 0L;
    try {//from ww w .  j  a va  2 s .  c om
        float f = Float.valueOf(value);
        duration = (long) f * 1000;
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
    return duration;
}

From source file:no.firestorm.weathernotificatonservice.WeatherNotificationService.java

/**
 * Display a notification with temperature
 * /*from   w  ww. j  a  v a 2  s  .  co  m*/
 * @param weather
 *            Weather element to with data to be shown in notification, if
 *            null a message for that say that this station does not provide
 *            data will be shown
 */
private void makeNotification(WeatherElement weather) {
    int tickerIcon, contentIcon;
    CharSequence tickerText, contentTitle, contentText, contentTime;
    final DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
    long when;
    Float temperatureF = null;
    if (weather != null) {
        // Has data
        final WeatherElement temperature = weather;
        // Find name
        final String stationName = WeatherNotificationSettings.getStationName(WeatherNotificationService.this);

        // Find icon
        tickerIcon = TempToDrawable.getDrawableFromTemp(Float.valueOf(temperature.getValue()));
        contentIcon = tickerIcon;
        // Set title
        tickerText = stationName;
        contentTitle = stationName;
        contentTime = df.format(temperature.getDate());
        when = temperature.getDate().getTime();

        final Context context = WeatherNotificationService.this;
        temperatureF = new Float(temperature.getValue());
        contentText = String.format("%s %.1f C", context.getString(R.string.temperatur_),
                new Float(temperature.getValue()));

        updateAlarm(weather);

    } else {
        // No data
        contentIcon = android.R.drawable.stat_notify_error;
        final Context context = WeatherNotificationService.this;
        contentTime = df.format(new Date());
        when = (new Date()).getTime();
        tickerText = context.getText(R.string.no_available_data);
        contentTitle = context.getText(R.string.no_available_data);
        contentText = context.getString(R.string.try_another_station);
        tickerIcon = android.R.drawable.stat_notify_error;

    }

    makeNotification(tickerIcon, contentIcon, tickerText, contentTitle, contentText, contentTime, when,
            temperatureF);

}

From source file:com.meetup.memcached.NativeHandler.java

protected static Float decodeFloat(byte[] b) throws Exception {
    Integer l = decodeInteger(b);
    return Float.valueOf(Float.intBitsToFloat(l.intValue()));
}

From source file:com.topsem.common.io.excel.ImportExcel.java

/**
 * ??// w w  w  .ja  va 2  s.co m
 *
 * @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:org.brekka.stillingar.spring.bpp.ConfigurationBeanPostProcessorTest.java

@Test
public void primitiveDefaultFloat() {
    assertEquals(ConfigurationBeanPostProcessor.primitiveDefault(Float.TYPE), Float.valueOf(0f));
}

From source file:gov.nih.nci.ncicb.tcga.dcc.datareports.service.ProjectCaseDashboardServiceImpl.java

/**
 * getBCRJson/* w  w  w .  jav  a 2 s. c  o m*/
 *
 * @param fileName
 * @return list of BCRJson
 * @throws IOException
 */
protected List<BCRJson> getBCRJson(String fileName) {
    final List<BCRJson> list = new LinkedList<BCRJson>();
    try {
        final String json = FileUtil.readFile(new File(fileName), true);
        final JSONObject jsonObject = JSONObject.fromObject(json);
        final JSONArray caseByDisease = (JSONArray) jsonObject.get("case_summary_by_disease");
        for (int i = 0; i < caseByDisease.size(); i++) {
            final JSONObject jo = caseByDisease.getJSONObject(i);
            final String disease = (String) jo.get("tumor_abbrev");
            final int shipped = (Integer) jo.get("shipped");
            final int pending = (Integer) jo.get("pending_shipment");
            final int received = (Integer) jo.get("total_cases_rcvd");
            final float jsonPassRate = jo.get("qual_pass_rate") == null ? 0f
                    : Float.valueOf(jo.get("qual_pass_rate").toString());
            list.add(new BCRJson(disease, shipped, pending, received, jsonPassRate));
        }
    } catch (Exception e) {
        return list;
    }
    return list;
}

From source file:com.highcharts.export.controller.ExportController.java

private static Float scaleToFloat(String scale) throws SVGConverterException {
    scale = sanitize(scale);//from  w w w. j  a  va  2 s.  co  m
    if (scale != null) {
        try {
            Float parsedScale = Float.valueOf(scale);
            if (parsedScale.compareTo(MAX_SCALE) > 0) {
                return MAX_SCALE;
            } else if (parsedScale.compareTo(0.0F) > 0) {
                return parsedScale;
            }
        } catch (NumberFormatException nfe) {
            logger.error("Parameter scale is wrong for value: " + scale, nfe.fillInStackTrace());
            throw new SVGConverterException("Parameter scale is wrong for value: " + scale);
        }
    }
    return null;
}