Example usage for java.lang Float Float

List of usage examples for java.lang Float Float

Introduction

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

Prototype

@Deprecated(since = "9")
public Float(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Float object that represents the floating-point value of type float represented by the string.

Usage

From source file:org.hdiv.web.servlet.tags.form.InputTagTests.java

protected TestBean createTestBean() {
    // set up test data
    this.rob = new TestBean();
    this.rob.setName("Rob");
    this.rob.setMyFloat(new Float(12.34));

    TestBean sally = new TestBean();
    sally.setName("Sally");
    this.rob.setSpouse(sally);

    return this.rob;
}

From source file:Logica.Usuario.java

/**
 *
 * @return ArrayList//w w  w. j a  v a  2  s .  c o m
 * @throws RemoteException
 *
 * Devuelve un listado con los ltimos tems que han sido ingresados.
 */
@Override
public ArrayList<ItemInventario> ultimos() throws RemoteException {
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    String numero;
    String lab;
    String descripcion;
    String presentacion;
    float cantidad;
    float precio;
    String cCalidad;
    String cEsp;
    String sucursal;
    ItemInventario in;
    ArrayList<ItemInventario> lista = new ArrayList<>();
    try {
        con = Conexion.conexion.getConnection();
        String statement = "(select * from item where cinterno like '%MMC%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%MT%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%AS%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%B%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%ER%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%I%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%MT%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%MV%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%N%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%PL%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%T%' order by CINTERNO desc limit 1)\n"
                + "union\n" + "(select * from item where cinterno like '%V%' order by CINTERNO desc limit 1)";
        ps = con.prepareStatement(statement);
        rs = ps.executeQuery();
        while (rs.next()) {
            numero = rs.getString("CINTERNO");
            lab = rs.getString("INVENTARIO");
            descripcion = rs.getString("DESCRIPCION");
            presentacion = rs.getString("PRESENTACION");
            cantidad = rs.getFloat("CANTIDAD");
            precio = rs.getFloat("PRECIO");
            cCalidad = rs.getString("CCALIDAD");
            cEsp = rs.getString("CESP");
            in = new ItemInventario(numero, lab, descripcion, presentacion, cantidad, precio, cCalidad, cEsp,
                    "", new Float(0));
            lista.add(in);
        }
    } catch (SQLException ex) {
        System.out.println("Error en la funcin \"CVer ltimos\"");
    } finally {

        try {
            if (ps != null) {
                ps.close();
            }
            if (rs != null) {
                rs.close();
            }
            if (con != null) {
                con.close();
            }
        } catch (SQLException ex) {
            System.out.println("Error cerrando la conexin");
        }
    }

    return lista;

}

From source file:com.feilong.commons.core.lang.ObjectUtil.java

/**
 * object to float.//from www .  ja  va2s. c o m
 * 
 * @param value
 *            the value
 * @return the float
 */
public static final Float toFloat(Object value) {
    if (Validator.isNotNullOrEmpty(value)) {
        if (value instanceof Float) {
            return (Float) value;
        }
        return new Float(value.toString());
    }
    return null;
}

From source file:gov.nih.nci.ncicb.cadsr.common.persistence.dao.jdbc.JDBCFormDAO.java

public static void main(String[] args) {
    ServiceLocator locator = new SimpleServiceLocator();

    JDBCFormDAO formTest = new JDBCFormDAO(locator);
    //public String createNewFormVersion(String formIdSeq, Float newVersionNumber, String changeNote, String createdBy) throws DMLException {
    formTest.createNewFormVersion("0870F3C9-8AC2-25FC-E044-0003BA0B1A09", new Float(18), "version 14",
            "SBREXT");
    System.out.println("jereera ");

    /*//from   w  w w . j  ava2 s  . c  om
    FormTransferObject newForm = new FormTransferObject();
            
    newForm.setLongName("CHRIS TEST 1");
    newForm.setPreferredName(formTest.generatePreferredName(newForm.getLongName()));
    //     newForm.setFormIdseq();
            
    newForm.setPreferredDefinition("This is a test Definition");
            
    ContextTransferObject newContext = new ContextTransferObject(null);
    newContext.setConteIdseq("99BA9DC8-2095-4E69-E034-080020C9C0E0");
    newForm.setContext(newContext);
            
    ProtocolTransferObject newProtocol = new ProtocolTransferObject(null);
    newProtocol.setProtoIdseq("9DC06830-EB45-2E3C-E034-080020C9C0E0");
    newForm.setProtocol(newProtocol);
            
    newForm.setFormCategory("Comments");
    newForm.setFormType("CRF");
            
    newForm.setAslName("DRAFT NEW");
            
    newForm.setVersion(new Float(1.0));
            
    //     newForm.setPreferredName(newForm.getLongName());
    newForm.setCreatedBy("Anonymous");
            
    try {
       formTest.copyForm("9DC06CFF-6DF7-2B36-E034-080020C9C0E0",  newForm);
    } catch (DMLException e){
       System.out.println("Failed: " + e);
    }
    */

    //     //String formId1 = "9E343E83-5FEB-119F-E034-080020C9C0E0";  //CRF
    //     String formId1 = "99CD59C5-A98A-3FA4-E034-080020C9C0E0"; // TEMPLATE

    //     try {
    //       System.out.println(formTest.findFormByPrimaryKey(formId1));
    //     }
    //     catch (DMLException e) {
    //       System.out.println("Failed to get a form for " + formId1);
    //     }

    //     try {
    //       Form form1 =
    //         formTest.findFormByPrimaryKey("D3830147-13E8-11BF-E034-0003BA0B1A09");
    //       Form form2 =
    //         formTest.findFormByPrimaryKey("D3830147-13E8-11BF-E034-0003BA0B1A09");
    //       form2.setPreferredName("testcopyprna1456");
    //       form2.setLongName("my form test 456123");
    //       form2.setAslName("DRAFT MOD");
    //       form2.setConteIdseq("29A8FB18-0AB1-11D6-A42F-0010A4C1E842");
    //       System.out.println(form2.getProtocol().getProtoIdseq() + "Conte_idseq");

    //       //System.out.println(formTest.copyForm(form1, form2).getFormIdseq());
    //     }

    //     catch (DMLException e) {
    //       System.out.println("Failed to find Form");
    //     }

    //formLongName, protocolIdSeq, contextIdSeq, workflow, categoryName,
    // type, classificationIdseq

    /*
       System.out.println(formTest.getAllForms(
         "", "", "99BA9DC8-2095-4E69-E034-080020C9C0E0", "", "", "",
         "99BA9DC8-A622-4E69-E034-080020C9C0E0"));
       System.out.println(formTest.getAllForms(
         "", "", "99BA9DC8-2095-4E69-E034-080020C9C0E0", "", "", "", null));
       System.out.println(
         formTest.getModulesInAForm("99CD59C5-A9A0-3FA4-E034-080020C9C0E0"));
       String formId = "9E343E83-5FEB-119F-E034-080020C9C0E0";
       try {
         Form test = formTest.findFormByPrimaryKey(formId);
         //System.out.println(formTest.findFormByPrimaryKey(formId));
         System.out.println(formTest.findFormByTimestamp(formId, test.getDateModified()));
       }
       catch (DMLException e) {
         System.out.println("Failed to get a form for " + formId);
       }
     */
    /*
       // test createFormComponent method.
       // for each test, change long name(preferred name generated from long name)
       try {
         Form newForm = new FormTransferObject();
         newForm.setVersion(new Float(2.31));
         newForm.setLongName("Test Form Long Name 030104 1");
         newForm.setPreferredDefinition("Test Form pref def");
         newForm.setConteIdseq("99BA9DC8-2095-4E69-E034-080020C9C0E0");
         Protocol protocol = new ProtocolTransferObject("TEST");
         protocol.setProtoIdseq("A1204FD0-22B8-3B68-E034-080020C9C0E0");
         newForm.setProtocol(protocol);
         newForm.setAslName("DRAFT NEW");
         newForm.setCreatedBy("Hyun Kim");
         newForm.setFormCategory("Registration");
         newForm.setFormType("CRF");
         System.out.println(formTest.createFormComponent(newForm));
       }
       catch (DMLException de) {
         System.out.println("******Printing DMLException*******");
         de.printStackTrace();
         System.out.println("******Finishing printing DMLException*******");
       }
     */
    /*
       try {
         int res = formTest.deleteForm("D4700045-2FD0-0DAA-E034-0003BA0B1A09");
         System.out.println("\n*****Delete Form Result 1: " + res);
       }
       catch (DMLException de) {
         System.out.println("******Printing DMLException*******");
         de.printStackTrace();
         System.out.println("******Finishing printing DMLException*******");
       }
     */
    Form formX = null;
    try {
        /*
        //Test getAllTemplatesForContextId
        Collection temps = formTest.getAllTemplatesForContextId("99BA9DC8-2095-4E69-E034-080020C9C0E0");
        System.out.println(temps.size() + " templates retrieved");
                
        // Test getAllPublishedFormsByType
        Collection temps = formTest.getAllPublishedFormsByType("CRF", "D9344734-8CAF-4378-E034-0003BA12F5E7");
        System.out.println(temps.size() + " templates retrieved");
        */
        // Test getAllPublishedFormsByType
        //Collection temps = formTest.getAllProtocolsForPublishedForms("D9344734-8CAF-4378-E034-0003BA12F5E7");
        //Collection temps = formTest.getAllFormsOrderByContextProtocol();
        //  Collection temps = formTest.getAllPublishingCSCSIsForForm();

        //   formX = formTest.findFormByPrimaryKey("D4D75662-033F-6DD1-E034-0003BA0B1A09");
        //  Collection temps = formTest.getAllTemplatesOrderByContext();
        //  System.out.println(temps.size() + " templates retrieved");
    }

    catch (DMLException e) {
        System.out.println("Failed to get a form for " + formX);
    }
    if (formX != null) {
        formX.setFormType("CRF");
        formX.getContext().setConteIdseq("99BA9DC8-2095-4E69-E034-080020C9C0E0");
        formX.setAslName("CRF TEMPLATE");
        formX.setPreferredName("Form update test");
        formX.setPreferredDefinition("Form update test definition");
        //for multiple protocols...
        //formX.getProtocol().setProtoIdseq("9B0EAC7E-6A62-0DEB-E034-080020C9C0E0");
        formX.setLongName("Form update test long name");
        formX.setFormCategory("Lab");
        formX.setModifiedBy("sbrext");
        formTest.updateFormComponent(formX);
    }
}

From source file:es.udc.fic.test.model.ClasificacionServiceTest.java

@Test
public void getPuntuacionFinalTest() {

    List<Posicion> posiciones = new ArrayList<Posicion>();

    Tipo tipo = new Tipo("Crucero", "Desc Crucero", false);

    Barco mockBarco = new Barco(201402, "La Perla Negra", tipo, new Float(1.5), "X6");

    Posicion posicion;/*  w w w.j  a v  a2  s  . c  o  m*/

    //Comprobacion de eliminacion de mayor puntuacion en casos normales
    //(sin penalizaciones ni historias)
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(8);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(9);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(10);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(7);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(20);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(21);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(23);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(22);
    posiciones.add(posicion);

    //TODO Revisar esto xq creo que a conta est mal botada
    assertEquals(75, regataService.getPuntuacionFinal(posiciones));

    posiciones.clear();

    //probamos el caso de que el numero de posiciones no sea multiplo de cuatro
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(8);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(9);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(10);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(7);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(1);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(2);
    posiciones.add(posicion);

    assertEquals(27, regataService.getPuntuacionFinal(posiciones));

    posiciones.clear();

    //probamos el caso de penalizacion insalvable
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(8);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(9);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.DNE, null, mockBarco, (long) 0);
    posicion.setPuntos(10);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(7);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(1);
    posiciones.add(posicion);
    posicion = new Posicion(new Long(2800), Posicion.Penalizacion.NAN, null, mockBarco, (long) 0);
    posicion.setPuntos(2);
    posiciones.add(posicion);

    assertEquals(28, regataService.getPuntuacionFinal(posiciones));

    posiciones.clear();

}

From source file:com.judoscript.jamaica.JavaClassCreator.java

public final void inst_fconst(float val) throws JavaClassCreatorException {
    if (val == 0)
        inst(11); // fconst_0
    else if (val == 1)
        inst(12); // fconst_1
    else if (val == 2)
        inst(13); // fconst_2
    else/*from w ww . j a va  2  s .c om*/
        inst_ldc(new Float(val));
}

From source file:com.github.xbn.array.primitive.ObjectArrayFromPrimitive.java

/**
   <p>Get a {@code java.lang.Object} array from an array of {@code float}-s.</p>
        /*from   w w  w . ja  v a  2 s .c  o  m*/
 * @return  If {@code prmtv_array} is<ul>
 <li>{@code null}: {@code null}</li>
 <li>non-{@code null} and has no elements: <code>org.apache.commons.lang3.{@link org.apache.commons.lang3.ArrayUtils ArrayUtils}.{@link org.apache.commons.lang3.ArrayUtils#EMPTY_OBJECT_ARRAY EMPTY_OBJECT_ARRAY}</code></li>
 <li>Otherwise: A new {@code Object} array containing all elements in {@code prmtv_array}.</li>
   </ul>
 * @see  #get(boolean[], NullContainer, String) get(b[])
 */
public static final Object[] get(float[] prmtv_array, NullContainer nnull, String cntrName_forNullBad) {
    if (prmtv_array == null) {
        IndexableUtil.crashIfContainerIsNullAndThatIsBad(nnull, cntrName_forNullBad);
        return null;
    }

    if (prmtv_array.length == 0) {
        return ArrayUtils.EMPTY_OBJECT_ARRAY;
    }

    Float[] ao = new Float[prmtv_array.length];
    for (int i = 0; i < prmtv_array.length; i++) {
        ao[i] = new Float(prmtv_array[i]);
    }

    return ao;
}

From source file:com.linkedin.pinot.segments.v1.creator.DictionariesTest.java

@Test
public void testFloatColumnPreIndexStatsCollector() throws Exception {
    FieldSpec spec = new DimensionFieldSpec("column1", DataType.FLOAT, true);
    AbstractColumnStatisticsCollector statsCollector = new FloatColumnPreIndexStatsCollector(spec);
    statsCollector.collect(new Integer(1));
    Assert.assertTrue(statsCollector.isSorted());
    statsCollector.collect(new Float(2));
    Assert.assertTrue(statsCollector.isSorted());
    statsCollector.collect(new Long(3));
    Assert.assertTrue(statsCollector.isSorted());
    statsCollector.collect(new Double(4));
    Assert.assertTrue(statsCollector.isSorted());
    statsCollector.collect(new Integer(4));
    Assert.assertTrue(statsCollector.isSorted());
    statsCollector.collect(new Float(2));
    Assert.assertFalse(statsCollector.isSorted());
    statsCollector.collect(new Double(40));
    Assert.assertFalse(statsCollector.isSorted());
    statsCollector.collect(new Double(20));
    Assert.assertFalse(statsCollector.isSorted());
    statsCollector.seal();// w  w w  .  j  a v  a 2 s.  c o  m
    Assert.assertEquals(statsCollector.getCardinality(), 6);
    Assert.assertEquals(((Number) statsCollector.getMinValue()).intValue(), 1);
    Assert.assertEquals(((Number) statsCollector.getMaxValue()).intValue(), 40);
    Assert.assertFalse(statsCollector.isSorted());
}

From source file:com.gisgraphy.importer.GeonamesZipCodeImporterTest.java

@Test
public void findFeatureBasicWithOneResult() {
    String lat = "3.5";
    String lng = "44";
    String accuracy = "5";
    String placeName = "place name";
    String countryCode = "FR";
    String adm1Name = "adm1name";
    String adm1Code = "adm1code";
    String adm2Name = "adm2name";
    String adm2Code = "adm2code";
    String adm3Name = "adm3name";
    String adm3COde = "adm3code";
    FulltextQuery fulltextQuery = new FulltextQuery(placeName + " " + adm1Name);
    fulltextQuery.limitToCountryCode(countryCode);
    fulltextQuery.withPlaceTypes(com.gisgraphy.fulltext.Constants.CITY_AND_CITYSUBDIVISION_PLACETYPE);

    GeonamesZipCodeSimpleImporter importer = new GeonamesZipCodeSimpleImporter() {

        @Override//from www.  jav a  2 s  .  c o  m
        protected FulltextResultsDto doAFulltextSearch(String query, String countryCode) {
            return dtoWithOneResult;
        }
    };
    String[] fields = { countryCode, "post", placeName, adm1Name, adm1Code, adm2Name, adm2Code, adm3Name,
            adm3COde, lat, lng, accuracy };
    Point point = GeolocHelper.createPoint(new Float(lng), new Float(lat));
    int maxDistance = importer.getAccurateDistance(new Integer(accuracy));
    Long actualFeatureId = importer.findFeature(fields, point, maxDistance);
    Assert.assertEquals(dtoWithOneResult.getResults().get(0).getFeature_id(), actualFeatureId);

}

From source file:eu.cloud4soa.tests.TestReqSec_Deploy.java

private ApplicationInstance createApplicationInstance(String applicationName) throws FileNotFoundException {
    URL fileURL = this.getClass().getClassLoader().getResource("SimpleWar.war");
    if (fileURL == null)
        throw new FileNotFoundException("SimpleWar.war");

    ByteArrayOutputStream bas = new ByteArrayOutputStream();

    File file = new File(fileURL.getPath());
    file.length();//from ww  w  .ja  va2  s.c o m
    FileInputStream fis = new FileInputStream(file);
    BufferedInputStream bis = new BufferedInputStream(fis);
    DataInputStream dis = new DataInputStream(bis);

    //Calculate digest from InputStream
    //        InputStream tempIs = new FileInputStream(file);
    String tempFileDigest = null;
    try {
        FileInputStream tempFis = new FileInputStream(file);
        tempFileDigest = DigestUtils.sha256Hex(tempFis);
    } catch (IOException ex) {
        Logger.getLogger(ApplicationDeploymentTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    ApplicationInstance applicationInstance = null;
    applicationInstance = new ApplicationInstance();
    applicationInstance.setAcronym(applicationName);
    applicationInstance.setApplicationcode(applicationName);
    applicationInstance.setDigest(tempFileDigest);
    applicationInstance.setProgramminglanguage("Java");
    applicationInstance.setProgramminglanguageVersion("1.6");
    applicationInstance.setSizeQuantity(new Float(file.length()));
    applicationInstance.setVersion("1.0");
    applicationInstance.setArchiveFileName("SimpleWar");
    applicationInstance.setArchiveExtensionName(".war");

    try {
        fis.close();
        bis.close();
        dis.close();
    } catch (IOException ex) {
        Logger.getLogger(ApplicationDeploymentTest.class.getName()).log(Level.SEVERE, null, ex);
    }

    return applicationInstance;
}