List of usage examples for java.lang Float floatValue
@HotSpotIntrinsicCandidate public float floatValue()
From source file:org.apache.jmeter.protocol.http.parser.HTMLParser.java
/** * /*from ww w.j a va 2s.c om*/ * @param ieVersion Float IE version * @return true if IE version < IE v10 */ protected final boolean isEnableConditionalComments(Float ieVersion) { // Conditional comment have been dropped in IE10 // http://msdn.microsoft.com/en-us/library/ie/hh801214%28v=vs.85%29.aspx return ieVersion != null && ieVersion.floatValue() < IE_10; }
From source file:org.intermine.bio.dataconversion.PdbConverter.java
private void processPDBFile(File file, String taxonId) throws Exception { Item proteinStructure = createItem("ProteinStructure"); PDBFileParser pdbfileparser = new PDBFileParser(); Reader reader = new FileReader(file); PdbBufferedReader pdbBuffReader = new PdbBufferedReader(reader); Structure structure = pdbfileparser.parsePDBFile(pdbBuffReader); String idCode = (String) structure.getHeader().get("idCode"); if (StringUtils.isNotEmpty(idCode)) { proteinStructure.setAttribute("identifier", idCode); } else {/* w w w . ja v a 2 s .c o m*/ throw new BuildException("No value for title in structure: " + idCode); } List<String> dbrefs = pdbBuffReader.getDbrefs(); for (String accnum : dbrefs) { String proteinRefId = getProtein(accnum, taxonId); proteinStructure.addToCollection("proteins", proteinRefId); } String title = (((String) structure.getHeader().get("title"))).trim(); if (StringUtils.isNotEmpty(title)) { proteinStructure.setAttribute("title", title); } else { LOG.warn("No value for title in structure: " + idCode); } String technique = ((String) structure.getHeader().get("technique")).trim(); if (StringUtils.isNotEmpty(technique)) { proteinStructure.setAttribute("technique", technique); } else { LOG.warn("No value for technique in structure: " + idCode); } String classification = ((String) structure.getHeader().get("classification")).trim(); proteinStructure.setAttribute("classification", classification); Object resolution = structure.getHeader().get("resolution"); if (resolution instanceof Float) { final Float resolutionFloat = (Float) structure.getHeader().get("resolution"); proteinStructure.setAttribute("resolution", Float.toString(resolutionFloat.floatValue())); } try { proteinStructure.setAttribute("atm", structure.toPDB()); } catch (ArrayIndexOutOfBoundsException e) { LOG.error("Failed to process structure " + idCode); } store(proteinStructure); }
From source file:net.lightbody.bmp.proxy.jetty.http.HttpFields.java
/** List values in quality order. * @param enm Enumeration of values with quality parameters * @return values in quality order./*from w w w . j a v a 2 s.c o m*/ */ public static List qualityList(Enumeration enm) { if (enm == null || !enm.hasMoreElements()) return Collections.EMPTY_LIST; Object list = null; Object qual = null; // Assume list will be well ordered and just add nonzero while (enm.hasMoreElements()) { String v = enm.nextElement().toString(); Float q = getQuality(v); if (q.floatValue() >= 0.001) { list = LazyList.add(list, v); qual = LazyList.add(qual, q); } } List vl = LazyList.getList(list, false); if (vl.size() < 2) return vl; List ql = LazyList.getList(qual, false); // sort list with swaps Float last = __zero; for (int i = vl.size(); i-- > 0;) { Float q = (Float) ql.get(i); if (last.compareTo(q) > 0) { Object tmp = vl.get(i); vl.set(i, vl.get(i + 1)); vl.set(i + 1, tmp); ql.set(i, ql.get(i + 1)); ql.set(i + 1, q); last = __zero; i = vl.size(); continue; } last = q; } ql.clear(); return vl; }
From source file:com.stimulus.archiva.language.LanguageIdentifier.java
/** * Identify language of content.//from w ww. j av a 2s . co m * * @param content is the content to analyze. * @return The 2 letter * <a href="http://www.w3.org/WAI/ER/IG/ert/iso639.htm">ISO 639 * language code</a> (en, fi, sv, ...) of the language that best * matches the specified content. */ public synchronized String identify(StringBuffer content) { //logger.debug("language identification sample:"); //logger.debug(content.toString()); StringBuffer text = content; if ((analyzeLength > 0) && (content.length() > analyzeLength)) { text = new StringBuffer().append(content); text.setLength(analyzeLength); } suspect.analyze(text); Iterator iter = suspect.getSorted().iterator(); float topscore = Float.MIN_VALUE; String lang = null; HashMap scores = new HashMap(); NGramEntry searched = null; while (iter.hasNext()) { searched = (NGramEntry) iter.next(); NGramEntry[] ngrams = (NGramEntry[]) ngramsIdx.get(searched.getSeq()); if (ngrams != null) { for (int j = 0; j < ngrams.length; j++) { NGramProfile profile = ngrams[j].getProfile(); Float pScore = (Float) scores.get(profile); if (pScore == null) { pScore = new Float(0); } float plScore = pScore.floatValue(); plScore += ngrams[j].getFrequency() + searched.getFrequency(); scores.put(profile, new Float(plScore)); if (plScore > topscore) { topscore = plScore; lang = profile.getName(); } } } } logger.debug("document language identified {language='" + lang + "'}"); return lang; }
From source file:ome.server.itests.query.pojos.QueryTest.java
private void assertFloatsNotRounded(double dbl) { Correction correction = iQuery.findAll(Correction.class, null).get(0); Immersion immersion = iQuery.findAll(Immersion.class, null).get(0); Objective o = new Objective(); Instrument instrument = new Instrument(); o.setCorrection(correction);// www . j ava 2 s.co m o.setImmersion(immersion); o.setInstrument(instrument); // o.setLensNA(new Float(dbl)); o.setLensNA(dbl); Objective t1 = iUpdate.saveAndReturnObject(o); // Test value via jdbc String jdbcQuery = "SELECT lensNa FROM Objective WHERE id = :id"; Float lensNA = (Float) iQuery.projection(jdbcQuery, new Parameters().addId(t1.getId())).get(0)[0]; assertEquals(dbl, lensNA.floatValue(), 0.01); try { assertEquals(dbl, lensNA.floatValue(), Float.MIN_VALUE); } catch (AssertionFailedError e) { // This is what fails!! } // now test is with double which is our chosen solution Double lensNADoubled = (Double) iQuery.projection(jdbcQuery, new Parameters().addId(t1.getId())).get(0)[0]; assertEquals(dbl, lensNADoubled.doubleValue(), 0.01); assertEquals(dbl, lensNADoubled.doubleValue(), Float.MIN_VALUE); assertEquals(dbl, lensNADoubled.doubleValue(), Double.MIN_VALUE); // Test value return by iUpdate // Now changing these to doubleValue() post #1150 fix. assertEquals(dbl, t1.getLensNA().doubleValue(), 0.001); assertEquals(dbl, t1.getLensNA().doubleValue(), Float.MIN_VALUE); assertEquals(dbl, t1.getLensNA().doubleValue()); // Test via query Objective t2 = iQuery.find(Objective.class, o.getId()); assertEquals(dbl, t2.getLensNA().doubleValue()); }
From source file:org.apache.cocoon.components.flow.java.test.FlowTest.java
public void testSimple() throws Exception { /* ClassLoader cl = getClass().getClassLoader(); while (cl != null) {//from w ww.j av a 2 s .c o m System.out.println(cl); cl = cl.getParent(); } try { System.out.println( getClass(). getProtectionDomain(). getCodeSource(). getLocation()); } catch (Exception e) { }*/ Class clazz = loader.loadClass("org.apache.cocoon.components.flow.java.test.SimpleFlow"); Continuable flow = (Continuable) clazz.newInstance(); Method method = clazz.getMethod("run", new Class[0]); Continuation c = new Continuation(context); assertTrue(!c.isRestoring()); assertTrue(!c.isCapturing()); System.out.println("*** start flow"); c.registerThread(); method.invoke(flow, new Object[0]); if (c.isCapturing()) c.getStack().popReference(); c.deregisterThread(); System.out.println("*** return from flow"); assertTrue(!c.isRestoring()); assertTrue(c.isCapturing()); //System.out.println("request=" + request); request.addParameter("a", "2.3"); redirector.reset(); c = new Continuation(c, context); assertTrue(c.isRestoring()); assertTrue(!c.isCapturing()); System.out.println("*** resume flow"); c.registerThread(); method.invoke(flow, new Object[0]); if (c.isCapturing()) c.getStack().popReference(); c.deregisterThread(); System.out.println("*** return from flow"); assertTrue(!c.isRestoring()); assertTrue(!c.isCapturing()); VarMap map = (VarMap) FlowHelper.getContextObject(objectmodel); assertEquals(((Float) map.getMap().get("result")).floatValue(), 3.3f, 0.1f); JXPathContext jxcontext = JXPathContext.newContext(FlowHelper.getContextObject(objectmodel)); Float result = (Float) jxcontext.getValue("result"); assertEquals(result.floatValue(), 3.3f, 0.1f); }
From source file:org.eclipse.wb.internal.swing.MigLayout.model.MigDimensionInfo.java
/** * @return <code>true</code> if this {@link MigDimensionInfo} has not <code>null</code> grow * weight./*from w ww .ja v a2 s . com*/ */ public final boolean hasGrow() { Float grow = m_constraint.getGrow(); return grow != null && grow.floatValue() > 0.001f; }
From source file:com.hotwire.sid.QuovaIP_GeoServerAdapter.java
/** * Helper method that takes an ipInfoRecord as input and populates an * IP_GeoResponse with the record It currently sets the countryCode, * gmtOffset, ndmaCode and zipCode if cityConfidenceFactor is >= * cityConfidenceFactorThreshold//from w ww . j av a 2 s. c om * * @param ipInfoRecord * @return IP_GeoResponse */ private IP_GeoResponse getIP_GeoResponseFromIPInfoRecord(IPInfo ipInfoRecord) { IP_GeoResponse ipGeoResponse = new IP_GeoResponse(ipInfoRecord.getString(IPInfoField.IP_ADDRESS), 'Q'); // set country code ipGeoResponse.setCountryCode(ipInfoRecord.getString(IPInfoField.COUNTRY)); // parse GMT try { Float gmtOffset = ipInfoRecord.getFloat(IPInfoField.TIMEZONE); if (gmtOffset != null) { ipGeoResponse.setGmtOffset(gmtOffset.floatValue()); } } catch (QuovaException qe) { // this is expected since gmtOffset sometimes comes back as // 'multizone' so ignore this if (log.isLoggable(Level.FINE)) { log.fine("Could not parse IPInfoField.TIMEZONE for ip: " + ipGeoResponse.getIP_Address() + ". " + "String value of field is: " + ipInfoRecord.getString(IPInfoField.TIMEZONE)); } } // parse NDMA code try { Integer ndmaCode = ipInfoRecord.getInt(IPInfoField.DMA); if (ndmaCode != null) { ipGeoResponse.setNDMA_Code(ndmaCode.intValue()); } } catch (QuovaException qe) { log.log(Level.SEVERE, "Could not parse IPInfoField.DMA for ip: " + ipGeoResponse.getIP_Address() + ". " + "String value of field is: " + ipInfoRecord.getString(IPInfoField.DMA), qe); } // evaluate the city confidence factor and if it is >= // cityConfidenceFactorThreshold, set the zip code Integer cityConfidenceFactor = ipInfoRecord.getCF(IPInfoField.CITY); if (cityConfidenceFactor != null && cityConfidenceFactor.intValue() >= cityConfidenceFactorThreshold) { ipGeoResponse.setZipCode(ipInfoRecord.getString(IPInfoField.ZIP)); ipGeoResponse.setCityName(ipInfoRecord.getString(IPInfoField.CITY)); ipGeoResponse.setStateName(ipInfoRecord.getString(IPInfoField.STATE)); } // parse other numeric fields try { Float longitude = ipInfoRecord.getFloat(IPInfoField.LONGITUDE); if (longitude != null) { ipGeoResponse.setLongitude(longitude.floatValue()); } Float latitude = ipInfoRecord.getFloat(IPInfoField.LATITUDE); if (latitude != null) { ipGeoResponse.setLatitude(latitude.floatValue()); } } catch (QuovaException qe) { log.log(Level.SEVERE, "Could not parse latitude / longitude for ip: " + ipGeoResponse.getIP_Address() + ". " + "String value of latitude is: " + ipInfoRecord.getString(IPInfoField.LATITUDE) + ". " + "String value of longitude is: " + ipInfoRecord.getString(IPInfoField.LONGITUDE) + ".", qe); } return ipGeoResponse; }
From source file:org.openconcerto.erp.core.humanresources.payroll.report.EtatChargesPayeSheet.java
protected void createMap() { this.mapReplace = new HashMap(); this.mCell = new HashMap(); this.mapStyleRow = new HashMap(); SQLSelect sel = new SQLSelect(base); sel.addSelect(tableFichePaye.getField("ID")); sel.addSelect(tableFichePayeElement.getField("ID")); // sel.addSelect(tableSalarie.getField("ID")); Where w = (new Where(tableFichePayeElement.getField("ID_FICHE_PAYE"), "=", tableFichePaye.getField("ID"))); Where w6 = (new Where(tableFichePayeElement.getField("SOURCE"), "=", "RUBRIQUE_COTISATION")); // Where w2 = (new Where(tableFichePaye.getField("ID_SALARIE"), "=", // tableSalarie.getField("ID"))); Where w3 = (new Where(tableFichePaye.getField("ID_MOIS"), new Integer(this.moisDu), new Integer(this.moisAu))); Where w4 = (new Where(tableFichePaye.getField("ANNEE"), "=", new Integer(this.annee))); Where w5 = (new Where(tableFichePaye.getField("VALIDE"), "=", Boolean.TRUE)); sel.setWhere(w);//from ww w . j a va 2 s . c o m // sel.andWhere(w2); sel.andWhere(w3); sel.andWhere(w4); sel.andWhere(w5); sel.andWhere(w6); sel.setDistinct(true); String req = sel.asString(); System.err.println(req); // Liste des rubriques de chaque salaries List l = (List) base.getDataSource().execute(req, new ArrayListHandler()); // Association idCaisse, Map rowValsRubCotCumul Map mapCaisse = new HashMap(); Map mapFiche = new HashMap(); // Cumuls des rubriques de cotisations par caisse for (int i = 0; i < l.size(); i++) { Object[] tmp = (Object[]) l.get(i); mapFiche.put(tmp[0], ""); int idFicheElt = Integer.parseInt(tmp[1].toString()); SQLRow rowFicheElt = tableFichePayeElement.getRow(idFicheElt); SQLRow rowRub = tableRubCot.getRow(rowFicheElt.getInt("IDSOURCE")); // On recupere la map de la caisse Map mapValueRub; if (mapCaisse.containsKey(new Integer(rowRub.getInt("ID_CAISSE_COTISATION")))) { mapValueRub = (Map) mapCaisse.get(new Integer(rowRub.getInt("ID_CAISSE_COTISATION"))); } else { mapValueRub = new HashMap(); mapCaisse.put(new Integer(rowRub.getInt("ID_CAISSE_COTISATION")), mapValueRub); } // on recupere la rowvalues de la rubrique SQLRowValues rowVals; if (mapValueRub.containsKey(rowFicheElt.getObject("IDSOURCE"))) { rowVals = (SQLRowValues) mapValueRub.get(rowFicheElt.getObject("IDSOURCE")); // on cumule les donnes if (rowFicheElt.getObject("NB_BASE") != null) { Object o = rowVals.getObject("NB_BASE"); float base = (o == null) ? 0.0F : ((Float) o).floatValue(); base += rowFicheElt.getFloat("NB_BASE"); rowVals.put("NB_BASE", new Float(base)); } if (rowFicheElt.getObject("MONTANT_PAT") != null) { Object o = rowVals.getObject("MONTANT_PAT"); float montant = (o == null) ? 0.0F : ((Float) o).floatValue(); montant += rowFicheElt.getFloat("MONTANT_PAT"); rowVals.put("MONTANT_PAT", new Float(montant)); } if (rowFicheElt.getObject("MONTANT_SAL_DED") != null) { Object o = rowVals.getObject("MONTANT_SAL_DED"); float montant = (o == null) ? 0.0F : ((Float) o).floatValue(); montant += rowFicheElt.getFloat("MONTANT_SAL_DED"); rowVals.put("MONTANT_SAL_DED", new Float(montant)); } } else { rowVals = new SQLRowValues(tableFichePayeElement); Configuration.getInstance().getDirectory().getElement(tableFichePayeElement).loadAllSafe(rowVals, rowFicheElt); float montantPat, montantSal; Object o = rowVals.getObject("MONTANT_PAT"); montantPat = (o == null) ? 0.0F : ((Float) o).floatValue(); o = rowVals.getObject("MONTANT_SAL_DED"); montantSal = (o == null) ? 0.0F : ((Float) o).floatValue(); if (montantPat != 0 || montantSal != 0) { mapValueRub.put(rowFicheElt.getObject("IDSOURCE"), rowVals); } } } // Fill int posLine = 1; int firstLine = 1; System.err.println("Dump fiche " + mapFiche); System.err.println("NB Pages = " + mapCaisse.keySet().size()); for (int n = 0; n < mapCaisse.keySet().size(); n++) { // entete makeEntete(posLine); posLine += (debutFill - 1); Map mapValue = (Map) mapCaisse.get(mapCaisse.keySet().toArray()[n]); float totalMontantSal = 0.0F; float totalMontantPat = 0.0F; SQLRow rowCaisse = tableCaisse.getRow(Integer.parseInt(mapCaisse.keySet().toArray()[n].toString())); this.mCell.put("A" + posLine, "Caisse " + rowCaisse.getObject("NOM")); this.mCell.put("B" + posLine, ""); this.mCell.put("C" + posLine, ""); this.mCell.put("D" + posLine, ""); this.mCell.put("E" + posLine, ""); this.mCell.put("F" + posLine, ""); this.mapStyleRow.put(new Integer(posLine), "Titre 1"); posLine++; for (int i = 0; i < mapValue.keySet().size(); i++) { SQLRowValues rowVals = (SQLRowValues) mapValue.get(mapValue.keySet().toArray()[i]); this.mCell.put("A" + posLine, rowVals.getObject("NOM")); this.mCell.put("B" + posLine, rowVals.getObject("NB_BASE")); Float oTxSal = (Float) rowVals.getObject("TAUX_SAL"); float txSal = (oTxSal == null) ? 0.0F : oTxSal.floatValue(); Float oTxPat = (Float) rowVals.getObject("TAUX_PAT"); float txPat = (oTxPat == null) ? 0.0F : oTxPat.floatValue(); this.mCell.put("C" + posLine, new Float(txSal + txPat)); System.err.println(rowVals.getObject("MONTANT_SAL_DED").getClass()); Float oMontantSal = (Float) rowVals.getObject("MONTANT_SAL_DED"); float montantSal = (oMontantSal == null) ? 0.0F : oMontantSal.floatValue(); Float oMontantPat = (Float) rowVals.getObject("MONTANT_PAT"); float montantPat = (oMontantPat == null) ? 0.0F : oMontantPat.floatValue(); this.mCell.put("D" + posLine, new Float(montantPat)); this.mCell.put("E" + posLine, new Float(montantSal)); this.mCell.put("F" + posLine, new Float(montantSal + montantPat)); totalMontantPat += montantPat; totalMontantSal += montantSal; this.mapStyleRow.put(new Integer(posLine), "Normal"); posLine++; } this.mCell.put("A" + posLine, "Total"); this.mCell.put("B" + posLine, ""); this.mCell.put("C" + posLine, ""); this.mCell.put("D" + posLine, new Float(totalMontantPat)); this.mCell.put("E" + posLine, new Float(totalMontantSal)); this.mCell.put("F" + posLine, new Float(totalMontantPat + totalMontantSal)); this.mapStyleRow.put(new Integer(posLine), "Titre 1"); // pied de page posLine = firstLine + endFill - 1; posLine += 2; makeBasPage(posLine); posLine++; firstLine = posLine; } this.nbPage = mapCaisse.size(); System.err.println("Nombre de page " + this.nbPage); // on conserve la page d'origine du model if (this.nbPage > 0) { this.nbPage--; } }
From source file:org.zilverline.lucene.BoostingParser.java
/** * Callback that returns Query with boosted fields using BoostFactors * /* ww w . j a v a 2 s . co m*/ * @param field the field to query * @param analyzer the analyzer to use * @param queryText the query * * @return Query object * * @throws ParseException if Query can't be made * */ protected Query getFieldQuery(String field, Analyzer analyzer, String queryText) throws ParseException { // Use the analyzer to get all the tokens, and then build a TermQuery, // PhraseQuery, or nothing based on the term count // for field that contain 'contents' add boostfactors for other terms // specified in BoostFactor if (factors != null && factors.getFactors() != null && !factors.getFactors().isEmpty() && defaultField.equals(field)) { TokenStream source = analyzer.tokenStream(field, new StringReader(queryText)); Vector v = new Vector(); org.apache.lucene.analysis.Token t; while (true) { try { t = source.next(); } catch (IOException e) { t = null; } if (t == null) { break; } v.addElement(t.termText()); log.debug(field + " , " + t.termText()); } try { source.close(); } catch (IOException e) { log.error("Unexpected Exception"); } if (v.size() == 0) { return null; } else { // create a new composed query BooleanQuery bq = new BooleanQuery(); // For all boostfactors create a new PhraseQuery Iterator iter = factors.getFactors().entrySet().iterator(); while (iter.hasNext()) { Map.Entry element = (Map.Entry) iter.next(); String thisField = ((String) element.getKey()).toLowerCase(); Float boost = (Float) element.getValue(); PhraseQuery q = new PhraseQuery(); // and add all the terms of the query for (int i = 0; i < v.size(); i++) { q.add(new Term(thisField, (String) v.elementAt(i))); } // boost the query q.setBoost(boost.floatValue()); // and add it to the composed query bq.add(q, false, false); } log.debug("Query: " + bq); return bq; } } else { log.debug("Treat like normal query: " + queryText); return super.getFieldQuery(field, analyzer, queryText); } }