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:com.chinamobile.bcbsp.examples.bytearray.pagerank.PRVertexLiteNew.java

@Override
public void fromString(String vertexData) throws Exception {
    String[] buffer = new String[2];
    StringTokenizer str = new StringTokenizer(vertexData, Constants.KV_SPLIT_FLAG);
    if (str.hasMoreElements()) {
        buffer[0] = str.nextToken();//from   w  w  w .ja  va2  s.  co m
    } else {
        throw new Exception();
    }
    if (str.hasMoreElements()) {
        buffer[1] = str.nextToken();
    }
    str = new StringTokenizer(buffer[0], Constants.SPLIT_FLAG);
    if (str.countTokens() != 2) {
        throw new Exception();
    }
    this.vertexID = Integer.valueOf(str.nextToken());
    this.vertexValue = Float.valueOf(str.nextToken());
    if (buffer[1].length() > 0) { // There has edges.
        str = new StringTokenizer(buffer[1], Constants.SPACE_SPLIT_FLAG);
        while (str.hasMoreTokens()) {
            PREdgeLiteNew edge = new PREdgeLiteNew();
            edge.fromString(str.nextToken());
            this.edgesList.add(edge);
        }
    }
}

From source file:CB_Core.GCVote.GCVote.java

public static ArrayList<RatingData> GetRating(String User, String password, ArrayList<String> Waypoints) {
    ArrayList<RatingData> result = new ArrayList<RatingData>();

    String data = "userName=" + User + "&password=" + password + "&waypoints=";
    for (int i = 0; i < Waypoints.size(); i++) {
        data += Waypoints.get(i);//from w ww  .j  a  v a2s .  co  m
        if (i < (Waypoints.size() - 1))
            data += ",";
    }

    try {
        HttpPost httppost = new HttpPost("http://gcvote.de/getVotes.php");

        httppost.setEntity(new ByteArrayEntity(data.getBytes("UTF8")));

        // Log.info(log, "GCVOTE-Post" + data);

        // Execute HTTP Post Request
        String responseString = Execute(httppost);

        // Log.info(log, "GCVOTE-Response" + responseString);

        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        InputSource is = new InputSource();
        is.setCharacterStream(new StringReader(responseString));

        Document doc = db.parse(is);

        NodeList nodelist = doc.getElementsByTagName("vote");

        for (Integer i = 0; i < nodelist.getLength(); i++) {
            Node node = nodelist.item(i);

            RatingData ratingData = new RatingData();
            ratingData.Rating = Float.valueOf(node.getAttributes().getNamedItem("voteAvg").getNodeValue());
            String userVote = node.getAttributes().getNamedItem("voteUser").getNodeValue();
            ratingData.Vote = (userVote == "") ? 0 : Float.valueOf(userVote);
            ratingData.Waypoint = node.getAttributes().getNamedItem("waypoint").getNodeValue();
            result.add(ratingData);

        }

    } catch (Exception e) {
        String Ex = "";
        if (e != null) {
            if (e != null && e.getMessage() != null)
                Ex = "Ex = [" + e.getMessage() + "]";
            else if (e != null && e.getLocalizedMessage() != null)
                Ex = "Ex = [" + e.getLocalizedMessage() + "]";
            else
                Ex = "Ex = [" + e.toString() + "]";
        }
        Log.err(log, "GcVote-Error" + Ex);
        return null;
    }
    return result;

}

From source file:com.zhengxuetao.gupiao.service.impl.DayServiceImpl.java

@Override
public boolean saveDayDataFromFile(File file) {
    if (file != null && file.exists() && file.isFile()) {
        DayData dayData = new DayData();
        String fileName = file.getName(); //SH#600004.txt
        dayData.setFinanceId(Long.parseLong(fileName.substring(3, 9)));
        String encoding = "GBK";
        InputStreamReader reader = null;
        DateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
        DateFormat parseFormat = new SimpleDateFormat("yyyy-mm-dd");
        try {/*from w  ww .  j a  va2s.com*/
            reader = new InputStreamReader(new FileInputStream(file), encoding);
            BufferedReader bufferedReader = new BufferedReader(reader);
            String readLine;
            while ((readLine = bufferedReader.readLine()) != null) {
                //??????????
                String[] arr = readLine.split(",");
                dayData.setTime(Timestamp.valueOf(format.format(parseFormat.parse(arr[0]))));
                dayData.setStartPrice(Float.valueOf(arr[1]));
                dayData.setHighPrice(Float.valueOf(arr[2]));
                dayData.setLowPrice(Float.valueOf(arr[3]));
                dayData.setEndPrice(Float.valueOf(arr[4]));
                dayData.setVolume(Long.valueOf(arr[5]));
                dayData.setAmount(Double.valueOf(arr[6]));
                userDAO.saveDayData(dayData);
            }
        } catch (IOException | ParseException ex) {
            logger.error(ex.getMessage());
        } finally {
            try {
                reader.close();
            } catch (IOException ex) {
                logger.error(ex.getMessage());
            }
        }
    } else {
        logger.error("?!");
    }
    return true;
}

From source file:gov.nih.nci.caintegrator.application.analysis.SegmentDatasetFileWriterTest.java

private List<SegmentData> createTestResult() {
    List<SegmentData> dataSet = new ArrayList<SegmentData>();
    SegmentData result = new SegmentData();
    result.setArrayData(new ArrayData());
    result.getArrayData().setSample(new Sample());
    result.getArrayData().getSample().setName("Sample 1");
    result.setLocation(new ChromosomalLocation());
    result.getLocation().setChromosome("1");
    result.getLocation().setStartPosition(Integer.valueOf(1));
    result.getLocation().setEndPosition(Integer.valueOf(5));
    result.setSegmentValue(Float.valueOf("0.1"));
    dataSet.add(result);//  w  w w  .  j av  a  2  s  .c om

    result = new SegmentData();
    result.setArrayData(new ArrayData());
    result.getArrayData().setSample(new Sample());
    result.getArrayData().getSample().setName("Sample 2");
    result.setLocation(new ChromosomalLocation());
    result.getLocation().setChromosome("2");
    result.getLocation().setStartPosition(Integer.valueOf(6));
    result.getLocation().setEndPosition(Integer.valueOf(9));
    result.setSegmentValue(Float.valueOf("0.2"));
    dataSet.add(result);

    return dataSet;
}

From source file:gov.nih.nci.caintegrator.web.action.analysis.KMPlotGeneExpressionBasedAction.java

private void retrieveFormValues() {
    if (NumberUtils.isNumber(getForm().getOverexpressedNumber())) {
        kmPlotParameters.setOverValue(Float.valueOf(getForm().getOverexpressedNumber()));
    }//from w ww.  ja v a2s  .c  om
    if (NumberUtils.isNumber(getForm().getUnderexpressedNumber())) {
        kmPlotParameters.setUnderValue(Float.valueOf(getForm().getUnderexpressedNumber()));
    }
    kmPlotParameters.setGeneSymbol(getForm().getGeneSymbol());
    kmPlotParameters.setControlSampleSetName(getForm().getControlSampleSetName());
    kmPlotParameters.setExpressionType(getForm().getExpressionType());
    kmPlotParameters.setPlatformName(getForm().getPlatformName());
}

From source file:org.opens.color.finder.webapp.validator.ColorModelValidator.java

private Float isValidRatio(String ratio) {
    try {/*from  ww w. j  a  v  a2s .  co  m*/
        Float.parseFloat(ratio);
    } catch (NumberFormatException nfe) {
        return 0.0f;
    }
    Float coeff = Float.valueOf(ratio);
    if (coeff >= MIN_VALID_RATIO && coeff <= MAX_VALID_RATIO) {
        return coeff;
    } else {
        return Float.valueOf(0.0f);
    }
}

From source file:ch.cyberduck.cli.TerminalTransferFactory.java

public Transfer create(final CommandLine input, final Host host, final Path remote,
        final List<TransferItem> items) throws BackgroundException {
    final Transfer transfer;
    final TerminalAction type = TerminalActionFinder.get(input);
    if (null == type) {
        throw new BackgroundException(LocaleFactory.localizedString("Unknown"), "Unknown transfer type");
    }//from  www .j  a v  a  2 s. co m
    switch (type) {
    case download:
        if (StringUtils.containsAny(remote.getName(), '*')) {
            transfer = new DownloadTransfer(host, items, new DownloadGlobFilter(remote.getName()));
        } else {
            transfer = new DownloadTransfer(host, items);
        }
        break;
    case upload:
        transfer = new UploadTransfer(host, items);
        break;
    case synchronize:
        transfer = new SyncTransfer(host, items.iterator().next());
        break;
    default:
        throw new BackgroundException(LocaleFactory.localizedString("Unknown"),
                String.format("Unknown transfer type %s", type.name()));
    }
    if (input.hasOption(TerminalOptionsBuilder.Params.throttle.name())) {
        try {
            transfer.setBandwidth(
                    Float.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.throttle.name())));
        } catch (NumberFormatException ignore) {
            //
        }
    }
    return transfer;
}

From source file:net.antidot.semantic.rdf.rdb2rdf.r2rml.core.R2RMLProcessor.java

/**
 * Convert a database into a RDF graph from a database Connection
 * and a R2RML instance (with native storage).
 * @throws R2RMLDataError /*  ww  w . j av  a 2s . co m*/
 * @throws InvalidR2RMLSyntaxException 
 * @throws InvalidR2RMLStructureException 
 * @throws IOException 
 * @throws RDFParseException 
 * @throws RepositoryException 
 */
public static SesameDataSet convertDatabase(Connection conn, String pathToR2RMLMappingDocument, String baseIRI,
        String pathToNativeStore, DriverType driver) throws InstantiationException, IllegalAccessException,
        ClassNotFoundException, SQLException, R2RMLDataError, InvalidR2RMLStructureException,
        InvalidR2RMLSyntaxException, RepositoryException, RDFParseException, IOException {
    log.info("[R2RMLMapper:convertMySQLDatabase] Start Mapping R2RML...");
    // Init time
    start = System.currentTimeMillis();
    // Extract R2RML Mapping object
    R2RMLMapping r2rmlMapping = null;

    R2RMLProcessor.driver = driver;
    r2rmlMapping = R2RMLMappingFactory.extractR2RMLMapping(pathToR2RMLMappingDocument, driver);

    // Connect database
    R2RMLEngine r2rmlEngine = new R2RMLEngine(conn);
    SesameDataSet result = r2rmlEngine.runR2RMLMapping(r2rmlMapping, baseIRI, pathToNativeStore);
    log.info("[R2RMLMapper:convertDatabase] Mapping R2RML done.");
    Float stop = Float.valueOf(System.currentTimeMillis() - start) / 1000;
    log.info("[R2RMLMapper:convertDatabase] Database extracted in " + stop + " seconds.");
    log.info("[R2RMLMapper:convertDatabase] Number of extracted triples : " + result.getSize());

    R2RMLProcessor.driver = null;
    return result;
}

From source file:net.antidot.semantic.rdf.rdb2rdf.dm.core.DirectMapper.java

public static SesameDataSet generateDirectMapping(Connection conn, Version version, DriverType driver,
        String baseURI, String timeZone, String fileToNativeStore) throws UnsupportedEncodingException {
    log.info("Generate Direct Mapping...");
    Long start = System.currentTimeMillis();
    SesameDataSet result = null;/*  ww w. j  av  a2  s .  c  o m*/
    // Check if use of native store is required
    if (fileToNativeStore != null) {
        result = new SesameDataSet(fileToNativeStore, false);
    } else {
        result = new SesameDataSet();
    }
    DirectMappingEngine dme = null;
    switch (version) {
    case WD_20110324:
        dme = new DirectMappingEngineWD20110324();
        break;
    case WD_20120529:
        dme = new DirectMappingEngineWD20120529();
        break;
    default:
        // Working draft Mars 2011 by default
        dme = new DirectMappingEngineWD20110324();
        break;
    }
    TupleExtractor te = new TupleExtractor(conn, dme, driver, timeZone);
    nbTriples = 0;
    lastModulo = 0;
    while (te.next()) {
        convertNextTuple(result, te, dme, driver, baseURI);
    }
    Float stop = Float.valueOf(System.currentTimeMillis() - start) / 1000;
    log.info("Database extracted in " + stop + " seconds.");
    log.info(nbTriples + " triples has been extracted.");
    return result;
}

From source file:com.github.rnewson.couchdb.lucene.couchdb.ViewSettings.java

private ViewSettings(final String field, final String index, final String store, final String type,
        final String boost, final String termvector, final ViewSettings defaults) {
    this.field = field != null ? field : defaults.getField();
    this.index = index != null ? Index.valueOf(index.toUpperCase()) : defaults.getIndex();
    this.store = store != null ? Store.valueOf(store.toUpperCase()) : defaults.getStore();
    this.type = type != null ? FieldType.valueOf(type.toUpperCase()) : defaults.getFieldType();
    this.boost = boost != null ? Float.valueOf(boost) : defaults.getBoost();
    this.termvector = termvector != null ? TermVector.valueOf(termvector.toUpperCase())
            : defaults.getTermVector();/*from  w  w w  .j  av  a  2  s .c o m*/
}