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 static String toString(float f) 

Source Link

Document

Returns a string representation of the float argument.

Usage

From source file:com.facebook.litho.ComponentsStethoManagerImpl.java

private static void storeFloat(StyleAccumulator accumulator, SimpleArrayMap<String, String> overrides,
        String key, float value) {
    if (overrides.containsKey(key)) {
        accumulator.store(key, overrides.get(key), false);
    } else {/*from ww  w.ja  va  2  s.  c o  m*/
        accumulator.store(key, Float.toString(value), false);
    }
}

From source file:i5.las2peer.services.analytics.AnalyticsClass.java

@GET
@Path("weight")
public HttpResponse getWeight(@QueryParam(name = "edge", defaultValue = "0") int edge) {

    dbm = new DatabaseManager();
    dbm.init(driverName, databaseServer, port, database, this.username, password, hostName);

    float weight = dbm.getWeight(edge);

    HttpResponse r = new HttpResponse(Float.toString(weight));
    r.setStatus(200);//from   www .  jav  a2 s  .  co  m
    return r;
}

From source file:net.kaczmarzyk.spring.data.jpa.domain.GreaterThanOrEqualTest.java

@Test
public void filtersByPrimitiveFloatValue() {
    assertFilterContainsOnlyExpectedMembers("weightFloat", HEAVIER_THAN_MOE_DOUBLE, homerSimpson);
    assertFilterContainsOnlyExpectedMembers("weightFloat", "65.0", moeSzyslak, homerSimpson);
    assertFilterContainsOnlyExpectedMembers("weightFloat", "65.09", moeSzyslak, homerSimpson);

    // float arithmetic bites us again! kludge to make this test pass:
    assertFilterContainsOnlyExpectedMembers("weightFloat",
            Float.toString(moeSzyslak.getWeightFloat() - 0.0001f), moeSzyslak, homerSimpson);

    //  float arithmetic bites us again! This test fails:
    //assertFilterMembers("weightFloat", Float.toString(moeSzyslak.getWeightFloat()), moeSzyslak, homerSimpson);
}

From source file:byps.BBufferJson.java

public void putFloat(float v) {
    putJsonValueAscii(null, Float.toString(v), STRING_WITHOUT_QUOTE);
}

From source file:net.kaczmarzyk.spring.data.jpa.domain.LessThanOrEqualTest.java

@Test
public void filtersByPrimitiveFloatValue() {
    assertFilterContainsOnlyExpectedMembers("weightFloat", String.valueOf(moeSzyslak.getWeightFloat()),
            margeSimpson, moeSzyslak, joeQuimby);
    assertFilterContainsOnlyExpectedMembers("weightFloat", Float.toString(margeSimpson.getWeightFloat()),
            margeSimpson, joeQuimby);//from w ww.j a va 2 s .  c o m
}

From source file:fredboat.audio.queue.MusicPersistenceHandler.java

public static void handlePreShutdown(int code) {
    File dir = new File("music_persistence");
    if (!dir.exists()) {
        boolean created = dir.mkdir();
        if (!created) {
            log.error("Failed to create music persistence directory");
            return;
        }/* www  . ja  v  a  2s.co  m*/
    }
    Map<Long, GuildPlayer> reg = PlayerRegistry.getRegistry();

    boolean isUpdate = code == ExitCodes.EXIT_CODE_UPDATE;
    boolean isRestart = code == ExitCodes.EXIT_CODE_RESTART;

    for (long gId : reg.keySet()) {
        try {
            GuildPlayer player = reg.get(gId);

            if (!player.isPlaying()) {
                continue;//Nothing to see here
            }

            String msg;

            if (isUpdate) {
                msg = I18n.get(player.getGuild()).getString("shutdownUpdating");
            } else if (isRestart) {
                msg = I18n.get(player.getGuild()).getString("shutdownRestarting");
            } else {
                msg = I18n.get(player.getGuild()).getString("shutdownIndef");
            }

            TextChannel activeTextChannel = player.getActiveTextChannel();
            if (activeTextChannel != null) {
                CentralMessaging.sendMessage(activeTextChannel, msg);
            }

            JSONObject data = new JSONObject();
            data.put("vc", player.getCurrentVoiceChannel().getId());
            data.put("tc", activeTextChannel != null ? activeTextChannel.getId() : "");
            data.put("isPaused", player.isPaused());
            data.put("volume", Float.toString(player.getVolume()));
            data.put("repeatMode", player.getRepeatMode());
            data.put("shuffle", player.isShuffle());

            if (player.getPlayingTrack() != null) {
                data.put("position", player.getPosition());
            }

            ArrayList<JSONObject> identifiers = new ArrayList<>();

            for (AudioTrackContext atc : player.getRemainingTracks()) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                AbstractPlayer.getPlayerManager().encodeTrack(new MessageOutput(baos), atc.getTrack());

                JSONObject ident = new JSONObject()
                        .put("message", Base64.encodeBase64String(baos.toByteArray()))
                        .put("user", atc.getUserId());

                if (atc instanceof SplitAudioTrackContext) {
                    JSONObject split = new JSONObject();
                    SplitAudioTrackContext c = (SplitAudioTrackContext) atc;
                    split.put("title", c.getEffectiveTitle()).put("startPos", c.getStartPosition())
                            .put("endPos", c.getStartPosition() + c.getEffectiveDuration());

                    ident.put("split", split);
                }

                identifiers.add(ident);
            }

            data.put("sources", identifiers);

            try {
                FileUtils.writeStringToFile(new File(dir, Long.toString(gId)), data.toString(),
                        Charset.forName("UTF-8"));
            } catch (IOException ex) {
                if (activeTextChannel != null) {
                    CentralMessaging.sendMessage(activeTextChannel, MessageFormat.format(
                            I18n.get(player.getGuild()).getString("shutdownPersistenceFail"), ex.getMessage()));
                }
            }
        } catch (Exception ex) {
            log.error("Error when saving persistence file", ex);
        }
    }
}

From source file:Main.java

public static void appendChild(Document document, Node root, String name, float value) {
    appendChild(document, root, name, Float.toString(value));
    return;//from www . j a va2s  .co  m
}

From source file:org.apache.ojb.broker.util.logging.LoggerWrapperPrintWriter.java

public void print(float v) {
    if (!filterEverything) {
        log(Float.toString(v));
    }
}

From source file:com.mgalgs.trackthatthing.LocationReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    mContext = context;//  www.  j  av  a 2  s .c om
    Location loc = (Location) intent.getExtras().get(LocationPoller.EXTRA_LOCATION);

    if (loc == null) {
        msg = intent.getStringExtra(LocationPoller.EXTRA_ERROR);
    } else {
        SharedPreferences settings = context.getSharedPreferences(TrackThatThing.PREFS_NAME,
                Context.MODE_PRIVATE);

        long sleep_period = settings.getLong(TrackThatThing.PREF_SLEEP_TIME, TrackThatThing.DEFAULT_SLEEP_TIME);
        if (getTimeSinceLastLoc_S() > sleep_period - 3 || mLastLocTime == -1) {
            // it has been long enough
        } else {
            // it hasn't been long enough!
            Log.d(TrackThatThing.TAG, "It has only been " + getTimeSinceLastLoc_S()
                    + " seconds since the last location update, not long enough!");
            return;
        }

        mLastLocTime = SystemClock.elapsedRealtime();

        float acc = loc.getAccuracy();
        double lat = loc.getLatitude();
        double lon = loc.getLongitude();
        float speed = loc.getSpeed();

        String secret_code = settings.getString(TrackThatThing.PREF_SECRET_CODE, null);

        QueryString qs = new QueryString(TrackThatThing.BASE_URL + "/put");
        qs.add("secret", secret_code);
        qs.add("lat", Double.toString(lat));
        qs.add("lon", Double.toString(lon));
        qs.add("acc", Float.toString(acc));
        qs.add("speed", Float.toString(speed));

        Runnable r = new MyInternetThread(qs);
        new Thread(r).start();

        msg = loc.toString();
    }

    Log.d(TrackThatThing.TAG, "got this location: " + msg);
}

From source file:com.hichinaschool.flashcards.libanki.sync.BasicHttpSyncer.java

public BasicHttpSyncer(String hkey, Connection con) {
    mHKey = hkey;
    mSKey = Utils.checksum(Float.toString(new Random().nextFloat())).substring(0, 8);
    mCon = con;
}