/** * <p>Convert a <code>String</code> to a <code>float</code>, returning * <code>0.0f</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0f</code> is returned.</p> * * <pre> * NumberUtils.toFloat(null) = 0.0f * NumberUtils.toFloat("") = 0.0f * NumberUtils.toFloat("1.5") = 1.5f * </pre> * * @param str the string to convert, may be <code>null</code> * @return the float represented by the string, or <code>0.0f</code> * if conversion fails * @since 2.1 */ public static float toFloat(String str) { return toFloat(str, 0.0f); }
public static float getFloat( Object obj ) { if ( obj instanceof Float ) { return ( Float ) obj; } if ( obj instanceof Number ) { return ( ( Number ) obj ).floatValue(); } if ( obj instanceof String ) { return NumberUtils.toFloat( ( String ) obj ); } if ( obj instanceof Date ) { return ( ( Date ) obj ).getTime(); } if ( obj instanceof byte[] ) { return getFloat( ( byte[] ) obj ); } if ( obj instanceof ByteBuffer ) { return getFloat( ( ByteBuffer ) obj ); } return 0; }
public static float getFloat( Object obj ) { if ( obj instanceof Float ) { return ( Float ) obj; } if ( obj instanceof Number ) { return ( ( Number ) obj ).floatValue(); } if ( obj instanceof String ) { return NumberUtils.toFloat( ( String ) obj ); } if ( obj instanceof Date ) { return ( ( Date ) obj ).getTime(); } if ( obj instanceof byte[] ) { return getFloat( ( byte[] ) obj ); } if ( obj instanceof ByteBuffer ) { return getFloat( ( ByteBuffer ) obj ); } return 0; }
public static float parseFloat(String s, float defaultValue) { return NumberUtils.toFloat(s, defaultValue); }
/** * Get the parameter passed by controller. When it's executed in the * validation mode, always returns the given default value 0. * * @return param. 0 if the param was not provided. * @since 3.2.3 */ public static float getParamFloat() { return NumberUtils.toFloat(getParam("0"), 0f); }
public static float parseFloat(final String s, final float defaultValue) { return NumberUtils.toFloat(s, defaultValue); }
/** * <p>Convert a <code>String</code> to a <code>float</code>, returning * <code>0.0f</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0f</code> is returned.</p> * * <pre> * NumberUtils.toFloat(null) = 0.0f * NumberUtils.toFloat("") = 0.0f * NumberUtils.toFloat("1.5") = 1.5f * </pre> * * @param str the string to convert, may be <code>null</code> * @return the float represented by the string, or <code>0.0f</code> * if conversion fails * @since 2.1 */ public static float toFloat(String str) { return toFloat(str, 0.0f); }
/** * <p>Convert a <code>String</code> to a <code>float</code>, returning * <code>0.0f</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0f</code> is returned.</p> * * <pre> * NumberUtils.toFloat(null) = 0.0f * NumberUtils.toFloat("") = 0.0f * NumberUtils.toFloat("1.5") = 1.5f * </pre> * * @param str the string to convert, may be <code>null</code> * @return the float represented by the string, or <code>0.0f</code> * if conversion fails * @since 2.1 */ public static float toFloat(String str) { return toFloat(str, 0.0f); }
/** * <p>Convert a <code>String</code> to a <code>float</code>, returning * <code>0.0f</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0f</code> is returned.</p> * * <pre> * NumberUtils.toFloat(null) = 0.0f * NumberUtils.toFloat("") = 0.0f * NumberUtils.toFloat("1.5") = 1.5f * </pre> * * @param str the string to convert, may be <code>null</code> * @return the float represented by the string, or <code>0.0f</code> * if conversion fails * @since 2.1 */ public static float toFloat(String str) { return toFloat(str, 0.0f); }
/** * <p>Convert a <code>String</code> to a <code>float</code>, returning * <code>0.0f</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0f</code> is returned.</p> * * <pre> * NumberUtils.toFloat(null) = 0.0f * NumberUtils.toFloat("") = 0.0f * NumberUtils.toFloat("1.5") = 1.5f * </pre> * * @param str the string to convert, may be <code>null</code> * @return the float represented by the string, or <code>0.0f</code> * if conversion fails * @since 2.1 */ public static float toFloat(String str) { return toFloat(str, 0.0f); }
/** * <p>Convert a <code>String</code> to a <code>float</code>, returning * <code>0.0f</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0f</code> is returned.</p> * * <pre> * NumberUtils.toFloat(null) = 0.0f * NumberUtils.toFloat("") = 0.0f * NumberUtils.toFloat("1.5") = 1.5f * </pre> * * @param str the string to convert, may be <code>null</code> * @return the float represented by the string, or <code>0.0f</code> * if conversion fails * @since 2.1 */ public static float toFloat(String str) { return toFloat(str, 0.0f); }
/** * Carves up a media range and returns a ParseResults. * * For example, the media range 'application/*;q=0.5' would get parsed into: * * ('application', '*', {'q', '0.5'}) * * In addition this function also guarantees that there is a value for 'q' * in the params dictionary, filling it in with a proper default if * necessary. */ protected static ParseResults parseMediaRange(String range) { ParseResults results = parseMimeType(range); String q = results.params.get("q"); float f = NumberUtils.toFloat(q, 1); if (StringUtils.isBlank(q) || f < 0 || f > 1) results.params.put("q", "1"); return results; }
/** * Parses a string like 'application/*;q=0.5' into a typed object. */ protected Atom(String range) { String[] parts = StringUtils.split(range, ";"); for (int i = 1; i < parts.length; ++i) { String p = parts[i]; String[] subParts = StringUtils.split(p, '='); if (subParts.length == 2) params.put(subParts[0].trim(), subParts[1].trim()); } String fullType = parts[0].trim(); // Java URLConnection class sends an Accept header that includes a // single "*" - Turn it into a legal wildcard. if (fullType.equals("*")) fullType = "*/*"; String[] types = StringUtils.split(fullType, "/"); major = types[0].trim(); minor = types[1].trim(); float q = NumberUtils.toFloat(params.get("q"), 1); if (q < 0 || q > 1) q = 1; this.q = q; params.remove("q"); // normalize this away as this gets in the fitting }
/** * Carves up a media range and returns a ParseResults. * * For example, the media range 'application/*;q=0.5' would get parsed into: * * ('application', '*', {'q', '0.5'}) * * In addition this function also guarantees that there is a value for 'q' * in the params dictionary, filling it in with a proper default if * necessary. * * @param range */ protected static ParseResults parseMediaRange(String range) { ParseResults results = parseMimeType(range); String q = results.params.get("q"); float f = NumberUtils.toFloat(q, 1); if (StringUtils.isBlank(q) || f < 0 || f > 1) results.params.put("q", "1"); return results; }
/** * Parses a string like 'application/*;q=0.5' into a typed object. */ protected Atom(String range) { String[] parts = StringUtils.split(range, ";"); for (int i = 1; i < parts.length; ++i) { String p = parts[i]; String[] subParts = StringUtils.split(p, '='); if (subParts.length == 2) params.put(subParts[0].trim(), subParts[1].trim()); } String fullType = parts[0].trim(); // Java URLConnection class sends an Accept header that includes a // single "*" - Turn it into a legal wildcard. if (fullType.equals("*")) fullType = "*/*"; String[] types = StringUtils.split(fullType, "/"); major = types[0].trim(); minor = types[1].trim(); float q = NumberUtils.toFloat(params.get("q"), 1); if (q < 0 || q > 1) q = 1; this.q = q; params.remove("q"); // normalize this away as this gets in the fitting }
.toFloat(range.params.get("q"), 0);
.toFloat(range.params.get("q"), 0);
tmp.put("y", Lists.newArrayList()); for (int i = 0; i < y.size(); i++) { if (!step.containsKey(key) || y.get(i) > NumberUtils.toFloat(String.valueOf(step.get(key)), 0f)) { tmp.get("x").add(x.get(i)); tmp.get("y").add(y.get(i));