List of usage examples for java.lang Float valueOf
@HotSpotIntrinsicCandidate public static Float valueOf(float f)
From source file:business.security.control.OwmClient.java
/** * Find current weather within a circle//from ww w. ja va2 s . c o m * * @param lat is the latitude of the geographic center of the circle * (North/South coordinate) * @param lon is the longitude of the geographic center of the circle * (East/West coordinate) * @param radius is the radius of the circle (in kilometres) * @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 currentWeatherInCircle(float lat, float lon, float radius) throws IOException, JSONException { //, boolean cluster, OwmClient.Lang lang) { String subUrl = String.format(Locale.ROOT, "find/station?lat=%f&lon=%f&radius=%f&cluster=yes", Float.valueOf(lat), Float.valueOf(lon), Float.valueOf(radius)); JSONObject response = doQuery(subUrl); return new WeatherStatusResponse(response); }
From source file:com.autentia.wuija.web.JasperReportsServlet.java
/** * Load parameters of the report from the request * // w w w . j a v a2s . c om * @param report report * @param request HTTP request * @return map of parameters */ private Map<String, Object> loadParameters(JasperReport report, HttpServletRequest request) throws ServletException { final Map<String, Object> ret = new HashMap<String, Object>(); // Iterate report parameters for (JRParameter param : report.getParameters()) { // Get parameter value final String name = param.getName(); String stringValue = ""; List valueDatesource = null; if (name.equals("LIST_DATASOURCE")) { valueDatesource = (List) request.getSession().getAttribute(SESSION_PREFIX + name); } else { stringValue = (String) request.getSession().getAttribute(SESSION_PREFIX + name); } if (stringValue == null) { stringValue = request.getParameter(name); } // Get parameter type if (stringValue != null) { final Class<?> clazz = param.getValueClass(); Object value; if (clazz == Integer.class) { value = Integer.valueOf(stringValue); } else if (clazz == Long.class) { value = Long.valueOf(stringValue); } else if (clazz == Float.class) { value = Float.valueOf(stringValue); } else if (clazz == Double.class) { value = Double.valueOf(stringValue); } else if (clazz == Boolean.class) { value = Boolean.valueOf(stringValue); } else if (clazz == String.class) { value = stringValue; } else if (clazz == Date.class) { try { value = dateFormat.parse(stringValue); } catch (ParseException e) { throw new ServletException( "Cannot parse value of parameter " + name + " as date: " + stringValue, e); } } else if (clazz == List.class) { value = valueDatesource; } else { throw new ServletException( "Type " + clazz.getName() + " of report parameter " + name + " is not supported"); } ret.put(name, value); } } return ret; }
From source file:magma.agent.perception.impl.ServerMessageParser.java
/** * Parse a symbol tree node into a Hinge Joint Perceptor object * /*w w w . j av a2 s .c o m*/ * @param node Symbol tree node * @return Hinge Joint Perceptor object * @throws PerceptorConversionException */ private HingeJointPerceptor parseHingeJoint(SymbolNode node) throws PerceptorConversionException { try { if (!(node.getChild(1) instanceof SymbolNode) || !(node.getChild(2) instanceof SymbolNode)) throw new PerceptorConversionException("Malformed Message: " + node.toString()); /* Check content */ SymbolNode nameNode = (SymbolNode) node.getChild(1); SymbolNode rotationNode = (SymbolNode) node.getChild(2); if (!nameNode.getChild(0).content().equals("n")) throw new PerceptorConversionException("Malformed Message: " + node.toString() + ": name expected"); if (!rotationNode.getChild(0).content().equals("ax")) throw new PerceptorConversionException("Malformed Message: " + node.toString() + ": axis expected"); return new HingeJointPerceptor(nameNode.getChild(1).content(), Float.valueOf(rotationNode.getChild(1).content())); } catch (IndexOutOfBoundsException e) { throw new PerceptorConversionException("Malformed node: " + node.toString()); } }
From source file:cosm.DataIn.java
public float getValue(String dStream) { String currVal = null;//from www . j a v a 2 s . c o m float value = 0.0f; if (root.has("datastreams")) { JSONArray streams = root.getJSONArray("datastreams"); for (int i = 0; i < streams.length(); i++) { JSONObject row; try { row = streams.getJSONObject(i); if (row.getString("id").equals(dStream)) { currVal = row.getString("current_value"); value = Float.valueOf(currVal.trim()).floatValue(); } // else // value = 0.0f; } catch (JSONException e) { e.printStackTrace(); } } if (currVal == null) System.out.println("DATASTREAM DOES NOT EXIST"); return value; } else return 0.0f; }
From source file:HelloUniverse.java
public VirtualInputDevice(String[] args) { // default user-definable values printvalues = false;//from www .ja v a 2 s. c om xscreeninitloc = 400; yscreeninitloc = 0; xscreensize = 400; yscreensize = 200; xobjinitloc = 0.0f; yobjinitloc = 0.0f; zobjinitloc = 2.2f; xaxisrotinit = 0.0f; yaxisrotinit = 0.0f; zaxisrotinit = 0.0f; for (int i = 0; i < args.length; i += 2) { if (args[i] == null) break; else if (args[i] == "printvalues") printvalues = (Boolean.valueOf(args[i + 1])).booleanValue(); else if (args[i] == "xscreeninitloc") xscreeninitloc = (Integer.valueOf(args[i + 1])).intValue(); else if (args[i] == "yscreeninitloc") yscreeninitloc = (Integer.valueOf(args[i + 1])).intValue(); else if (args[i] == "xscreensize") xscreensize = (Integer.valueOf(args[i + 1])).intValue(); else if (args[i] == "yscreensize") yscreensize = (Integer.valueOf(args[i + 1])).intValue(); else if (args[i] == "xobjinitloc") xobjinitloc = (Float.valueOf(args[i + 1])).floatValue(); else if (args[i] == "yobjinitloc") yobjinitloc = (Float.valueOf(args[i + 1])).floatValue(); else if (args[i] == "zobjinitloc") zobjinitloc = (Integer.valueOf(args[i + 1])).floatValue(); } if (printvalues == true) { System.out.println("Initial values for VirtualInputDevice:"); System.out.println("xscreeninitloc = " + xscreeninitloc); System.out.println("yscreeninitloc = " + yscreeninitloc); System.out.println("xscreeninitsize = " + xscreensize); System.out.println("yscreeninitsize = " + yscreensize); System.out.println("xobjinitloc = " + xobjinitloc); System.out.println("yobjinitloc = " + yobjinitloc); System.out.println("zobjinitloc = " + zobjinitloc); System.out.println("xaxisrotinit = " + xaxisrotinit); System.out.println("yaxisrotinit = " + yaxisrotinit); System.out.println("zaxisrotinit = " + zaxisrotinit); } // initialize the InputDevice GUI Frame deviceFrame = new Frame(); deviceFrame.setSize(xscreensize, yscreensize); deviceFrame.setLocation(xscreeninitloc, yscreeninitloc); deviceFrame.setTitle("Virtual Input Device"); ButtonPositionControls positionControls; // initialize position with initial x, y, and z position positionControls = new ButtonPositionControls(xobjinitloc, yobjinitloc, zobjinitloc); WheelControls rotControls; // initialize rotations with initial angles in radians) rotControls = new WheelControls(xaxisrotinit, yaxisrotinit, zaxisrotinit); positionControls.setDevice(this); Panel devicePanel = new Panel(); devicePanel.setLayout(new BorderLayout()); devicePanel.add("East", positionControls); devicePanel.add("West", rotControls); deviceFrame.add(devicePanel); deviceFrame.pack(); deviceFrame.setVisible(true); initPos.set(xobjinitloc, yobjinitloc, zobjinitloc); this.positionControls = positionControls; this.rotControls = rotControls; // default processing mode processingMode = InputDevice.DEMAND_DRIVEN; sensors[0] = new Sensor(this); }
From source file:org.openspaces.rest.utils.ControllerUtils.java
public static Object convertPropertyToPrimitiveType(String object, Class type, String propKey) { if (type.equals(Long.class) || type.equals(Long.TYPE)) return Long.valueOf(object); if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) return Boolean.valueOf(object); if (type.equals(Integer.class) || type.equals(Integer.TYPE)) return Integer.valueOf(object); if (type.equals(Byte.class) || type.equals(Byte.TYPE)) return Byte.valueOf(object); if (type.equals(Short.class) || type.equals(Short.TYPE)) return Short.valueOf(object); if (type.equals(Float.class) || type.equals(Float.TYPE)) return Float.valueOf(object); if (type.equals(Double.class) || type.equals(Double.TYPE)) return Double.valueOf(object); if (type.isEnum()) return Enum.valueOf(type, object); if (type.equals(String.class) || type.equals(Object.class)) return String.valueOf(object); if (type.equals(java.util.Date.class)) { try {//from w w w.j a v a2 s. c om return simpleDateFormat.parse(object); } catch (ParseException e) { throw new RestException( "Unable to parse date [" + object + "]. Make sure it matches the format: " + date_format); } } //unknown type throw new UnsupportedTypeException("Non primitive type when converting property [" + propKey + "]:" + type); }
From source file:com.highcharts.export.controller.ExportController.java
private static Float widthToFloat(String width) { width = sanitize(width);//from ww w. j av a 2s . c om if (width != null) { Float parsedWidth = Float.valueOf(width); if (parsedWidth.compareTo(MAX_WIDTH) > 0) { return MAX_WIDTH; } if (parsedWidth.compareTo(0.0F) > 0) { return parsedWidth; } } return null; }
From source file:Main.java
/** * <p>Convert a <code>String</code> to a <code>Float</code>.</p> * /* www . j a v a 2 s .c o m*/ * @param val a <code>String</code> to convert * @return converted <code>Float</code> * @throws NumberFormatException if the value cannot be converted */ public static Float createFloat(String val) { return Float.valueOf(val); }
From source file:com.silverpeas.projectManager.model.TaskDetail.java
public void setRaf(String f) { if (f != null && f.length() > 0) { raf = Float.valueOf(f); } else { raf = 0; } }
From source file:com.ksmpartners.ernie.util.TestUtil.java
/** * Creates a standard hash of common test values for use with testing getters * and setters./*from w ww . j av a 2 s . c o m*/ */ private static void createTestValues() { testValues.put(Long.class, Long.valueOf(123L)); testValues.put(Integer.class, Integer.valueOf(456)); testValues.put(String.class, "FOOBAR"); testValues.put(Double.class, Double.valueOf(123.456)); testValues.put(Float.class, Float.valueOf(789.123f)); testValues.put(BigDecimal.class, BigDecimal.ZERO); testValues.put(Boolean.class, Boolean.TRUE); testValues.put(Byte.class, Mockito.anyByte()); testValues.put(Character.class, Mockito.anyChar()); testValues.put(Collection.class, Mockito.anyCollection()); testValues.put(List.class, Mockito.anyList()); testValues.put(Set.class, Mockito.anySet()); testValues.put(Map.class, Mockito.anyMap()); testValues.put(JobStatus.class, JobStatus.PENDING); testValues.put(ReportType.class, ReportType.PDF); }