Example usage for java.lang Float valueOf

List of usage examples for java.lang Float valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Float valueOf(float f) 

Source Link

Document

Returns a Float instance representing the specified float value.

Usage

From source file:Visao.grafico.GraficoRelatorioEstoque.java

private void PreencherTabelaFiltrada() {
    //JOptionPane.showMessageDialog(null, "Size! " + jListFiltrar.getSelectedIndices().length + jListFiltrar.getModel().getSize());
    Locale brasil = new Locale("pt", "BR");
    DecimalFormat decformat = new DecimalFormat("#,##0.00", new DecimalFormatSymbols(brasil));
    ConexaoBD con = ConexaoBD.getConexao(0);
    String query = "";
    String whereSql = "";
    String andSql = "";
    ResultSet rs;//from www . ja  v  a 2  s.  c  o  m

    int mat_gem = 0;

    linhas = new ArrayList();
    colunas = new String[] { "Id", "Fazenda", "Projeto", "Material Genetico",

            "Area total", "Media geral m/ha", "Media ponderada mdc/ha", "Volume madeira praa total",
            "Volume carvao praa total",

            "Volume madeira estimada total", "Volume madeira transportada total",
            "Volume madeira processada total", "Toneladas de madeira estimada totais",
            "Toneladas de madeira transportada totais",

            "Volume carvo estimado total", "Volume carvo produzido total",
            "Volume carvo transportado total", "Toneladas de carvo estimado total",
            "Toneladas de carvo produzido total", "Toneladas de carvo transportado total" };

    /*id, fazenda, material material, area, m3ha, mdcha*/
    id = 0;

    //defini quantidade de colunas
    /*colunas = new String[tamanho];
              
    //carrega nomes das colunas selecionadas ou todas.
    for(int i = 0; i < tamanho; i++)
    {
    colunas[i] = (String) jTableRelatorioGrafico.getColumnName(i);
    }*/

    //Controle e definio das variaveis da clausula where like. Filtros
    if (jComboBoxMatGen.getSelectedItem().equals("-")) {
        filtro_matgen = "";
        mat_gem = list_mat_gen.size();
    } else {
        filtro_matgen = jComboBoxMatGen.getSelectedItem().toString();
        mat_gem = 1;
        //list_mat_gen.clear();
        //list_mat_gen.add(filtro_matgen);
    }

    //faz busca a partir dos filtros acima
    //System.out.println("list_fazendas: "+list_fazendas.size());
    //System.out.println("list_mat_gen: "+list_mat_gen.size());
    //System.out.println("mat_gem: "+mat_gem);
    for (int i = 0; i < list_fazendas.size(); i++) {
        for (int j = 0; j < mat_gem; j++) {
            //for(int k = 0; k < list_projeto.size(); k++){

            whereSql = "where fazenda = '" + list_fazendas.get(i) + "'";
            //System.out.println("list_projeto: "+list_mat_gen.size());
            //if(list_mat_gen.size()>1){
            if (filtro_matgen.equals("")) {
                whereSql += "and material_genetico = '" + list_mat_gen.get(j) + "'";
                //System.out.println("list_mat_gen: "+list_mat_gen.get(j));
            } else {
                whereSql += " and material_genetico = '" + filtro_matgen + "'";
                //System.out.println("filtro_matgen: "+filtro_matgen);
            }

            query = "SELECT * FROM estoque_principal " + whereSql + " ORDER BY fazenda,projeto,upc,talhao ASC";

            //System.out.println("Query: "+query);

            fazenda = "";
            projeto = "";
            material_genetico = "";
            areaTotal = 0;
            m3_haMedia = 0;
            mdc_haMedia = 0;
            vol_mad_pracaTotal = 0;
            vol_carv_pracaTotal = 0;
            vol_mad_estTotal = 0;
            vol_mad_transpTotal = 0;
            vol_mad_procTotal = 0;
            madeira_fornoTotal = 0;
            mad_ton_estTotal = 0;
            mad_ton_transpTotal = 0;
            mdc_estTotal = 0;
            mdc_prodTotal = 0;
            mdc_transpTotal = 0;
            carv_ton_estTotal = 0;
            carv_ton_prodTotal = 0;
            carv_ton_transpTotal = 0;
            media_idades = 0;
            cont = 0;
            //System.out.println("Query: " + query);
            //carrega dados do banco de dados dependendo da consulta sql
            rs = con.consultaSql(query);
            //cria um objeto coluna de acordo com as colunas selecionadas para cada linha encontrada na consulta
            Object[] coluna = new Object[TAMANHO];
            try {
                while (rs.next()) {

                    //coluna[31] = decformat.format(rs.getString("vol_mad_estimado"));
                    //System.out.println("Add Dados ["+31+"]: "+coluna[31]);
                    projeto = rs.getString("projeto");
                    //area total
                    if (rs.getString("area") != null) {
                        areaTotal += Float.valueOf(rs.getString("area"));
                    }

                    //media aritmetica  m3/ha
                    if (rs.getString("m3_ha") != null && Float.valueOf(rs.getString("m3_ha")) > 0) {
                        //m3_haMedia += Float.valueOf(rs.getString("m3_ha"));
                        m3_haMedia += Float.valueOf(rs.getString("m3_ha"))
                                * Float.valueOf(rs.getString("area"));
                    }

                    //media ponderada mdc/ha
                    if (rs.getString("mdc_ha") != null && Float.valueOf(rs.getString("mdc_ha")) > 0) {
                        mdc_haMedia += Float.valueOf(rs.getString("mdc_ha"))
                                * Float.valueOf(rs.getString("area"));
                    }

                    //madeira praa total
                    if (rs.getString("madeira_praca") != null
                            && Float.valueOf(rs.getString("madeira_praca")) > 0) {
                        vol_mad_pracaTotal += Float.valueOf(rs.getString("madeira_praca"));
                    }

                    //carvo praa total
                    if (rs.getString("carvao_praca") != null
                            && Float.valueOf(rs.getString("carvao_praca")) > 0) {
                        vol_carv_pracaTotal += Float.valueOf(rs.getString("carvao_praca"));
                    }

                    //Volumes totais de madeira
                    if (rs.getString("vol_mad_estimado") != null) {
                        vol_mad_estTotal += Float.valueOf(rs.getString("vol_mad_estimado"));
                    }
                    if (rs.getString("vol_mad_transp") != null) {
                        vol_mad_transpTotal += Float.valueOf(rs.getString("vol_mad_transp"));
                    }
                    if (rs.getString("madeira_forno") != null) {
                        madeira_fornoTotal += Float.valueOf(rs.getString("madeira_forno"));
                    }

                    //Toneladas totais de madeira
                    if (rs.getString("mad_ton_estimado") != null) {
                        mad_ton_estTotal += Float.valueOf(rs.getString("mad_ton_estimado"));
                    }
                    if (rs.getString("mad_ton_transp") != null) {
                        mad_ton_transpTotal += Float.valueOf(rs.getString("mad_ton_transp"));
                    }

                    //Volumes totais de carvao
                    if (rs.getString("mdc_estimado") != null) {
                        mdc_estTotal += Float.valueOf(rs.getString("mdc_estimado"));
                    }
                    if (rs.getString("mdc_prod") != null) {
                        mdc_prodTotal += Float.valueOf(rs.getString("mdc_prod"));
                    }
                    if (rs.getString("mdc_transp") != null) {
                        mdc_transpTotal += Float.valueOf(rs.getString("mdc_transp"));
                    }

                    //Toneladas totais de carvao
                    if (rs.getString("carv_ton_estimado") != null) {
                        carv_ton_estTotal += Float.valueOf(rs.getString("carv_ton_estimado"));
                    }
                    if (rs.getString("carv_ton_prod") != null) {
                        carv_ton_prodTotal += Float.valueOf(rs.getString("carv_ton_prod"));
                    }
                    if (rs.getString("carv_ton_transp") != null) {
                        carv_ton_transpTotal += Float.valueOf(rs.getString("carv_ton_transp"));
                    }

                    if (rs.getString("idade_hoje") != null) {
                        media_idades += Float.valueOf(rs.getString("idade_hoje"));
                        cont++;
                    }
                    //System.out.printf("\nCalculo m3ha: "+ m3_haMedia); 
                }

                if (areaTotal > 0) {
                    mdc_haMedia = mdc_haMedia / areaTotal;
                    m3_haMedia = m3_haMedia / areaTotal;

                    fazenda = list_fazendas.get(i).toString();
                    System.out.println("list_mat_gen: " + list_mat_gen.size());
                    if (mat_gem > 1) {
                        material_genetico = list_mat_gen.get(j).toString();
                    } else {
                        material_genetico = jComboBoxMatGen.getSelectedItem().toString();
                    }

                    System.out.println("material_genetico: " + material_genetico);

                    coluna[0] = id;
                    coluna[1] = fazenda;
                    coluna[2] = projeto;
                    coluna[3] = material_genetico;

                    coluna[4] = areaTotal;
                    coluna[5] = m3_haMedia;
                    coluna[6] = mdc_haMedia;

                    coluna[7] = vol_mad_pracaTotal;
                    coluna[8] = vol_carv_pracaTotal;

                    coluna[9] = vol_mad_estTotal;
                    coluna[10] = vol_mad_transpTotal;
                    coluna[11] = madeira_fornoTotal;
                    coluna[12] = mad_ton_estTotal;
                    coluna[13] = mad_ton_transpTotal;

                    coluna[14] = mdc_estTotal;
                    coluna[15] = mdc_prodTotal;
                    coluna[16] = mdc_transpTotal;
                    coluna[17] = carv_ton_estTotal;
                    coluna[18] = carv_ton_prodTotal;
                    coluna[19] = carv_ton_transpTotal;
                    //coluna[20]=media_idades;

                    //adiciona a cada linha os valores de cada objeto coluna
                    linhas.add(coluna);
                    id++;
                } else {
                    mdc_haMedia = 0;
                    m3_haMedia = 0;
                }

                //System.out.printf("\nlinha m3ha: "+ linhas.get(id));                     
                //System.out.printf("\nCalculo m3ha: "+ m3_haMedia); 

            } catch (SQLException ex) {
                Logger.getLogger(GerarRelatorioEstoqueBasico.class.getName()).log(Level.SEVERE, null,
                        "Erro ao Preencher Tabela Filtrada ! " + ex);
                JOptionPane.showMessageDialog(null, "Erro ao Preencher Tabela Filtrada ! " + ex);
            }
        }
        //}
    }
    //System.out.printf("\nLinha m3ha: "+ linhas.get(0));   

    MontarTabela();
    con.fecharConexao();
}

From source file:com.jada.order.document.CreditEngine.java

public void calculateHeader() throws Exception {
    float creditTotal = 0;
    Iterator<?> iterator = creditHeader.getCreditDetails().iterator();
    while (iterator.hasNext()) {
        CreditDetail creditDetail = (CreditDetail) iterator.next();
        creditTotal += creditDetail.getItemCreditAmount().floatValue();
        Iterator<?> taxIterator = creditDetail.getCreditDetailTaxes().iterator();
        while (taxIterator.hasNext()) {
            CreditDetailTax creditDetailTax = (CreditDetailTax) taxIterator.next();
            creditTotal += creditDetailTax.getTaxAmount();
        }/*from   ww  w .j  a va  2  s  . c om*/
    }
    creditTotal += creditHeader.getShippingTotal();
    iterator = creditHeader.getCreditTaxes().iterator();
    while (iterator.hasNext()) {
        CreditDetailTax creditDetailTax = (CreditDetailTax) iterator.next();
        if (creditDetailTax.getCreditDetail() != null) {
            continue;
        }
        creditTotal += creditDetailTax.getTaxAmount();
    }

    creditHeader.setCreditTotal(Float.valueOf(creditTotal));
    creditHeader.setRecUpdateBy(user.getUserId());
    creditHeader.setRecUpdateDatetime(new Date());
}

From source file:com.dodo.wbbshoutbox.codebot.MainActivity.java

public static void setTextSize() {
    lblVerlauf.setTextSize(Float.valueOf(UserData.readPref("textsize", context)));
    refresh();
}

From source file:edu.ku.brc.af.prefs.AppPreferences.java

/**
 * Returns the value as a Float./*from ww  w .j a  va 2  s. c o  m*/
 * @param name the name
 * @param defaultValue the default value
 * @return the value as a Float
 */
public Float getFloat(final String name, final Float defaultValue) {
    String val = get(name, (defaultValue == null ? null : Float.toString(defaultValue)));
    return val == null ? null : Float.valueOf(val);
}

From source file:de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderTest.java

@DataProvider(name = "typesAsSessionAttributesProvider")
protected Object[][] createTypesAsSessionAttributesData() {
    return new Object[][] { { int.class, 42 }, { long.class, 42 }, { Boolean.class, Boolean.TRUE },
            { String.class, "42" }, { StringBuilder.class, new StringBuilder("42") },
            { StringBuffer.class, new StringBuffer("42") }, { Class.class, String.class },
            { Long.class, Long.valueOf(42) }, { Integer.class, Integer.valueOf(42) },
            { Character.class, Character.valueOf('c') }, { Byte.class, Byte.valueOf("b".getBytes()[0]) },
            { Double.class, Double.valueOf(42d) }, { Float.class, Float.valueOf(42f) },
            { Short.class, Short.valueOf((short) 42) }, { BigDecimal.class, new BigDecimal(42) },
            { AtomicInteger.class, new AtomicInteger(42) }, { AtomicLong.class, new AtomicLong(42) },
            { MutableInt.class, new MutableInt(42) }, { Integer[].class, new Integer[] { 42 } },
            { Date.class, new Date(System.currentTimeMillis() - 10000) },
            { Calendar.class, Calendar.getInstance() }, { Currency.class, Currency.getInstance("EUR") },
            { ArrayList.class, new ArrayList<String>(Arrays.asList("foo")) },
            { int[].class, new int[] { 1, 2 } }, { long[].class, new long[] { 1, 2 } },
            { short[].class, new short[] { 1, 2 } }, { float[].class, new float[] { 1, 2 } },
            { double[].class, new double[] { 1, 2 } }, { int[].class, new int[] { 1, 2 } },
            { byte[].class, "42".getBytes() }, { char[].class, "42".toCharArray() },
            { String[].class, new String[] { "23", "42" } },
            { Person[].class, new Person[] { createPerson("foo bar", Gender.MALE, 42) } } };
}

From source file:com.visionet.platform.cooperation.service.OrderService.java

/**
 * ?//w w w  . j  a v  a2 s  . c  o m
 *
 * @return
 * @throws Exception
 */
public OrderResultDTO insertOrder(String partnerOrderId, String partnerOrderNo, Integer businessType,
        Integer orderType, String carType, String startPlace, String startGps, String endPlace,
        Double expectedKm, String endGps, String expectedPrice, String customerPhone, String customerName,
        String callDate, String bookDate, Integer orderSource, String city, Integer cityId, String sign,
        String channel) throws Exception {
    if (!"1".equals(RECIVE_SHOUYUE_ORDER)) {
        throw new BizException("?");
    }

    if (cityId == null || "".equals(cityId)) {
        throw new BizException("?ID?");
    }
    ThirdPartyCity thirdPartyCity = thirdPartyCityMapper.selectByDzcxCityId(cityId, 1);
    if (thirdPartyCity == null) {
        throw new BizException("?");
    }
    Integer reciveOrder = thirdPartyCity.getReciveOrder();
    if (reciveOrder == 0) {
        throw new BizException("?");
    }
    Date orderBookDate = null;
    // ----------------?? -------------------
    if (StringUtils.isEmpty(partnerOrderId)) {
        throw new BizException("???ID");
    }
    if (StringUtils.isEmpty(partnerOrderNo)) {
        throw new BizException("???");
    }
    ThirdPartyOrder tpo = thirdPartyOrderMapper.selectOneByPartnerOrderNo(partnerOrderNo);
    if (tpo != null) {
        throw new BizException("???");
    }
    if (StringUtils.isEmpty(customerPhone)) {
        throw new BizException("??");
    }
    if (expectedKm == null || "".equals(expectedKm)) {
        throw new BizException("");
    }
    if (expectedPrice == null || "".equals(expectedPrice)) {
        throw new BizException("?");
    }
    if (StringUtils.isEmpty(bookDate)) {
        throw new BizException("??");
    } else {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            orderBookDate = sdf.parse(bookDate);
        } catch (Exception e) {
            throw new BizException("???yyyy-MM-dd HH:mm:ss");
        }
        if (orderBookDate.before(new Date())) {
            throw new BizException("????");
        }
    }
    if (orderType == null || "".equals(orderType)) {
        throw new BizException("?");
    }

    if (StringUtils.isEmpty(city)) {
        throw new BizException("??");
    }
    if (businessType == null || "".equals(businessType)) {
        throw new BizException("??");
    }
    // ----------------?? ?-------------------

    // -------------??? ------------------
    Customer customer = customerMapper.selectByPrimaryKey(customerPhone);
    if (customer == null) {
        // ?
        Customer customer_new = new Customer();
        customer_new.setPhone(customerPhone);
        customer_new.setName(customerName);
        customer_new.setCreateDate(new Date());
        customer_new.setDelFlag(1);
        customer_new.setIsValid(0);
        customer_new.setLevel(1);
        customer_new.setIsApp(0);// 0APP
        customer_new.setStatus(4);// 4
        customer_new.setIsLogin(0);// 10
        customer_new.setSource("5");// 5
        customer_new.setCity(city);
        customer_new.setCityId(cityId);
        customerMapper.insertSelective(customer_new);
    }
    // -----------------??? ?---------------

    // ----------------------? ---------------------
    OrderResultDTO orderResultDTO = new OrderResultDTO();
    Order tOrder = new Order();
    Date date = new Date();
    String orderID = OrderCreaterUtil.createrOrder(businessType + "");
    tOrder.setOrderId(orderID);
    tOrder.setBusinessType(businessType);
    tOrder.setOrderType(orderType);// 6 
    tOrder.setOrderSource(4);// 4 
    tOrder.setCarType(carType);
    tOrder.setCarNumber(1);
    tOrder.setStartPlace(startPlace);
    tOrder.setStartGps(startGps);
    tOrder.setEndPlace(endPlace);
    tOrder.setEndGps(endGps);
    tOrder.setCustomerPhone(customerPhone);
    tOrder.setCustomerName(customerName);
    tOrder.setCallDate(date);// ??
    tOrder.setStatus(0);// ?0
    tOrder.setExpectedKm(expectedKm.floatValue());
    tOrder.setVirtual(0f);
    tOrder.setExpectedPrice(Float.valueOf(expectedPrice));
    tOrder.setIncreasePrice(0.0);
    tOrder.setIncreaseType(0);// ?012
    tOrder.setCity(city);
    tOrder.setCityId(cityId);
    tOrder.setBookDate(orderBookDate);

    orderMapper.insertSelective(tOrder);// ?

    SQSService.put(JSONObject.toJSONString(tOrder)); // aws SQS

    // ?????
    OrderStatusTracking orderStatusTracking = new OrderStatusTracking();
    orderStatusTracking.setOrderId(orderID);
    orderStatusTracking.setCustomerPhone(customerPhone);
    orderStatusTracking.setBusinessType(businessType);
    orderStatusTracking.setNewStatus(0);// 0?
    orderStatusTracking.setCreateDate(date);
    orderStatusTracking.setOperator(0);// 
    orderStatusTrackingMapper.insertSelective(orderStatusTracking);

    // ???
    Integer thirdPartyOrderType = 1;// 0 ? 1 ?
    Long minutes = DateUtil.minusTime(new Date(), orderBookDate);
    if (yuyuedanShishidanPoint > minutes) {
        thirdPartyOrderType = 0;
    }
    ThirdPartyOrder thirdPartyOrder = new ThirdPartyOrder();
    thirdPartyOrder.setMerchantId(1);// 1
    thirdPartyOrder.setSource(1);// ???0?1
    thirdPartyOrder.setOrderId(orderID);// ??
    thirdPartyOrder.setPartnerOrderId(partnerOrderId);
    thirdPartyOrder.setPartnerOrderNo(partnerOrderNo);
    thirdPartyOrder.setCreateDate(new Date());
    thirdPartyOrder.setOrderType(thirdPartyOrderType);
    thirdPartyOrder.setNotice(0);
    thirdPartyOrderMapper.insertSelective(thirdPartyOrder);

    // ----------------------? ?---------------------

    orderResultDTO.setOrderNo(orderID);
    return orderResultDTO;
}

From source file:abelymiguel.miralaprima.GetPrima.java

private HashMap<String, Float> getPrimaDataBloom(String country_code, String providerUrl, String indexName) {

    HashMap<String, Float> respuestaJson = new HashMap<String, Float>();
    HashMap<String, Object> primaJson;

    Float prima_value;//from  ww  w . jav a 2 s  .  c  om
    Float prima_delta;
    Float prima_percent;

    Document doc;
    try {
        doc = Jsoup.connect(providerUrl + indexName).get();
        Element riskPremium = doc.select(".price").last();
        //              System.out.println("Prima: " + riskPremium.text());
        prima_value = Float.valueOf(riskPremium.text().replace(".", "")).floatValue();

        Elements riskPremiumsUp = doc.select(".trending_up");
        Elements riskPremiumsDown = doc.select(".trending_down");
        //              System.out.println("Trending: " + riskPremiumsUp.text());
        //              System.out.println("Trending: " + riskPremiumsDown.text());

        if (!riskPremiumsUp.text().equals("")) {
            String delta = riskPremiumsUp.text();
            prima_delta = Float.valueOf(delta.substring(0, delta.indexOf(" ")).replace(",", "")).floatValue();
            //                  System.out.println("Delta: " + prima_delta);

            String percent = riskPremiumsUp.text();
            prima_percent = Float.valueOf(percent.substring(percent.indexOf(" ") + 1, percent.length() - 1))
                    .floatValue();
            //                  System.out.println("Percent: " + prima_percent);
        } else if (!riskPremiumsDown.text().equals("")) {
            String delta = riskPremiumsDown.text();
            prima_delta = Float.valueOf(delta.substring(0, delta.indexOf(" ")).replace(",", "")).floatValue();
            prima_delta = prima_delta * -1;
            //                  System.out.println("Delta: " + prima_delta);

            String percent = riskPremiumsDown.text();
            prima_percent = Float.valueOf(percent.substring(percent.indexOf(" ") + 1, percent.length() - 1))
                    .floatValue();
            prima_percent = prima_percent * -1;
            //                  System.out.println("Percent: " + prima_percent);
        } else {
            prima_delta = 0f;
            prima_percent = 0f;
        }
        respuestaJson.put("prima_value", prima_value);
        respuestaJson.put("prima_delta", prima_delta);
        respuestaJson.put("prima_percent", prima_percent);

        if (isSameDay(country_code)) {
            this.updatePrimaInDB(prima_value, prima_delta, prima_percent,
                    this.getLatestPrimaIdFromDB(country_code));
        } else {
            this.storePrimaInDB(prima_value, prima_delta, prima_percent, country_code);
        }
    } catch (Exception ex) {
        Logger.getLogger(GetPrima.class.getName()).log(Level.SEVERE, null, ex);
        primaJson = getLatestPrimaFromDB(country_code);
        respuestaJson.put("prima_value", (Float) primaJson.get("prima_value"));
        respuestaJson.put("prima_delta", (Float) primaJson.get("prima_delta"));
        respuestaJson.put("prima_percent", (Float) primaJson.get("prima_percent"));
    }

    return respuestaJson;
}

From source file:se.technipelago.weather.chart.Generator.java

public Map<String, Object> getWeatherData() {
    Map<String, Object> map = new HashMap<String, Object>();

    // Put archived data into the map.
    setArchivedData(map);/*from  w w w  .  j a va  2s  .  c om*/

    // Put current data into the map.
    setCurrentData(map);

    // Daily high/low values.
    //
    Calendar cal = Calendar.getInstance();
    cal.setTime((Date) map.get("timestamp"));
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    cal.add(Calendar.DAY_OF_MONTH, -6);
    Date day7 = cal.getTime();
    cal.add(Calendar.DAY_OF_MONTH, 6);
    Date day0 = cal.getTime();
    cal.add(Calendar.DAY_OF_MONTH, 1);
    cal.add(Calendar.MILLISECOND, -1);
    Date day1 = cal.getTime();
    // High values.
    setHiLowData(day0, day1, "temp_out", true, map, "dailyHighTemp");
    setHiLowData(day0, day1, "hum_out", true, map, "dailyHighHumidity");
    setHiLowData(day0, day1, "wind_high", true, map, "dailyHighWind");
    // Low values.
    setHiLowData(day0, day1, "temp_out", false, map, "dailyLowTemp");
    setHiLowData(day0, day1, "hum_out", false, map, "dailyLowHumidity");
    setHiLowData(day0, day1, "wind_avg", false, map, "dailyLowWind");

    map.put("rain_today", getValue(day0, day1, "rain", SUM));

    map.put("solar_hours", getSolarHours(new Timespan(day7, day1)));

    cal.set(Calendar.MONTH, Calendar.JUNE);
    cal.set(Calendar.DAY_OF_MONTH, 19);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Date midsummer = cal.getTime();
    cal.setTime(new Date());
    cal.set(Calendar.HOUR_OF_DAY, 23);
    cal.set(Calendar.MINUTE, 59);
    cal.set(Calendar.SECOND, 59);
    cal.set(Calendar.MILLISECOND, 999);
    while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY) {
        cal.add(Calendar.DAY_OF_MONTH, -1);
    }
    Date thursday = cal.getTime();
    if (thursday.getTime() > midsummer.getTime()) {
        map.put("solligan", getSolarHours(new Timespan(midsummer, thursday)));
        map.put("solligan_time", thursday);
    } else {
        map.put("solligan", Float.valueOf(0));
    }

    return map;
}

From source file:com.ti.sensortag.gui.services.ServicesActivity.java

/**
 * This class listens to changes in the model of sensor values.
 * *//*from   w  ww .  j  av  a2  s .  c  o  m*/

@Override
public void propertyChange(final PropertyChangeEvent event) {
    final String property = event.getPropertyName();

    runOnUiThread(new Runnable() {
        public void run() {
            try {
                /*if (property.equals(PROPERTY_ACCELEROMETER)) {
                  // A change in accelerometer data has occured.
                  Point3D newValue = (Point3D) event.getNewValue();
                  String xaxis = decimal.format(newValue.x);
                  String yaxis = decimal.format(newValue.y);
                  String zaxis = decimal.format(newValue.z);
                        
                  String acl = "X: " + decimal.format(newValue.x) + "g" + "\nY: " + decimal.format(newValue.y) + "g" + "\nZ: " + decimal.format(newValue.z) + "g";
                          
                  ((TextView) findViewById(R.id.accelerometerTxt)).setText(acl);
                          
                }
                } else */if (property.equals(PROPERTY_AMBIENT_TEMPERATURE)) {
                    double newAmbientValue = (Double) event.getNewValue();

                    final int img;
                    TextView textView = (TextView) findViewById(R.id.ambientTemperatureTxt);
                    String formattedText = "Touch Not Detected";

                    if (newAmbientValue == 11.00) {
                        formattedText = "Touch Detected";
                        //img = touch;

                    } else {

                        //img = notouch;
                    }

                    //((ImageView) findViewById(R.id.touch)).setImageResource(img);

                    textView.setText(formattedText);
                } /*ARVelse*/

                else if (property.equals(PROPERTY_IR_TEMPERATURE)) {
                    double newIRValue = (Double) event.getNewValue();
                    //  float newIRValue_1 = (Float) event.getNewValue();
                    TextView textView = (TextView) findViewById(R.id.ir_temperature);
                    String value = decimal.format(newIRValue);
                    String formattedText = value + DEGREE_SYM;
                    wakelockk.acquire();
                    textView.setText(formattedText);
                    tempwriteintoafile(value);
                    analyze(Float.valueOf(value), patient); // Added by Nihesh for analysis of incoming readings.

                    //ARV
                    /*try {
                    java.util.Date date = new java.util.Date();
                    Timestamp chk = new Timestamp(date.getTime());
                    long timemilli =  System.currentTimeMillis();
                    String abc = String.valueOf(timemilli);//chk.toString();
                    String separator = System.getProperty("line.separator");
                            
                    File ext = Environment.getExternalStorageDirectory();
                    File myFile = new File(ext, "mysdfile_7.txt");
                    if(myFile.exists()){
                       try {
                          FileOutputStream fOut = new FileOutputStream(myFile,true);
                           OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
                           myOutWriter.append(abc);
                           myOutWriter.append("   ");
                           myOutWriter.append(formattedText_1);
                           myOutWriter.append(separator);
                           myOutWriter.flush();
                           myOutWriter.close();
                           fOut.close();
                       } catch (Exception e) {
                          // TODO: handle exception
                       }
                    }
                    else{
                       myFile.createNewFile();
                    }
                            
                    //   File myFile = new File("/sdcard/mysdfile.txt");
                    //   myFile.createNewFile();
                    //   FileOutputStream fOut = new FileOutputStream(myFile);
                    //ARV            OutputStreamWriter myOutWriter = 
                    //ARV                              new OutputStreamWriter(openFileOutput(FILENAME, Context.MODE_APPEND));//fOut
                    //   myOutWriter.append(txtData.getText());
                    //ARV            myOutWriter.write(abc);
                    //ARV            myOutWriter.append(separator);
                    //ARV            myOutWriter.flush();
                    //ARV            myOutWriter.close();
                    //      fOut.close();
                    Toast.makeText(getBaseContext(),
                          "Done writing SD 'mysdfile.txt'",
                          Toast.LENGTH_SHORT).show();
                    } catch (Exception e) {
                    Toast.makeText(getBaseContext(), e.getMessage(),
                          Toast.LENGTH_SHORT).show();
                    } //ARV
                            
                    */

                } //endif

                /* else if (property.equals(PROPERTY_HUMIDITY)) {
                  double newHumidity = (Double) event.getNewValue();
                // ARV        TextView textView = (TextView) findViewById(R.id.humidityTxt);
                  String formattedText = decimal.format(newHumidity) + "%rH";
                //ARV         textView.setText(formattedText);
                } else if (property.equals(PROPERTY_MAGNETOMETER)) {
                  Point3D newValue = (Point3D) event.getNewValue();
                        
                  String msg = "X: " + decimal.format(newValue.x) + "uT" + "\nY: " + decimal.format(newValue.y) + "uT" + "\nZ: " + decimal.format(newValue.z) + "uT";
                        
                //ARV         ((TextView) findViewById(R.id.magnetometerTxt)).setText(msg);
                } else if (property.equals(PROPERTY_GYROSCOPE)) {
                  Point3D newValue = (Point3D) event.getNewValue();
                        
                  String msg = "X: " + decimal.format(newValue.x) + "deg/s" + "\nY: " + decimal.format(newValue.y) + "deg/s" + "\nZ: " + decimal.format(newValue.z)
                      + "deg/s";
                        
                //ARV          ((TextView) findViewById(R.id.gyroscopeTxt)).setText(msg);
                } else if (property.equals(Measurements.PROPERTY_BAROMETER)) {
                  Double newValue = (Double) event.getNewValue();
                        
                  String msg = new DecimalFormat("+0.0;-0.0").format(newValue / 100) + " hPa";
                        
                //ARV           ((TextView) findViewById(R.id.barometerTxt)).setText(msg);
                } else if (property.equals(PROPERTY_SIMPLE_KEYS)) {
                  SimpleKeysStatus newValue = (SimpleKeysStatus) event.getNewValue();
                        
                  final int img;
                  switch (newValue) {
                  case OFF_OFF:
                    img = buttonsoffoff;
                    break;
                  case OFF_ON:
                    img = buttonsoffon;
                    break;
                  case ON_OFF:
                    img = buttonsonoff;
                    break;
                  case ON_ON:
                    img = buttonsonon;
                    break;
                  default:
                    throw new UnsupportedOperationException();
                  }
                        
                  ((ImageView) findViewById(R.id.buttons)).setImageResource(img);
                }*/ else if (property.equals(LOST_DEVICE_ + CONNECTED)) {
                    // A device has been disconnected
                    // We notify the user with a toast

                    int duration = Toast.LENGTH_SHORT;
                    String text = "Lost connection";

                    Toast.makeText(ServicesActivity.this, text, duration).show();
                    finish();
                } else if (property.equals(NEW_DEVICE_ + CONNECTED)) {
                    // A device has been disconnected
                    // We notify the user with a toast

                    int duration = Toast.LENGTH_SHORT;
                    String text = "Established connection";

                    Toast.makeText(ServicesActivity.this, text, duration).show();
                }
            } catch (NullPointerException e) {
                e.printStackTrace();
                // Could be that the ServicesFragment is no longer visible
                // But we still receive property change events.
                // referring to the views with findViewById will then return a null.
            }
        }
    });
}

From source file:com.icsshs.datatransfer.database.impl.QueryBeanProcessor.java

/**
 * Convert a <code>ResultSet</code> column into an object.  Simple
 * implementations could just call <code>rs.getObject(index)</code> while
 * more complex implementations could perform type manipulation to match
 * the column's type to the bean property type.
 *
 * <p>//from ww  w  .ja  v  a  2s. c  om
 * This implementation calls the appropriate <code>ResultSet</code> getter
 * method for the given property type to perform the type conversion.  If
 * the property type doesn't match one of the supported
 * <code>ResultSet</code> types, <code>getObject</code> is called.
 * </p>
 *
 * @param rs The <code>ResultSet</code> currently being processed.  It is
 * positioned on a valid row before being passed into this method.
 *
 * @param index The current column index being processed.
 *
 * @param propType The bean property type that this column needs to be
 * converted into.
 *
 * @throws SQLException if a database access error occurs
 *
 * @return The object from the <code>ResultSet</code> at the given column
 * index after optional type processing or <code>null</code> if the column
 * value was SQL NULL.
 */
protected Object processColumn(ResultSet rs, int index, Class<?> propType) throws SQLException {

    if (!propType.isPrimitive() && rs.getObject(index) == null) {
        return null;
    }

    if (propType.equals(String.class)) {
        return rs.getString(index);

    } else if (propType.equals(Integer.TYPE) || propType.equals(Integer.class)) {
        return Integer.valueOf(rs.getInt(index));

    } else if (propType.equals(Boolean.TYPE) || propType.equals(Boolean.class)) {
        return Boolean.valueOf(rs.getBoolean(index));

    } else if (propType.equals(Long.TYPE) || propType.equals(Long.class)) {
        return Long.valueOf(rs.getLong(index));

    } else if (propType.equals(Double.TYPE) || propType.equals(Double.class)) {
        return Double.valueOf(rs.getDouble(index));

    } else if (propType.equals(Float.TYPE) || propType.equals(Float.class)) {
        return Float.valueOf(rs.getFloat(index));

    } else if (propType.equals(Short.TYPE) || propType.equals(Short.class)) {
        return Short.valueOf(rs.getShort(index));

    } else if (propType.equals(Byte.TYPE) || propType.equals(Byte.class)) {
        return Byte.valueOf(rs.getByte(index));

    } else if (propType.equals(Timestamp.class)) {
        return rs.getTimestamp(index);

    } else if (propType.equals(byte[].class)) {
        return rs.getBytes(index);

    } else {
        return rs.getObject(index);

    }

}