List of usage examples for java.lang Float Float
@Deprecated(since = "9") public Float(String s) throws NumberFormatException
From source file:ca.phon.app.session.editor.view.media_player.PlayCustomSegmentDialog.java
private void updateSegmentTimes() { final MediaSegment segment = getSegment(); final String txt = MsFormatter.msToDisplayString(new Float(segment.getStartValue()).longValue()) + "-" + MsFormatter.msToDisplayString(new Float(segment.getEndValue()).longValue()); segmentField.setText(txt);// ww w. j a v a2 s . c om }
From source file:dsd.dao.CalculatedDataDAO.java
private static Object[][] PrepareMultipleValuesForInsert(List<CalculatedData> listOfData) { Object[][] valueArray = new Object[listOfData.size()][20]; for (int i = 0; i < listOfData.size(); i++) { valueArray[i][0] = new Float(listOfData.get(i).getWindSpeed()); valueArray[i][1] = new Float(listOfData.get(i).getWindDirection()); valueArray[i][2] = new Float(listOfData.get(i).getWindSpeedMax()); valueArray[i][3] = new Float(listOfData.get(i).getWindDirectionMax()); valueArray[i][4] = new Float(listOfData.get(i).getHydrometer()); valueArray[i][5] = new Float(listOfData.get(i).getHydrometerVariance()); valueArray[i][6] = new Float(listOfData.get(i).getSonar()); valueArray[i][7] = new Float(listOfData.get(i).getSonarVariance()); valueArray[i][8] = new Float(listOfData.get(i).getSonarPercCorrect()); valueArray[i][9] = new Float(listOfData.get(i).getSonarPercWrong()); valueArray[i][10] = new Float(listOfData.get(i).getSonarPercOutOfWater()); valueArray[i][11] = new Float(listOfData.get(i).getSonarPercError()); valueArray[i][12] = new Float(listOfData.get(i).getSonarPercUncertain()); valueArray[i][13] = new Float(listOfData.get(i).getSafetyFactor00()); valueArray[i][14] = new Float(listOfData.get(i).getSafetyFactor01()); valueArray[i][15] = new Float(listOfData.get(i).getSafetyFactor10()); valueArray[i][16] = new Float(listOfData.get(i).getSafetyFactor11()); valueArray[i][17] = new Float(listOfData.get(i).getWaterSpeed()); valueArray[i][18] = new Float(listOfData.get(i).getWaterFlowRate()); valueArray[i][19] = new Timestamp(listOfData.get(i).getTimestamp()); }//from w w w . j a va 2 s .c om return valueArray; }
From source file:dsd.dao.WorstCaseDAO.java
private static Object[][] PrepareMultipleValuesForUpdate(List<WorstPylonCase> listOfData) { Object[][] valueArray = new Object[listOfData.size()][11]; for (int i = 0; i < listOfData.size(); i++) { valueArray[i][0] = new Long(listOfData.get(i).getID()); valueArray[i][1] = new Integer(listOfData.get(i).getPylonNumber()); valueArray[i][2] = new Float(listOfData.get(i).getN()); valueArray[i][3] = new Float(listOfData.get(i).getTx()); valueArray[i][4] = new Float(listOfData.get(i).getTy()); valueArray[i][5] = new Float(listOfData.get(i).getMx()); valueArray[i][6] = new Float(listOfData.get(i).getMy()); valueArray[i][7] = new Float(listOfData.get(i).getM()); valueArray[i][8] = new Float(listOfData.get(i).getSafetyFactor()); valueArray[i][9] = new Integer(listOfData.get(i).getComboNumber()); valueArray[i][10] = new Timestamp(listOfData.get(i).getTimestamp()); }/*from www. j ava 2 s .co m*/ return valueArray; }
From source file:com.ms.commons.summer.web.util.json.JsonNumberMorpher.java
private Object morphToFloat(String str) { try {/* w w w. jav a 2 s . c o m*/ return new Float(str); } catch (Exception e) { throw new ConvertErrorException(str, this.type); } }
From source file:com.turn.shapeshifter.SchemaParser.java
/** * Reads the value of a JSON node and returns the corresponding Java object. * * @param jsonNode the node to convert to a Java object * @param field the protocol buffer field to which the resulting value will be assigned * @param registry a schema registry in which enclosed message fields are expected to * be defined/*w ww . j a va2s.c om*/ * @return a Java object representing the field's value * @throws ParsingException * @throws * @throws UnmappableValueException in case the JSON value node cannot be converted * to a Java object that could be assigned to {@code field} */ private Object parseValue(JsonNode jsonNode, FieldDescriptor field, ReadableSchemaRegistry registry) throws ParsingException { Object value = null; if (schema.getTransforms().containsKey(field.getName())) { return schema.getTransforms().get(field.getName()).parse(jsonNode); } switch (field.getType()) { case BOOL: JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_BOOLEAN_TOKENS); value = Boolean.valueOf(jsonNode.asBoolean()); break; case BYTES: break; case DOUBLE: value = new Double(jsonNode.asDouble()); break; case ENUM: JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_ENUM_TOKENS); String enumValue = schema.getEnumCaseFormat().to(NamedSchema.PROTO_ENUM_CASE_FORMAT, jsonNode.asText()); value = field.getEnumType().findValueByName(enumValue); break; case FLOAT: JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_FLOAT_TOKENS); value = new Float(jsonNode.asDouble()); break; case GROUP: break; case FIXED32: case INT32: case SFIXED32: case SINT32: case UINT32: JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_INTEGER_TOKENS); value = new Integer(jsonNode.asInt()); break; case FIXED64: case INT64: case SFIXED64: case SINT64: case UINT64: JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_INTEGER_TOKENS); value = new Long(jsonNode.asLong()); break; case MESSAGE: if (!jsonNode.isObject()) { throw new IllegalArgumentException( "Expected to parse object, found value of type " + jsonNode.asToken()); } Schema subSchema = null; if (schema.getSubObjectsSchemas().containsKey(field.getName())) { String schemaName = schema.getSubObjectsSchemas().get(field.getName()); if (registry.contains(schemaName)) { subSchema = registry.get(schemaName); } else { throw new IllegalStateException(); } } else { try { subSchema = registry.get(field.getMessageType()); } catch (SchemaObtentionException soe) { throw new ParsingException(soe); } } value = subSchema.getParser().parse(jsonNode, registry); break; case STRING: JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_STRING_TOKENS); value = jsonNode.asText(); break; default: break; } return value; }
From source file:au.org.ala.delta.translation.dist.DistItemsFileWriter.java
protected void writeCharacterWeights() { List<Float> weights = new ArrayList<Float>(); Iterator<IdentificationKeyCharacter> keyChars = _dataSet.unfilteredIdentificationKeyCharacterIterator(); while (keyChars.hasNext()) { IdentificationKeyCharacter keyChar = keyChars.next(); weights.add(new Float(_context.getCharacterWeight(keyChar.getCharacterNumber()))); }//from w w w.j ava 2 s .c o m _itemsFile.writeCharacterWeights(weights); }
From source file:org.infoglue.deliver.util.charts.TimeSeriesDiagram.java
/** * Creates a dataset, consisting of two series of monthly data. * * @return the dataset./*from w w w . j a v a2 s .com*/ */ private XYDataset createDataset() throws Exception { TimeSeriesCollection timeSeriesDataset = new TimeSeriesCollection(); Document document = new DOMBuilder().getDocument(this.xmlData); this.writeDebug(document); Element headerElement = (Element) document.selectSingleNode("//chartHeader"); this.header = headerElement.getText(); Element axisYHeaderElement = (Element) document.selectSingleNode("//axisYHeader"); this.axisYHeader = axisYHeaderElement.getText(); Element axisXHeaderElement = (Element) document.selectSingleNode("//axisXHeader"); this.axisXHeader = axisXHeaderElement.getText(); Element timeGranularityElement = (Element) document.selectSingleNode("//timeGranularity"); this.timeGranulariry = timeGranularityElement.getText(); Element dateFormatElement = (Element) document.selectSingleNode("//dateFormat"); this.dateFormat = dateFormatElement.getText(); List series = document.selectNodes("//Series"); Iterator seriesIterator = series.iterator(); while (seriesIterator.hasNext()) { Element serieElement = (Element) seriesIterator.next(); String serieName = serieElement.attributeValue("name"); TimeSeries s1 = null; if (this.timeGranulariry.equalsIgnoreCase("Month")) s1 = new TimeSeries(serieName, Month.class); else if (this.timeGranulariry.equalsIgnoreCase("Week")) s1 = new TimeSeries(serieName, Week.class); List items = serieElement.selectNodes("Item"); Iterator itemsIterator = items.iterator(); while (itemsIterator.hasNext()) { Element itemElement = (Element) itemsIterator.next(); Element yearElement = (Element) itemElement.selectSingleNode("yearId"); Element timeElement = (Element) itemElement.selectSingleNode("timeId"); Element valueElement = (Element) itemElement.selectSingleNode("value"); String year = yearElement.getText(); String time = timeElement.getText(); String value = valueElement.getText(); if (this.timeGranulariry.equalsIgnoreCase("Month")) s1.add(new Month(new Integer(time).intValue(), new Integer(year).intValue()), new Float(value)); else if (this.timeGranulariry.equalsIgnoreCase("Week")) s1.add(new Week(new Integer(time).intValue(), new Integer(year).intValue()), new Float(value)); } timeSeriesDataset.addSeries(s1); //timeSeriesDataset.addSeries(s2); timeSeriesDataset.setDomainIsPointsInTime(true); } return timeSeriesDataset; }
From source file:com.searchbox.collection.oppfin.CordisCollection.java
public ItemProcessor<JSONObject, FieldMap> itemProcessor() { return new ItemProcessor<JSONObject, FieldMap>() { @Override/* ww w . ja v a 2 s . c o m*/ public FieldMap process(JSONObject item) throws IOException { DateFormat dfSource = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy", Locale.ENGLISH); LOGGER.info("Processing cordis {}", item.get("id")); FieldMap doc = new FieldMap(); doc.put("docSource", "Cordis"); doc.put("docType", "Cordis"); doc.put("programme", item.get("program")); doc.put("cordisId", item.get("id")); doc.put("cordisTag", item.get("tag")); doc.put("cordisStartYear", item.get("start_year")); doc.put("cordisProjectFunding", new Float((String) item.get("projectfunding"))); doc.put("cordisContractType", item.get("contract_type")); doc.put("cordisProjectStatus", item.get("project_status")); doc.put("cordisUrl", item.get("url")); doc.put("cordisCategory", item.get("category")); doc.put("cordisProgram", item.get("program")); doc.put("cordisProjectCost", new Float((String) item.get("projectcost"))); doc.put("cordisProjectDuration", item.get("projectduration")); doc.put("cordisSnippet", item.get("snippet")); doc.put("cordisSubProgrammArea", item.get("subprogrammearea")); doc.put("cordisCallIdentifier", item.get("call_identifier")); doc.put("cordisTitle", item.get("title")); doc.put("cordisCountryCode", item.get("country_code")); doc.put("cordisArea", item.get("aera")); doc.put("cordisSubjectIndexCode", item.get("subjectindexcode")); doc.put("cordisProjectTeaser", item.get("teaser")); doc.put("cordisCallTitle", item.get("cordisCallTitle")); try { doc.put("cordisProjectStartDate", item.get("projectstartdate")); } catch (Exception e) { LOGGER.error("Cannot parse date", e); } try { doc.put("cordisProjectEndDate", item.get("projectenddate")); } catch (Exception e) { LOGGER.error("Cannot parse date", e); } return doc; } }; }
From source file:nz.co.senanque.validationengine.ConvertUtils.java
public static Object getObjectForNull(Class<?> clazz) { if (clazz.equals(Long.TYPE)) { return new Long(0); } else if (clazz.equals(Integer.TYPE)) { return new Integer(0); } else if (clazz.equals(Float.TYPE)) { return new Float(0.0F); } else if (clazz.equals(Double.TYPE)) { return new Double(0.0D); } else if (clazz.equals(Boolean.TYPE)) { return new Boolean(false); }//from w ww . jav a 2s . c om return null; }
From source file:Coordinate.java
/** * A method to add distance in a northerly direction to a coordinate * * @param latitude a latitude coordinate in decimal notation * @param longitude a longitude coordinate in decimal notation * @param distance the distance to add in metres * * @return the new coordinate/*from w w w . j a v a2 s . c om*/ */ public static Coordinate addDistanceNorth(float latitude, float longitude, int distance) { // check on the parameters if (isValidLatitude(latitude) == false || isValidLongitude(longitude) == false || distance <= 0) { throw new IllegalArgumentException("All parameters are required and must be valid"); } // convert the distance from metres to kilometers float kilometers = distance / new Float(1000); // calculate the new latitude double newLat = latitude + (kilometers / latitudeConstant()); return new Coordinate(new Float(newLat).floatValue(), longitude); }