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:fi.mikuz.boarder.util.FileProcessor.java

public static GraphicalSoundboardHolder loadUnlimitedSoundboardBoard(File boardDir, String boardName)
        throws IOException {
    GraphicalSoundboardHolder holder = new GraphicalSoundboardHolder();
    GraphicalSoundboard gsb = new GraphicalSoundboard();

    DataInputStream in = new DataInputStream(new FileInputStream(boardDir + "/graphicalBoard"));
    BufferedReader br = new BufferedReader(new InputStreamReader(in), 8192);

    String line;//from   w  ww . jav a  2s .c o m
    line = br.readLine();

    gsb.setPlaySimultaneously(Boolean.parseBoolean(line.substring(0, line.indexOf("1"))));
    gsb.setBoardVolume(
            Float.valueOf(line.substring(line.indexOf("1") + 3, line.indexOf("2"))).floatValue());
    gsb.setUseBackgroundImage(
            Boolean.parseBoolean(line.substring(line.indexOf("2") + 3, line.indexOf("3"))));
    gsb.setBackgroundColor(
            Integer.valueOf(line.substring(line.indexOf("3") + 3, line.indexOf("4"))).intValue());
    File backgroundImagePath = new File(line.substring(line.indexOf("4") + 3, line.indexOf("5")));
    if (backgroundImagePath.toString().contains("local/")) {
        backgroundImagePath = new File(SoundboardMenu.mSbDir + "/" + boardName,
                backgroundImagePath.toString().substring(6, backgroundImagePath.toString().length()));
    } else if (backgroundImagePath.toString().equals("na")) {
        backgroundImagePath = null;
    }
    gsb.setBackgroundImagePath(backgroundImagePath);
    gsb.setBackgroundX(
            Float.valueOf(line.substring(line.indexOf("5") + 3, line.indexOf("6"))).floatValue());
    gsb.setBackgroundY(
            Float.valueOf(line.substring(line.indexOf("6") + 3, line.indexOf("7"))).floatValue());
    gsb.setBackgroundWidthHeight(null,
            Float.valueOf(line.substring(line.indexOf("7") + 3, line.indexOf("8"))).floatValue(),
            Float.valueOf(line.substring(line.indexOf("8") + 3, line.indexOf("9"))).floatValue());
    gsb.setScreenOrientation(
            Integer.valueOf(line.substring(line.indexOf("9") + 3, line.indexOf("10"))).intValue());
    gsb.setAutoArrange(Boolean.parseBoolean(line.substring(line.indexOf("10") + 4, line.indexOf("11"))));
    gsb.setAutoArrangeColumns(
            Integer.valueOf(line.substring(line.indexOf("11") + 4, line.indexOf("12"))).intValue());
    gsb.setAutoArrangeRows(Integer.valueOf(line.substring(line.indexOf("12") + 4, line.length())).intValue());

    while ((line = br.readLine()) != null) {
        GraphicalSound sound = new GraphicalSound();

        sound.setName(line.substring(0, line.indexOf("1")).replaceAll("lineBreak", "\n"));

        File soundPath = new File(line.substring(line.indexOf("1") + 3, line.indexOf("2")));
        if (soundPath.toString().contains("local/")) {
            sound.setPath(new File(SoundboardMenu.mSbDir + "/" + boardName,
                    soundPath.toString().substring(6, soundPath.toString().length())));
        } else {
            sound.setPath(soundPath);
        }

        sound.setVolumeLeft(
                Float.valueOf(line.substring(line.indexOf("2") + 3, line.indexOf("3"))).floatValue());
        sound.setVolumeRight(
                Float.valueOf(line.substring(line.indexOf("3") + 3, line.indexOf("4"))).floatValue());
        sound.setNameFrameX(
                Float.valueOf(line.substring(line.indexOf("4") + 3, line.indexOf("5"))).floatValue());
        sound.setNameFrameY(
                Float.valueOf(line.substring(line.indexOf("5") + 3, line.indexOf("6"))).floatValue());
        sound.setHideImageOrText(Integer.valueOf(line.substring(line.indexOf("8") + 3, line.indexOf("9"))));

        File imagePath = new File(line.substring(line.indexOf("9") + 3, line.indexOf("10")));
        if (imagePath.toString().contains("local/")) {
            sound.setImagePath(new File(SoundboardMenu.mSbDir + "/" + boardName,
                    imagePath.toString().substring(6, imagePath.toString().length())));
        } else {
            sound.setImagePath(imagePath);
        }

        sound.setImageX(
                Float.valueOf(line.substring(line.indexOf("10") + 4, line.indexOf("11"))).floatValue());
        sound.setImageY(
                Float.valueOf(line.substring(line.indexOf("11") + 4, line.indexOf("12"))).floatValue());
        sound.setImageWidthHeight(null,
                Float.valueOf(line.substring(line.indexOf("12") + 4, line.indexOf("13"))).floatValue(),
                Float.valueOf(line.substring(line.indexOf("13") + 4, line.indexOf("14"))).floatValue());
        sound.setHideImageOrText(
                Integer.valueOf(line.substring(line.indexOf("14") + 4, line.indexOf("15"))));
        sound.setNameTextColorInt(
                Integer.valueOf(line.substring(line.indexOf("15") + 4, line.indexOf("16"))));
        sound.setNameFrameInnerColorInt(
                Integer.valueOf(line.substring(line.indexOf("16") + 4, line.indexOf("17"))));
        sound.setNameFrameBorderColorInt(
                Integer.valueOf(line.substring(line.indexOf("17") + 4, line.indexOf("18"))));
        sound.setShowNameFrameInnerPaint(
                Boolean.parseBoolean(line.substring(line.indexOf("18") + 4, line.indexOf("19"))));
        sound.setShowNameFrameBorderPaint(
                Boolean.parseBoolean(line.substring(line.indexOf("19") + 4, line.indexOf("20"))));
        sound.setLinkNameAndImage(
                Boolean.parseBoolean(line.substring(line.indexOf("20") + 4, line.indexOf("21"))));
        sound.setNameSize(Float.valueOf(line.substring(line.indexOf("21") + 4, line.indexOf("22"))));
        sound.setAutoArrangeColumn(
                Integer.valueOf(line.substring(line.indexOf("22") + 4, line.indexOf("23"))));
        sound.setAutoArrangeRow(
                Integer.valueOf(line.substring(line.indexOf("23") + 4, line.indexOf("24"))));

        File activeImagePath = new File(line.substring(line.indexOf("24") + 4, line.indexOf("25")));
        if (activeImagePath.toString().contains("local/")) {
            sound.setActiveImagePath(new File(SoundboardMenu.mSbDir + "/" + boardName,
                    activeImagePath.toString().substring(6, activeImagePath.toString().length())));
        } else {
            sound.setActiveImagePath(activeImagePath);
        }
        sound.setSecondClickAction(Integer.valueOf(line.substring(line.indexOf("25") + 4, line.length())));

        if (sound.getImagePath().getAbsolutePath().equals("/"))
            sound.setImagePath(null);
        if (sound.getActiveImagePath().getAbsolutePath().equals("/"))
            sound.setActiveImagePath(null);

        gsb.addSound(sound);
    }

    in.close();
    holder.getBoardList().add(gsb);

    return holder;
}

From source file:com.aol.advertising.qiao.util.ContextUtils.java

protected static Object stringToValueByType(String str, DataType type) {

    switch (type) {
    case STRING://from www  .  ja v a2 s  . co  m
        return str;
    case INTEGER:
        return Integer.parseInt(str);
    case CLZ_INTEGER:
        return Integer.valueOf(str);
    case SHORT:
        return Short.parseShort(str);
    case CLZ_SHORT:
        return Short.valueOf(str);
    case LONG:
        return Long.parseLong(str);
    case CLZ_LONG:
        return Long.valueOf(str);
    case FLOAT:
        return Float.parseFloat(str);
    case CLZ_FLOAT:
        return Float.valueOf(str);
    case DOUBLE:
        return Double.parseDouble(str);
    case CLZ_DOUBLE:
        return Double.valueOf(str);
    case BOOLEAN:
        return Boolean.parseBoolean(str);
    case CLZ_BOOLEAN:
        return Boolean.valueOf(str);
    default: // default to string
        return str;
    }

}

From source file:gov.nih.nci.caintegrator.web.action.query.form.ExpressionLevelCriterionWrapper.java

private TextFieldParameter createLessOrEqualParameter() {
    final String label = RangeTypeEnum.INSIDE_RANGE.equals(criterion.getRangeType())
            || RangeTypeEnum.OUTSIDE_RANGE.equals(criterion.getRangeType()) ? "And" : "Expression level <=";
    TextFieldParameter rangeParameter = new TextFieldParameter(getParameters().size(), getRow().getRowIndex(),
            criterion.getUpperLimit().toString());
    rangeParameter.setLabel(label);//from  w w w .j a  v a2s .  c  o m
    ValueHandler expressionHandler = new ValueHandlerAdapter() {

        @Override
        public boolean isValid(String value) {
            return NumberUtils.isNumber(value);
        }

        @Override
        public void validate(String formFieldName, String value, ValidationAware action) {
            if (!isValid(value)) {
                action.addActionError("Numeric value required for " + label);
            }
        }

        @Override
        public void valueChanged(String value) {
            criterion.setUpperLimit(Float.valueOf(value));
        }
    };
    rangeParameter.setValueHandler(expressionHandler);
    return rangeParameter;
}

From source file:gov.nih.nci.caintegrator.domain.analysis.GisticAllLesionsFileParser.java

private void loadGisticData(GisticGenomicRegionReporter regionReporter, String[] fields) {
    for (int i = REQUIRED_HEADERS.length; i < fields.length; i++) {
        if (!StringUtils.isBlank(fields[i])) {
            gisticData.get(sampleMap.get(i)).put(regionReporter, Float.valueOf(fields[i]));
        }//  ww  w  . j  av a  2 s. com
    }
}

From source file:com.netflix.hollow.jsonadapter.HollowJsonAdapterPrimaryKeyFinder.java

private void addObjectField(JsonParser parser, JsonToken token, HollowObjectSchema schema, String fieldName,
        StringBuilder currentFieldPath) throws IOException {
    if (token != JsonToken.FIELD_NAME) {
        int fieldPosition = schema.getPosition(fieldName);

        if (fieldPosition == -1) {
            skipObjectField(parser, token);
        } else {//from w ww . j  av  a  2  s .c om
            int parentFieldPathLength = currentFieldPath.length();
            if (parentFieldPathLength > 0)
                currentFieldPath.append(".");
            currentFieldPath.append(fieldName);
            Integer keyFieldPosition = keyFieldPathPositions.get(currentFieldPath.toString());

            switch (token) {
            case START_ARRAY:
                skipSubArray(parser);
                break;
            case START_OBJECT:
                String referencedType = schema.getReferencedType(fieldName);
                HollowSchema referencedSchema = hollowSchemas.get(referencedType);

                if (referencedSchema.getSchemaType() == SchemaType.OBJECT)
                    addObject(parser, (HollowObjectSchema) referencedSchema, currentFieldPath);
                else
                    skipObject(parser);

                break;
            case VALUE_FALSE:
            case VALUE_TRUE:
            case VALUE_NUMBER_INT:
            case VALUE_NUMBER_FLOAT:
            case VALUE_STRING:
                switch (schema.getFieldType(fieldPosition)) {
                case BOOLEAN:
                    if (keyFieldPosition != null)
                        keyElementArray[keyFieldPosition.intValue()] = Boolean
                                .valueOf(parser.getBooleanValue());
                    break;
                case INT:
                    if (keyFieldPosition != null)
                        keyElementArray[keyFieldPosition.intValue()] = Integer.valueOf(parser.getIntValue());
                    break;
                case LONG:
                    if (keyFieldPosition != null)
                        keyElementArray[keyFieldPosition.intValue()] = Long.valueOf(parser.getLongValue());
                    break;
                case DOUBLE:
                    if (keyFieldPosition != null)
                        keyElementArray[keyFieldPosition.intValue()] = Double.valueOf(parser.getDoubleValue());
                    break;
                case FLOAT:
                    if (keyFieldPosition != null)
                        keyElementArray[keyFieldPosition.intValue()] = Float.valueOf(parser.getFloatValue());
                    break;
                case STRING:
                    if (keyFieldPosition != null)
                        keyElementArray[keyFieldPosition.intValue()] = parser.getValueAsString();
                    break;
                case REFERENCE:
                    if (keyFieldPosition != null)
                        throw new IllegalStateException("Key elements must not be REFERENCE");
                    HollowObjectSchema subSchema = (HollowObjectSchema) hollowSchemas
                            .get(schema.getReferencedType(fieldPosition));
                    currentFieldPath.append(".").append(subSchema.getFieldName(0));
                    keyFieldPosition = keyFieldPathPositions.get(currentFieldPath.toString());
                    if (keyFieldPosition != null) {
                        switch (subSchema.getFieldType(0)) {
                        case BOOLEAN:
                            if (keyFieldPosition != null)
                                keyElementArray[keyFieldPosition.intValue()] = Boolean
                                        .valueOf(parser.getBooleanValue());
                            break;
                        case INT:
                            if (keyFieldPosition != null)
                                keyElementArray[keyFieldPosition.intValue()] = Integer
                                        .valueOf(parser.getIntValue());
                            break;
                        case LONG:
                            if (keyFieldPosition != null)
                                keyElementArray[keyFieldPosition.intValue()] = Long
                                        .valueOf(parser.getLongValue());
                            break;
                        case DOUBLE:
                            if (keyFieldPosition != null)
                                keyElementArray[keyFieldPosition.intValue()] = Double
                                        .valueOf(parser.getDoubleValue());
                            break;
                        case FLOAT:
                            if (keyFieldPosition != null)
                                keyElementArray[keyFieldPosition.intValue()] = Float
                                        .valueOf(parser.getFloatValue());
                            break;
                        case STRING:
                            if (keyFieldPosition != null)
                                keyElementArray[keyFieldPosition.intValue()] = parser.getValueAsString();
                            break;
                        case REFERENCE:
                            throw new IllegalStateException("Key elements must not be REFERENCE");
                        default:
                        }
                    }

                default:
                }
            case VALUE_NULL:
                break;
            default:
            }

            currentFieldPath.setLength(parentFieldPathLength);
        }
    }
}

From source file:com.yoncabt.abys.core.util.EBRConf.java

public Float getValue(String key, Float defaultValue) {
    String ret = getValueFromAll(key, defaultValue == null ? null : defaultValue.toString());
    return ret == null ? null : Float.valueOf(ret);
}

From source file:com.dream.messaging.engine.DataHandler.java

/**
 * Generate object property value, the message content is String.
 * /*from   ww w .j a  v a  2s .c  om*/
 * @param data the data
 * @param node the node
 * 
 * @return the object
 */
public Object createValue(String data, Node node) {

    String clsname = QueryNode.getAttribute(node, ElementAttr.Attr_Class);
    try {
        Class cls = null;
        Object value = null;
        if (clsname == null || clsname.equalsIgnoreCase(ElementClassType.CLASS_STRING)) {
            value = StringUtils.stripToEmpty(data);
        } else if (clsname.equalsIgnoreCase(ElementClassType.CLASS_INT)
                || clsname.equalsIgnoreCase(ElementClassType.CLASS_COUNTER)) {
            try {
                value = Integer.valueOf(data.trim());
            } catch (NumberFormatException e) {
                value = 0;
            }
        } else if (clsname.equalsIgnoreCase(ElementClassType.CLASS_LONG)) {
            try {
                value = Long.valueOf(data.trim());
            } catch (NumberFormatException e) {
                value = 0;
            }
        } else if (clsname.equalsIgnoreCase(ElementClassType.CLASS_DOUBLE)) {
            try {
                value = Float.valueOf(data.trim());
            } catch (NumberFormatException e) {
                value = Float.valueOf("0");
            }
        } else if (clsname.equalsIgnoreCase(ElementClassType.CLASS_FLOAT)) {
            try {
                value = Double.valueOf(data.trim());
            } catch (NumberFormatException e) {
                value = Double.valueOf("0");
            }
        } else if (clsname.equalsIgnoreCase(ElementClassType.CLASS_DECIMAL)) {
            try {
                value = new java.math.BigDecimal(data.trim());
            } catch (NumberFormatException e) {
                value = java.math.BigDecimal.ZERO;
            }
        } else if (clsname.equalsIgnoreCase(ElementClassType.CLASS_DATE)
                || clsname.equalsIgnoreCase(ElementClassType.CLASS_TIME)) {
            String format = QueryNode.getAttribute(node, ElementAttr.Attr_Format);
            SimpleDateFormat sdf = new SimpleDateFormat(format);
            try {
                value = sdf.parse(data);
            } catch (ParseException e) {
                value = data;
            }
        } else {
            cls = Class.forName(clsname);
            Constructor c = cls.getConstructor(String.class);
            value = c.newInstance(new Object[] { data });
        }
        return value;
    } catch (ClassNotFoundException e) {

        return null;
    } catch (IllegalArgumentException e) {

        return null;
    } catch (InstantiationException e) {

        return null;
    } catch (IllegalAccessException e) {

        return null;
    } catch (InvocationTargetException e) {

        return null;
    } catch (SecurityException e) {

        return null;
    } catch (NoSuchMethodException e) {

        return null;
    }
}

From source file:com.laxser.blitz.lama.core.UpdateOperation.java

private Object executeSignle(DataAccess dataAccess, Map<String, Object> parameters, Class<?> returnType) {

    if (returnGeneratedKeys) {
        return dataAccess.insertReturnId(sql, modifier, parameters);
    } else {/*from  ww w.  j a va2s .  c o  m*/

        //  UPDATE / DELETE 
        int updated = dataAccess.update(sql, modifier, parameters);

        if (returnType == void.class) {
            return null;
        }

        // ?
        if (returnType.isPrimitive()) {
            returnType = ClassUtils.primitiveToWrapper(returnType);
        }

        // ?
        if (returnType == Integer.class) {
            return Integer.valueOf(updated);
        } else if (returnType == Long.class) {
            return Long.valueOf(updated);
        } else if (returnType == Boolean.class) {
            return Boolean.valueOf(updated > 0);
        } else if (returnType == Long.class) {
            return Long.valueOf(updated);
        } else if (returnType == Double.class) {
            return Double.valueOf(updated);
        } else if (returnType == Float.class) {
            return Float.valueOf(updated);
        } else if (Number.class.isAssignableFrom(returnType)) {
            return updated;
        }
    }

    return null; // 
}

From source file:business.security.control.OwmClient.java

/**
 * Find current weather within a bounding box
 *
 * @param northLat is the latitude of the geographic top left point of the
 * bounding box/*from  ww w  . j  a  v a2 s.  c  o m*/
 * @param westLon is the longitude of the geographic top left point of the
 * bounding box
 * @param southLat is the latitude of the geographic bottom right point of
 * the bounding box
 * @param eastLon is the longitude of the geographic bottom right point of
 * the bounding box
 * @throws JSONException if the response from the OWM server can't be parsed
 * @throws IOException if there's some network error or the OWM server
 * replies with a error.
 */
public WeatherStatusResponse currentWeatherInBoundingBox(float northLat, float westLon, float southLat,
        float eastLon) throws IOException, JSONException { //, boolean cluster, OwmClient.Lang lang) {
    String subUrl = String.format(Locale.ROOT, "find/station?bbox=%f,%f,%f,%f&cluster=yes",
            Float.valueOf(northLat), Float.valueOf(westLon), Float.valueOf(southLat), Float.valueOf(eastLon));
    JSONObject response = doQuery(subUrl);
    return new WeatherStatusResponse(response);
}

From source file:aurelienribon.texturepackergui.Project.java

public static Settings loadSettings(String str) {
    Settings settings = new Settings();
    String[] lines = str.split("\n");
    Matcher m;/*w w  w .  j a  va2  s . c  o m*/

    for (String ln : lines) {
        m = Pattern.compile("alias=(true|false)").matcher(ln.trim());
        if (m.matches())
            settings.alias = Boolean.valueOf(m.group(1));
        m = Pattern.compile("alphaThreshold=(\\d+)").matcher(ln.trim());
        if (m.matches())
            settings.alphaThreshold = Integer.valueOf(m.group(1));
        m = Pattern.compile("debug=(true|false)").matcher(ln.trim());
        if (m.matches())
            settings.debug = Boolean.valueOf(m.group(1));
        m = Pattern.compile("defaultFileFormat=(.+)").matcher(ln.trim());
        if (m.matches())
            settings.defaultFileFormat = FileFormat.valueOf(m.group(1));
        m = Pattern.compile("defaultFilterMag=(.+)").matcher(ln.trim());
        if (m.matches())
            settings.defaultFilterMag = TextureFilter.valueOf(m.group(1));
        m = Pattern.compile("defaultFilterMin=(.+)").matcher(ln.trim());
        if (m.matches())
            settings.defaultFilterMin = TextureFilter.valueOf(m.group(1));
        m = Pattern.compile("defaultFormat=(.+)").matcher(ln.trim());
        if (m.matches())
            settings.defaultFormat = Format.valueOf(m.group(1));
        m = Pattern.compile("defaultImageQuality=(.+)").matcher(ln.trim());
        if (m.matches())
            settings.defaultImageQuality = Float.valueOf(m.group(1));
        m = Pattern.compile("duplicatePadding=(true|false)").matcher(ln.trim());
        if (m.matches())
            settings.duplicatePadding = Boolean.valueOf(m.group(1));
        m = Pattern.compile("edgePadding=(true|false)").matcher(ln.trim());
        if (m.matches())
            settings.edgePadding = Boolean.valueOf(m.group(1));
        m = Pattern.compile("ignoreBlankImages=(true|false)").matcher(ln.trim());
        if (m.matches())
            settings.ignoreBlankImages = Boolean.valueOf(m.group(1));
        m = Pattern.compile("incremental=(true|false)").matcher(ln.trim());
        if (m.matches())
            settings.incremental = Boolean.valueOf(m.group(1));
        m = Pattern.compile("incrementalFilePath=(.+)").matcher(ln.trim());
        if (m.matches())
            settings.incrementalFilePath = m.group(1).trim().equals("") ? null
                    : FilenameHelper.trim(m.group(1).trim());
        m = Pattern.compile("maxHeight=(\\d+)").matcher(ln.trim());
        if (m.matches())
            settings.maxHeight = Integer.valueOf(m.group(1));
        m = Pattern.compile("maxWidth=(\\d+)").matcher(ln.trim());
        if (m.matches())
            settings.maxWidth = Integer.valueOf(m.group(1));
        m = Pattern.compile("minHeight=(\\d+)").matcher(ln.trim());
        if (m.matches())
            settings.minHeight = Integer.valueOf(m.group(1));
        m = Pattern.compile("minWidth=(\\d+)").matcher(ln.trim());
        if (m.matches())
            settings.minWidth = Integer.valueOf(m.group(1));
        m = Pattern.compile("padding=(\\d+)").matcher(ln.trim());
        if (m.matches())
            settings.padding = Integer.valueOf(m.group(1));
        m = Pattern.compile("pot=(true|false)").matcher(ln.trim());
        if (m.matches())
            settings.pot = Boolean.valueOf(m.group(1));
        m = Pattern.compile("rotate=(true|false)").matcher(ln.trim());
        if (m.matches())
            settings.rotate = Boolean.valueOf(m.group(1));
        m = Pattern.compile("stripWhitespace=(true|false)").matcher(ln.trim());
        if (m.matches())
            settings.stripWhitespace = Boolean.valueOf(m.group(1));
    }

    return settings;
}