Example usage for java.lang Float toString

List of usage examples for java.lang Float toString

Introduction

In this page you can find the example usage for java.lang Float toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of this Float object.

Usage

From source file:com.stratio.cassandra.lucene.service.RowService.java

/**
 * Adds to the specified {@link Row} the specified Lucene score column.
 *
 * @param row       A {@link Row}./*ww w.jav  a2 s.  com*/
 * @param timestamp The score column timestamp.
 * @param scoreDoc  The score column value.
 * @return The {@link Row} with the score.
 */
protected Row addScoreColumn(Row row, long timestamp, ScoreDoc scoreDoc) {
    ColumnFamily cf = row.cf;
    CellName cellName = rowMapper.makeCellName(cf);
    Float score = Float.parseFloat(((FieldDoc) scoreDoc).fields[0].toString());
    ByteBuffer cellValue = UTF8Type.instance.decompose(score.toString());

    ColumnFamily dcf = ArrayBackedSortedColumns.factory.create(baseCfs.metadata);
    dcf.addColumn(cellName, cellValue, timestamp);
    dcf.addAll(row.cf);

    return new Row(row.key, dcf);
}

From source file:org.apache.axis2.databinding.utils.ConverterUtil.java

public static String convertToString(Float o) {
    return o.toString();
}

From source file:org.apache.solr.update.processor.AddSchemaFieldsUpdateProcessorFactoryTest.java

public void testSingleFieldRoundTrip() throws Exception {
    IndexSchema schema = h.getCore().getLatestSchema();
    final String fieldName = "newfield2";
    assertNull(schema.getFieldOrNull(fieldName));
    Float floatValue = -13258.992f;
    SolrInputDocument d = processAdd("add-fields", doc(f("id", "2"), f(fieldName, floatValue)));
    assertNotNull(d);/*from  ww w.ja v a2 s.com*/
    schema = h.getCore().getLatestSchema();
    assertNotNull(schema.getFieldOrNull(fieldName));
    assertEquals("tfloat", schema.getFieldType(fieldName).getTypeName());
    assertU(commit());
    assertQ(req("id:2"), "//arr[@name='" + fieldName + "']/float[.='" + floatValue.toString() + "']");
}

From source file:org.apache.pig.builtin.Utf8StorageConverter.java

@Override
public byte[] toBytes(Float f) throws IOException {
    return f.toString().getBytes();
}

From source file:org.f3.tools.framework.Reporter.java

private void printHeapReport() {
    HtmlWriter footprintReport = null;/*  w  w  w. j  a  v a  2  s .  c  o  m*/
    HtmlWriter dashboardFootprintReport = null;
    try {
        footprintReport = new HtmlWriter(FOOTPRINT_RESULT_FILE_NAME, detailsTable("Footprint in MBytes"));
        dashboardFootprintReport = new HtmlWriter("footprint-dashboard.html", dashboardTable("Footprint"));

        Set<String> kset = new TreeSet<String>(result.keySet());
        for (String x : kset) {
            Float currentToGoal = percentChangeHeap(goals, result, x);
            Float currentToLast = percentChangeHeap(last, result, x);
            footprintReport.writeToHtmlTable(nameAsHref(x), getHeapsizeValue(result12, x),
                    getHeapsizeValue(result13, x), getHeapsizeValue(goals, x), getHeapsizeValue(last, x),
                    getHeapsizeValue(result, x), currentToGoal.toString(), currentToLast.toString());

            // generate images and print to dashboard
            dashboardFootprintReport.writeToHtmlTable(nameAsHref(x),
                    generateImage(FOOTPRINT_RESULT_FILE_NAME, x + FOOTPRINT_GOAL_PLOT_FILE_NAME_TAIL,
                            currentToGoal),
                    generateImage(FOOTPRINT_RESULT_FILE_NAME, x + FOOTPRINT_LAST_PLOT_FILE_NAME_TAIL,
                            currentToLast));
        }
    } catch (IOException ioe) {
        Utils.logger.severe(ioe.toString());
    } finally {
        Utils.close(footprintReport);
        Utils.close(dashboardFootprintReport);
    }
}

From source file:com.mum.app.AutoSubmitPriceApp.java

public String BuildSubmitPriceXml(Map<String, Float> submitSkuMap) {
    XmlBuilder xmlBuilder = new XmlBuilder();
    xmlBuilder.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
    xmlBuilder.beginObject("AmazonEnvelope");
    xmlBuilder.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    xmlBuilder.writeAttribute("xsi:noNamespaceSchemaLocation", "amznenvelope.xsd");

    xmlBuilder.beginObject("Header");
    xmlBuilder.write("DocumentVersion", "1.01");
    xmlBuilder.write("MerchantIdentifier", AutoSubmitPriceConfig.sellerId);
    xmlBuilder.endObject("Header");

    xmlBuilder.write("MessageType", "Price");

    int msgid = 1;
    for (Entry<String, Float> entry : submitSkuMap.entrySet()) {
        xmlBuilder.beginObject("Message");
        xmlBuilder.write("MessageID", msgid);
        xmlBuilder.beginObject("Price");
        xmlBuilder.write("SKU", entry.getKey());
        xmlBuilder.beginObject("StandardPrice");
        xmlBuilder.writeAttribute("currency", "USD");
        //// w w w . j  a v  a2 s  . co  m
        BigDecimal b = new BigDecimal(entry.getValue());
        Float fvalue = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
        xmlBuilder.writeValue(fvalue.toString());

        xmlBuilder.endObject("StandardPrice");
        xmlBuilder.endObject("Price");
        xmlBuilder.endObject("Message");
        msgid++;
    }

    xmlBuilder.endObject("AmazonEnvelope");
    return xmlBuilder.toString();
}

From source file:org.apache.solr.update.processor.AddSchemaFieldsUpdateProcessorFactoryTest.java

public void testSingleFieldMixedFieldTypesRoundTrip() throws Exception {
    IndexSchema schema = h.getCore().getLatestSchema();
    final String fieldName = "newfield3";
    assertNull(schema.getFieldOrNull(fieldName));
    Float fieldValue1 = -13258.0f;
    Double fieldValue2 = 8.4828800808E10;
    SolrInputDocument d = processAdd("add-fields", doc(f("id", "3"), f(fieldName, fieldValue1, fieldValue2)));
    assertNotNull(d);/*  w w w  .j a v  a 2 s  .  c om*/
    schema = h.getCore().getLatestSchema();
    assertNotNull(schema.getFieldOrNull(fieldName));
    assertEquals("tdouble", schema.getFieldType(fieldName).getTypeName());
    assertU(commit());
    assertQ(req("id:3"), "//arr[@name='" + fieldName + "']/double[.='" + fieldValue1.toString() + "']",
            "//arr[@name='" + fieldName + "']/double[.='" + fieldValue2.toString() + "']");
}

From source file:org.opencastproject.sox.impl.SoxServiceImpl.java

/**
 * {@inheritDoc}// w ww.  j a va  2 s.  co  m
 *
 * @see org.opencastproject.sox.api.SoxService#normalize(Track, Float)
 */
@Override
public Job normalize(Track sourceAudioTrack, Float targetRmsLevDb) throws MediaPackageException, SoxException {
    try {
        return serviceRegistry.createJob(JOB_TYPE, Operation.Normalize.toString(),
                Arrays.asList(MediaPackageElementParser.getAsXml(sourceAudioTrack), targetRmsLevDb.toString()));
    } catch (ServiceRegistryException e) {
        throw new SoxException("Unable to create a job", e);
    }
}

From source file:org.openmeetings.app.data.flvrecord.converter.FlvRecorderConverter.java

public void stripAudioFromFLVs(FlvRecording flvRecording) {
    List<HashMap<String, String>> returnLog = new LinkedList<HashMap<String, String>>();
    List<String> listOfFullWaveFiles = new LinkedList<String>();
    String streamFolderName = getStreamFolderName(flvRecording);
    try {/*w  ww.j a va2  s  .  c o  m*/
        stripAudioFirstPass(flvRecording, returnLog, listOfFullWaveFiles, streamFolderName);

        // Merge Wave to Full Length
        String streamFolderGeneralName = getStreamFolderName();

        FlvRecordingMetaData flvRecordingMetaDataOfScreen = this.flvRecordingMetaDataDaoImpl
                .getFlvRecordingMetaDataScreenFlvByRecording(flvRecording.getFlvRecordingId());

        if (flvRecordingMetaDataOfScreen == null) {
            throw new Exception(
                    "flvRecordingMetaDataOfScreen is Null FlvRecordingId " + flvRecording.getFlvRecordingId());
        }

        if (flvRecordingMetaDataOfScreen.getStreamReaderThreadComplete() == null) {
            throw new Exception("StreamReaderThreadComplete Bit is NULL, error in recording");
        }

        if (!flvRecordingMetaDataOfScreen.getStreamReaderThreadComplete()) {

            log.debug("### meta ScreenStream not yet written to disk"
                    + flvRecordingMetaDataOfScreen.getFlvRecordingMetaDataId());
            boolean doStop = true;
            while (doStop) {

                log.debug("### Stream not yet written Thread Sleep - "
                        + flvRecordingMetaDataOfScreen.getFlvRecordingMetaDataId());

                Thread.sleep(100L);

                flvRecordingMetaDataOfScreen = flvRecordingMetaDataDaoImpl
                        .getFlvRecordingMetaDataById(flvRecordingMetaDataOfScreen.getFlvRecordingMetaDataId());

                if (flvRecordingMetaDataOfScreen.getStreamReaderThreadComplete()) {
                    log.debug("### Screen Stream now written Thread continue - ");
                    doStop = false;
                }
            }
        }

        String hashFileFullName = flvRecordingMetaDataOfScreen.getStreamName() + "_FINAL_WAVE.wav";
        String outputFullWav = streamFolderName + hashFileFullName;

        if (listOfFullWaveFiles.size() == 1) {

            outputFullWav = listOfFullWaveFiles.get(0);

            flvRecordingMetaDataOfScreen.setFullWavAudioData(hashFileFullName);

        } else if (listOfFullWaveFiles.size() > 0) {

            String[] argv_full_sox = mergeAudioToWaves(listOfFullWaveFiles, outputFullWav);

            log.debug("START mergeAudioToWaves ################# ");
            log.debug(argv_full_sox.toString());
            String iString = "";
            for (int i = 0; i < argv_full_sox.length; i++) {
                iString += argv_full_sox[i] + " ";
            }
            log.debug(iString);
            log.debug("END mergeAudioToWaves ################# ");

            flvRecordingMetaDataOfScreen.setFullWavAudioData(hashFileFullName);

            this.flvRecordingMetaDataDaoImpl.updateFlvRecordingMetaData(flvRecordingMetaDataOfScreen);

            returnLog.add(ProcessHelper.executeScript("mergeWave", argv_full_sox));
        } else {

            // create default Audio to merge it.
            // strip to content length
            String outputWav = streamFolderGeneralName + "one_second.wav";

            // Calculate delta at beginning
            Long deltaTimeMilliSeconds = flvRecording.getRecordEnd().getTime()
                    - flvRecording.getRecordStart().getTime();
            Float deltaPadding = (Float.parseFloat(deltaTimeMilliSeconds.toString()) / 1000) - 1;

            String[] argv_full_sox = new String[] { this.getPathToSoX(), outputWav, outputFullWav, "pad", "0",
                    deltaPadding.toString() };

            log.debug("START generateSampleAudio ################# ");
            String tString = "";
            for (int i = 0; i < argv_full_sox.length; i++) {
                tString += argv_full_sox[i] + " ";
            }
            log.debug(tString);
            log.debug("END generateSampleAudio ################# ");

            flvRecordingMetaDataOfScreen.setFullWavAudioData(hashFileFullName);

            this.flvRecordingMetaDataDaoImpl.updateFlvRecordingMetaData(flvRecordingMetaDataOfScreen);

            returnLog.add(ProcessHelper.executeScript("mergeWave", argv_full_sox));

        }

        // Merge Audio with Video / Calculate resulting FLV

        String inputScreenFullFlv = streamFolderName + flvRecordingMetaDataOfScreen.getStreamName() + ".flv";

        String hashFileFullNameFlv = "flvRecording_" + flvRecording.getFlvRecordingId() + ".flv";
        String outputFullFlv = streamFolderGeneralName + hashFileFullNameFlv;

        // ffmpeg -vcodec flv -qscale 9.5 -r 25 -ar 22050 -ab 32k -s 320x240
        // -i
        // 65318fb5c54b1bc1b1bca077b493a914_28_12_2009_23_38_17_FINAL_WAVE.wav
        // -i 65318fb5c54b1bc1b1bca077b493a914_28_12_2009_23_38_17.flv
        // final1.flv

        int flvWidth = flvRecording.getWidth();
        int flvHeight = flvRecording.getHeight();

        log.debug("flvWidth -1- " + flvWidth);
        log.debug("flvHeight -1- " + flvHeight);

        flvWidth = Double.valueOf((Math.floor(flvWidth / 16)) * 16).intValue();
        flvHeight = Double.valueOf((Math.floor(flvHeight / 16)) * 16).intValue();

        log.debug("flvWidth -2- " + flvWidth);
        log.debug("flvHeight -2- " + flvHeight);

        flvRecording.setFlvWidth(flvWidth);
        flvRecording.setFlvHeight(flvHeight);

        String[] argv_fullFLV = new String[] { this.getPathToFFMPEG(), //
                "-i", inputScreenFullFlv, "-i", outputFullWav, "-ar", "22050", //
                "-acodec", "libmp3lame", //
                "-ab", "32k", //
                "-s", flvWidth + "x" + flvHeight, //
                "-vcodec", "flashsv", //
                "-map", "0" + FFMPEG_MAP_PARAM + "0", //
                "-map", "1" + FFMPEG_MAP_PARAM + "0", //
                outputFullFlv };

        log.debug("START generateFullFLV ################# ");
        String tString = "";
        for (int i = 0; i < argv_fullFLV.length; i++) {
            tString += argv_fullFLV[i] + " ";
            // log.debug(" i " + i + " argv-i " + argv_fullFLV[i]);
        }
        log.debug(tString);
        log.debug("END generateFullFLV ################# ");

        returnLog.add(ProcessHelper.executeScript("generateFullFLV", argv_fullFLV));

        flvRecording.setFileHash(hashFileFullNameFlv);

        // Extract first Image for preview purpose
        // ffmpeg -i movie.flv -vcodec mjpeg -vframes 1 -an -f rawvideo -s
        // 320x240 movie.jpg

        String hashFileFullNameJPEG = "flvRecording_" + flvRecording.getFlvRecordingId() + ".jpg";
        String outPutJpeg = streamFolderGeneralName + hashFileFullNameJPEG;

        flvRecording.setPreviewImage(hashFileFullNameJPEG);

        String[] argv_previewFLV = new String[] { //
                this.getPathToFFMPEG(), //
                "-i", outputFullFlv, //
                "-vcodec", "mjpeg", //
                "-vframes", "1", "-an", //
                "-f", "rawvideo", //
                "-s", flvWidth + "x" + flvHeight, //
                outPutJpeg };

        log.debug("START previewFullFLV ################# ");
        log.debug(argv_previewFLV.toString());
        String kString = "";
        for (int i = 0; i < argv_previewFLV.length; i++) {
            kString += argv_previewFLV[i] + " ";
        }
        log.debug(kString);
        log.debug("END previewFullFLV ################# ");

        returnLog.add(ProcessHelper.executeScript("generateFullFLV", argv_previewFLV));

        String alternateDownloadName = "flvRecording_" + flvRecording.getFlvRecordingId() + ".avi";
        String alternateDownloadFullName = streamFolderGeneralName + alternateDownloadName;

        String[] argv_alternateDownload = new String[] { this.getPathToFFMPEG(), "-i", outputFullFlv, "-vcodec",
                "copy", alternateDownloadFullName };

        log.debug("START alternateDownLoad ################# ");
        log.debug(argv_previewFLV.toString());
        String sString = "";
        for (int i = 0; i < argv_alternateDownload.length; i++) {
            sString += argv_alternateDownload[i] + " ";
        }
        log.debug(sString);
        log.debug("END alternateDownLoad ################# ");

        returnLog.add(ProcessHelper.executeScript("alternateDownload", argv_alternateDownload));

        flvRecording.setAlternateDownload(alternateDownloadName);

        this.flvRecordingDaoImpl.updateFlvRecording(flvRecording);

        for (HashMap<String, String> returnMap : returnLog) {
            this.flvRecordingLogDaoImpl.addFLVRecordingLog("generateFFMPEG", flvRecording, returnMap);
        }

        // Delete Wave Files
        for (String fileName : listOfFullWaveFiles) {
            File audio = new File(fileName);
            if (audio.exists()) {
                audio.delete();
            }
        }

    } catch (Exception err) {
        log.error("[stripAudioFromFLVs]", err);
    }
}

From source file:org.openhab.binding.gpioremotecontrol.internal.GpioRemoteControlBinding.java

private void parseAndUpdateTemperature(String message) {
    //      logger.debug("GpioRemoteControl: parseAndUpdateTemperature.");
    Temperature tempConfig = gson.fromJson(message, Temperature.class);
    if (tempConfig.getDeviceId() != "") { //Was successfully parsed      
        //         logger.debug("GpioRemoteControl: receiveServerMessage: TemperatureConfig: {}, {}, {}", tempConfig.getDeviceId(), tempConfig.getTemperature(), getItemNameByTemperatureDeviceId(tempConfig.getDeviceId()));
        if (providers.iterator().next().getConfig(getItemNameByTemperatureDeviceId(
                tempConfig.getDeviceId())).configMode == ConfigMode.TEMPERATURE) {
            providers.iterator().next().getConfig(
                    getItemNameByTemperatureDeviceId(tempConfig.getDeviceId())).temperature = tempConfig;
            Float temperatureRaw = (float) (tempConfig.getTemperature());
            Float temperature = temperatureRaw / 1000; //Received value is like 22500 for 22,5C 
            //            logger.debug("GpioRemoteControl: parseAndUpdateTemperature: {}", temperature.toString());
            eventPublisher.postUpdate(getItemNameByTemperatureDeviceId(tempConfig.getDeviceId()),
                    DecimalType.valueOf(temperature.toString()));
        }//from www  . ja va2  s  .  c  om
    }
}