List of usage examples for java.lang Float valueOf
@HotSpotIntrinsicCandidate public static Float valueOf(float f)
From source file:com.matchpoint.smartmove.content.pearson.PearsonReaderText.java
/** * <Pre>//w ww .ja v a 2 s . c o m * { * "block":{ * "@parent":"EWTG_LONDON097APSHOU", * "title":{ * "#text":"Apsley House" * }, * "tg_info":{ * "@id":"EWTG_LONDON097APSHOU_001", * "@lat":"51.50331", * "@long":"-0.151641", * "address":{ * "#text":"Hyde Park Corner W1" * }, * "map_ref":{ * "#text":"12 D4" * }, * "phone":{ * "#text":"020 7499 5676" * }, * "transport":{ * "@role":"underground_railway", * "@keyref":"EWTG_LONDONKEYMAI_001", * "#text":"Hyde Park Corner" * }, * "opening_info":{ * "@keyref":"EWTG_LONDONKEYMAI_023", * "#text":"AprOct: 11am5pm WedSun & bank hols; NovMar: 11am4pm WedSun & bank hols" * }, * "closing_info":{ * "@keyref":"EWTG_LONDONKEYMAI_025", * "#text":"2426 Dec, 1 Jan" * }, * "admission_charge":{ * "@keyref":"EWTG_LONDONKEYMAI_021", * "#text":"joint ticket with Wellington Arch available" * }, * "tg_data":[ * { * "@role":"photography", * "@keyref":"EWTG_LONDONKEYMAI_007" * }, * { * "@role":"audio_tours", * "@keyref":"EWTG_LONDONKEYMAI_011" * }, * { * "@role":"guided_tours", * "@keyref":"EWTG_LONDONKEYMAI_010", * "#text":"pre-booked only" * } * ], * "url":{ * "#text":"www.english-heritage.org.uk" * } * } * } * } * @throws Exception */ // @Test public void getEntryRss() throws Exception { HttpConnectionManager manager = new HttpConnectionManager(PEARSON_URL, false); ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally JsonNode rootNode = mapper.readValue( new String(manager.getByteArrayResourcePost( "/eyewitness/london/block.json?lon=-0.164739&lat=51.497866&apikey=" + API_KEY, null, null)), JsonNode.class); java.util.Iterator<JsonNode> it = rootNode.get("list").get("link").getElements(); while (it.hasNext()) { JsonNode entry = it.next(); System.out.println(entry.get("@id")); // Chiamo la singola string per eseguire la query // https://api.pearson.com/eyewitness/london/block/EWTG_LONDON097APSHOU_001.json?apikey=d14b9d3c132ba476437046de8b1395a8 ObjectMapper mapper_item = new ObjectMapper(); String id = entry.get("@id").getTextValue(); JsonNode itemNode = mapper.readValue( new String(manager.getByteArrayResourcePost( "/eyewitness/london/block/" + id + ".json?apikey=" + API_KEY, null, null)), JsonNode.class); System.out.println(itemNode.toString()); JsonNode block = itemNode.get("block"); String text = block.get("title").get("#text").getTextValue(); System.out.println(id); Item item = new Item(); // Category c = new Category("pearson"); // item.setCategory(c); item.setGid(new Gid("PEARSON")); item.setItemId(id); JsonNode tagInfo = block.get("tg_info"); Category c = new Category(tagInfo.get("info").get("category").get("@text").getTextValue()); item.setCategory(c); Cost cost = new Cost(); if (tagInfo.get("admission_charge") != null) { cost.setItem(item); cost.setLocale(Locale.ENGLISH); cost.setValue(tagInfo.get("admission_charge").getTextValue()); item.setWebsite(tagInfo.get("url").get("#text").getTextValue()); item.getCosts().add(cost); } String description = text; if (tagInfo.get("opening_info") != null) { description += "Opening:" + tagInfo.get("opening_info").get("#text").getTextValue(); } if (tagInfo.get("closing_info") != null) { description += "Closing: " + tagInfo.get("closing_info").get("#text").getTextValue(); } item.getLocalizedItems().add(new LocalizedItem(item, Label.Description, Locale.ENGLISH, description)); item.getLocalizedItems().add(new LocalizedItem(item, Label.Title, Locale.ENGLISH, text)); item.getGpsPositions() .add(new GpsPosition(item, Float.valueOf(tagInfo.get("@lat").getTextValue()), Float.valueOf(tagInfo.get("@long").getTextValue()), tagInfo.get("address").get("#text").getTextValue(), "London")); itemService.saveOrUpdate(item); } // JSON.parse(new // String(manager.getByteArrayResourcePost("eyewitness/london/block.json", // null, params)); }
From source file:com.github.binlee1990.transformers.spider.PersonCrawler.java
@Override public void visit(Page page) { int docid = page.getWebURL().getDocid(); String url = page.getWebURL().getURL(); logger.info(url);//from w w w.j a v a 2 s. co m if (!url.startsWith("http://www.javlibrary.com/cn/?v=jav")) { return; } if (page.getParseData() instanceof HtmlParseData) { HtmlParseData htmlParseData = (HtmlParseData) page.getParseData(); String html = htmlParseData.getHtml(); Document doc = Jsoup.parse(html); String videoIdentificationCode = doc.select("div#video_id td.text").first().text().toString(); Video queryVideo = new Video(); queryVideo.setIdentificationCode(videoIdentificationCode); Video video = videoMapper.queryByVideo(queryVideo); if (null != video) { return; } video = new Video(); video.setUrl(url); Date now = new Date(); video.setCreateTime(now); video.setUpdateTime(now); String title = doc.select("div#video_title a").first().text().toString(); video.setTitle(title); video.setIdentificationCode(videoIdentificationCode); Elements rdElements = doc.select("div#video_date td.text"); if (CollectionUtils.isNotEmpty(rdElements)) { String releaseDate = rdElements.first().text().toString(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { Date date = sdf.parse(releaseDate); video.setReleaseDate(date); } catch (ParseException e) { } } Elements dmElements = doc.select("div#video_length span.text"); if (CollectionUtils.isNotEmpty(dmElements)) { String durationMinutes = dmElements.first().text().toString(); video.setDurationMinutes(Integer.valueOf(durationMinutes)); } Elements dElements = doc.select("div#video_director td.text"); if (CollectionUtils.isNotEmpty(dElements)) { String director = dElements.first().text().toString(); video.setDirector(director); } Elements pElements = doc.select("div#video_maker td.text"); if (CollectionUtils.isNotEmpty(pElements)) { String producer = pElements.first().text().toString(); video.setProducer(producer); } Elements disElements = doc.select("div#video_label td.text"); if (CollectionUtils.isNotEmpty(disElements)) { String distributor = disElements.first().text().toString(); video.setDistributor(distributor); } Elements countElements = doc.select("div#video_favorite_edit span"); if (CollectionUtils.isNotEmpty(countElements)) { Elements countWantedElements = countElements.select("#subscribed a"); if (CollectionUtils.isNotEmpty(countWantedElements)) { String countWanted = countWantedElements.first().text(); try { video.setCountWanted(Integer.valueOf(countWanted)); } catch (Exception e) { } } Elements countWatchedElements = countElements.select("#watched a"); if (CollectionUtils.isNotEmpty(countWatchedElements)) { String countWatched = countWatchedElements.first().text(); try { video.setCountWatched(Integer.valueOf(countWatched)); } catch (Exception e) { } } Elements countOwnedElements = countElements.select("#owned a"); if (CollectionUtils.isNotEmpty(countOwnedElements)) { String countOwned = countOwnedElements.first().text(); try { video.setCountOwned(Integer.valueOf(countOwned)); } catch (Exception e) { } } } Elements sElements = doc.select("div#video_review td.text span.score"); if (CollectionUtils.isNotEmpty(sElements)) { String score = sElements.first().text().toString(); score = StringUtils.replace(score, "(", ""); score = StringUtils.replace(score, ")", ""); if (StringUtils.isNotBlank(score)) { try { video.setScore(Float.valueOf(score)); } catch (Exception e) { } } } Elements actressElements = doc.select("div#video_cast span.star"); if (CollectionUtils.isNotEmpty(actressElements)) { if (actressElements.size() <= 1) { video.setSingleFemaleFlag(true); } else { video.setSingleFemaleFlag(false); } } videoMapper.insertSelective(video); int videoId = videoMapper.queryByVideo(video).getId(); logger.info("handle " + videoId + "\n" + JSON.toJSONString(video)); if (CollectionUtils.isNotEmpty(actressElements)) { actressElements.stream().forEach(a -> { String aName = a.text().toString().trim(); if (StringUtils.isNotBlank(aName)) { Actress queryActress = new Actress(); queryActress.setName(aName); Actress actress = actressMapper.queryByActress(queryActress); if (null != actress) { VideoActress va = new VideoActress(); va.setActressCode(actress.getCode()); va.setVideoId(videoId); videoActressMapper.insertSelective(va); } else { actress = new Actress(); actress.setName(aName); actressMapper.insertSelective(actress); int actressId = actressMapper.queryByActress(actress).getId(); VideoActress va = new VideoActress(); va.setActressCode(actress.getCode()); va.setVideoId(videoId); videoActressMapper.insertSelective(va); } } }); } Elements categoryElements = doc.select("div#video_genres span.genre"); if (CollectionUtils.isNotEmpty(categoryElements)) { categoryElements.stream().forEach(c -> { String cDescription = c.text().toString().trim(); if (StringUtils.isNotBlank(cDescription)) { Category queryCategory = new Category(); queryCategory.setSubtype(cDescription); Category category = categoryMapper.queryByCategory(queryCategory); if (null != category) { VideoCategory vc = new VideoCategory(); vc.setCategoryId(category.getId()); vc.setCategoryDescription(category.getSubtype()); vc.setVideoId(videoId); videoCategoryMapper.insertSelective(vc); } else { category = new Category(); category.setSubtype(cDescription); categoryMapper.insertSelective(category); int categoryId = categoryMapper.queryByCategory(category).getId(); VideoCategory vc = new VideoCategory(); vc.setCategoryId(categoryId); vc.setCategoryDescription(category.getSubtype()); vc.setVideoId(videoId); videoCategoryMapper.insertSelective(vc); } } }); } } }
From source file:de.iteratec.svg.SvgGraphicWriter.java
/** * Converts the generated SVG Document to a PDF and writes in onto the given output stream. * /*from www . ja va 2 s. c om*/ * @param document * SVG-{@link Document} to write as PDF * @param outputStream * The stream to write to. * @throws SvgExportException * Iff the write operation was unsuccessful. */ public static void writeToPDF(org.w3c.dom.Document document, OutputStream outputStream) throws SvgExportException { PDFTranscoder t = new PDFTranscoder(); LOGGER.debug("Trying to write the document to the output stream as PDF."); // Set the transcoding hints. Double width = getWidthFromDom(document); if (width != null) { t.addTranscodingHint(PDFTranscoder.KEY_WIDTH, Float.valueOf(width.floatValue())); } write(document, outputStream, t); }
From source file:au.edu.archer.dimsim.plugins.sensorDisplayController.java
private float getCurrSensorData(String urlParam) { float data = 0.0f; //System.out.println("in with "+ urlParam); try {//from www . j a v a2 s . c o m URL sensorURL = new URL(this.sensorBaseURL + "/" + urlParam); URLConnection uc = sensorURL.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream())); String dataStr = in.readLine(); in.close(); data = Float.valueOf(dataStr).floatValue(); } catch (IOException e) { // do nothing } return data; }
From source file:io.coala.config.AbstractPropertyGetter.java
/** * @return * @throws CoalaException */ public Float getFloat() throws CoalaRuntimeException { return Float.valueOf(get()); }
From source file:com.qihang.winter.poi.excel.imports.CellValueServer.java
/** * ??/*from w w w. j a va 2 s . c o m*/ * * @param xclass * @param result * @param entity * @return */ private Object getValueByType(String xclass, Object result, ExcelImportEntity entity) { try { if ("class java.util.Date".equals(xclass)) { return result; } if ("class java.lang.Boolean".equals(xclass) || "boolean".equals(xclass)) { return Boolean.valueOf(String.valueOf(result)); } if ("class java.lang.Double".equals(xclass) || "double".equals(xclass)) { return result == null || result.equals("") ? null : Double.valueOf(String.valueOf(result)); } if ("class java.lang.Long".equals(xclass) || "long".equals(xclass)) { return result == null || result.equals("") ? null : Long.valueOf(String.valueOf(result)); } if ("class java.lang.Float".equals(xclass) || "float".equals(xclass)) { return result == null || result.equals("") ? null : Float.valueOf(String.valueOf(result)); } if ("class java.lang.Integer".equals(xclass) || "int".equals(xclass)) { return result == null || result.equals("") ? null : Integer.valueOf(String.valueOf(result)); } if ("class java.math.BigDecimal".equals(xclass)) { return new BigDecimal(String.valueOf(result)); } if ("class java.lang.String".equals(xclass)) { //String ,Excel????String,Double, if (result instanceof String) { return result; } // double if (result instanceof Double) { return PoiPublicUtil.doubleToString((Double) result); } return String.valueOf(result); } return result; } catch (Exception e) { LOGGER.error(e.getMessage(), e); throw new ExcelImportException(ExcelImportEnum.GET_VALUE_ERROR); } }
From source file:com.kircherelectronics.accelerationexplorer.activity.NoiseActivity.java
private float getPrefMeanFilterSmoothingTimeConstant() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); return Float.valueOf(prefs.getString(NoiseConfigActivity.MEAN_FILTER_SMOOTHING_TIME_CONSTANT_KEY, "1")); }
From source file:com.pandich.dropwizard.curator.refresh.Refresher.java
protected final Object getValue(final A element, final NodeValue nodeValue) { final String rawValue = nodeValue.getValue(); final Class<?> clazz = getType(element); final CuratorMapper<?> mapper = this.mappers.get(clazz); if (mapper != null) { return mapper.readValueFroMString(rawValue); }/*w w w. ja v a2 s . co m*/ if (isAssignable(clazz, String.class)) { return rawValue; } if (isAssignable(clazz, Boolean.class)) { return Boolean.valueOf(rawValue); } if (isAssignable(clazz, Character.class)) { return CharUtils.toChar(rawValue); } if (isAssignable(clazz, Byte.class)) { return Byte.valueOf(rawValue); } if (isAssignable(clazz, Short.class)) { return Short.valueOf(rawValue); } if (isAssignable(clazz, Integer.class)) { return Integer.valueOf(rawValue); } if (isAssignable(clazz, Long.class)) { return Long.valueOf(rawValue); } if (isAssignable(clazz, Float.class)) { return Float.valueOf(rawValue); } if (isAssignable(clazz, Double.class)) { return Double.valueOf(rawValue); } if (isAssignable(clazz, BigInteger.class)) { return new BigInteger(rawValue); } if (isAssignable(clazz, BigDecimal.class)) { return new BigDecimal(rawValue); } try { return objectMapper.readValue(rawValue, clazz); } catch (IOException e) { throw new RuntimeException("type '" + clazz.getName() + "' is not supported", e); } }
From source file:cc.redpen.validator.Validator.java
protected float getFloat(String name) { Object value = getOrDefault(name); if (value instanceof Float) { return (float) value; } else {//from w w w. ja v a 2 s . co m return Float.valueOf((String) value); } }
From source file:com.eventsourcing.postgresql.PostgreSQLJournalTest.java
@Test @SneakyThrows//from ww w . j a v a 2 s .c o m public void serializationNull() { HybridTimestamp timestamp = new HybridTimestamp(timeProvider); timestamp.update(); Journal.Transaction tx = journal.beginTransaction(); SerializationEvent event = SerializationEvent.builder().test(TestClass.builder().build()).build(); event = (SerializationEvent) journal.journal(tx, event); tx.rollback(); TestClass test = event.getTest(); assertEquals(test.pByte, 0); assertEquals(test.oByte, Byte.valueOf((byte) 0)); assertEquals(test.pByteArr.length, 0); assertEquals(test.oByteArr.length, 0); assertEquals(test.pShort, 0); assertEquals(test.oShort, Short.valueOf((short) 0)); assertEquals(test.pInt, 0); assertEquals(test.oInt, Integer.valueOf(0)); assertEquals(test.pLong, 0); assertEquals(test.oLong, Long.valueOf(0)); assertTrue(test.pFloat == 0.0); assertEquals(test.oFloat, Float.valueOf((float) 0.0)); assertEquals(test.pDouble, 0.0); assertEquals(test.oDouble, Double.valueOf(0.0)); assertEquals(test.pBoolean, false); assertEquals(test.oBoolean, Boolean.FALSE); assertEquals(test.str, ""); assertEquals(test.uuid, new UUID(0, 0)); assertEquals(test.e, TestClass.E.A); assertNotNull(test.value); assertEquals(test.value.value, ""); assertNotNull(test.value1); assertTrue(test.value1.value().isEmpty()); assertNotNull(test.list); assertEquals(test.list.size(), 0); assertNotNull(test.map); assertEquals(test.map.size(), 0); assertNotNull(test.optional); assertFalse(test.optional.isPresent()); assertNotNull(test.bigDecimal); assertEquals(test.bigDecimal, BigDecimal.ZERO); assertNotNull(test.bigInteger); assertEquals(test.bigInteger, BigInteger.ZERO); assertNotNull(test.date); assertEquals(test.date, new Date(0)); }