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:org.owasp.benchmark.testcode.BenchmarkTest01951.java

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    String param = "";
    if (request.getHeader("BenchmarkTest01951") != null) {
        param = request.getHeader("BenchmarkTest01951");
    }//w w w . j  a v a  2s  .  c o m

    // URL Decode the header value since req.getHeader() doesn't. Unlike req.getParameter().
    param = java.net.URLDecoder.decode(param, "UTF-8");

    String bar = doSomething(request, param);

    try {
        float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat();
        String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front.

        String user = "SafeFloyd";
        String fullClassName = this.getClass().getName();
        String testCaseNumber = fullClassName
                .substring(fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
        user += testCaseNumber;

        String cookieName = "rememberMe" + testCaseNumber;

        boolean foundUser = false;
        javax.servlet.http.Cookie[] cookies = request.getCookies();
        if (cookies != null) {
            for (int i = 0; !foundUser && i < cookies.length; i++) {
                javax.servlet.http.Cookie cookie = cookies[i];
                if (cookieName.equals(cookie.getName())) {
                    if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
                        foundUser = true;
                    }
                }
            }
        }

        if (foundUser) {
            response.getWriter().println("Welcome back: " + user + "<br/>");
        } else {
            javax.servlet.http.Cookie rememberMe = new javax.servlet.http.Cookie(cookieName, rememberMeKey);
            rememberMe.setSecure(true);
            //         rememberMe.setPath("/benchmark/" + this.getClass().getSimpleName());
            rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet 
            // e.g., /benchmark/sql-01/BenchmarkTest01001
            request.getSession().setAttribute(cookieName, rememberMeKey);
            response.addCookie(rememberMe);
            response.getWriter().println(user + " has been remembered with cookie: " + rememberMe.getName()
                    + " whose value is: " + rememberMe.getValue() + "<br/>");
        }
    } catch (java.security.NoSuchAlgorithmException e) {
        System.out.println("Problem executing SecureRandom.nextFloat() - TestCase");
        throw new ServletException(e);
    }
    response.getWriter().println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed");
}

From source file:blue.Marker.java

public Element saveAsXML() {
    Element retVal = new Element("marker");

    retVal.setAttribute("time", Float.toString(getTime()));
    retVal.setAttribute("name", getName());

    return retVal;
}

From source file:com.cloudera.oryx.rdf.common.rule.NumericPrediction.java

@Override
public String toString() {
    return Float.toString(prediction);
}

From source file:org.apereo.lap.controllers.ConfigController.java

/**
 * Selects the home page and populates the model with a message
 *//* w ww. j av a  2  s  .c o m*/
@RequestMapping(value = "/config", method = RequestMethod.GET)
public String index(Model viewModel) {

    Configuration configuration = getConfiguration();

    ConfigurationRequest model = new ConfigurationRequest();
    model.setSspBaseUrl(configuration.getSspBaseUrl());
    if (configuration.getSSPRiskConfidenceThreshold() != null) {
        model.setSspRiskConfidenceThreshold(Float.toString(configuration.getSSPRiskConfidenceThreshold()));
    }
    model.setSspActive(configuration.isSSPActive());
    ;

    viewModel.addAttribute("configuration", model);

    return "config";
}

From source file:javafxapplicationdemo.FXMLDocumentController.java

@FXML
private void handleButtonAction(ActionEvent event) throws IOException, MalformedURLException, JSONException {
    System.out.println("You clicked me!");

    OpenWeatherMap owm = new OpenWeatherMap("");

    owm.setApiKey("95b844c054292e842f1cb4fc3d5b4367");
    owm.setUnits(OpenWeatherMap.Units.METRIC);
    owm.setLang(OpenWeatherMap.Language.RUSSIAN);

    // getting current weather data for the "London" city
    CurrentWeather cwd = owm.currentWeatherByCityName("Saratov");

    city.setText(cwd.getCityName() + "," + cwd.getSysInstance().getCountryCode());

    JSONObject jsonObj = new JSONObject(cwd.getRawResponse());
    System.out.println(jsonObj);//from www.  ja va 2  s .c  o m

    JSONArray array = jsonObj.getJSONArray("weather");

    for (int i = 0; i < array.length(); i++) {
        System.out.println(array.getJSONObject(i).getString("description"));
        other_data1.setText(array.getJSONObject(i).getString("main") + ", "
                + array.getJSONObject(i).getString("description"));

        Image image = new Image(
                "http://openweathermap.org/img/w/" + array.getJSONObject(i).getString("icon") + ".png");
        img.setGraphic(new ImageView(image));

    }

    other_data.setText("Wind speed " + Float.toString(cwd.getWindInstance().getWindSpeed()) + " meter/sec"
            + " Clouds " + cwd.getCloudsInstance().getPercentageOfClouds() + "%" + " Pressure "
            + (int) cwd.getMainInstance().getPressure() / 1.333 + " mm of mercury column");
    current_temp.setText("Current Temp " + cwd.getMainInstance().getTemperature() + (char) 0x00B0 + "C");

}

From source file:org.owasp.benchmark.testcode.BenchmarkTest02001.java

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    String param = "";
    java.util.Enumeration<String> names = request.getHeaderNames();
    while (names.hasMoreElements()) {
        String name = (String) names.nextElement();

        if (org.owasp.benchmark.helpers.Utils.commonHeaders.contains(name)) {
            continue;
        }//  w  w w.j av a2  s  . c o  m

        java.util.Enumeration<String> values = request.getHeaders(name);
        if (values != null && values.hasMoreElements()) {
            param = name;
            break;
        }
    }
    // Note: We don't URL decode header names because people don't normally do that

    String bar = doSomething(request, param);

    float rand = new java.util.Random().nextFloat();
    String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front.

    String user = "Floyd";
    String fullClassName = this.getClass().getName();
    String testCaseNumber = fullClassName
            .substring(fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
    user += testCaseNumber;

    String cookieName = "rememberMe" + testCaseNumber;

    boolean foundUser = false;
    javax.servlet.http.Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (int i = 0; !foundUser && i < cookies.length; i++) {
            javax.servlet.http.Cookie cookie = cookies[i];
            if (cookieName.equals(cookie.getName())) {
                if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
                    foundUser = true;
                }
            }
        }
    }

    if (foundUser) {
        response.getWriter().println("Welcome back: " + user + "<br/>");
    } else {
        javax.servlet.http.Cookie rememberMe = new javax.servlet.http.Cookie(cookieName, rememberMeKey);
        rememberMe.setSecure(true);
        //         rememberMe.setPath("/benchmark/" + this.getClass().getSimpleName());
        rememberMe.setPath(request.getRequestURI()); // i.e., set path to JUST this servlet 
        // e.g., /benchmark/sql-01/BenchmarkTest01001
        request.getSession().setAttribute(cookieName, rememberMeKey);
        response.addCookie(rememberMe);
        response.getWriter().println(user + " has been remembered with cookie: " + rememberMe.getName()
                + " whose value is: " + rememberMe.getValue() + "<br/>");

    }

    response.getWriter().println("Weak Randomness Test java.util.Random.nextFloat() executed");
}

From source file:org.owasp.benchmark.testcode.BenchmarkTest01172.java

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html");

    String param = "";
    boolean flag = true;
    java.util.Enumeration<String> names = request.getHeaderNames();
    while (names.hasMoreElements() && flag) {
        String name = (String) names.nextElement();
        java.util.Enumeration<String> values = request.getHeaders(name);
        if (values != null) {
            while (values.hasMoreElements() && flag) {
                String value = (String) values.nextElement();
                if (value.equals("vector")) {
                    param = name;//w w w  .j  a v a2 s  . c om
                    flag = false;
                }
            }
        }
    }

    String bar = new Test().doSomething(param);

    try {
        float rand = java.security.SecureRandom.getInstance("SHA1PRNG").nextFloat();
        String rememberMeKey = Float.toString(rand).substring(2); // Trim off the 0. at the front.

        String user = "SafeFloyd";
        String fullClassName = this.getClass().getName();
        String testCaseNumber = fullClassName
                .substring(fullClassName.lastIndexOf('.') + 1 + "BenchmarkTest".length());
        user += testCaseNumber;

        String cookieName = "rememberMe" + testCaseNumber;

        boolean foundUser = false;
        javax.servlet.http.Cookie[] cookies = request.getCookies();
        for (int i = 0; cookies != null && ++i < cookies.length && !foundUser;) {
            javax.servlet.http.Cookie cookie = cookies[i];
            if (cookieName.equals(cookie.getName())) {
                if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
                    foundUser = true;
                }
            }
        }

        if (foundUser) {
            response.getWriter().println("Welcome back: " + user + "<br/>");
        } else {
            javax.servlet.http.Cookie rememberMe = new javax.servlet.http.Cookie(cookieName, rememberMeKey);
            rememberMe.setSecure(true);
            request.getSession().setAttribute(cookieName, rememberMeKey);
            response.addCookie(rememberMe);
            response.getWriter().println(user + " has been remembered with cookie: " + rememberMe.getName()
                    + " whose value is: " + rememberMe.getValue() + "<br/>");
        }

    } catch (java.security.NoSuchAlgorithmException e) {
        System.out.println("Problem executing SecureRandom.nextFloat() - TestCase");
        throw new ServletException(e);
    }
    response.getWriter().println("Weak Randomness Test java.security.SecureRandom.nextFloat() executed");
}

From source file:Main.java

public static Element createElement(Document document, String nsURI, String name, float value) {
    return createElement(document, nsURI, name, Float.toString(value));
}

From source file:com.jaeksoft.searchlib.request.BoostQuery.java

public void writeXmlConfig(XmlWriter writer) throws SAXException {
    writer.startElement(BOOSTQUERY_NODE, BOOSTQUERY_ATTR_BOOST, Float.toString(boost));
    if (query != null)
        writer.textNode(StringEscapeUtils.escapeXml(query));
    writer.endElement();//w  w w . j a  v a2  s  .  c  om
}

From source file:nz.org.winters.android.custompreference.FloatPreference.java

@Override
protected void onBindView(View view) {
    // TextView mSummaryView = (TextView) view.findViewById(android.R.id.summary);
    setSummary(Float.toString(getValue()));

    super.onBindView(view);

}